[go: up one dir, main page]

File: mainimpl.h

package info (click to toggle)
qgit 2.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 1,424 kB
  • sloc: cpp: 13,042; xml: 25; sh: 25; javascript: 16; makefile: 3
file content (248 lines) | stat: -rw-r--r-- 7,007 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
	Author: Marco Costalba (C) 2005-2007

	Copyright: See COPYING file that comes with this distribution

*/
#ifndef MAINIMPL_H
#define MAINIMPL_H

#include <QProcess>
#include <QRegExp>
#include <QDir>
#include "exceptionmanager.h"
#include "common.h"
#include "ui_mainview.h"

class QAction;
class QCloseEvent;
class QComboBox;
class QEvent;
class QListWidgetItem;
class QModelIndex;
class QProgressBar;
class QShortcutEvent;
class QTextEdit;

class Domain;
class Git;
class FileHistory;
class FileView;
class RevsView;

class MainImpl : public QMainWindow, public Ui_MainBase {
Q_OBJECT
public:
	MainImpl(const QString& curDir = "", QWidget* parent = 0);
	void updateContextActions(SCRef newRevSha, SCRef newFileName, bool isDir, bool found);
	const QString getRevisionDesc(SCRef sha);
	const QString currentDir() const {return curDir;}

	// not buildable with Qt designer, will be created manually
	QLineEdit* lineEditSHA;
	QLineEdit* lineEditFilter;

	enum ComboSearch {
		CS_SHORT_LOG,
		CS_LOG_MSG,
		CS_AUTHOR,
		CS_SHA1,
		CS_FILE,
		CS_PATCH,
		CS_PATCH_REGEXP
	};

	QComboBox* cmbSearch;

signals:
	void highlightPatch(const QString&, bool);
	void updateRevDesc();
	void closeAllWindows();
	void closeAllTabs();
	void changeFont(const QFont&);
	void typeWriterFontChanged();
	void flagChanged(uint);

private slots:
	void tabWdg_currentChanged(int);
	void newRevsAdded(const FileHistory*, const QVector<ShaString>&);
	void fileNamesLoad(int, int);
	void applyRevisions(const QStringList& shas, const QString& remoteRepo);
	bool applyPatches(const QStringList &files);
	void rebase(const QString& from, const QString& to, const QString& onto);
	void merge(const QStringList& shas, const QString& into);
	void moveRef(const QString& refName, const QString& toSHA);
	void shortCutActivated();

protected:
	virtual bool event(QEvent* e);

protected slots:
	void initWithEventLoopActive();
	void refreshRepo(bool setCurRevAfterLoad = true);
	void listViewLog_doubleClicked(const QModelIndex&);
	void fileList_itemDoubleClicked(QListWidgetItem*);
	void treeView_doubleClicked(QTreeWidgetItem*, int);
	void histListView_doubleClicked(const QModelIndex&);
	void customActionListChanged(const QStringList& list);
	void openRecent_triggered(QAction*);
	void customAction_triggered(QAction*);
	void customAction_exited(const QString& name);
	void goRef_triggered(QAction*);
	void changesCommitted(bool);
	void lineEditSHA_returnPressed();
	void lineEditFilter_returnPressed();
	void tabBar_tabCloseRequested(int index);
	void ActBack_activated();
	void ActForward_activated();
	void ActFind_activated();
	void ActFindNext_activated();
	void ActRangeDlg_activated();
	void ActViewRev_activated();
	void ActViewFile_activated();
	void ActViewFileNewTab_activated();
	void ActViewDiff_activated();
	void ActViewDiffNewTab_activated();
	void ActExternalDiff_activated();
	void ActExternalEditor_activated();
	void ActSplitView_activated();
	void ActToggleLogsDiff_activated();
	void ActShowDescHeader_activated();
	void ActOpenRepo_activated();
	void ActOpenRepoNewWindow_activated();
	void ActRefresh_activated();
	void ActSaveFile_activated();
	void ActMailFormatPatch_activated();
	void ActMailApplyPatch_activated();
	void ActSettings_activated();
	void ActCommit_activated();
	void ActAmend_activated();
	void ActCheckout_activated();
	void ActBranch_activated();
	void ActTag_activated();
	void ActDelete_activated();
	void ActPush_activated();
	void ActPop_activated();
	void ActClose_activated();
	void ActExit_activated();
	void ActSearchAndFilter_toggled(bool);
	void ActSearchAndHighlight_toggled(bool);
	void ActCustomActionSetup_activated();
	void ActCheckWorkDir_toggled(bool);
	void ActShowTree_toggled(bool);
	void ActFilterTree_toggled(bool);
	void ActAbout_activated();
	void ActHelp_activated();
	void ActMarkDiffToSha_activated();
	void closeEvent(QCloseEvent* ce);

private:
	friend class setRepoDelayed;

