OSDN Git Service

PATCH: [ 805875 ] Switch to diffcode flags
authorPerry Rapp <elsapo@users.sourceforge.net>
Mon, 15 Sep 2003 00:32:09 +0000 (00:32 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Mon, 15 Sep 2003 00:32:09 +0000 (00:32 +0000)
13 files changed:
Src/DiffContext.cpp
Src/DiffContext.h
Src/DirActions.cpp
Src/DirDoc.cpp
Src/DirDoc.h
Src/DirScan.cpp
Src/DirView.cpp
Src/DirView.h
Src/DirViewColHandler.cpp
Src/DirViewColItems.cpp
Src/MainFrm.cpp
Src/MainFrm.h
Src/readme.txt

index 3d7e87f..435326b 100644 (file)
@@ -104,7 +104,7 @@ void CDiffContext::AddDiff(LPCTSTR pszFilename, LPCTSTR szSubdir
        , __int64 lmtime, __int64 rmtime
        , __int64 lctime, __int64 rctime
        , __int64 lsize, __int64 rsize
-       , BYTE code
+       , int diffcode
        )
 {
        DIFFITEM di;
@@ -116,7 +116,7 @@ void CDiffContext::AddDiff(LPCTSTR pszFilename, LPCTSTR szSubdir
        di.right.mtime = rmtime;
        di.left.ctime = lctime;
        di.right.ctime = rctime;
-       di.code = code;
+       di.diffcode = diffcode;
        di.left.size = lsize;
        di.right.size = rsize;
        UpdateFieldsNeededForNewItems(di, di.left);
@@ -137,7 +137,7 @@ void CDiffContext::AddDiff(DIFFITEM di)
 
        m_pList->AddTail(di);
        // ignore return value
-       SendMessage(m_hMainFrame, m_msgUpdateStatus, di.code, NULL);
+       SendMessage(m_hMainFrame, m_msgUpdateStatus, di.diffcode, NULL);
 }
 
 void CDiffContext::RemoveDiff(POSITION diffpos)
@@ -166,30 +166,23 @@ DIFFITEM CDiffContext::GetNextDiffPosition(POSITION & diffpos)
        return m_pList->GetNext(diffpos);
 }
 
-DIFFITEM CDiffContext::GetDiffAt(POSITION diffpos)
+const DIFFITEM & CDiffContext::GetDiffAt(POSITION diffpos) const
 {
        return m_pList->GetAt(diffpos);
 }
 
-const DIFFITEM CDiffContext::GetDiffAt(POSITION diffpos) const
-{
-       return m_pList->GetAt(diffpos);
-}
-
-BYTE CDiffContext::GetDiffStatus(POSITION diffpos)
-{
-       return m_pList->GetAt(diffpos).code;
-}
-
 int CDiffContext::GetDiffCount()
 {
        return m_pList->GetCount();
 }
 
-void CDiffContext::UpdateStatusCode(POSITION diffpos, BYTE status)
+void CDiffContext::SetDiffStatusCode(POSITION diffpos, UINT diffcode, UINT mask)
 {
+       ASSERT(diffpos);
        DIFFITEM & di = m_pList->GetAt(diffpos);
-       di.code = status;
+       ASSERT(! ((~mask) && diffcode) ); // make sure they only set flags in their mask
+       di.diffcode = di.diffcode & (~mask); // remove current data
+       di.diffcode = di.diffcode | diffcode; // add new data
 }
 
 /**
@@ -203,7 +196,7 @@ void CDiffContext::UpdateFieldsNeededForNewItems(DIFFITEM & di, DiffFileInfo & d
 }
 
 /**
- * @brief Update information from disk
+ * @brief Update the diffitem passed from disk
  */
 void CDiffContext::UpdateInfoFromDisk(DIFFITEM & di)
 {
@@ -212,6 +205,14 @@ void CDiffContext::UpdateInfoFromDisk(DIFFITEM & di)
 }
 
 /**
+ * @brief Update info in list (specified by position) from disk
+ */
+void CDiffContext::UpdateStatusFromDisk(POSITION diffpos)
+{
+       UpdateInfoFromDisk(m_pList->GetAt(diffpos));
+}
+
+/**
  * @brief Convert a FILETIME to a long (standard time)
  */
 static __int64 FileTimeToInt64(FILETIME & ft)
index 2e21d82..b19d1fd 100644 (file)
@@ -19,6 +19,20 @@ struct dirdata
 };
 
 // values for DIFFITEM.code
+namespace DIFFCODE {
+       enum { 
+               // We use extra bits so that no valid values are 0
+               // and each set of flags is in a different hex digit
+               // to make debugging easier
+               // These can always be packed down in the future
+               TEXTFLAG=0x3, TEXT=0x1, BIN=0x2,
+               DIRFLAG=0x30, FILE=0x10, DIR=0x20,
+               SIDEFLAG=0x300, LEFT=0x100, RIGHT=0x200, BOTH=0x300,
+               COMPAREFLAGS=0x7000, SAME=0x1000, DIFF=0x2000, SKIPPED=0x3000, CMPERR=0x4000
+       };
+};
+// old codes
+/* TODO: delete
 #define FILE_LUNIQUE     0
 #define FILE_RUNIQUE     1
 #define FILE_DIFF        2
@@ -30,6 +44,7 @@ struct dirdata
 #define FILE_RDIRUNIQUE  8
 #define FILE_SKIP        9
 #define FILE_DIRSKIP    10
+*/
 
 struct FileFlags
 {
@@ -71,10 +86,24 @@ struct DIFFITEM
        CString sfilename;
        CString sSubdir; //*< Common subdirectory from root of comparison */
        CString sext;
-       BYTE code;
+       int diffcode;
+
+       DIFFITEM() : diffcode(0) { }
+
        CString getLeftFilepath() const;
        CString getRightFilepath() const;
-       DIFFITEM() : code(0) { }
+
+       // file/directory
+       bool isDirectory() const { return ((diffcode & DIFFCODE::DIRFLAG) == DIFFCODE::DIR); }
+       // left/right
+       bool isSideLeft() const { return ((diffcode & DIFFCODE::SIDEFLAG) == DIFFCODE::LEFT); }
+       bool isSideRight() const { return ((diffcode & DIFFCODE::SIDEFLAG) == DIFFCODE::RIGHT); }
+       // result filters
+       bool isResultError() const { return ((diffcode & DIFFCODE::COMPAREFLAGS) == DIFFCODE::CMPERR); }
+       bool isResultSame() const { return ((diffcode & DIFFCODE::COMPAREFLAGS) == DIFFCODE::SAME); }
+       bool isResultSkipped() const { return ((diffcode & DIFFCODE::COMPAREFLAGS) == DIFFCODE::SKIPPED); }
+       // type
+       bool isBin() const { return ((diffcode & DIFFCODE::TEXTFLAG) == DIFFCODE::BIN); }
 };
 
 // Interface for reporting current file, as diff traverses file tree
