Version 2.6
[qgit4/redivivus.git] / src / mainimpl.h
blobe70b683366c5c302c2e76e362de3fe68f21a4dbc
1 /*
2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
6 */
7 #ifndef MAINIMPL_H
8 #define MAINIMPL_H
10 #include <QProcess>
11 #include <QRegExp>
12 #include <QDir>
13 #include "exceptionmanager.h"
14 #include "common.h"
15 #include "ui_mainview.h"
17 class QAction;
18 class QCloseEvent;
19 class QComboBox;
20 class QEvent;
21 class QListWidgetItem;
22 class QModelIndex;
23 class QProgressBar;
24 class QShortcutEvent;
25 class QTextEdit;
27 class Domain;
28 class Git;
29 class FileHistory;
30 class FileView;
31 class RevsView;
33 class MainImpl : public QMainWindow, public Ui_MainBase {
34 Q_OBJECT
35 public:
36 MainImpl(const QString& curDir = "", QWidget* parent = 0);
37 void updateContextActions(SCRef newRevSha, SCRef newFileName, bool isDir, bool found);
38 const QString getRevisionDesc(SCRef sha);
40 // not buildable with Qt designer, will be created manually
41 QLineEdit* lineEditSHA;
42 QLineEdit* lineEditFilter;
44 enum ComboSearch {
45 CS_SHORT_LOG,
46 CS_LOG_MSG,
47 CS_AUTHOR,
48 CS_SHA1,
49 CS_FILE,
50 CS_PATCH,
51 CS_PATCH_REGEXP
54 QComboBox* cmbSearch;
56 signals:
57 void highlightPatch(const QString&, bool);
58 void updateRevDesc();
59 void closeAllWindows();
60 void closeAllTabs();
61 void changeFont(const QFont&);
62 void closeTabButtonEnabled(bool);
63 void typeWriterFontChanged();
64 void flagChanged(uint);
66 private slots:
67 void tabWdg_currentChanged(int);
68 void newRevsAdded(const FileHistory*, const QVector<ShaString>&);
69 void fileNamesLoad(int, int);
70 void revisionsDragged(const QStringList&);
71 void revisionsDropped(const QStringList&);
72 void shortCutActivated();
74 protected:
75 virtual bool event(QEvent* e);
77 protected slots:
78 void initWithEventLoopActive();
79 void refreshRepo(bool setCurRevAfterLoad = true);
80 void listViewLog_doubleClicked(const QModelIndex&);
81 void fileList_itemDoubleClicked(QListWidgetItem*);
82 void treeView_doubleClicked(QTreeWidgetItem*, int);
83 void histListView_doubleClicked(const QModelIndex&);
84 void customActionListChanged(const QStringList& list);
85 void openRecent_triggered(QAction*);
86 void customAction_triggered(QAction*);
87 void customAction_exited(const QString& name);
88 void goRef_triggered(QAction*);
89 void changesCommitted(bool);
90 void lineEditSHA_returnPressed();
91 void lineEditFilter_returnPressed();
92 void pushButtonCloseTab_clicked();
93 void ActBack_activated();
94 void ActForward_activated();
95 void ActFind_activated();
96 void ActFindNext_activated();
97 void ActRangeDlg_activated();
98 void ActViewRev_activated();
99 void ActViewFile_activated();
100 void ActViewFileNewTab_activated();
101 void ActViewDiff_activated();
102 void ActViewDiffNewTab_activated();
103 void ActExternalDiff_activated();
104 void ActSplitView_activated();
105 void ActToggleLogsDiff_activated();
106 void ActShowDescHeader_activated();
107 void ActOpenRepo_activated();
108 void ActOpenRepoNewWindow_activated();
109 void ActRefresh_activated();
110 void ActSaveFile_activated();
111 void ActMailFormatPatch_activated();
112 void ActMailApplyPatch_activated();
113 void ActSettings_activated();
114 void ActCommit_activated();
115 void ActAmend_activated();
116 void ActBranch_activated();
117 void ActTag_activated();
118 void ActTagDelete_activated();
119 void ActPush_activated();
120 void ActPop_activated();
121 void ActClose_activated();
122 void ActExit_activated();
123 void ActSearchAndFilter_toggled(bool);
124 void ActSearchAndHighlight_toggled(bool);
125 void ActCustomActionSetup_activated();
126 void ActCheckWorkDir_toggled(bool);
127 void ActShowTree_toggled(bool);
128 void ActFilterTree_toggled(bool);
129 void ActAbout_activated();
130 void ActHelp_activated();
131 void closeEvent(QCloseEvent* ce);
133 private:
134 friend class setRepoDelayed;
136 virtual bool eventFilter(QObject* obj, QEvent* ev);
137 void updateGlobalActions(bool b);
138 void setupShortcuts();
139 int currentTabType(Domain** t);
140 void filterList(bool isOn, bool onlyHighlight);
141 bool isMatch(SCRef sha, SCRef f, int cn, const QMap<QString,bool>& sm);
142 void highlightAbbrevSha(SCRef abbrevSha);
143 void setRepository(SCRef wd, bool = false, bool = false, const QStringList* = NULL, bool = false);
144 void getExternalDiffArgs(QStringList* args, QStringList* filenames);
145 void lineEditSHASetText(SCRef text);
146 void updateCommitMenu(bool isStGITStack);
147 void updateRecentRepoMenu(SCRef newEntry = "");
148 void doUpdateRecentRepoMenu(SCRef newEntry);
149 void doUpdateCustomActionMenu(const QStringList& list);
150 void doBranchOrTag(bool isTag);
151 void ActCommit_setEnabled(bool b);
152 void doContexPopup(SCRef sha);
153 void doFileContexPopup(SCRef fileName, int type);
154 void adjustFontSize(int delta);
155 void scrollTextEdit(int delta);
156 void goMatch(int delta);
157 bool askApplyPatchParameters(bool* commit, bool* fold);
158 void saveCurrentGeometry();
159 QTextEdit* getCurrentTextEdit();
160 template<class X> QList<X*>* getTabs(QWidget* tabPage = NULL);
161 template<class X> X* firstTab(QWidget* startPage = NULL);
162 void openFileTab(FileView* fv = NULL);
164 EM_DECLARE(exExiting);
166 Git* git;
167 RevsView* rv;
168 QProgressBar* pbFileNamesLoading;
170 // curDir is the repository working directory, could be different from qgit running
171 // directory QDir::current(). Note that qgit could be run from subdirectory
172 // so only after git->isArchive() that updates curDir to point to working directory
173 // we are sure is correct.
174 QString curDir;
175 QString startUpDir;
176 QString textToFind;
177 QRegExp shortLogRE;
178 QRegExp longLogRE;
179 bool setRepositoryBusy;
182 class ExternalDiffProc : public QProcess {
183 Q_OBJECT
184 public:
185 ExternalDiffProc(const QStringList& f, QObject* p)
186 : QProcess(p), filenames(f) {
188 connect(this, SIGNAL(finished(int, QProcess::ExitStatus)),
189 this, SLOT(on_finished(int, QProcess::ExitStatus)));
191 ~ExternalDiffProc() {
193 terminate();
194 removeFiles();
196 QStringList filenames;
198 private slots:
199 void on_finished(int, QProcess::ExitStatus) { deleteLater(); }
201 private:
202 void removeFiles() {
204 if (!filenames.empty()) {
205 QDir d; // remove temporary files to diff on
206 d.remove(filenames[0]);
207 d.remove(filenames[1]);
212 #endif