1 /* 2 * KDiff3 - Text Diff And Merge Tool 3 * 4 * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de 5 * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com 6 * SPDX-License-Identifier: GPL-2.0-or-later 7 */ 8 9 #ifndef DIRECTORY_MERGE_WINDOW_H 10 #define DIRECTORY_MERGE_WINDOW_H 11 12 #include "common.h" 13 #include "fileaccess.h" 14 #include "diff.h" //TotalDiffStatus 15 16 #include <QTreeWidget> 17 #include <QEvent> 18 19 #include <list> 20 #include <map> 21 22 class Options; 23 class StatusInfo; 24 class DirectoryMergeInfo; 25 class OneDirectoryInfo; 26 class QLabel; 27 class QAction; 28 class KToggleAction; 29 class KActionCollection; 30 class TotalDiffStatus; 31 class DirectoryInfo; 32 33 class MergeFileInfos; 34 35 class KDiff3App; 36 class DirectoryMergeWindow : public QTreeView 37 { 38 Q_OBJECT 39 public: 40 struct t_ItemInfo; 41 42 DirectoryMergeWindow(QWidget* pParent, const QSharedPointer<Options>& pOptions); 43 ~DirectoryMergeWindow() override; 44 void setDirectoryMergeInfo(DirectoryMergeInfo* p); 45 bool init( 46 const QSharedPointer<DirectoryInfo>& dirInfo, 47 bool bDirectoryMerge, 48 bool bReload = false 49 ); 50 bool isFileSelected(); 51 bool isDirectoryMergeInProgress(); 52 int totalColumnWidth(); 53 bool isSyncMode(); 54 bool isScanning(); 55 void initDirectoryMergeActions(KDiff3App* pKDiff3App, KActionCollection* ac); 56 57 void setupConnections(const KDiff3App* app); 58 void updateAvailabilities(bool bMergeEditorVisible, bool bDirCompare, bool bDiffWindowVisible, 59 KToggleAction* chooseA, KToggleAction* chooseB, KToggleAction* chooseC); 60 void updateFileVisibilities(); 61 62 void mousePressEvent(QMouseEvent* e) override; 63 void keyPressEvent(QKeyEvent* e) override; 64 void focusInEvent(QFocusEvent* e) override; 65 void focusOutEvent(QFocusEvent* e) override; 66 void contextMenuEvent(QContextMenuEvent* e) override; 67 68 QString getDirNameA() const; 69 QString getDirNameB() const; 70 QString getDirNameC() const; 71 QString getDirNameDest() const; 72 73 public Q_SLOTS: 74 void reload(); 75 void mergeCurrentFile(); 76 void compareCurrentFile(); 77 void slotRunOperationForAllItems(); 78 void slotRunOperationForCurrentItem(); 79 void mergeResultSaved(const QString& fileName); 80 void slotChooseAEverywhere(); 81 void slotChooseBEverywhere(); 82 void slotChooseCEverywhere(); 83 void slotAutoChooseEverywhere(); 84 void slotNoOpEverywhere(); 85 void slotFoldAllSubdirs(); 86 void slotUnfoldAllSubdirs(); 87 void slotShowIdenticalFiles(); 88 void slotShowDifferentFiles(); 89 void slotShowFilesOnlyInA(); 90 void slotShowFilesOnlyInB(); 91 void slotShowFilesOnlyInC(); 92 93 void slotSynchronizeDirectories(); 94 void slotChooseNewerFiles(); 95 96 void slotCompareExplicitlySelectedFiles(); 97 void slotMergeExplicitlySelectedFiles(); 98 99 // Merge current item (merge mode) 100 void slotCurrentDoNothing(); 101 void slotCurrentChooseA(); 102 void slotCurrentChooseB(); 103 void slotCurrentChooseC(); 104 void slotCurrentMerge(); 105 void slotCurrentDelete(); 106 // Sync current item 107 void slotCurrentCopyAToB(); 108 void slotCurrentCopyBToA(); 109 void slotCurrentDeleteA(); 110 void slotCurrentDeleteB(); 111 void slotCurrentDeleteAAndB(); 112 void slotCurrentMergeToA(); 113 void slotCurrentMergeToB(); 114 void slotCurrentMergeToAAndB(); 115 116 void slotSaveMergeState(); 117 void slotLoadMergeState(); 118 slotRefresh()119 inline void slotRefresh() { updateFileVisibilities(); }; 120 121 Q_SIGNALS: 122 void startDiffMerge(QStringList &errors, const QString& fn1, const QString& fn2, const QString& fn3, const QString& ofn, const QString&, const QString&, const QString&, TotalDiffStatus*); 123 void updateAvailabilities(); 124 void statusBarMessage(const QString& msg); 125 protected Q_SLOTS: 126 void onDoubleClick(const QModelIndex&); 127 void onExpanded(); 128 void currentChanged(const QModelIndex& current, const QModelIndex& previous) override; // override 129 private: 130 int getIntFromIndex(const QModelIndex& index) const; 131 const QSharedPointer<Options>& getOptions() const; 132 133 class DirectoryMergeWindowPrivate; 134 DirectoryMergeWindowPrivate* d; 135 class DirMergeItemDelegate; 136 }; 137 138 class DirectoryMergeInfo : public QFrame 139 { 140 Q_OBJECT 141 public: 142 explicit DirectoryMergeInfo(QWidget* pParent); 143 void setInfo( 144 const FileAccess& dirA, 145 const FileAccess& dirB, 146 const FileAccess& dirC, 147 const FileAccess& dirDest, 148 MergeFileInfos& mfi); getInfoList()149 QTreeWidget* getInfoList() { return m_pInfoList; } 150 bool eventFilter(QObject* o, QEvent* e) override; 151 Q_SIGNALS: 152 void gotFocus(); 153 154 private: 155 void addListViewItem(const QString& dir, const QString& basePath, FileAccess* fi); 156 157 QLabel* m_pInfoA; 158 QLabel* m_pInfoB; 159 QLabel* m_pInfoC; 160 QLabel* m_pInfoDest; 161 162 QLabel* m_pA; 163 QLabel* m_pB; 164 QLabel* m_pC; 165 QLabel* m_pDest; 166 167 QTreeWidget* m_pInfoList; 168 }; 169 170 #endif 171