@@ -104,7 +133,7 @@ public:
        // add & remove differences
        void AddDiff(LPCTSTR pszFilename, LPCTSTR szSubdir, LPCTSTR pszLeftDir, LPCTSTR pszRightDir
                , __int64 lmtime, __int64 rmtime, __int64 lctime, __int64 rctime
-               , __int64 lsize, __int64 rsize, BYTE code);
+               , __int64 lsize, __int64 rsize, int diffcode);
        void AddDiff(DIFFITEM di);
        void RemoveDiff(POSITION diffpos);
        void RemoveAll();
@@ -114,15 +143,16 @@ public:
        // to iterate over all differences on list
        POSITION GetFirstDiffPosition();
        DIFFITEM GetNextDiffPosition(POSITION & diffpos);
-       DIFFITEM GetDiffAt(POSITION diffpos);
-       const DIFFITEM GetDiffAt(POSITION diffpos) const;
-       BYTE GetDiffStatus(POSITION diffpos);
+//     DIFFITEM GetDiffAt(POSITION diffpos);
+       const DIFFITEM GetDiffAt(POSITION diffpos) const;
+//     int GetDiffStatus(POSITION diffpos);
        int GetDiffCount();
 
        // change an existing difference
-       void UpdateStatusCode(POSITION diffpos, BYTE status);
+       void SetDiffStatusCode(POSITION diffpos, UINT diffcode, UINT mask);
        void UpdateInfoFromDisk(DIFFITEM & di);
        void UpdateInfoFromDiskHalf(DIFFITEM & di, DiffFileInfo & dfi);
+       void UpdateStatusFromDisk(POSITION diffpos);
 
        BOOL m_bRecurse;
        CString m_strLeft;
index 58ffdbb..73ca3c1 100644 (file)
@@ -67,12 +67,6 @@ static BOOL ConfirmSingleDelete(LPCTSTR filepath)
        return (rtn==IDYES);
 }
 
