OSDN Git Service

Update of Lithuanian translation (#496)
[winmerge-jp/winmerge-jp.git] / Src / DirDoc.h
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 /////////////////////////////////////////////////////////////////////////////
6 /** 
7  * @file  DirDoc.h
8  *
9  * @brief Declaration file for CDirDoc
10  *
11  */
12 #pragma once
13
14 #include <memory>
15 #include "DiffThread.h"
16 #include "PluginManager.h"
17 #include "FileFilterHelper.h"
18 #include "DirCmpReport.h"
19
20 class CDirView;
21 struct IMergeDoc;
22 typedef CTypedPtrList<CPtrList, IMergeDoc *> MergeDocPtrList;
23 class DirDocFilterGlobal;
24 class DirDocFilterByExtension;
25 class CTempPathContext;
26 struct FileActionItem;
27 struct FileLocation;
28
29 /////////////////////////////////////////////////////////////////////////////
30 // CDirDoc document
31
32 /**
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.
38  */
39 class CDirDoc : public CDocument
40 {
41 protected:
42         CDirDoc();           // protected constructor used by dynamic creation
43         DECLARE_DYNCREATE(CDirDoc)
44
45 // Attributes
46 public:
47         CTempPathContext *m_pTempPathContext;
48         int m_nDirs;
49         static int m_nDirsTemp;
50
51 // Operations
52 public:
53         bool CloseMergeDocs();
54         CDirView * GetMainView() const;
55
56 // Overrides
57         // ClassWizard generated virtual function overrides
58         //{{AFX_VIRTUAL(CDirDoc)
59         public:
60         virtual void Serialize(CArchive& ar);   // overridden for document i/o
61         virtual void SetTitle(LPCTSTR lpszTitle);
62         protected:
63         virtual BOOL OnNewDocument();
64         virtual BOOL SaveModified();
65         //}}AFX_VIRTUAL
66
67 // Implementation
68 public:
69         void InitCompare(const PathContext & paths, bool bRecursive, CTempPathContext *);
70         void DiffThreadCallback(int& state);
71         void Rescan();
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();
82         void CompareReady();
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);
88         void Redisplay();
89         virtual ~CDirDoc();
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 &);
101
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         
115         bool CompareFilesIfFilesAreLarge(int nFiles, const FileLocation ifileloc[]);
116
117 protected:
118         void InitDiffContext(CDiffContext *pCtxt);
119         void LoadLineFilterList(CDiffContext *pCtxt);
120
121         // Generated message map functions
122         //{{AFX_MSG(CDirDoc)
123                 // NOTE - the ClassWizard will add and remove member functions here.
124         //}}AFX_MSG
125         DECLARE_MESSAGE_MAP()
126
127         // Implementation data
128 private:
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;
141 };
142
143 /**
144  * @brief Set left/middle/right side readonly-status
145  * @param nIndex Select side to set 
146  * @param bReadOnly New status of selected side
147  */
148 inline void CDirDoc::SetReadOnly(int nIndex, bool bReadOnly)
149 {
150         m_bRO[nIndex] = bReadOnly;
151 }
152
153 /**
154  * @brief Return left/middle/right side readonly-status
155  * @param nIndex Select side to ask
156  */
157 inline bool CDirDoc::GetReadOnly(int nIndex) const
158 {
159         return m_bRO[nIndex];
160 }
161
162 inline const bool *CDirDoc::GetReadOnly(void) const
163 {
164         return m_bRO;
165 }
166