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);
115 bool CompareFilesIfFilesAreLarge(int nFiles, const FileLocation ifileloc[]);
118 void InitDiffContext(CDiffContext *pCtxt);
119 void LoadLineFilterList(CDiffContext *pCtxt);
121 // Generated message map functions
123 // NOTE - the ClassWizard will add and remove member functions here.
125 DECLARE_MESSAGE_MAP()
127 // Implementation data
129 std::unique_ptr<CDiffContext> m_pCtxt; /**< Pointer to diff-data */
130 CDirView *m_pDirView; /**< Pointer to GUI */
131 std::unique_ptr<CompareStats> m_pCompareStats; /**< Compare statistics */
132 MergeDocPtrList m_MergeDocs; /**< List of file compares opened from this compare */
133 bool m_bRO[3]; /**< Is left/middle/right side read-only */
134 String m_strDesc[3]; /**< Left/middle/right side desription text */
135 String m_sReportFile;
136 PluginManager m_pluginman;
137 FileFilterHelper m_imgfileFilter;
138 bool m_bMarkedRescan; /**< If `true` next rescan scans only marked items */
139 bool m_bGeneratingReport;
140 std::unique_ptr<DirCmpReport> m_pReport;
144 * @brief Set left/middle/right side readonly-status
145 * @param nIndex Select side to set
146 * @param bReadOnly New status of selected side
148 inline void CDirDoc::SetReadOnly(int nIndex, bool bReadOnly)
150 m_bRO[nIndex] = bReadOnly;
154 * @brief Return left/middle/right side readonly-status
155 * @param nIndex Select side to ask
157 inline bool CDirDoc::GetReadOnly(int nIndex) const
159 return m_bRO[nIndex];
162 inline const bool *CDirDoc::GetReadOnly(void) const