-static BOOL
-IsItemCodeDir(int code)
-{
-       return code==FILE_LDIRUNIQUE || code==FILE_RDIRUNIQUE;
-}
-
 // Prompt & copy item from right to left, if legal
 void CDirView::DoCopyFileToLeft()
 {
@@ -82,15 +76,15 @@ void CDirView::DoCopyFileToLeft()
        while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (IsItemCopyableToLeft(di.code))
+               if (IsItemCopyableToLeft(di))
                {
                        GetItemFileNames(sel, slFile, srFile);
                        action act;
                        act.src = srFile;
                        act.dest = slFile;
                        act.idx = sel;
-                       act.code = di.code;
-                       act.dirflag = IsItemCodeDir(di.code);
+                       act.code = di.diffcode;
+                       act.dirflag = di.isDirectory();
                        actionList.actions.AddTail(act);
                }
                ++actionList.selcount;
@@ -107,15 +101,15 @@ void CDirView::DoCopyFileToRight()
        while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (IsItemCopyableToRight(di.code))
+               if (IsItemCopyableToRight(di))
                {
                        GetItemFileNames(sel, slFile, srFile);
                        action act;
                        act.src = slFile;
                        act.dest = srFile;
-                       act.dirflag = IsItemCodeDir(di.code);
+                       act.dirflag = di.isDirectory();
                        act.idx = sel;
-                       act.code = di.code;
+                       act.code = di.diffcode;
                        actionList.actions.AddTail(act);
                }
                ++actionList.selcount;
@@ -133,14 +127,14 @@ void CDirView::DoDelLeft()
        while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (IsItemDeletableOnLeft(di.code))
+               if (IsItemDeletableOnLeft(di))
                {
                        GetItemFileNames(sel, slFile, srFile);
                        action act;
                        act.src = slFile;
-                       act.dirflag = IsItemCodeDir(di.code);
+                       act.dirflag = di.isDirectory();
                        act.idx = sel;
-                       act.code = di.code;
+                       act.code = di.diffcode;
                        actionList.actions.AddTail(act);
                }
                ++actionList.selcount;
@@ -158,14 +152,14 @@ void CDirView::DoDelRight()
        {
                const DIFFITEM& di = GetDiffItem(sel);
 
-               if (IsItemDeletableOnRight(di.code))
+               if (IsItemDeletableOnRight(di))
                {
                        GetItemFileNames(sel, slFile, srFile);
                        action act;
                        act.src = srFile;
-                       act.dirflag = IsItemCodeDir(di.code);
+                       act.dirflag = di.isDirectory();
                        act.idx = sel;
-                       act.code = di.code;
+                       act.code = di.diffcode;
                        actionList.actions.AddTail(act);
                }
                ++actionList.selcount;
@@ -183,15 +177,15 @@ void CDirView::DoDelBoth()
        {
                const DIFFITEM& di = GetDiffItem(sel);
 
-               if (IsItemDeletableOnBoth(di.code))
+               if (IsItemDeletableOnBoth(di))
                {
                        GetItemFileNames(sel, slFile, srFile);
                        action act;
                        act.src = srFile;
                        act.dest = slFile;
-                       act.dirflag = IsItemCodeDir(di.code);
+                       act.dirflag = di.isDirectory();
                        act.idx = sel;
-                       act.code = di.code;
+                       act.code = di.diffcode;
                        actionList.actions.AddTail(act);
                }
                ++actionList.selcount;
@@ -304,10 +298,7 @@ void CDirView::PerformAndRemoveTopAction(ActionList & actionList)
                        // copy single file, and update status immediately
                        if (mf->SyncFiles(act.src, act.dest, &s))
                        {
-                               if (act.code == FILE_BINDIFF)
-                                       mf->UpdateCurrentFileStatus(GetDocument(), FILE_BINSAME, act.idx);
-                               else
-                                       mf->UpdateCurrentFileStatus(GetDocument(), FILE_SAME, act.idx);
+                               GetDocument()->SetDiffStatus(DIFFCODE::SAME, DIFFCODE::COMPAREFLAGS, act.idx);
                        }
                        else
                        {
@@ -343,11 +334,11 @@ void CDirView::PerformAndRemoveTopAction(ActionList & actionList)
                                {
                                        // figure out if copy on right
                                        POSITION diffpos = GetItemKey(act.idx);
-                                       BYTE code = GetDiffContext()->GetDiffStatus(diffpos);
-                                       if (IsItemLeftOnly(code))
+                                       const DIFFITEM & di = GetDiffContext()->GetDiffAt(diffpos);
+                                       if (di.isSideLeft())
                                                actionList.deletedItems.AddTail(act.idx);
                                        else
-                                               mf->UpdateCurrentFileStatus(GetDocument(), FILE_RUNIQUE, act.idx);
+                                               GetDocument()->SetDiffStatus(DIFFCODE::RIGHT, DIFFCODE::SIDEFLAG, act.idx);
                                }
                                else
                                {
@@ -362,11 +353,11 @@ void CDirView::PerformAndRemoveTopAction(ActionList & actionList)
                                {
                                        // figure out if copy on right
                                        POSITION diffpos = GetItemKey(act.idx);
-                                       BYTE code = GetDiffContext()->GetDiffStatus(diffpos);
-                                       if (IsItemRightOnly(code))
+                                       const DIFFITEM & di = GetDiffContext()->GetDiffAt(diffpos);
+                                       if (di.isSideRight())
                                                actionList.deletedItems.AddTail(act.idx);
                                        else
-                                               mf->UpdateCurrentFileStatus(GetDocument(), FILE_LUNIQUE, act.idx);
+                                               GetDocument()->SetDiffStatus(DIFFCODE::LEFT, DIFFCODE::SIDEFLAG, act.idx);
                                }
                                else
                                {
@@ -390,146 +381,96 @@ BOOL CDirView::GetSelectedDirNames(CString& strLeft, CString& strRight) const
        return bResult;
 }
 
-// Does item exist only on the left ?
-BOOL CDirView::IsItemLeftOnly(int code)
-{
-       return code==FILE_LUNIQUE || code==FILE_LDIRUNIQUE;
-}
-// Does item exist only on the right ?
-BOOL CDirView::IsItemRightOnly(int code)
-{
-       return code==FILE_RUNIQUE || code==FILE_RDIRUNIQUE;
-}
-
 // is it possible to copy item to left ?
-BOOL CDirView::IsItemCopyableToLeft(int code)
-{
-       switch(code)
-       {
-       case FILE_RUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINDIFF:
-               return TRUE;
-       // no point in allowing FILE_SAME
-       // TODO: FILE_RDIRUNIQUE: add code for directory copy
-       }
-       return FALSE;
+BOOL CDirView::IsItemCopyableToLeft(const DIFFITEM & di)
+{
+       // don't let them mess with error items
+       if (di.isResultError()) return FALSE;
+       // no directory copying right now
+       if (di.isDirectory()) return FALSE; 
+       // can't copy same items
+       if (di.isResultSame()) return FALSE;
+       // impossible if only on left
+       if (di.isSideLeft()) return FALSE;
+
+       // everything else can be copied to left
+       return TRUE;
 }
 // is it possible to copy item to right ?
-BOOL CDirView::IsItemCopyableToRight(int code)
-{
-       switch(code)
-       {
-       case FILE_LUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINDIFF:
-               return TRUE;
-       // no point in allowing FILE_SAME
-       // TODO: FILE_LDIRUNIQUE: add code for directory copy
-       }
-       return FALSE;
+BOOL CDirView::IsItemCopyableToRight(const DIFFITEM & di)
+{
+       // don't let them mess with error items
+       if (di.isResultError()) return FALSE;
+       // no directory copying right now
+       if (di.isDirectory()) return FALSE; 
+       // can't copy same items
+       if (di.isResultSame()) return FALSE;
+       // impossible if only on right
+       if (di.isSideRight()) return FALSE;
+
+       // everything else can be copied to right
+       return TRUE;
 }
 // is it possible to delete left item ?
-BOOL CDirView::IsItemDeletableOnLeft(int code)
+BOOL CDirView::IsItemDeletableOnLeft(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_LUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-       case FILE_LDIRUNIQUE:
-               return TRUE;
-       }
-       return FALSE;
+       // don't let them mess with error items
+       if (di.isResultError()) return FALSE;
+       // impossible if only on right
+       if (di.isSideRight()) return FALSE;
+       // everything else can be deleted on left
+       return TRUE;
 }
 // is it possible to delete right item ?
-BOOL CDirView::IsItemDeletableOnRight(int code)
+BOOL CDirView::IsItemDeletableOnRight(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_RUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-       case FILE_RDIRUNIQUE:
-               return TRUE;
-       }
-       return FALSE;
+       // don't let them mess with error items
+       if (di.isResultError()) return FALSE;
+       // impossible if only on right
+       if (di.isSideLeft()) return FALSE;
+
+       // everything else can be deleted on right
+       return TRUE;
 }
 // is it possible to delete both items ?
-BOOL CDirView::IsItemDeletableOnBoth(int code)
+BOOL CDirView::IsItemDeletableOnBoth(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-               return TRUE;
-       }
-       return FALSE;
+       // don't let them mess with error items
+       if (di.isResultError()) return FALSE;
+       // impossible if only on right or left
+       if (di.isSideLeft() || di.isSideRight()) return FALSE;
+
+       // everything else can be deleted on both
+       return TRUE;
 }
 
 // is it possible to open left item ?
-BOOL CDirView::IsItemOpenableOnLeft(int code)
+BOOL CDirView::IsItemOpenableOnLeft(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_LUNIQUE:
-       case FILE_LDIRUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-               return TRUE;
-       }
-       return FALSE;
+       // impossible if only on right
+       if (di.isSideRight()) return FALSE;
+
+       // everything else can be opened on right
+       return TRUE;
 }
 // is it possible to open right item ?
-BOOL CDirView::IsItemOpenableOnRight(int code)
+BOOL CDirView::IsItemOpenableOnRight(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_RUNIQUE:
-       case FILE_RDIRUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-               return TRUE;
-       }
-       return FALSE;
+       // impossible if only on left
+       if (di.isSideLeft()) return FALSE;
+
+       // everything else can be opened on left
+       return TRUE;
 }
 // is it possible to open left ... item ?
-BOOL CDirView::IsItemOpenableOnLeftWith(int code)
+BOOL CDirView::IsItemOpenableOnLeftWith(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_LUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-               return TRUE;
-       }
-       return FALSE;
+       return (!di.isDirectory() && IsItemOpenableOnLeft(di));
 }
 // is it possible to open with ... right item ?
-BOOL CDirView::IsItemOpenableOnRightWith(int code)
+BOOL CDirView::IsItemOpenableOnRightWith(const DIFFITEM & di)
 {
-       switch(code)
-       {
-       case FILE_RUNIQUE:
-       case FILE_DIFF:
-       case FILE_BINSAME:
-       case FILE_BINDIFF:
-       case FILE_SAME:
-               return TRUE;
-       }
-       return FALSE;
+       return (!di.isDirectory() && IsItemOpenableOnRight(di));
 }
 
 // get the file names on both sides for first selected item
index 6cfc05f..fb998c4 100644 (file)
@@ -265,58 +265,31 @@ static LPCTSTR GetItemPathIfShowable(const DIFFITEM & di, int llen, int rlen)
        if (IsItemHiddenBackup(di))
                return NULL;
 
-       LPCTSTR p = NULL;
+       // file type filters
+       if (di.isBin() && !mf->m_bShowBinaries)
+               return 0;
 
-       BOOL leftside = (di.code==FILE_LUNIQUE || di.code==FILE_LDIRUNIQUE);
-       BOOL rightside = (di.code==FILE_RUNIQUE || di.code==FILE_RDIRUNIQUE);
+       // result filters
+       if (di.isResultSame() && !mf->m_bShowIdent)
+               return 0;
+       if (di.isResultError() && !mf->m_bShowErrors)
+               return 0;
+       if (di.isResultSkipped() && !mf->m_bShowSkipped)
+               return 0;
 
-       switch (di.code)
-       {
-       case FILE_DIFF:
-               if (mf->m_bShowDiff)
-               {
-                       p = _tcsninc(di.getLeftFilepath(), llen);
-               }
-               break;
-       case FILE_BINSAME:
-               if (mf->m_bShowIdent && mf->m_bShowBinaries)
-               {
-                       p = _tcsninc(di.getLeftFilepath(), llen);
-               }
-               break;
-       case FILE_BINDIFF:
-               if (mf->m_bShowDiff && mf->m_bShowBinaries)
-               {
-                       p = _tcsninc(di.getLeftFilepath(), llen);
-               }
-               break;
-       case FILE_LUNIQUE:
-       case FILE_RUNIQUE:
-       case FILE_LDIRUNIQUE:
-       case FILE_RDIRUNIQUE:
-               if ((mf->m_bShowUniqueLeft && leftside) 
-                       || (mf->m_bShowUniqueRight && rightside))
-               {
-                       if (di.code==FILE_LUNIQUE || di.code==FILE_LDIRUNIQUE)
-                       {
-                               p = _tcsninc(di.getLeftFilepath(), llen);
-                       }
-                       else
-                       {
-                               p = _tcsninc(di.getRightFilepath(), rlen);
-                       }
-               }
-               break;
-       case FILE_SAME:
-               if (mf->m_bShowIdent)
-               {
-                       p = _tcsninc(di.getLeftFilepath(), llen);
-               }
-               break;
-       default: // error
+       // left/right filters
+       if (di.isSideLeft() && !mf->m_bShowUniqueLeft)
+               return 0;
+       if (di.isSideRight() && !mf->m_bShowUniqueRight)
+               return 0;
+
+
+       LPCTSTR p = NULL;
+       if (di.isSideRight())
+               p = _tcsninc(di.getRightFilepath(), rlen);
+       else
                p = _tcsninc(di.getLeftFilepath(), llen);
-               break;
-       }
+
        return p;
 }
 
