OSDN Git Service

66af331034b6bd6442acda43643f722ca115a35b
[winmerge-jp/winmerge-jp.git] / Src / DirDoc.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    WinMerge:  an interactive diff/merge utility
3 //    Copyright (C) 1997  Dean P. Grimm
4 //
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.
9 //
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.
14 //
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.
18 //
19 /////////////////////////////////////////////////////////////////////////////
20 /** 
21  * @file  DirDoc.h
22  *
23  * @brief Declaration file for CDirDoc
24  *
25  */
26 #pragma once
27
28 #include <memory>
29 #include <cstdint>
30 #include "DiffThread.h"
31 #include "PluginManager.h"
32
33 class CDirView;
34 struct IMergeDoc;
35 typedef CTypedPtrList<CPtrList, IMergeDoc *> MergeDocPtrList;
36 class DirDocFilterGlobal;
37 class DirDocFilterByExtension;
38 class CustomStatusCursor;
39 class CTempPathContext;
40 struct FileActionItem;
41
42 /////////////////////////////////////////////////////////////////////////////
43 // CDirDoc document
44
45 /**
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.
51  */
52 class CDirDoc : public CDocument
53 {
54 protected:
55         CDirDoc();           // protected constructor used by dynamic creation
56         DECLARE_DYNCREATE(CDirDoc)
57
58 // Attributes
59 public:
60         CTempPathContext *m_pTempPathContext;
61         int m_nDirs;
62         static int m_nDirsTemp;
63
64 // Operations
65 public:
66         BOOL CloseMergeDocs();
67         CDirView * GetMainView() const;
68
69 // Overrides
70         // ClassWizard generated virtual function overrides
71         //{{AFX_VIRTUAL(CDirDoc)
72         public:
73         virtual void Serialize(CArchive& ar);   // overridden for document i/o
74         virtual void SetTitle(LPCTSTR lpszTitle);
75         protected:
76         virtual BOOL OnNewDocument();
77         virtual BOOL SaveModified();
78         //}}AFX_VIRTUAL
79
80 // Implementation
81 public:
82         void InitCompare(const PathContext & paths, bool bRecursive, CTempPathContext *);
83         void DiffThreadCallback(int& state);
84         void Rescan();
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();
90         void CompareReady();
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);
100         void Redisplay();
101         virtual ~CDirDoc();
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 &);
114
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;
121
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
132         {
133                 enum ReturnCode
134                 {
135                         Never,
136                         No,
137                         ParentIsRegularPath,
138                         ParentIsTempPath
139                 };
140         };
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;
146
147 protected:
148         void LoadLineFilterList();
149
150         // Generated message map functions
151         //{{AFX_MSG(CDirDoc)
152                 // NOTE - the ClassWizard will add and remove member functions here.
153         //}}AFX_MSG
154         DECLARE_MESSAGE_MAP()
155
156         // Implementation data
157 private:
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 */
167 };
168
169 //{{AFX_INSERT_LOCATION}}
170 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.