	virtual bool eventFilter(QObject* obj, QEvent* ev);
	void updateGlobalActions(bool b);
	void updateRevVariables(SCRef sha);
	void setupShortcuts();
	int currentTabType(Domain** t);
	int tabType(Domain** t, int index);
	void filterList(bool isOn, bool onlyHighlight);
	bool isMatch(SCRef sha, SCRef f, int cn, const QMap<QString,bool>& sm);
	void highlightAbbrevSha(SCRef abbrevSha);
	void setRepository(SCRef wd, bool = false, bool = false, const QStringList* = NULL, bool = false);
	void getExternalDiffArgs(QStringList* args, QStringList* filenames);
	QString copyFileToDiffIfNeeded(QStringList* filenames, QString sha);
	QStringList getExternalEditorArgs();
	void lineEditSHASetText(SCRef text);
	void updateCommitMenu(bool isStGITStack);
	void updateRecentRepoMenu(SCRef newEntry = "");
	void doUpdateRecentRepoMenu(SCRef newEntry);
	void doUpdateCustomActionMenu(const QStringList& list);
	void doBranchOrTag(bool isTag);
	void ActCommit_setEnabled(bool b);
	void doContexPopup(SCRef sha);
	void doFileContexPopup(SCRef fileName, int type);
	void adjustFontSize(int delta);
	void scrollTextEdit(int delta);
	void goMatch(int delta);
	bool askApplyPatchParameters(bool* commit, bool* fold);
	void saveCurrentGeometry();
	QTextEdit* getCurrentTextEdit();
	template<class X> QList<X*>* getTabs(QWidget* tabPage = NULL);
	template<class X> X* firstTab(QWidget* startPage = NULL);
	void openFileTab(FileView* fv = NULL);

	EM_DECLARE(exExiting);

	Git* git;
	RevsView* rv;
	QProgressBar* pbFileNamesLoading;

	// curDir is the repository working directory, could be different from qgit running
	// directory QDir::current(). Note that qgit could be run from subdirectory
	// so only after git->isArchive() that updates curDir to point to working directory
	// we are sure is correct.
	QString curDir;
	QString startUpDir;
	QString startUpFile;
	QString textToFind;
	QRegExp shortLogRE;
	QRegExp longLogRE;
	static const QRegExp emptySha;
	QMap<QString, QVariant> revision_variables; // variables used in generic input dialogs
	bool setRepositoryBusy;

};

class ExternalDiffProc : public QProcess {
Q_OBJECT
public:
	ExternalDiffProc(const QStringList& f, QObject* p)
		: QProcess(p), filenames(f) {

		connect(this, SIGNAL(finished(int, QProcess::ExitStatus)),
		        this, SLOT(on_finished(int, QProcess::ExitStatus)));
	}
	~ExternalDiffProc() {

		terminate();
		removeFiles();
	}
	QStringList filenames;

private slots:
	void on_finished(int, QProcess::ExitStatus) { deleteLater(); }

private:
	void removeFiles() {

		if (!filenames.empty()) {
			QDir d; // remove temporary files to diff on
			for (int i = 0; i < filenames.size(); i++)
			{
				d.remove(filenames[i]);
			}
		}
	}
};

class ExternalEditorProc : public QProcess {
Q_OBJECT
public:
	ExternalEditorProc(QObject* p)
	    : QProcess(p) {

		connect(this, SIGNAL(finished(int, QProcess::ExitStatus)),
		        this, SLOT(on_finished(int, QProcess::ExitStatus)));
	}
	~ExternalEditorProc() {
		terminate();
	}

private slots:
	void on_finished(int, QProcess::ExitStatus) { deleteLater(); }

private:
};


#endif