@@ -575,17 +548,16 @@ void CDirDoc::UpdateChangedItem(LPCTSTR pathLeft, LPCTSTR pathRight, bool unifie
 
        // Get index at view, update filetimes to context
        // and tell view to update found item
-       DIFFITEM current = m_pCtxt->GetDiffAt(pos);
-       m_pCtxt->UpdateInfoFromDisk(current);
+       m_pCtxt->UpdateStatusFromDisk(pos);
 
        // Figure out new status code
-       current.code = (unified ? FILE_SAME : FILE_DIFF);
-
+       UINT diffcode = (unified ? DIFFCODE::SAME : DIFFCODE::DIFF);
        // Save new status code to diff context memory
-       m_pCtxt->UpdateStatusCode(pos, current.code);
+       m_pCtxt->SetDiffStatusCode(pos, diffcode, DIFFCODE::COMPAREFLAGS);
 
        // Update view
-       UpdateScreenItemStatus(ind, current);
+       const DIFFITEM & updated = m_pCtxt->GetDiffAt(pos);
+       UpdateScreenItemStatus(ind, updated);
 }
 
 /**
@@ -641,3 +613,30 @@ void CDirDoc::SetRecursive(BOOL bRecursive)
 {
        m_bRecursive = bRecursive;
 }
+
+void CDirDoc::SetDiffSide(UINT diffcode, int idx)
+{
+       SetDiffStatus(diffcode, DIFFCODE::SIDEFLAG, idx);
+}
+
+void CDirDoc::SetDiffCompare(UINT diffcode, int idx)
+{
+       SetDiffStatus(diffcode, DIFFCODE::COMPAREFLAGS, idx);
+}
+
+void CDirDoc::SetDiffStatus(UINT diffcode, UINT mask, int idx)
+{
+       CDirView *pv = GetMainView();
+       ASSERT(pv);
+       // first change it in the dirlist
+       POSITION diffpos = pv->GetItemKey(idx);
+
+       // TODO: Why is the update broken into these pieces ?
+       // Someone could figure out these pieces and probably simplify this.
+
+       // update DIFFITEM code
+       m_pCtxt->SetDiffStatusCode(diffpos, diffcode, mask);
+       // update DIFFITEM time, and also tell views
+       ReloadItemStatus(idx);
+}
+
index 09aec18..45490b3 100644 (file)
@@ -86,7 +86,8 @@ public:
        void CompareReady();
        void UpdateChangedItem(LPCTSTR pathLeft, LPCTSTR pathRight, bool unified);
        POSITION FindItemFromPaths(LPCTSTR pathLeft, LPCTSTR pathRight);
-       void SetDiffContext(CDiffContext *pCtxt);
+       void SetDiffSide(UINT diffcode, int idx);
+       void SetDiffCompare(UINT diffcode, int idx);
        void UpdateResources();
        void InitStatusStrings();
        void ReloadItemStatus(UINT nIdx);
@@ -98,6 +99,8 @@ public:
        void AddMergeDoc(CMergeDoc * pMergeDoc);
        void MergeDocClosing(CMergeDoc * pMergeDoc);
        CDiffThread m_diffThread;
+       void SetDiffStatus(UINT diffcode, UINT mask, int idx);
+       void SetDiffContext(CDiffContext *pCtxt);
 
 #ifdef _DEBUG
        virtual void AssertValid() const;
index a3ef3e4..afd9a2c 100644 (file)
@@ -79,14 +79,14 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                if (i<leftDirs.GetSize() && (j==rightDirs.GetSize() || collstr(leftDirs[i].name, rightDirs[j].name, casesensitive)<0))
                {
                        // Advance left pointer over left-only entry, and then retest with new pointers
-                       FilterAdd(subdir, &leftDirs[i], 0, FILE_LDIRUNIQUE, pCtxt);
+                       FilterAdd(subdir, &leftDirs[i], 0, DIFFCODE::LEFT+DIFFCODE::DIR, pCtxt);
                        ++i;
                        continue;
                }
                if (j<rightDirs.GetSize() && (i==leftDirs.GetSize() || collstr(leftDirs[i].name, rightDirs[j].name, casesensitive)>0))
                {
                        // Advance right pointer over right-only entry, and then retest with new pointers
-                       FilterAdd(subdir, 0, &rightDirs[j], FILE_RDIRUNIQUE, pCtxt);
+                       FilterAdd(subdir, 0, &rightDirs[j], DIFFCODE::RIGHT+DIFFCODE::DIR, pCtxt);
                        ++j;
                        continue;
                }
@@ -96,7 +96,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                        CString newsub = subprefix + leftDirs[i].name;
                        if (!depth || !pCtxt->m_piFilter->includeDir(newsub))
                        {
-                               FilterAdd(subdir, &leftDirs[i], &rightDirs[j], FILE_DIRSKIP, pCtxt);
+                               FilterAdd(subdir, &leftDirs[i], &rightDirs[j], DIFFCODE::SKIPPED+DIFFCODE::DIR, pCtxt);
                        }
                        else
                        {
@@ -122,14 +122,14 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                if (i<leftFiles.GetSize() && (j==rightFiles.GetSize() || collstr(leftFiles[i].name, rightFiles[j].name, casesensitive)<0))
                {
                        // Advance left pointer over left-only entry, and then retest with new pointers
-                       FilterAdd(subdir, &leftFiles[i], 0, FILE_LUNIQUE, pCtxt);
+                       FilterAdd(subdir, &leftFiles[i], 0, DIFFCODE::LEFT+DIFFCODE::FILE, pCtxt);
                        ++i;
                        continue;
                }
                if (j<rightFiles.GetSize() && (i==leftFiles.GetSize() || collstr(leftFiles[i].name, rightFiles[j].name, casesensitive)>0))
                {
                        // Advance right pointer over right-only entry, and then retest with new pointers
-                       FilterAdd(subdir, 0, &rightFiles[j], FILE_RUNIQUE, pCtxt);
+                       FilterAdd(subdir, 0, &rightFiles[j], DIFFCODE::RIGHT+DIFFCODE::FILE, pCtxt);
                        ++j;
                        continue;
                }
@@ -139,7 +139,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                        CString newsubfile = subprefix + leftFiles[i].name;
                        if (!pCtxt->m_piFilter->includeFile(newsubfile))
                        {
-                               FilterAdd(subdir, &leftFiles[i], &rightFiles[j], FILE_SKIP, pCtxt);
+                               FilterAdd(subdir, &leftFiles[i], &rightFiles[j], DIFFCODE::SKIPPED+DIFFCODE::FILE, pCtxt);
                        }
                        else
                        {
@@ -154,12 +154,12 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                                if (res == 0)
                                {
                                        // same
-                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], FILE_SAME, pCtxt);
+                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], DIFFCODE::SAME+DIFFCODE::FILE, pCtxt);
                                }
                                else if (res == 1)
                                {
                                        // different
-                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], FILE_DIFF, pCtxt);
+                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], DIFFCODE::DIFF+DIFFCODE::FILE, pCtxt);
                                }
                                else 
                                {
@@ -170,7 +170,7 @@ int DirScan(const CString & subdir, CDiffContext * pCtxt, bool casesensitive, in
                                                ASSERT(0);
                                        }
                                        // error
-                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], FILE_ERROR, pCtxt);
+                                       FilterAdd(subdir, &leftFiles[i], &rightFiles[j], DIFFCODE::CMPERR+DIFFCODE::FILE, pCtxt);
                                }
                        }
                        ++i;
index 00efdf1..1f5f850 100644 (file)
@@ -231,6 +231,43 @@ void CDirView::OnInitialUpdate()
        SetFullRowSel(FALSE);
 }
 
+// These are the offsets into the image list created in OnInitDialog
+#define DIFFIMG_LUNIQUE     0
+#define DIFFIMG_RUNIQUE     1
+#define DIFFIMG_DIFF        2
+#define DIFFIMG_SAME        3
+#define DIFFIMG_ERROR       4
+#define DIFFIMG_BINSAME     5
+#define DIFFIMG_BINDIFF     6
+#define DIFFIMG_LDIRUNIQUE  7
+#define DIFFIMG_RDIRUNIQUE  8
+#define DIFFIMG_SKIP        9
+#define DIFFIMG_DIRSKIP    10
+
+/**
+ * @brief Return image index appropriate for this row
+ */
+int CDirView::GetColImage(const DIFFITEM & di) const
+{
+       // Must return an image index into image list created above in OnInitDialog
+       if (di.isResultError()) return DIFFIMG_ERROR;
+       if (di.isResultSkipped())
+               return (di.isDirectory() ? DIFFIMG_DIRSKIP : DIFFIMG_SKIP);
+       if (di.isSideLeft())
+               return (di.isDirectory() ? DIFFIMG_LDIRUNIQUE : DIFFIMG_LUNIQUE);
+       if (di.isSideRight())
+               return (di.isDirectory() ? DIFFIMG_RDIRUNIQUE : DIFFIMG_RUNIQUE);
+       if (di.isResultSame())
+               return (di.isBin() ? DIFFIMG_BINSAME : DIFFIMG_SAME);
+       // diff
+       return (di.isBin() ? DIFFIMG_BINDIFF : DIFFIMG_DIFF);
+}
+int CDirView::GetDefaultColImage() const
+{
+       return DIFFIMG_ERROR;
+}
+
+
 void CDirView::OnLButtonDblClk(UINT nFlags, CPoint point) 
 {
        WaitStatusCursor waitstatus(LoadResString(IDS_STATUS_OPENING_SELECTION));
@@ -446,7 +483,7 @@ void CDirView::DoUpdateDirCopyFileToLeft(CCmdUI* pCmdUI, eMenuType menuType)
                while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
                {
                        const DIFFITEM& di = GetDiffItem(sel);
-                       if (IsItemCopyableToLeft(di.code))
+                       if (IsItemCopyableToLeft(di))
                                ++legalcount;
                        ++selcount;
                }
@@ -472,7 +509,7 @@ void CDirView::DoUpdateDirCopyFileToRight(CCmdUI* pCmdUI, eMenuType menuType)
                while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
                {
                        const DIFFITEM& di = GetDiffItem(sel);
-                       if (IsItemCopyableToRight(di.code))
+                       if (IsItemCopyableToRight(di))
                                ++legalcount;
                        ++selcount;
                }
@@ -558,42 +595,20 @@ void CDirView::OpenSelection()
        {
                POSITION diffpos = GetItemKey(sel);
                DIFFITEM di = GetDiffContext()->GetDiffAt(diffpos);
-               switch(di.code)
+               if (di.isDirectory())
+                       AfxMessageBox(IDS_FILEISDIR, MB_ICONINFORMATION);
+               else if (di.isSideLeft() || di.isSideRight())
+                       AfxMessageBox(IDS_FILEUNIQUE, MB_ICONINFORMATION);
+               else if (di.isBin())
+                       AfxMessageBox(IDS_FILEBINARY, MB_ICONSTOP);
+               else
                {
-               // Open identical and different files
-               case FILE_DIFF:
-               case FILE_SAME:
-                       {
-                               CString left, right;
-                               GetItemFileNames(sel, left, right);
-                               mf->ShowMergeDoc(GetDocument(), left, right,
-                                       GetDocument()->GetReadOnly(TRUE),
-                                       GetDocument()->GetReadOnly(FALSE));
-                       }
-                       break;
-               case FILE_LDIRUNIQUE:
-               case FILE_RDIRUNIQUE:
-                       {
-                               AfxMessageBox(IDS_FILEISDIR, MB_ICONINFORMATION);
-                       }
-                       break;
-               case FILE_LUNIQUE:
-               case FILE_RUNIQUE:
-                       {
-                               AfxMessageBox(IDS_FILEUNIQUE, MB_ICONINFORMATION);
-                       }
-                       break;
-               case FILE_BINDIFF:
-               case FILE_BINSAME:
-                       {
-                               AfxMessageBox(IDS_FILEBINARY, MB_ICONSTOP);
-                       }
-                       break;
-               default:
-                       {
-                               AfxMessageBox(IDS_FILEERROR, MB_ICONSTOP);
-                       }
-                       break;
+                       // Open identical and different files
+                       CString left, right;
+                       GetItemFileNames(sel, left, right);
+                       mf->ShowMergeDoc(GetDocument(), left, right,
+                               GetDocument()->GetReadOnly(TRUE),
+                               GetDocument()->GetReadOnly(FALSE));
                }
        }
 }
