-// DirCompStateBar.cpp : implementation file
-//
+/**
+ * @file DirCompStateBar.cpp
+ *
+ * @brief Implementation file for Directory compare statuspanel class
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
#include "stdafx.h"
#include "merge.h"
/////////////////////////////////////////////////////////////////////////////
// CDirCompStateBar construction destruction
+/**
+ * @brief Set all stats to zero
+ */
void CDirCompStateBar::ClearStat()
{
//{{AFX_DATA_INIT(CDirCompStateBar)
CDirCompStateBar::CDirCompStateBar(CWnd* pParent /*=NULL*/)
{
ClearStat();
+ m_bFirstUpdate = FALSE;
VERIFY(strAbort.LoadString(IDC_COMPARISON_STOP));
VERIFY(strClose.LoadString(IDC_COMPARISON_CLOSE));
BOOL CDirCompStateBar::Create(CWnd* pParentWnd)
{
if (! CDialogBar::Create(pParentWnd, CDirCompStateBar::IDD,
- WS_VISIBLE|CBRS_SIZE_FIXED|CBRS_FLYBY,
- CDirCompStateBar::IDD))
+ WS_VISIBLE|CBRS_SIZE_FIXED|CBRS_FLYBY,
+ CDirCompStateBar::IDD))
return FALSE;
return TRUE;
pCmdUI->Enable(TRUE);
}
-
-
-// diff completed another file
+/**
+ * @brief Increase given category count by one and update panel
+ *
+ * Diff code calls this function every time it has compeleted comparing
+ * one item.
+ * @todo This could be optimised by letting timer call UI update
+ * couple of times per second.
+ */
void CDirCompStateBar::AddElement(UINT diffcode)
{
DIFFITEM di;
+
+ if (!m_bFirstUpdate)
+ FirstUpdate();
+
di.diffcode = diffcode;
if (di.isSideLeft())
{
if (di.isDirectory())
{
++m_nLFolder;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_LFOLDER);
+ UpdateText(pCtrl, m_nLFolder);
}
else
{
++m_nLFile;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_LFILE);
+ UpdateText(pCtrl, m_nLFile);
}
}
else if (di.isSideRight())
if (di.isDirectory())
{
++m_nRFolder;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_RFOLDER);
+ UpdateText(pCtrl, m_nRFolder);
}
else
{
if (di.isDirectory())
{
++m_nFolderSkip;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_FOLDERSKIP);
+ UpdateText(pCtrl, m_nFolderSkip);
}
else
{
++m_nFileSkip;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_FILESKIP);
+ UpdateText(pCtrl, m_nFileSkip);
}
}
else if (di.isResultError())
{
// could be directory error ?
++m_nUnknown;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_UNKNOWN);
+ UpdateText(pCtrl, m_nUnknown);
}
// Now we know it was on both sides & compared!
else if (di.isResultSame())
if (di.isBin())
{
++m_nBinarySame;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_BINARYSAME);
+ UpdateText(pCtrl, m_nBinarySame);
}
else
{
++m_nEqual;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_EQUAL);
+ UpdateText(pCtrl, m_nEqual);
}
}
else
if (di.isBin())
{
++m_nBinaryDiff;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_BINARYDIFF);
+ UpdateText(pCtrl, m_nBinaryDiff);
}
else
{
++m_nNotEqual;
+ CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_NOTEQUAL);
+ UpdateText(pCtrl, m_nNotEqual);
}
}
}
-
-
- UpdateData(FALSE);
}
BOOL CDirCompStateBar::PreTranslateMessage(MSG* pMsg)
pDirFrame->NotifyHideStateBar();
}
}
+
+void CDirCompStateBar::UpdateText(CStatic * ctrl, int num) const
+{
+ ASSERT(ctrl != NULL);
+ TCHAR strNum[20] = {0};
+
+ _itot(num, strNum, 10);
+ ctrl->SetWindowText(strNum);
+}
+
+void CDirCompStateBar::FirstUpdate()
+{
+ m_bFirstUpdate = TRUE;
+ UpdateData(FALSE);
+}
+/**
+ * @file DirCompStateBar.h
+ *
+ * @brief Declaration file for Directory compare statuspanel class
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
+
#if !defined(AFX_DIRCOMPSTATEDLG_H__8F66C090_C232_429F_A4A2_18D43CCC6C38__INCLUDED_)
#define AFX_DIRCOMPSTATEDLG_H__8F66C090_C232_429F_A4A2_18D43CCC6C38__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
-// DirCompStateBar.h : header file
-//
class CDirFrame;
/////////////////////////////////////////////////////////////////////////////
// CDirCompStateBar dialog
+/**
+ * @brief Class for directory compare statuspanel
+ *
+ * Implements floating statuspanel during directory compares.
+ * Shows statistics from compare and allows stopping compare.
+ */
class CDirCompStateBar : public CDialogBar
{
// Construction
void ClearStat();
void AddElement(UINT diffcode);
BOOL GetDefaultRect( LPRECT lpRect ) const;
+ void UpdateText(CStatic * ctrl, int num) const;
+ void FirstUpdate();
// Dialog Data
//{{AFX_DATA(CDirCompStateBar)
afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
+
+private:
+ BOOL m_bFirstUpdate; /**< Is first update (all to zeros) done? */
};
//{{AFX_INSERT_LOCATION}}