2 Author: Marco Costalba (C) 2005-2007
4 Copyright: See COPYING file that comes with this distribution
13 #include "exceptionmanager.h"
15 #include "ui_mainview.h"
21 class QListWidgetItem
;
33 class MainImpl
: public QMainWindow
, public Ui_MainBase
{
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
);
39 const QString
currentDir() const {return curDir
;}
41 // not buildable with Qt designer, will be created manually
42 QLineEdit
* lineEditSHA
;
43 QLineEdit
* lineEditFilter
;
58 void highlightPatch(const QString
&, bool);
60 void closeAllWindows();
62 void changeFont(const QFont
&);
63 void typeWriterFontChanged();
64 void flagChanged(uint
);
67 void tabWdg_currentChanged(int);
68 void newRevsAdded(const FileHistory
*, const QVector
<ShaString
>&);
69 void fileNamesLoad(int, int);
70 void applyRevisions(const QStringList
& shas
, const QString
& remoteRepo
);
71 bool applyPatches(const QStringList
&files
);
72 void rebase(const QString
& from
, const QString
& to
, const QString
& onto
);
73 void merge(const QStringList
& shas
, const QString
& into
);
74 void moveRef(const QString
& refName
, const QString
& toSHA
);
75 void shortCutActivated();
78 virtual bool event(QEvent
* e
);
81 void initWithEventLoopActive();
82 void refreshRepo(bool setCurRevAfterLoad
= true);
83 void listViewLog_doubleClicked(const QModelIndex
&);
84 void fileList_itemDoubleClicked(QListWidgetItem
*);
85 void treeView_doubleClicked(QTreeWidgetItem
*, int);
86 void histListView_doubleClicked(const QModelIndex
&);
87 void customActionListChanged(const QStringList
& list
);
88 void openRecent_triggered(QAction
*);
89 void customAction_triggered(QAction
*);
90 void customAction_exited(const QString
& name
);
91 void goRef_triggered(QAction
*);
92 void changesCommitted(bool);
93 void lineEditSHA_returnPressed();
94 void lineEditFilter_returnPressed();
95 void tabBar_tabCloseRequested(int index
);
96 void ActBack_activated();
97 void ActForward_activated();
98 void ActFind_activated();
99 void ActFindNext_activated();
100 void ActRangeDlg_activated();
101 void ActViewRev_activated();
102 void ActViewFile_activated();
103 void ActViewFileNewTab_activated();
104 void ActViewDiff_activated();
105 void ActViewDiffNewTab_activated();
106 void ActExternalDiff_activated();
107 void ActExternalEditor_activated();
108 void ActSplitView_activated();
109 void ActToggleLogsDiff_activated();
110 void ActShowDescHeader_activated();
111 void ActOpenRepo_activated();
112 void ActOpenRepoNewWindow_activated();
113 void ActRefresh_activated();
114 void ActSaveFile_activated();
115 void ActMailFormatPatch_activated();
116 void ActMailApplyPatch_activated();
117 void ActSettings_activated();
118 void ActCommit_activated();
119 void ActAmend_activated();
120 void ActCheckout_activated();
121 void ActBranch_activated();
122 void ActTag_activated();
123 void ActDelete_activated();
124 void ActPush_activated();
125 void ActPop_activated();
126 void ActClose_activated();
127 void ActExit_activated();
128 void ActSearchAndFilter_toggled(bool);
129 void ActSearchAndHighlight_toggled(bool);
130 void ActCustomActionSetup_activated();
131 void ActCheckWorkDir_toggled(bool);
132 void ActShowTree_toggled(bool);
133 void ActFilterTree_toggled(bool);
134 void ActAbout_activated();
135 void ActHelp_activated();
136 void ActMarkDiffToSha_activated();
137 void closeEvent(QCloseEvent
* ce
);
140 friend class setRepoDelayed
;
142 virtual bool eventFilter(QObject
* obj
, QEvent
* ev
);
143 void updateGlobalActions(bool b
);
144 void updateRevVariables(SCRef sha
);
145 void setupShortcuts();
146 int currentTabType(Domain
** t
);
147 int tabType(Domain
** t
, int index
);
148 void filterList(bool isOn
, bool onlyHighlight
);
149 bool isMatch(SCRef sha
, SCRef f
, int cn
, const QMap
<QString
,bool>& sm
);
150 void highlightAbbrevSha(SCRef abbrevSha
);
151 void setRepository(SCRef wd
, bool = false, bool = false, const QStringList
* = NULL
, bool = false);
152 void getExternalDiffArgs(QStringList
* args
, QStringList
* filenames
);
153 QString
copyFileToDiffIfNeeded(QStringList
* filenames
, QString sha
);
154 QStringList
getExternalEditorArgs();
155 void lineEditSHASetText(SCRef text
);
156 void updateCommitMenu(bool isStGITStack
);
157 void updateRecentRepoMenu(SCRef newEntry
= "");
158 void doUpdateRecentRepoMenu(SCRef newEntry
);
159 void doUpdateCustomActionMenu(const QStringList
& list
);
160 void doBranchOrTag(bool isTag
);
161 void ActCommit_setEnabled(bool b
);
162 void doContexPopup(SCRef sha
);
163 void doFileContexPopup(SCRef fileName
, int type
);
164 void adjustFontSize(int delta
);
165 void scrollTextEdit(int delta
);
166 void goMatch(int delta
);
167 bool askApplyPatchParameters(bool* commit
, bool* fold
);
168 void saveCurrentGeometry();
169 QTextEdit
* getCurrentTextEdit();
170 template<class X
> QList
<X
*>* getTabs(QWidget
* tabPage
= NULL
);
171 template<class X
> X
* firstTab(QWidget
* startPage
= NULL
);
172 void openFileTab(FileView
* fv
= NULL
);
174 EM_DECLARE(exExiting
);
178 QProgressBar
* pbFileNamesLoading
;
180 // curDir is the repository working directory, could be different from qgit running
181 // directory QDir::current(). Note that qgit could be run from subdirectory
182 // so only after git->isArchive() that updates curDir to point to working directory
183 // we are sure is correct.
190 static const QRegExp emptySha
;
191 QMap
<QString
, QVariant
> revision_variables
; // variables used in generic input dialogs
192 bool setRepositoryBusy
;
196 class ExternalDiffProc
: public QProcess
{
199 ExternalDiffProc(const QStringList
& f
, QObject
* p
)
200 : QProcess(p
), filenames(f
) {
202 connect(this, SIGNAL(finished(int, QProcess::ExitStatus
)),
203 this, SLOT(on_finished(int, QProcess::ExitStatus
)));
205 ~ExternalDiffProc() {
210 QStringList filenames
;
213 void on_finished(int, QProcess::ExitStatus
) { deleteLater(); }
218 if (!filenames
.empty()) {
219 QDir d
; // remove temporary files to diff on
220 for (int i
= 0; i
< filenames
.size(); i
++)
222 d
.remove(filenames
[i
]);
228 class ExternalEditorProc
: public QProcess
{
231 ExternalEditorProc(QObject
* p
)
234 connect(this, SIGNAL(finished(int, QProcess::ExitStatus
)),
235 this, SLOT(on_finished(int, QProcess::ExitStatus
)));
237 ~ExternalEditorProc() {
242 void on_finished(int, QProcess::ExitStatus
) { deleteLater(); }