@@ -645,7 +660,7 @@ void CDirView::DoUpdateCtxtDirDelLeft(CCmdUI* pCmdUI)
                while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
                {
                        const DIFFITEM& di = GetDiffItem(sel);
-                       if (IsItemDeletableOnLeft(di.code))
+                       if (IsItemDeletableOnLeft(di))
                                ++count;
                        ++total;
                }
@@ -668,7 +683,7 @@ void CDirView::DoUpdateCtxtDirDelRight(CCmdUI* pCmdUI)
                while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
                {
                        const DIFFITEM& di = GetDiffItem(sel);
-                       if (IsItemDeletableOnRight(di.code))
+                       if (IsItemDeletableOnRight(di))
                                ++count;
                        ++total;
                }
@@ -691,7 +706,7 @@ void CDirView::DoUpdateCtxtDirDelBoth(CCmdUI* pCmdUI)
                while ((sel = m_pList->GetNextItem(sel, LVNI_SELECTED)) != -1)
                {
                        const DIFFITEM& di = GetDiffItem(sel);
-                       if (IsItemDeletableOnBoth(di.code))
+                       if (IsItemDeletableOnBoth(di))
                                ++count;
                        ++total;
                }
@@ -803,7 +818,7 @@ void CDirView::DoUpdateOpenLeft(CCmdUI* pCmdUI)
        if (sel != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (!IsItemOpenableOnLeft(di.code))
+               if (!IsItemOpenableOnLeft(di))
                        sel = -1;
        }
 
