1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997 Dean P. Grimm
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 /////////////////////////////////////////////////////////////////////////////
23 * @brief Declaration file for CDirDoc
30 #include "DiffThread.h"
31 #include "PluginManager.h"
35 typedef CTypedPtrList<CPtrList, IMergeDoc *> MergeDocPtrList;
36 class DirDocFilterGlobal;
37 class DirDocFilterByExtension;
38 class CustomStatusCursor;
39 class CTempPathContext;
40 struct FileActionItem;
42 /////////////////////////////////////////////////////////////////////////////
46 * @brief Class for folder compare data.
47 * This class is "document" class for folder compare. It has compare context,
48 * which in turn has a list of differences and other compare result data.
49 * This class also has compare statistics which are updated during compare.
50 * GUI calls this class to operate with results.
52 class CDirDoc : public CDocument
55 CDirDoc(); // protected constructor used by dynamic creation
56 DECLARE_DYNCREATE(CDirDoc)
60 CTempPathContext *m_pTempPathContext;
62 static int m_nDirsTemp;
66 BOOL CloseMergeDocs();
67 CDirView * GetMainView() const;
70 // ClassWizard generated virtual function overrides
71 //{{AFX_VIRTUAL(CDirDoc)
73 virtual void Serialize(CArchive& ar); // overridden for document i/o
74 virtual void SetTitle(LPCTSTR lpszTitle);
76 virtual BOOL OnNewDocument();
77 virtual BOOL SaveModified();
82 void InitCompare(const PathContext & paths, bool bRecursive, CTempPathContext *);
83 void DiffThreadCallback(int& state);
85 bool GetRecursive() const { return m_bRecursive; }
86 bool GetReadOnly(int nIndex) const;
87 void SetReadOnly(int nIndex, bool bReadOnly);
88 bool HasDirView() { return m_pDirView != NULL; }
89 void RefreshOptions();
91 void UpdateChangedItem(PathContext & paths,
92 UINT nDiffs, UINT nTrivialDiffs, BOOL bIdentical);
93 uintptr_t FindItemFromPaths(const String& pathLeft, const String& pathRight);
94 void SetDiffSide(UINT diffcode, int idx);
95 void SetDiffCompare(UINT diffcode, int idx);
96 void UpdateResources();
97 void InitStatusStrings();
98 void UpdateStatusFromDisk(uintptr_t diffPos, int idx);
99 void ReloadItemStatus(uintptr_t diffPos, int idx);
102 void SetDirView( CDirView *newView ); // TODO Perry
103 void AddMergeDoc(IMergeDoc * pMergeDoc);
104 void MergeDocClosing(IMergeDoc * pMergeDoc);
105 CDiffThread m_diffThread;
106 void SetDiffStatus(UINT diffcode, UINT mask, int idx);
107 void SetDiffCounts(UINT diffs, UINT ignored, int idx);
108 void UpdateDiffAfterOperation(const FileActionItem & act, uintptr_t pos);
109 void UpdateHeaderPath(BOOL bLeft);
110 void AbortCurrentScan();
111 bool IsCurrentScanAbortable() const;
112 void SetDescriptions(const String strDesc[]);
113 void ApplyDisplayRoot(int nIndex, String &);
115 void SetPluginPrediffSetting(const String& filteredFilenames, int newsetting);
116 void SetPluginPrediffSettingAll(int newsetting) { m_pluginman.SetPrediffSettingAll(newsetting); }
117 void SetPluginPrediffer(const String& filteredFilenames, const String & prediffer);
118 void FetchPluginInfos(const String& filteredFilenames,
119 PackingInfo ** infoUnpacker, PrediffingInfo ** infoPrediffer);
120 bool IsShowable(const DIFFITEM & di) const;
122 bool HasDiffs() const { return m_pCtxt != NULL; }
123 const CDiffContext & GetDiffContext() const { return *m_pCtxt; }
124 const DIFFITEM & GetDiffByKey(uintptr_t key) const { return m_pCtxt->GetDiffAt(key); }
125 DIFFITEM & GetDiffRefByKey(uintptr_t key) { return m_pCtxt->GetDiffRefAt(key); }
126 String GetLeftBasePath() const { return m_pCtxt->GetNormalizedLeft(); }
127 String GetRightBasePath() const { return m_pCtxt->GetNormalizedRight(); }
128 String GetBasePath(int nIndex) const { return m_pCtxt->GetNormalizedPath(nIndex); }
129 void RemoveDiffByKey(uintptr_t key) { m_pCtxt->RemoveDiff(key); }
130 void SetMarkedRescan() {m_bMarkedRescan = TRUE; }
131 struct AllowUpwardDirectory
141 AllowUpwardDirectory::ReturnCode AllowUpwardDirectory(PathContext &paths);
142 void SetItemViewFlag(uintptr_t key, UINT flag, UINT mask);
143 void SetItemViewFlag(UINT flag, UINT mask);
144 const CompareStats * GetCompareStats() const { return m_pCompareStats.get(); };
145 bool IsArchiveFolders() const;
148 void LoadLineFilterList();
150 // Generated message map functions
152 // NOTE - the ClassWizard will add and remove member functions here.
154 DECLARE_MESSAGE_MAP()
156 // Implementation data
158 std::unique_ptr<CDiffContext> m_pCtxt; /**< Pointer to diff-data */
159 CDirView *m_pDirView; /**< Pointer to GUI */
160 std::unique_ptr<CompareStats> m_pCompareStats; /**< Compare statistics */
161 MergeDocPtrList m_MergeDocs; /**< List of file compares opened from this compare */
162 bool m_bRO[3]; /**< Is left/middle/right side read-only */
163 bool m_bRecursive; /**< Is current compare recursive? */
164 String m_strDesc[3]; /**< Left/middle/right side desription text */
165 PluginManager m_pluginman;
166 bool m_bMarkedRescan; /**< If TRUE next rescan scans only marked items */
169 //{{AFX_INSERT_LOCATION}}
170 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.