File indexing completed on 2024-04-28 17:00:57
0001 // clang-format off 0002 /* 0003 * KDiff3 - Text Diff And Merge Tool 0004 * 0005 * SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de 0006 * SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com 0007 * SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 // clang-format on 0010 0011 #ifndef DIRECTORY_MERGE_WINDOW_H 0012 #define DIRECTORY_MERGE_WINDOW_H 0013 0014 #include "common.h" 0015 #include "fileaccess.h" 0016 0017 #include <QEvent> 0018 #include <QTreeWidget> 0019 0020 #include <list> 0021 #include <memory> 0022 0023 class Options; 0024 class DirectoryMergeInfo; 0025 class QLabel; 0026 class KToggleAction; 0027 class KActionCollection; 0028 class TotalDiffStatus; 0029 0030 class MergeFileInfos; 0031 0032 class KDiff3App; 0033 class DirectoryMergeWindow : public QTreeView 0034 { 0035 Q_OBJECT 0036 public: 0037 struct ItemInfo; 0038 0039 DirectoryMergeWindow(QWidget* pParent, KDiff3App& app); 0040 ~DirectoryMergeWindow() override; 0041 void setDirectoryMergeInfo(DirectoryMergeInfo* p); 0042 bool init( 0043 bool bDirectoryMerge, 0044 bool bReload = false 0045 ); 0046 bool isFileSelected(); 0047 bool isDirectoryMergeInProgress(); 0048 qint32 totalColumnWidth(); 0049 bool isSyncMode(); 0050 bool isScanning(); 0051 void initDirectoryMergeActions(KDiff3App* pKDiff3App, KActionCollection* ac); 0052 0053 void setupConnections(const KDiff3App* app); 0054 void updateAvailabilities(bool bMergeEditorVisible, bool bDirCompare, bool bDiffWindowVisible, 0055 KToggleAction* chooseA, KToggleAction* chooseB, KToggleAction* chooseC); 0056 void updateFileVisibilities(); 0057 0058 void mousePressEvent(QMouseEvent* e) override; 0059 void keyPressEvent(QKeyEvent* e) override; 0060 void focusInEvent(QFocusEvent* e) override; 0061 void focusOutEvent(QFocusEvent* e) override; 0062 void contextMenuEvent(QContextMenuEvent* e) override; 0063 0064 [[nodiscard]] QString getDirNameA() const; 0065 [[nodiscard]] QString getDirNameB() const; 0066 [[nodiscard]] QString getDirNameC() const; 0067 [[nodiscard]] QString getDirNameDest() const; 0068 0069 public Q_SLOTS: 0070 void reload(); 0071 void mergeCurrentFile(); 0072 void compareCurrentFile(); 0073 void slotRunOperationForAllItems(); 0074 void slotRunOperationForCurrentItem(); 0075 void mergeResultSaved(const QString& fileName); 0076 void slotChooseAEverywhere(); 0077 void slotChooseBEverywhere(); 0078 void slotChooseCEverywhere(); 0079 void slotAutoChooseEverywhere(); 0080 void slotNoOpEverywhere(); 0081 void slotFoldAllSubdirs(); 0082 void slotUnfoldAllSubdirs(); 0083 void slotShowIdenticalFiles(); 0084 void slotShowDifferentFiles(); 0085 void slotShowFilesOnlyInA(); 0086 void slotShowFilesOnlyInB(); 0087 void slotShowFilesOnlyInC(); 0088 0089 void slotSynchronizeDirectories(); 0090 void slotChooseNewerFiles(); 0091 0092 void slotCompareExplicitlySelectedFiles(); 0093 void slotMergeExplicitlySelectedFiles(); 0094 0095 // Merge current item (merge mode) 0096 void slotCurrentDoNothing(); 0097 void slotCurrentChooseA(); 0098 void slotCurrentChooseB(); 0099 void slotCurrentChooseC(); 0100 void slotCurrentMerge(); 0101 void slotCurrentDelete(); 0102 // Sync current item 0103 void slotCurrentCopyAToB(); 0104 void slotCurrentCopyBToA(); 0105 void slotCurrentDeleteA(); 0106 void slotCurrentDeleteB(); 0107 void slotCurrentDeleteAAndB(); 0108 void slotCurrentMergeToA(); 0109 void slotCurrentMergeToB(); 0110 void slotCurrentMergeToAAndB(); 0111 0112 void slotSaveMergeState(); 0113 void slotLoadMergeState(); 0114 0115 inline void slotRefresh() { updateFileVisibilities(); }; 0116 0117 Q_SIGNALS: 0118 void startDiffMerge(QStringList &errors, const QString& fn1, const QString& fn2, const QString& fn3, const QString& ofn, const QString&, const QString&, const QString&, TotalDiffStatus*); 0119 void updateAvailabilities(); 0120 void statusBarMessage(const QString& msg); 0121 protected Q_SLOTS: 0122 void onDoubleClick(const QModelIndex&); 0123 void onExpanded(); 0124 void currentChanged(const QModelIndex& current, const QModelIndex& previous) override; // override 0125 private: 0126 class DirectoryMergeWindowPrivate; 0127 class DirMergeItemDelegate; 0128 [[nodiscard]] qint32 getIntFromIndex(const QModelIndex& index) const; 0129 0130 std::unique_ptr<DirectoryMergeWindowPrivate> d; 0131 }; 0132 0133 class DirectoryMergeInfo : public QFrame 0134 { 0135 Q_OBJECT 0136 public: 0137 explicit DirectoryMergeInfo(QWidget* pParent); 0138 void setInfo( 0139 const FileAccess& dirA, 0140 const FileAccess& dirB, 0141 const FileAccess& dirC, 0142 const FileAccess& dirDest, 0143 const MergeFileInfos& mfi); 0144 QTreeWidget* getInfoList() { return m_pInfoList; } 0145 bool eventFilter(QObject* o, QEvent* e) override; 0146 Q_SIGNALS: 0147 void gotFocus(); 0148 0149 private: 0150 void addListViewItem(const QString& dir, const QString& basePath, FileAccess* fi); 0151 0152 QLabel* m_pInfoA = nullptr; 0153 QLabel* m_pInfoB = nullptr; 0154 QLabel* m_pInfoC = nullptr; 0155 QLabel* m_pInfoDest = nullptr; 0156 0157 QLabel* m_pA = nullptr; 0158 QLabel* m_pB = nullptr; 0159 QLabel* m_pC = nullptr; 0160 QLabel* m_pDest = nullptr; 0161 0162 QTreeWidget* m_pInfoList = nullptr; 0163 }; 0164 0165 #endif