@@ -817,7 +832,7 @@ void CDirView::DoUpdateOpenRight(CCmdUI* pCmdUI)
        if (sel != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (!IsItemOpenableOnRight(di.code))
+               if (!IsItemOpenableOnRight(di))
                        sel = -1;
        }
 
@@ -831,7 +846,7 @@ void CDirView::DoUpdateOpenLeftWith(CCmdUI* pCmdUI)
        if (sel != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (!IsItemOpenableOnLeftWith(di.code))
+               if (!IsItemOpenableOnLeftWith(di))
                        sel = -1;
        }
 
@@ -845,7 +860,7 @@ void CDirView::DoUpdateOpenRightWith(CCmdUI* pCmdUI)
        if (sel != -1)
        {
                const DIFFITEM& di = GetDiffItem(sel);
-               if (!IsItemOpenableOnRightWith(di.code))
+               if (!IsItemOpenableOnRightWith(di))
                        sel = -1;
        }
 
@@ -1134,14 +1149,11 @@ int CDirView::GetLastDifferentItem()
 // When navigating differences, do we stop at this one ?
 bool CDirView::IsItemNavigableDiff(const DIFFITEM & di) const
 {
-       switch(di.code)
-       {
-       case FILE_DIFF: return true;
-       case FILE_BINDIFF: return true;
-       case FILE_LUNIQUE: return true;
-       case FILE_RUNIQUE: return true;
-       }
-       return false;
+       if (di.isResultSkipped() || di.isResultError())
+               return false;
+       if (di.isDirectory())
+               return false;
+       return true;
 }
 
 // move focus (& selection if only one selected) from currentInd to i
index 1b50686..893ffe9 100644 (file)
@@ -122,15 +122,15 @@ private:
        void GetItemFileNames(int sel, CString& strLeft, CString& strRight) const;
        BOOL IsItemLeftOnly(int code);
        BOOL IsItemRightOnly(int code);
-       BOOL IsItemCopyableToLeft(int code);
-       BOOL IsItemCopyableToRight(int code);
-       BOOL IsItemDeletableOnLeft(int code);
-       BOOL IsItemDeletableOnRight(int code);
-       BOOL IsItemDeletableOnBoth(int code);
-       BOOL IsItemOpenableOnLeft(int code);
-       BOOL IsItemOpenableOnRight(int code);
-       BOOL IsItemOpenableOnLeftWith(int code);
-       BOOL IsItemOpenableOnRightWith(int code);
+       BOOL IsItemCopyableToLeft(const DIFFITEM & di);
+       BOOL IsItemCopyableToRight(const DIFFITEM & di);
+       BOOL IsItemDeletableOnLeft(const DIFFITEM & di);
+       BOOL IsItemDeletableOnRight(const DIFFITEM & di);
+       BOOL IsItemDeletableOnBoth(const DIFFITEM & di);
+       BOOL IsItemOpenableOnLeft(const DIFFITEM & di);
+       BOOL IsItemOpenableOnRight(const DIFFITEM & di);
+       BOOL IsItemOpenableOnLeftWith(const DIFFITEM & di);
+       BOOL IsItemOpenableOnRightWith(const DIFFITEM & di);
        void DoCopyFileToRight();
        void DoCopyFileToLeft();
        void DoDelLeft();
@@ -191,6 +191,8 @@ protected:
        int GetFocusedItem();
        int GetFirstDifferentItem();
        int GetLastDifferentItem();
+       int GetColImage(const DIFFITEM & di) const;
+       int GetDefaultColImage() const;
 
 // Implementation data
 protected:
