1 /////////////////////////////////////////////////////////////////////////////
2 // WinMerge: an interactive diff/merge utility
3 // Copyright (C) 1997 Dean P. Grimm
4 // SPDX-License-Identifier: GPL-2.0-or-later
5 /////////////////////////////////////////////////////////////////////////////
9 * @brief Declaration file for CDirDoc
15 #include "DiffThread.h"
16 #include "PluginManager.h"
17 #include "FileFilterHelper.h"
18 #include "DirCmpReport.h"
22 typedef CTypedPtrList<CPtrList, IMergeDoc *> MergeDocPtrList;
23 class DirDocFilterGlobal;
24 class DirDocFilterByExtension;
25 class CTempPathContext;
26 struct FileActionItem;
29 /////////////////////////////////////////////////////////////////////////////
33 * @brief Class for folder compare data.
34 * This class is "document" class for folder compare. It has compare context,
35 * which in turn has a list of differences and other compare result data.
36 * This class also has compare statistics which are updated during compare.
37 * GUI calls this class to operate with results.
39 class CDirDoc : public CDocument
42 CDirDoc(); // protected constructor used by dynamic creation
43 DECLARE_DYNCREATE(CDirDoc)
47 CTempPathContext *m_pTempPathContext;
49 static int m_nDirsTemp;
53 bool CloseMergeDocs();
54 CDirView * GetMainView() const;
57 // ClassWizard generated virtual function overrides
58 //{{AFX_VIRTUAL(CDirDoc)
60 virtual void Serialize(CArchive& ar); // overridden for document i/o
61 virtual void SetTitle(LPCTSTR lpszTitle);
63 virtual BOOL OnNewDocument();
64 virtual BOOL SaveModified();
69 void InitCompare(const PathContext & paths, bool bRecursive, CTempPathContext *);
70 void DiffThreadCallback(int& state);
72 bool GetReadOnly(int nIndex) const;
73 const bool *GetReadOnly(void) const;
74 void SetReadOnly(int nIndex, bool bReadOnly);
75 String GetReportFile() const { return m_sReportFile; }
76 void SetReportFile(const String& sReportFile) { m_sReportFile = sReportFile; }
77 bool GetGeneratingReport() const { return m_bGeneratingReport; }
78 void SetGeneratingReport(bool bGeneratingReport) { m_bGeneratingReport = bGeneratingReport; }
79 void SetReport(DirCmpReport* pReport) { m_pReport.reset(pReport); }
80 bool HasDirView() const { return m_pDirView != nullptr; }
81 void RefreshOptions();
83 void UpdateChangedItem(const PathContext & paths,
84 UINT nDiffs, UINT nTrivialDiffs, bool bIdentical);
85 void UpdateResources();
86 void InitStatusStrings();
87 void ReloadItemStatus(DIFFITEM *diffPos, int idx);
90 void SetDirView( CDirView *newView ); // TODO Perry
91 void AddMergeDoc(IMergeDoc * pMergeDoc);
92 void MergeDocClosing(IMergeDoc * pMergeDoc);
93 CDiffThread m_diffThread;
94 void UpdateHeaderPath(int nIndex);
95 void AbortCurrentScan();
96 void PauseCurrentScan();
97 void ContinueCurrentScan();
98 bool IsCurrentScanAbortable() const;
99 void SetDescriptions(const String strDesc[]);
100 void ApplyDisplayRoot(int nIndex, String &);
102 bool HasDiffs() const { return m_pCtxt != nullptr; }
103 const CDiffContext & GetDiffContext() const { return *m_pCtxt; }
104 CDiffContext& GetDiffContext() { return *m_pCtxt.get(); }
105 void SetMarkedRescan() {m_bMarkedRescan = true; }
106 const CompareStats * GetCompareStats() const { return m_pCompareStats.get(); };
107 bool IsArchiveFolders() const;
108 PluginManager& GetPluginManager() { return m_pluginman; };
109 void Swap(int idx1, int idx2);
110 bool MoveableToNextDiff();
111 bool MoveableToPrevDiff();
112 void MoveToNextDiff(IMergeDoc *pMergeDoc);
113 void MoveToPrevDiff(IMergeDoc *pMergeDoc);
114 void MoveToFirstFile(IMergeDoc* pMergeDoc);
115 void MoveToLastFile(IMergeDoc* pMergeDoc);
116 void MoveToNextFile(IMergeDoc* pMergeDoc);
117 void MoveToPrevFile(IMergeDoc* pMergeDoc);
121 bool CompareFilesIfFilesAreLarge(int nFiles, const FileLocation ifileloc[]);
124 void InitDiffContext(CDiffContext *pCtxt);
125 void LoadLineFilterList(CDiffContext *pCtxt);
126 void LoadSubstitutionFiltersList(CDiffContext* pCtxt);
128 // Generated message map functions
130 // NOTE - the ClassWizard will add and remove member functions here.
132 DECLARE_MESSAGE_MAP()
134 // Implementation data
136 std::unique_ptr<CDiffContext> m_pCtxt; /**< Pointer to diff-data */
137 CDirView *m_pDirView; /**< Pointer to GUI */
138 std::unique_ptr<CompareStats> m_pCompareStats; /**< Compare statistics */
139 MergeDocPtrList m_MergeDocs; /**< List of file compares opened from this compare */
140 bool m_bRO[3]; /**< Is left/middle/right side read-only */
141 String m_strDesc[3]; /**< Left/middle/right side desription text */
142 String m_sReportFile;
143 PluginManager m_pluginman;
144 FileFilterHelper m_imgfileFilter;
145 bool m_bMarkedRescan; /**< If `true` next rescan scans only marked items */
146 bool m_bGeneratingReport;
147 std::unique_ptr<DirCmpReport> m_pReport;
151 * @brief Set left/middle/right side readonly-status
152 * @param nIndex Select side to set
153 * @param bReadOnly New status of selected side
155 inline void CDirDoc::SetReadOnly(int nIndex, bool bReadOnly)
157 m_bRO[nIndex] = bReadOnly;
161 * @brief Return left/middle/right side readonly-status
162 * @param nIndex Select side to ask
164 inline bool CDirDoc::GetReadOnly(int nIndex) const
166 return m_bRO[nIndex];
169 inline const bool *CDirDoc::GetReadOnly(void) const