File indexing completed on 2024-04-28 05:42:48
0001 /* 0002 SPDX-FileCopyrightText: 2001-2003 Otto Bruggeman <otto.bruggeman@home.nl> 0003 SPDX-FileCopyrightText: 2001-2003 John Firebaugh <jfirebaugh@kde.org> 0004 SPDX-FileCopyrightText: 2007-2011 Kevin Kofler <kevin.kofler@chello.at> 0005 0006 SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #ifndef KOMPARESHELL_H 0010 #define KOMPARESHELL_H 0011 0012 #include <KParts/MainWindow> 0013 0014 #include <KompareDiff2/Global> 0015 0016 #include <kompareshelldebug.h> 0017 0018 class KompareInterface; 0019 namespace KParts { 0020 class ReadOnlyPart; 0021 class ReadWritePart; 0022 } 0023 class KToggleAction; 0024 0025 class KSqueezedTextLabel; 0026 class KomparePart; 0027 class KompareNavTreePart; 0028 class QLabel; 0029 class QEventLoopLocker; 0030 0031 namespace KTextEditor { 0032 class Document; 0033 class EditInterface; 0034 class View; 0035 } 0036 0037 /** 0038 * This is the application "Shell". It has a menubar, toolbar, and 0039 * statusbar but relies on the "Part" to do all the real work. 0040 * 0041 * Adapted the shell a bit so it now handles separate view and navigation parts 0042 * 0043 * @short Application Shell 0044 * @author John Firebaugh <jfirebaugh@kde.org> 0045 * @author Otto Bruggeman <bruggie@home.nl> 0046 * @version 3.2.90 0047 */ 0048 class KompareShell : public KParts::MainWindow 0049 { 0050 Q_OBJECT 0051 public: 0052 /** 0053 * Default Constructor 0054 */ 0055 KompareShell(); 0056 0057 /** 0058 * Default Destructor 0059 */ 0060 ~KompareShell() override; 0061 0062 /** 0063 * Use this method to load whatever file/URL you have 0064 */ 0065 void openDiff(const QUrl& url); 0066 0067 /** 0068 * Use this method to load the diff from stdin 0069 */ 0070 void openStdin(); 0071 0072 /** 0073 * Use this method to compare 2 URLs (files or directories) 0074 */ 0075 void compare(const QUrl& source, const QUrl& destination); 0076 0077 /** 0078 * Use this method to blend diff into url1 (file or directory) 0079 */ 0080 void blend(const QUrl& url1, const QUrl& diff); 0081 0082 public Q_SLOTS: 0083 void slotUpdateStatusBar(int modelIndex, int differenceIndex, int modelCount, int differenceCount, int appliedCount); 0084 0085 KompareInterface* viewPart() const; 0086 0087 protected: 0088 bool queryClose() override; 0089 0090 /** 0091 * This method is called when it is time for the app to save its 0092 * properties for session management purposes. 0093 */ 0094 void saveProperties(KConfigGroup&) override; 0095 0096 /** 0097 * This method is called when this app is restored. The KConfig 0098 * object points to the session management config file that was saved 0099 * with @ref saveProperties 0100 */ 0101 void readProperties(const KConfigGroup&) override; 0102 0103 private Q_SLOTS: 0104 void slotSetStatusBarText(const QString& text) override; 0105 void slotFileOpen(); 0106 void slotFileCompareFiles(); 0107 void slotFileBlendURLAndDiff(); 0108 void slotShowTextView(); 0109 void slotFileClose(); 0110 void optionsConfigureKeys(); 0111 void optionsConfigureToolbars(); 0112 void slotSetDiffString(const QString& diffString); 0113 void newToolbarConfig(); 0114 void slotVisibilityChanged(bool visible); 0115 0116 private: 0117 void setupAccel(); 0118 void setupActions(); 0119 void setupStatusBar(); 0120 0121 private: 0122 QUrl m_sourceURL; 0123 QUrl m_destinationURL; 0124 QUrl m_diffURL; 0125 0126 KParts::ReadWritePart* m_viewPart; 0127 KParts::ReadOnlyPart* m_navTreePart; 0128 KTextEditor::Document* m_textViewPart; 0129 KTextEditor::View* m_textView; 0130 // KTextEditor::EditInterface* m_textEditIface; 0131 0132 QDockWidget* m_textViewWidget; 0133 QDockWidget* m_navTreeDock; 0134 0135 KToggleAction* m_showTextView; 0136 0137 enum KompareDiff2::Mode m_mode; 0138 // This is the statusbarwidget for displaying the general stuff 0139 KSqueezedTextLabel* m_generalLabel; 0140 0141 QString m_diffString; 0142 QLabel* m_filesLabel; 0143 QLabel* m_differencesLabel; 0144 QEventLoopLocker* m_eventLoopLocker; 0145 }; 0146 0147 #endif // KOMPARE_H