index e5e8289..d24cb22 100644 (file)
@@ -124,31 +124,10 @@ int CDirView::AddDiffItem(int index, const DIFFITEM & di, LPCTSTR szPath, POSITI
 {
        int i = AddNewItem(index);
        SetItemKey(i, curdiffpos);
-       SetImage(i, FILE_ERROR);
+       SetImage(i, GetDefaultColImage());
        return i;
 }
 
-/**
- * @brief Return image index appropriate for this row
- */
-static int GetColImage(const DIFFITEM & di)
-{
-       switch (di.code)
-       {
-       case FILE_DIFF: return FILE_DIFF;
-       case FILE_BINDIFF: return FILE_BINDIFF;
-       case FILE_BINSAME: return FILE_BINSAME;
-       case FILE_LUNIQUE:
-       case FILE_LDIRUNIQUE:
-               return di.code;
-       case FILE_RUNIQUE:
-       case FILE_RDIRUNIQUE:
-               return di.code;
-               break;
-       case FILE_SAME: return FILE_SAME;
-       default: return FILE_ERROR;
-       }
-}
 
 // Update listview display of details for specified row
 void CDirView::UpdateDiffItemStatus(UINT nIdx, const DIFFITEM & di)
index b2b8ce7..12a58b8 100644 (file)
@@ -50,6 +50,14 @@ static int cmp64(__int64 i1, __int64 i2)
        if (i1==i2) return 0;
        return i1>i2 ? 1 : -1;
 }
