--- /dev/null
+/**
+ * @file CompareStats.cpp
+ *
+ * @brief Implementation of CompareStats class.
+ */
+// RCS ID line follows -- this is updated by CVS
+// $Id$
+
+#include "stdafx.h"
+#include "DiffItem.h"
+#include "CompareStats.h"
+
+/**
+ * @brief Constructor, initializes critical section.
+ */
+CompareStats::CompareStats()
+: m_nTotalItems(0)
+{
+ InitializeCriticalSection(&m_csProtect);
+ ZeroMemory(&m_counts[0], sizeof(m_counts));
+}
+
+/**
+ * @brief Destructor, deletes critical section.
+ */
+CompareStats::~CompareStats()
+{
+ DeleteCriticalSection(&m_csProtect);
+}
+
+/**
+ * @brief Increase found items (dirs and files) count.
+ * @param [in] count Amount of items to add.
+ */
+void CompareStats::IncreaseTotalItems(int count /*= 1*/)
+{
+ m_nTotalItems += count;
+}
+
+/**
+ * @brief Add compared item.
+ * @param [in] code Resultcode to add.
+ */
+void CompareStats::AddItem(int code)
+{
+ EnterCriticalSection(&m_csProtect);
+ RESULT res = GetResultFromCode(code);
+ int index = static_cast<int>(res);
+ m_counts[index] += 1;
+ LeaveCriticalSection(&m_csProtect);
+}
+
+/**
+ * @brief Return count by resultcode.
+ * @param [in] result Resultcode to return.
+ * @return Count of items for given resultcode.
+ */
+int CompareStats::GetCount(CompareStats::RESULT result)
+{
+ int currentValue = 0;
+ EnterCriticalSection(&m_csProtect);
+ int resInd = static_cast<int>(result);
+ currentValue = m_counts[resInd];
+ LeaveCriticalSection(&m_csProtect);
+ return currentValue;
+}
+
+/**
+ * @brief Return total count of items (so far) found.
+ */
+int CompareStats::GetTotalItems()
+{
+ return m_nTotalItems;
+}
+
+/**
+ * @brief Reset comparestats.
+ * Use this function to reset stats before new compare.
+ */
+void CompareStats::Reset()
+{
+ ZeroMemory(&m_counts[0], sizeof(m_counts));
+ SetCompareState(STATE_IDLE);
+ m_nTotalItems = 0;
+}
+
+/**
+ * @brief Change compare state.
+ * @param [in] state New compare state.
+ */
+void CompareStats::SetCompareState(CompareStats::CMP_STATE state)
+{
+ m_state = state;
+}
+
+/**
+ * @brief Return current comparestate.
+ */
+CompareStats::CMP_STATE CompareStats::GetCompareState()
+{
+ return m_state;
+}
+
+/**
+ * @brief Convert diffcode to compare-result.
+ * @param [in] diffcode DIFFITEM.diffcode to convert.
+ * @return Compare result.
+ */
+CompareStats::RESULT CompareStats::GetResultFromCode(UINT diffcode)
+{
+ DIFFCODE di = diffcode;
+
+ // Test first for skipped so we pick all skipped items as such
+ if (di.isResultFiltered())
+ {
+ // skipped
+ if (di.isDirectory())
+ {
+ return RESULT_DIRSKIP;
+ }
+ else
+ {
+ return RESULT_SKIP;
+ }
+ }
+ else if (di.isSideLeft())
+ {
+ // left-only
+ if (di.isDirectory())
+ {
+ return RESULT_LDIRUNIQUE;
+ }
+ else
+ {
+ return RESULT_LUNIQUE;
+ }
+ }
+ else if (di.isSideRight())
+ {
+ // right-only
+ if (di.isDirectory())
+ {
+ return RESULT_RDIRUNIQUE;
+ }
+ else
+ {
+ return RESULT_RUNIQUE;
+ }
+ }
+ else if (di.isResultError())
+ {
+ // could be directory error ?
+ return RESULT_ERROR;
+ }
+ // Now we know it was on both sides & compared!
+ else if (di.isResultSame())
+ {
+ // same
+ if (di.isBin())
+ {
+ return RESULT_BINSAME;
+ }
+ else
+ {
+ return RESULT_SAME;
+ }
+ }
+ else
+ {
+ // presumably it is diff
+ if (di.isDirectory())
+ {
+ return RESULT_DIR;
+ }
+ else
+ {
+ if (di.isBin())
+ {
+ return RESULT_BINDIFF;
+ }
+ else
+ {
+ return RESULT_DIFF;
+ }
+ }
+ }
+}
--- /dev/null
+/**
+ * @file CompareStats.h
+ *
+ * @brief Declaration of class CompareStats
+ */
+//
+// RCS ID line follows -- this is updated by CVS
+// $Id$
+
+#ifndef _COMPARESTATS_H_
+#define _COMPARESTATS_H_
+
+/**
+ * @brief Class holding directory compare stats.
+ *
+ * This class is used for sharing compare stats between dir compare
+ * classes. DirScan.cpp functions and CDiffContext update statuses
+ * and compare statepane reads statuses and updates UI.
+ */
+class CompareStats
+{
+public:
+
+ /**
+ * @brief Different states for compare procedure.
+ */
+ enum CMP_STATE
+ {
+ STATE_IDLE,
+ STATE_COLLECT,
+ STATE_COMPARE,
+ STATE_READY,
+ };
+
+ /**
+ * @brief Resultcodes we store.
+ */
+ enum RESULT
+ {
+ RESULT_LUNIQUE = 0,
+ RESULT_RUNIQUE,
+ RESULT_DIFF,
+ RESULT_SAME,
+ RESULT_BINSAME,
+ RESULT_BINDIFF,
+ RESULT_LDIRUNIQUE,
+ RESULT_RDIRUNIQUE,
+ RESULT_SKIP,
+ RESULT_DIRSKIP,
+ RESULT_DIR,
+ RESULT_ERROR,
+ RESULT_COUNT //THIS MUST BE THE LAST ITEM
+ };
+
+ CompareStats();
+ ~CompareStats();
+ void AddItem(int code);
+ void IncreaseTotalItems(int count = 1);
+ int GetCount(CompareStats::RESULT result);
+ int GetTotalItems();
+ void Reset();
+ void SetCompareState(CompareStats::CMP_STATE state);
+ CompareStats::CMP_STATE GetCompareState();
+
+ static CompareStats::RESULT CompareStats::GetResultFromCode(UINT diffcode);
+
+private:
+ int m_counts[RESULT_COUNT]; /**< Table storing result counts */
+ CRITICAL_SECTION m_csProtect; /**< For synchronizing read/write of counts */
+ long m_nTotalItems; /**< Total items found to compare */
+ CMP_STATE m_state; /**< State for compare (collect, compare, ready..) */
+};
+
+#endif // _COMPARESTATS_H_
#include "stdafx.h"
#include "merge.h"
+#include "CompareStats.h"
#include "version.h"
#include "DiffContext.h"
#include "paths.h"
void CDiffContext::AddDiff(const DIFFITEM & di)
{
DiffItemList::AddDiff(di);
-
- // ignore return value
- SendMessage(m_hDirFrame, m_msgUpdateStatus, di.diffcode, NULL);
+ m_pCompareStats->AddItem(di.diffcode);
}
/**
class PrediffingInfo;
class IDiffFilter;
struct DIFFITEM;
+class CompareStats;
// Interface for reporting current file, as diff traverses file tree
class IDiffStatus
BOOL m_bGuessEncoding;
int m_nCompMethod; /**< Compare method */
BOOL m_bIgnoreSmallTimeDiff; /**< Ignore small timedifferences when comparing by date */
+ CompareStats *m_pCompareStats;
private:
CList<DIFFITEM,DIFFITEM&> *m_pList; /**< Pointer to list, used to access list */
}
else
{
- DirScan_GetItems(paths, subdir, &itemList, casesensitive, depth, myStruct->m_pAbortgate);
+ DirScan_GetItems(paths, subdir, &itemList, casesensitive, depth, myStruct->context, myStruct->m_pAbortgate);
DirScan_CompareItems(itemList, myStruct->context, myStruct->m_pAbortgate);
}
static char THIS_FILE[] = __FILE__;
#endif
-/////////////////////////////////////////////////////////////////////////////
-// CDirCompStateBar construction destruction
+/**
+ * @brief ID for timer updating UI.
+ */
+static const UINT IDT_UPDATE = 1;
+
+/**
+ * @brief Interval (in milliseconds) for UI updates.
+ */
+static const UINT UPDATE_INTERVAL = 500;
/**
- * @brief Set all stats to zero
+ * @brief Reset all UI fields to zero.
*/
void CDirCompStateBar::ClearStat()
{
- //{{AFX_DATA_INIT(CDirCompStateBar)
- m_nBinaryDiff = 0;
- m_nBinarySame = 0;
- m_nEqual = 0;
- m_nFileSkip = 0;
- m_nFolderSkip = 0;
- m_nLFile = 0;
- m_nLFolder = 0;
- m_nNotEqual = 0;
- m_nRFile = 0;
- m_nRFolder = 0;
- m_nError = 0;
- m_nFolder = 0;
- //}}AFX_DATA_INIT
+ SetDlgItemInt(IDC_COUNT_LFILE, 0);
+ SetDlgItemInt(IDC_COUNT_RFILE, 0);
+ SetDlgItemInt(IDC_COUNT_NOTEQUAL, 0);
+ SetDlgItemInt(IDC_COUNT_EQUAL, 0);
+ SetDlgItemInt(IDC_COUNT_BINARYSAME, 0);
+ SetDlgItemInt(IDC_COUNT_BINARYDIFF, 0);
+ SetDlgItemInt(IDC_COUNT_LFOLDER, 0);
+ SetDlgItemInt(IDC_COUNT_RFOLDER, 0);
+ SetDlgItemInt(IDC_COUNT_FILESKIP, 0);
+ SetDlgItemInt(IDC_COUNT_FOLDERSKIP, 0);
+ SetDlgItemInt(IDC_COUNT_FOLDER, 0);
+ SetDlgItemInt(IDC_COUNT_ERROR, 0);
}
/**
* @brief Constructor.
- *
- * Resets stats and loads strings from resource.
*/
CDirCompStateBar::CDirCompStateBar(CWnd* pParent /*=NULL*/)
+: m_bStopText(TRUE)
{
- ClearStat();
}
+/**
+ * @brief Loads strings from resource.
+ */
BOOL CDirCompStateBar::Create(CWnd* pParentWnd)
{
VERIFY(strAbort.LoadString(IDC_COMPARISON_STOP));
CDirCompStateBar::IDD))
return FALSE;
+ ClearStat();
return TRUE;
};
{
CDialogBar::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDirCompStateBar)
- DDX_Text(pDX, IDC_COUNT_BINARYDIFF, m_nBinaryDiff);
- DDX_Text(pDX, IDC_COUNT_BINARYSAME, m_nBinarySame);
- DDX_Text(pDX, IDC_COUNT_EQUAL, m_nEqual);
- DDX_Text(pDX, IDC_COUNT_FILESKIP, m_nFileSkip);
- DDX_Text(pDX, IDC_COUNT_FOLDERSKIP, m_nFolderSkip);
- DDX_Text(pDX, IDC_COUNT_LFILE, m_nLFile);
- DDX_Text(pDX, IDC_COUNT_LFOLDER, m_nLFolder);
- DDX_Text(pDX, IDC_COUNT_NOTEQUAL, m_nNotEqual);
- DDX_Text(pDX, IDC_COUNT_RFILE, m_nRFile);
- DDX_Text(pDX, IDC_COUNT_RFOLDER, m_nRFolder);
- DDX_Text(pDX, IDC_COUNT_ERROR, m_nError);
- DDX_Text(pDX, IDC_COUNT_FOLDER, m_nFolder);
DDX_Control(pDX, IDC_COMPARISON_STOP, m_ctlStop);
//}}AFX_DATA_MAP
}
-
BEGIN_MESSAGE_MAP(CDirCompStateBar, CDialogBar)
//{{AFX_MSG_MAP(CDirCompStateBar)
ON_COMMAND(IDC_COMPARISON_STOP, OnStop)
ON_UPDATE_COMMAND_UI(IDC_COMPARISON_STOP, OnUpdateStop)
ON_WM_WINDOWPOSCHANGING()
+ ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
* @brief User selects to stop compare.
*
* Aborts compare and hides status panel.
+ * @todo Couldn't we close this bar without using frame code?
*/
void CDirCompStateBar::OnStop()
{
}
/**
- * @brief Update button text.
+ * @brief Update button text (Stop/Close).
*
* Changes button text after compare is ready.
*/
CDirDoc * pDirDoc = dynamic_cast<CDirDoc*>(pFrameWnd->GetActiveDocument());
ASSERT(pDirDoc != NULL);
- // adapt the text of button
+ // Change button text if scan is finished and it hasn't been yet changed.
if (m_ctlStop.GetSafeHwnd())
{
if (!pDirDoc->IsCurrentScanAbortable())
{
- CString text;
- m_ctlStop.GetWindowText(text);
- if (text != strClose)
+ if (m_bStopText)
{
m_ctlStop.SetWindowText(strClose);
+ m_bStopText = FALSE;
m_lElapsed += ::GetTickCount();
+ CString text;
text.Format(IDS_ELAPSED_TIME, m_lElapsed);
pFrameWnd->SetMessageText(text);
}
}
/**
- * @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.
+ * @brief Return control ID for result code.
*/
-void CDirCompStateBar::AddElement(UINT diffcode)
+UINT CDirCompStateBar::GetIDFromResult(CompareStats::RESULT res)
{
- DIFFCODE di = diffcode;
-
- // Test first for skipped so we pick all skipped items as such
- if (di.isResultFiltered())
- {
- // skipped
- if (di.isDirectory())
- {
- ++m_nFolderSkip;
- SetDlgItemInt(IDC_COUNT_FOLDERSKIP, m_nFolderSkip);
- }
- else
- {
- ++m_nFileSkip;
- SetDlgItemInt(IDC_COUNT_FILESKIP, m_nFileSkip);
- }
- }
- else if (di.isSideLeft())
- {
- // left-only
- if (di.isDirectory())
- {
- ++m_nLFolder;
- SetDlgItemInt(IDC_COUNT_LFOLDER, m_nLFolder);
- }
- else
- {
- ++m_nLFile;
- SetDlgItemInt(IDC_COUNT_LFILE, m_nLFile);
- }
- }
- else if (di.isSideRight())
- {
- // right-only
- if (di.isDirectory())
- {
- ++m_nRFolder;
- SetDlgItemInt(IDC_COUNT_RFOLDER, m_nRFolder);
- }
- else
- {
- ++m_nRFile;
- SetDlgItemInt(IDC_COUNT_RFILE, m_nRFile);
- }
- }
- else if (di.isResultError())
- {
- // could be directory error ?
- ++m_nError;
- SetDlgItemInt(IDC_COUNT_ERROR, m_nError);
- }
- // Now we know it was on both sides & compared!
- else if (di.isResultSame())
- {
- // same
- if (di.isBin())
- {
- ++m_nBinarySame;
- SetDlgItemInt(IDC_COUNT_BINARYSAME, m_nBinarySame);
- }
- else
- {
- ++m_nEqual;
- SetDlgItemInt(IDC_COUNT_EQUAL, m_nEqual);
- }
- }
- else
+ UINT resID = 0;
+
+ switch ((int)res)
{
- // presumably it is diff
- if (di.isDirectory())
- {
- ++m_nFolder;
- SetDlgItemInt(IDC_COUNT_FOLDER, m_nFolder);
- }
- else
- {
- if (di.isBin())
- {
- ++m_nBinaryDiff;
- SetDlgItemInt(IDC_COUNT_BINARYDIFF, m_nBinaryDiff);
- }
- else
- {
- ++m_nNotEqual;
- SetDlgItemInt(IDC_COUNT_NOTEQUAL, m_nNotEqual);
- }
- }
+ case CompareStats::RESULT_LUNIQUE:
+ resID = IDC_COUNT_LFILE;
+ break;
+ case CompareStats::RESULT_RUNIQUE:
+ resID = IDC_COUNT_RFILE;
+ break;
+ case CompareStats::RESULT_DIFF:
+ resID = IDC_COUNT_NOTEQUAL;
+ break;
+ case CompareStats::RESULT_SAME:
+ resID = IDC_COUNT_EQUAL;
+ break;
+ case CompareStats::RESULT_BINSAME:
+ resID = IDC_COUNT_BINARYSAME;
+ break;
+ case CompareStats::RESULT_BINDIFF:
+ resID = IDC_COUNT_BINARYDIFF;
+ break;
+ case CompareStats::RESULT_LDIRUNIQUE:
+ resID = IDC_COUNT_LFOLDER;
+ break;
+ case CompareStats::RESULT_RDIRUNIQUE:
+ resID = IDC_COUNT_RFOLDER;
+ break;
+ case CompareStats::RESULT_SKIP:
+ resID = IDC_COUNT_FILESKIP;
+ break;
+ case CompareStats::RESULT_DIRSKIP:
+ resID = IDC_COUNT_FOLDERSKIP;
+ break;
+ case CompareStats::RESULT_DIR:
+ resID = IDC_COUNT_FOLDER;
+ break;
+ case CompareStats::RESULT_ERROR:
+ resID = IDC_COUNT_ERROR;
+ break;
}
+ return resID;
}
/**
- * @brief Reflow all status counts at current values
- *
- * Used when this bar is reloaded for a language change
- * This duplicates the SetDlgItem calls in AddElement.
+ * @brief Update all status counts at current values.
*/
void CDirCompStateBar::UpdateElements()
{
- SetDlgItemInt(IDC_COUNT_LFOLDER, m_nLFolder);
- SetDlgItemInt(IDC_COUNT_LFILE, m_nLFile);
- SetDlgItemInt(IDC_COUNT_RFOLDER, m_nRFolder);
- SetDlgItemInt(IDC_COUNT_RFILE, m_nRFile);
- SetDlgItemInt(IDC_COUNT_FOLDERSKIP, m_nFolderSkip);
- SetDlgItemInt(IDC_COUNT_FILESKIP, m_nFileSkip);
- SetDlgItemInt(IDC_COUNT_ERROR, m_nError);
- SetDlgItemInt(IDC_COUNT_BINARYSAME, m_nBinarySame);
- SetDlgItemInt(IDC_COUNT_EQUAL, m_nEqual);
- SetDlgItemInt(IDC_COUNT_FOLDER, m_nFolder);
- SetDlgItemInt(IDC_COUNT_BINARYDIFF, m_nBinaryDiff);
- SetDlgItemInt(IDC_COUNT_NOTEQUAL, m_nNotEqual);
+ for (int i = 0; i < CompareStats::RESULT_COUNT; i++)
+ {
+ CompareStats::RESULT resnum = static_cast<CompareStats::RESULT>(i);
+ UINT resID = GetIDFromResult(resnum);
+ int count = m_pCompareStats->GetCount(resnum);
+ SetDlgItemInt(resID, count);
+ }
}
/**
}
// When the scan is finished, any key will hide the bar
- CFrameWnd * pFrameWnd = static_cast<CFrameWnd*> (GetOwner());
- CDirDoc * pDirDoc = dynamic_cast<CDirDoc*>(pFrameWnd->GetActiveDocument());
- if (!pDirDoc->IsCurrentScanAbortable())
+ if (m_pCompareStats->GetCompareState() == CompareStats::STATE_READY)
{
OnStop();
return TRUE;
m_lElapsed -= ::GetTickCount();
UpdateData(FALSE);
m_ctlStop.SetWindowText(strAbort);
+ m_bStopText = TRUE;
// also give the focus to the button (PreTranslateMessage needs it)
m_ctlStop.SetFocus();
}
+
+/**
+ * @brief Set pointer to compare stats.
+ */
+void CDirCompStateBar::SetCompareStat(CompareStats * pCompareStats)
+{
+ m_pCompareStats = pCompareStats;
+}
+
+/**
+ * @brief Timer message received.
+ */
+void CDirCompStateBar::OnTimer(UINT nIDEvent)
+{
+ if (nIDEvent == IDT_UPDATE)
+ {
+ UpdateElements();
+
+ // If compare is finished, stop timer
+ if (m_pCompareStats->GetCompareState() == CompareStats::STATE_READY)
+ EndUpdating();
+ }
+ else
+ CDialogBar::OnTimer(nIDEvent);
+
+}
+
+/**
+ * @brief Start timer for UI updating.
+ */
+void CDirCompStateBar::StartUpdating()
+{
+ UpdateElements();
+ SetTimer(IDT_UPDATE, UPDATE_INTERVAL, NULL);
+}
+
+/**
+ * @brief Stop timer updating UI.
+ */
+void CDirCompStateBar::EndUpdating()
+{
+ KillTimer(IDT_UPDATE);
+}
#if !defined(AFX_DIRCOMPSTATEDLG_H__8F66C090_C232_429F_A4A2_18D43CCC6C38__INCLUDED_)
#define AFX_DIRCOMPSTATEDLG_H__8F66C090_C232_429F_A4A2_18D43CCC6C38__INCLUDED_
+#ifndef _COMPARESTATS_H_
+#include "CompareStats.h"
+#endif
class CDirFrame;
+class CompareStats;
/////////////////////////////////////////////////////////////////////////////
// CDirCompStateBar dialog
public:
CDirCompStateBar(CWnd* pParent = NULL); // standard constructor
BOOL Create(CWnd* pParentWnd);
- void AddElement(UINT diffcode);
BOOL GetDefaultRect( LPRECT lpRect ) const;
void UpdateText(CStatic * ctrl, int num) const;
void Reset();
void UpdateElements();
+ void SetCompareStat(CompareStats * pCompareStats);
+ void StartUpdating();
+ void EndUpdating();
+ UINT GetIDFromResult(CompareStats::RESULT res);
// Dialog Data
//{{AFX_DATA(CDirCompStateBar)
enum { IDD = IDD_DIRCOMPSTATE };
- int m_nBinaryDiff;
- int m_nBinarySame;
- int m_nEqual;
- int m_nFileSkip;
- int m_nFolderSkip;
- int m_nLFile;
- int m_nLFolder;
- int m_nNotEqual;
- int m_nRFile;
- int m_nRFolder;
- int m_nError;
- int m_nFolder;
CButton m_ctlStop;
//}}AFX_DATA
- CString strAbort;
- CString strClose;
-
- long m_lElapsed;
-
// Overrides
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
afx_msg void OnStop();
afx_msg void OnUpdateStop(CCmdUI* pCmdUI);
afx_msg void OnWindowPosChanging( WINDOWPOS* lpwndpos );
+ afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
+
+private:
+ CString strAbort; /**< 'Stop' text for button */
+ CString strClose; /**< 'Close' text for button */
+ long m_lElapsed; /**< Elapsed time for compare */
+ CompareStats *m_pCompareStats; /**< Pointer to comparestats */
+ BOOL m_bStopText; /**< Button has 'Stop' text? */
};
//{{AFX_INSERT_LOCATION}}
#include "stdafx.h"
#include <Shlwapi.h> // PathCompactPathEx()
#include "Merge.h"
+#include "CompareStats.h"
#include "DirDoc.h"
#include "DirFrame.h"
#include "diff.h"
CDirDoc::CDirDoc()
: m_pCtxt(NULL)
, m_pDirView(NULL)
+, m_pCompareStats(NULL)
, m_bROLeft(FALSE)
, m_bRORight(FALSE)
, m_bRecursive(FALSE)
CDirDoc::~CDirDoc()
{
delete m_pCtxt;
+ delete m_pCompareStats;
+
// Inform all of our merge docs that we're closing
for (POSITION pos = m_MergeDocs.GetHeadPosition(); pos; )
{
if (m_pCtxt != NULL)
delete m_pCtxt;
+ if (m_pCompareStats == NULL)
+ m_pCompareStats = new CompareStats();
+
m_pCtxt = new CDiffContext(paths.GetLeft(), paths.GetRight());
- if (m_pCtxt != NULL)
+ if (m_pCtxt != NULL && m_pCompareStats != NULL)
{
m_bRecursive = bRecursive;
// All plugin management is done by our plugin manager
gLog.Write(LOGLEVEL::LNOTICE, _T("Starting directory scan:\n\tLeft: %s\n\tRight: %s\n"),
m_pCtxt->GetLeftPath(), m_pCtxt->GetRightPath());
+ m_pCompareStats->Reset();
+ pf->SetCompareStats(m_pCompareStats);
pf->clearStatus();
pf->ShowProcessingBar(TRUE);
m_pCtxt->m_bGuessEncoding = mf->m_options.GetBool(OPT_CP_DETECT);
m_pCtxt->m_nCompMethod = mf->m_options.GetInt(OPT_CMP_METHOD);
m_pCtxt->m_bIgnoreSmallTimeDiff = mf->m_options.GetBool(OPT_IGNORE_SMALL_FILETIME);
+ m_pCtxt->m_pCompareStats = m_pCompareStats;
UpdateHeaderPath(TRUE);
UpdateHeaderPath(FALSE);
// draw the headers as active ones
{
gLog.Write(LOGLEVEL::LNOTICE, _T("Dircompare aborted!"));
m_diffThread.Abort();
+ m_pCompareStats->SetCompareState(CompareStats::STATE_READY);
}
/**
private:
CDiffContext *m_pCtxt; /**< Pointer to diff-data */
CDirView *m_pDirView;
+ CompareStats *m_pCompareStats;
MergeDocPtrList m_MergeDocs;
BOOL m_bROLeft; /**< Is left side read-only */
BOOL m_bRORight; /**< Is right side read-only */
#include "stdafx.h"
#include "Merge.h"
+#include "CompareStats.h"
#include "DirFrame.h"
#include "FilepathEdit.h"
#include "DirDoc.h"
ON_UPDATE_COMMAND_UI(ID_STATUS_DIFFNUM, OnUpdateStatusNum)
ON_WM_CLOSE()
ON_WM_SIZE()
- ON_MESSAGE(MSG_STAT_UPDATE, OnUpdateStatusMessage)
ON_WM_MDIACTIVATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
FloatControlBar(&m_wndCompStateBar, origin);
}
+/**
+ * @brief Empty diff-number pane from statusbar when dirview active
+ */
void CDirFrame::OnUpdateStatusNum(CCmdUI* pCmdUI)
{
pCmdUI->SetText(_T(""));
m_wndCompStateBar.Reset();
}
-/// diff completed another file
-void CDirFrame::rptStatus(UINT diffcode)
-{
- m_wndCompStateBar.AddElement(diffcode);
-}
-
-LRESULT CDirFrame::OnUpdateStatusMessage(WPARAM wParam, LPARAM lParam)
-{
- if (wParam == 0xFF)
- clearStatus();
- else
- rptStatus(wParam);
- return 0; // return value not meaningful
-}
-
/**
* @brief Interface to show/hide the floating state bar
*/
ShowControlBar(&m_wndCompStateBar, TRUE, FALSE);
// disable the list view as long as the state bar is shown
GetActiveView()->EnableWindow(FALSE);
+ m_wndCompStateBar.StartUpdating();
}
- else if (!bShow)
+ else if (!bShow)
+ {
+ m_wndCompStateBar.EndUpdating();
ShowControlBar(&m_wndCompStateBar, FALSE, FALSE);
+ }
m_bStateBarIsActive = bShow;
}
}
}
+void CDirFrame::SetCompareStats(CompareStats *pCompareStats)
+{
+ m_wndCompStateBar.SetCompareStat(pCompareStats);
+}
+void CDirFrame::UpdateStats()
+{
+ m_wndCompStateBar.UpdateElements();
+}
#include "EditorFilepathBar.h"
#include "DirCompStateBar.h"
+class CompareStats;
+
/////////////////////////////////////////////////////////////////////////////
// CDirFrame frame
CStatusBar m_wndStatusBar;
void SetClosableCallback(bool (*canclose)(void *), void * param);
IHeaderBar * GetHeaderInterface();
- void rptStatus(UINT diffcode);
void clearStatus();
void ShowProcessingBar(BOOL bShow);
void NotifyHideStateBar();
void UpdateResources();
+ void SetCompareStats(CompareStats *pCompareStats);
+ void UpdateStats();
// Overrides
// ClassWizard generated virtual function overrides
afx_msg void OnUpdateStatusNum(CCmdUI* pCmdUI);
afx_msg void OnClose();
afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg LRESULT OnUpdateStatusMessage(WPARAM wParam, LPARAM lParam);
afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
#include <shlwapi.h>
#include <sys/stat.h>
#include "DirScan.h"
+#include "CompareStats.h"
#include "common/unicoder.h"
#include "DiffContext.h"
#include "DiffWrapper.h"
* @return 1 normally, -1 if compare was aborted
*/
int DirScan_GetItems(const PathContext &paths, const CString & subdir, DiffItemList *pList,
- bool casesensitive, int depth, IAbortable * piAbortable)
+ bool casesensitive, int depth, CDiffContext * pCtxt, IAbortable * piAbortable)
{
static const TCHAR backslash[] = _T("\\");
+
+ pCtxt->m_pCompareStats->SetCompareState(CompareStats::STATE_COLLECT);
+
CString sLeftDir = paths.GetLeft();
CString sRightDir = paths.GetRight();
CString subprefix;
// Recursive compare
// Scan recursively all subdirectories too, we are not adding folders
if (DirScan_GetItems(paths, newsub, pList, casesensitive,
- depth - 1, piAbortable) == -1)
+ depth - 1, pCtxt, piAbortable) == -1)
{
return -1;
}
*/
int DirScan_CompareItems(DiffItemList & list, CDiffContext * pCtxt, IAbortable * piAbortable)
{
+ int res = 1;
+
+ pCtxt->m_pCompareStats->SetCompareState(CompareStats::STATE_COMPARE);
+
POSITION pos = list.GetFirstDiffPosition();
while (pos != NULL)
{
if (piAbortable && piAbortable->ShouldAbort())
- return -1;
+ {
+ res = -1;
+ break;
+ }
DIFFITEM di = list.GetNextDiffPosition(pos);
CompareDiffItem(di, pCtxt);
}
- return 1;
+ pCtxt->m_pCompareStats->SetCompareState(CompareStats::STATE_READY);
+ return res;
}
/**
*/
int DirScan_CompareItems(CDiffContext * pCtxt, IAbortable * piAbortable)
{
+ int res = 1;
+
+ pCtxt->m_pCompareStats->SetCompareState(CompareStats::STATE_COMPARE);
+
POSITION pos = pCtxt->GetFirstDiffPosition();
while (pos != NULL)
{
if (piAbortable && piAbortable->ShouldAbort())
- return -1;
+ {
+ res = -1;
+ break;
+ }
POSITION oldPos = pos;
DIFFITEM di = pCtxt->GetNextDiffPosition(pos);
CompareDiffItem(di, pCtxt);
}
}
- return 1;
+ pCtxt->m_pCompareStats->SetCompareState(CompareStats::STATE_READY);
+ return res;
}
/**
};
int DirScan_GetItems(const PathContext &paths, const CString & subdir, DiffItemList * pLst,
- bool casesensitive, int depth, IAbortable * piAbortable);
+ bool casesensitive, int depth, CDiffContext * pCtxt, IAbortable * piAbortable);
int DirScan_CompareItems(DiffItemList & list, CDiffContext * pCtxt, IAbortable * piAbortable);
int DirScan_CompareItems(CDiffContext * pCtxt, IAbortable * piAbortable);
// Clear and recount item numbers
pf->clearStatus();
- DIFFITEM di;
- POSITION pos = ctxt.GetFirstDiffPosition();
- while (pos)
- {
- di = ctxt.GetDiffAt(pos);
- pf->rptStatus(di.diffcode);
- ctxt.GetNextDiffPosition(pos);
- }
-
+ pf->UpdateStats();
pf->ShowProcessingBar(TRUE);
}
# End Source File
# Begin Source File
+SOURCE=.\CompareStats.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\ConfigLog.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
+SOURCE=.\CompareStats.h
+# End Source File
+# Begin Source File
+
SOURCE=.\ConfigLog.h
# End Source File
# Begin Source File
+2005-06-21 Kimmo
+ PATCH: [ 1223754 ] Improve dircompare stats system
+ Src: DiffContext.cpp DiffContext.h DiffThread.cpp DirCompareStateBar.cpp
+ DirCompareStateBar.h DirDoc.cpp DirDoc.h DirFrame.cpp DirFrame.h DirScan.cpp
+ DirScan.h DirView.cpp Merge.dsp
+ Src new files: CompareStats.cpp CompareStats.h
+
2005-06-21 WinMerge experimental release 2.3.3.6 (cvs)
2005-06-21 Kimmo