OSDN Git Service

PATCH: [ 861813 ] Optimise dircompare statuspane updating
authorKimmo Varis <kimmov@gmail.com>
Thu, 18 Dec 2003 17:18:50 +0000 (17:18 +0000)
committerKimmo Varis <kimmov@gmail.com>
Thu, 18 Dec 2003 17:18:50 +0000 (17:18 +0000)
Src/DirCompStateBar.cpp
Src/DirCompStateBar.h
Src/readme.txt

index ffad8ac..dcacc10 100644 (file)
@@ -1,5 +1,10 @@
-// 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"
@@ -17,6 +22,9 @@ static char THIS_FILE[] = __FILE__;
 /////////////////////////////////////////////////////////////////////////////
 // CDirCompStateBar construction destruction
 
+/**
+ * @brief Set all stats to zero
+ */
 void CDirCompStateBar::ClearStat()
 {
        //{{AFX_DATA_INIT(CDirCompStateBar)
@@ -37,6 +45,7 @@ void CDirCompStateBar::ClearStat()
 CDirCompStateBar::CDirCompStateBar(CWnd* pParent /*=NULL*/)
 {
        ClearStat();
+       m_bFirstUpdate = FALSE;
 
        VERIFY(strAbort.LoadString(IDC_COMPARISON_STOP));
        VERIFY(strClose.LoadString(IDC_COMPARISON_CLOSE));
@@ -45,8 +54,8 @@ CDirCompStateBar::CDirCompStateBar(CWnd* pParent /*=NULL*/)
 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;
@@ -149,12 +158,21 @@ void CDirCompStateBar::OnUpdateStop(CCmdUI* pCmdUI)
        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())
        {
@@ -162,10 +180,14 @@ void CDirCompStateBar::AddElement(UINT diffcode)
                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())
@@ -174,6 +196,8 @@ void CDirCompStateBar::AddElement(UINT diffcode)
                if (di.isDirectory())
                {
                        ++m_nRFolder;
+                       CStatic * pCtrl = (CStatic *)GetDlgItem(IDC_COUNT_RFOLDER);
+                       UpdateText(pCtrl, m_nRFolder);
                }
                else
                {
@@ -186,16 +210,22 @@ void CDirCompStateBar::AddElement(UINT diffcode)
                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())
@@ -204,10 +234,14 @@ void CDirCompStateBar::AddElement(UINT diffcode)
                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
@@ -223,16 +257,17 @@ void CDirCompStateBar::AddElement(UINT diffcode)
                        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)
@@ -265,3 +300,18 @@ void CDirCompStateBar::OnWindowPosChanging( WINDOWPOS* lpwndpos )
                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);
+}
index c75761a..b84d2b4 100644 (file)
@@ -1,17 +1,29 @@
+/** 
+ * @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
@@ -21,6 +33,8 @@ public:
        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)
@@ -62,6 +76,9 @@ protected:
        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}}
index 94a7d5f..a6bc969 100644 (file)
@@ -2,7 +2,10 @@
  PATCH: [ 860988 ] Change File from menu (Adds Window/Change Pane)
   WinMerge: Merge.rc MergeEditView.h MergeEditView.cpp resource.h
   Languages: *.rc resource.h
-
+ PATCH: [ 861813 ] Optimise dircompare statuspane updating
+  Fixes bug [ 860204 ] Dir compare statuspane flickers on slower machine
+  WinMerge: DirCompStateBar.h DirCompStateBar.cpp
+  
 2003-12-18 Laoran
  adapt plugins syntax check, consequence of patch #853147 
   WinMerge: Plugins.cpp