+/**
+ * @brief Function to compare two diffcodes
+ */
+static int cmpdiffcode(int diffcode1, int diffcode2)
+{
+       // TODO: How shall we order these ?
+       return diffcode1-diffcode2;     
+}
 
 /**
  * @{ Functions to display each type of column info
@@ -68,37 +76,38 @@ static CString ColPathGet(const DIFFITEM & di)
 static CString ColStatusGet(const DIFFITEM & di)
 {
        CString s;
-       switch (di.code)
+       if (di.isResultError())
+       {
+               VERIFY(s.LoadString(IDS_CANT_COMPARE_FILES));
+       }
+       else if (di.isSideLeft())
        {
-       case FILE_DIFF:
-               VERIFY(s.LoadString(IDS_FILES_ARE_DIFFERENT));
-               break;
-       case FILE_BINDIFF:
-               VERIFY(s.LoadString(IDS_BIN_FILES_DIFF));
-               break;
-       case FILE_BINSAME:
-               VERIFY(s.LoadString(IDS_BIN_FILES_SAME));
-               break;
-       case FILE_LUNIQUE:
-       case FILE_LDIRUNIQUE:
                AfxFormatString1(s, IDS_ONLY_IN_FMT, di.getLeftFilepath());
-               break;
-       case FILE_RUNIQUE:
-       case FILE_RDIRUNIQUE:
+       }
+       else if (di.isSideRight())
+       {
                AfxFormatString1(s, IDS_ONLY_IN_FMT, di.getRightFilepath());
-               break;
-       case FILE_SAME:
-               VERIFY(s.LoadString(IDS_IDENTICAL));
-               break;
-       case FILE_SKIP:
-               VERIFY(s.LoadString(IDS_FILE_SKIPPED));
-               break;
-       case FILE_DIRSKIP:
-               VERIFY(s.LoadString(IDS_DIR_SKIPPED));
-               break;
-       default: // error
-               VERIFY(s.LoadString(IDS_CANT_COMPARE_FILES));
-               break;
+       }
+       else if (di.isResultSkipped())
+       {
+               if (di.isDirectory())
+                       VERIFY(s.LoadString(IDS_DIR_SKIPPED));
+               else
+                       VERIFY(s.LoadString(IDS_FILE_SKIPPED));
+       }
+       else if (di.isResultSame())
+       {
+               if (di.isBin())
+                       VERIFY(s.LoadString(IDS_BIN_FILES_SAME));
+               else
+                       VERIFY(s.LoadString(IDS_IDENTICAL));
+       }
+       else // diff
+       {
+               if (di.isBin())
+                       VERIFY(s.LoadString(IDS_BIN_FILES_DIFF));
+               else
+                       VERIFY(s.LoadString(IDS_FILES_ARE_DIFFERENT));
        }
        return s;
 }
@@ -180,22 +189,41 @@ static CString ColRverGet(const DIFFITEM & di)
 static CString ColStatusAbbrGet(const DIFFITEM & di)
 {
        int id;
-       switch (di.code)
+
+       if (di.isResultError())
+       {
+               id = IDS_CANT_COMPARE_FILES;
+       }
+       else if (di.isSideLeft())
+       {
+               id = IDS_LEFTONLY;
+       }
+       else if (di.isSideRight())
        {
-       case FILE_DIFF: id = IDS_FILES_ARE_DIFFERENT; break;
-       case FILE_BINDIFF: id = IDS_BIN_FILES_DIFF; break;
-       case FILE_BINSAME: id = IDS_BIN_FILES_SAME; break;
-       case FILE_LUNIQUE:
-       case FILE_LDIRUNIQUE:
-               id = IDS_LEFTONLY; break;
-       case FILE_RUNIQUE:
-       case FILE_RDIRUNIQUE:
-               id = IDS_RIGHTONLY; break;
-       case FILE_SAME: id = IDS_IDENTICAL; break;
-       case FILE_SKIP: id = IDS_FILE_SKIPPED; break;
-       case FILE_DIRSKIP: id = IDS_DIR_SKIPPED; break;
-       default: id = IDS_CANT_COMPARE_FILES;
+               id = IDS_RIGHTONLY;
        }
+       else if (di.isResultSkipped())
+       {
+               if (di.isDirectory())
+                       id = IDS_DIR_SKIPPED;
+               else
+                       id = IDS_FILE_SKIPPED;
+       }
+       else if (di.isResultSame())
+       {
+               if (di.isBin())
+                       id = IDS_BIN_FILES_SAME;
+               else
+                       id = IDS_IDENTICAL;
+       }
+       else // diff
+       {
+               if (di.isBin())
+                       id = IDS_BIN_FILES_DIFF;
+               else
+                       id = IDS_FILES_ARE_DIFFERENT;
+       }
+
        CString s;
        VERIFY(s.LoadString(id));
        return s;
@@ -225,7 +253,7 @@ static int ColPathSort(const DIFFITEM & ldi, const DIFFITEM &rdi)
 }
 static int ColStatusSort(const DIFFITEM & ldi, const DIFFITEM &rdi)
 {
-       return rdi.code-ldi.code;
+       return cmpdiffcode(rdi.diffcode, ldi.diffcode);
 }
 static int ColLmtimeSort(const DIFFITEM & ldi, const DIFFITEM &rdi)
 {
index c3723d9..efed4fc 100644 (file)
@@ -134,6 +134,8 @@ CMainFrame::CMainFrame()
        m_bShowDiff = theApp.GetProfileInt(_T("Settings"), _T("ShowDifferent"), TRUE)!=0;
        m_bShowIdent = theApp.GetProfileInt(_T("Settings"), _T("ShowIdentical"), TRUE)!=0;
        m_bShowBinaries = theApp.GetProfileInt(_T("Settings"), _T("ShowBinaries"), TRUE)!=0;
+       m_bShowErrors = TRUE;
+       m_bShowSkipped = TRUE;
        m_bBackup = theApp.GetProfileInt(_T("Settings"), _T("BackupFile"), TRUE)!=0;
        m_bViewWhitespace = theApp.GetProfileInt(_T("Settings"), _T("ViewWhitespace"), FALSE)!=0;
        m_bScrollToFirst = theApp.GetProfileInt(_T("Settings"), _T("ScrollToFirst"), FALSE)!=0;
@@ -816,38 +818,79 @@ void CMainFrame::clearStatus()
 }
 
 // diff completed another file
-void CMainFrame::rptStatus(BYTE code)
+void CMainFrame::rptStatus(UINT diffcode)
 {
-       switch(code)
+       // TODO: This is a mess
+       // How do we fix this ?
+       DIFFITEM di;
+       di.diffcode = diffcode;
+       if (di.isSideLeft())
        {
-       case FILE_SAME:
-               ++m_nStatusFileSame;
-               break;
-       case FILE_BINSAME:
-               ++m_nStatusFileBinSame;
-               break;
-       case FILE_DIFF:
-               ++m_nStatusFileDiff;
-               break;
-       case FILE_BINDIFF:
-               ++m_nStatusFileBinDiff;
-               break;
-       case FILE_ERROR:
-               ++m_nStatusFileError;
-               break;
-       case FILE_LUNIQUE:
-               ++m_nStatusLeftFileOnly;
-               break;
-       case FILE_LDIRUNIQUE:
-               ++m_nStatusLeftDirOnly;
-               break;
-       case FILE_RUNIQUE:
-               ++m_nStatusRightFileOnly;
-               break;
-       case FILE_RDIRUNIQUE:
-               ++m_nStatusRightDirOnly;
-               break;
+               if (di.isDirectory())
+               {
+                       ++m_nStatusLeftDirOnly;
+               }
+               else
+               {
+                       ++m_nStatusLeftFileOnly;
+               }
        }
+       else if (di.isSideRight())
+       {
+               if (di.isDirectory())
+               {
+                       ++m_nStatusRightDirOnly;
+               }
+               else
+               {
+                       ++m_nStatusRightFileOnly;
+               }
+       }
+       else
+       {
+               if (di.isResultSkipped())
+               {
+                       // what about skipped items ?
+               }
+               else if (di.isResultError())
+               {
+                       // could be directory error ?
+                       ++m_nStatusFileError;
+               }
+               // Now we know it was on both sides & compared!
+               else if (di.isResultSame())
+               {
+                       if (di.isBin())
+                       {
+                               ++m_nStatusFileBinSame;
+                       }
+                       else
+                       {
+                               ++m_nStatusFileSame;
+                       }
+               }
+               else
+               {
+                       // presumably it is diff
+                       if (di.isDirectory())
+                       {
+                               // this doesn't happen right now, but it will
+                               // TODO
+                       }
+                       else
+                       {
+                               if (di.isBin())
+                               {
+                                       ++m_nStatusFileBinDiff;
+                               }
+                               else
+                               {
+                                       ++m_nStatusFileDiff;
+                               }
+                       }
+               }
+       }
+
        CString s;
        // TODO: Load the format string from resource
        s.Format(_T("s:%d bs:%d d:%d bd:%d lf:%d ld:%d rf:%d rd:%d e:%d")
@@ -1113,22 +1156,6 @@ BOOL CMainFrame::DoSyncFiles(LPCTSTR pszSrc, LPCTSTR pszDest, CString * psError)
        return TRUE;
 }
 
-void CMainFrame::UpdateCurrentFileStatus(CDirDoc * pDirDoc, UINT nStatus, int idx)
-{
-       ASSERT(pDirDoc);
-       CDirView *pv = pDirDoc->GetMainView();
-       ASSERT(pv);
-       // first change it in the dirlist
-       POSITION diffpos = pv->GetItemKey(idx);
-
-       // TODO: Why is the update broken into these pieces ?
-       // Someone could figure out these pieces and probably simplify this.
-
-       // update DIFFITEM code
-       pDirDoc->m_pCtxt->UpdateStatusCode(diffpos, (BYTE)nStatus);
-       // update DIFFITEM time, and also tell views
-       pDirDoc->ReloadItemStatus(idx);
-}
 
 void CMainFrame::OnViewSelectfont() 
 {
index cbd2c44..af17235 100644 (file)
@@ -76,6 +76,8 @@ public:
        BOOL m_bShowDiff;
        BOOL m_bShowIdent;
        BOOL m_bShowBinaries;
+       BOOL m_bShowErrors;
+       BOOL m_bShowSkipped;
        BOOL m_bBackup;
        BOOL m_bAllowMixedEol;
        LOGFONT m_lfDiff;
@@ -86,11 +88,10 @@ public:
 // Operations
 public:
        BOOL DeleteFileOrError(LPCTSTR szFile);
-       void rptStatus(BYTE code);
+       void rptStatus(UINT diffcode);
        void clearStatus();
        BOOL SyncFiles(LPCTSTR pszSrc, LPCTSTR pszDest, CString * psError);
        BOOL DoSyncFiles(LPCTSTR pszSrc, LPCTSTR pszDest, CString * psError);
-       void UpdateCurrentFileStatus(CDirDoc * pDirDoc, UINT nStatus, int idx);
        BOOL DoFileOpen(LPCTSTR pszLeft = NULL, LPCTSTR pszRight = NULL,
                DWORD dwLeftFlags = 0, DWORD dwRightFlags = 0, BOOL bRecurse = FALSE);
        void ShowMergeDoc(CDirDoc * pDirDoc, LPCTSTR szLeft, LPCTSTR szRight, BOOL bROLeft = FALSE, BOOL bRORight = FALSE);
index abac65f..6786cf3 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-14 Perry
+ PATCH: [ 805875 ] Switch to diffcode flags
+  WinMerge: DiffContext.cpp DiffContext.h DirActions.cpp DirDoc.cpp DirDoc.h
+   DirScan.cpp DirView.cpp DirView.h DirViewColHandler.cpp DirViewColItems.cpp
+   MainFrm.cpp MainFrm.h
+
 2003-09-13 Perry
  Widen label IDC_PRIVATEBUILD on about box.
   WinMerge: Merge.rc