jtkorhonen@0
|
1 /****************************************************************************
|
jtkorhonen@0
|
2 **
|
jtkorhonen@0
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
jtkorhonen@0
|
4 ** All rights reserved.
|
jtkorhonen@0
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
|
jtkorhonen@0
|
6 **
|
jtkorhonen@0
|
7 ** This file is part of the examples of the Qt Toolkit.
|
jtkorhonen@0
|
8 **
|
jtkorhonen@0
|
9 ** $QT_BEGIN_LICENSE:LGPL$
|
jtkorhonen@0
|
10 ** Commercial Usage
|
jtkorhonen@0
|
11 ** Licensees holding valid Qt Commercial licenses may use this file in
|
jtkorhonen@0
|
12 ** accordance with the Qt Commercial License Agreement provided with the
|
jtkorhonen@0
|
13 ** Software or, alternatively, in accordance with the terms contained in
|
jtkorhonen@0
|
14 ** a written agreement between you and Nokia.
|
jtkorhonen@0
|
15 **
|
jtkorhonen@0
|
16 ** GNU Lesser General Public License Usage
|
jtkorhonen@0
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
|
jtkorhonen@0
|
18 ** General Public License version 2.1 as published by the Free Software
|
jtkorhonen@0
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
|
jtkorhonen@0
|
20 ** packaging of this file. Please review the following information to
|
jtkorhonen@0
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
|
jtkorhonen@0
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
jtkorhonen@0
|
23 **
|
jtkorhonen@0
|
24 ** In addition, as a special exception, Nokia gives you certain additional
|
jtkorhonen@0
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
|
jtkorhonen@0
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
jtkorhonen@0
|
27 **
|
jtkorhonen@0
|
28 ** GNU General Public License Usage
|
jtkorhonen@0
|
29 ** Alternatively, this file may be used under the terms of the GNU
|
jtkorhonen@0
|
30 ** General Public License version 3.0 as published by the Free Software
|
jtkorhonen@0
|
31 ** Foundation and appearing in the file LICENSE.GPL included in the
|
jtkorhonen@0
|
32 ** packaging of this file. Please review the following information to
|
jtkorhonen@0
|
33 ** ensure the GNU General Public License version 3.0 requirements will be
|
jtkorhonen@0
|
34 ** met: http://www.gnu.org/copyleft/gpl.html.
|
jtkorhonen@0
|
35 **
|
jtkorhonen@0
|
36 ** If you have questions regarding the use of this file, please contact
|
jtkorhonen@0
|
37 ** Nokia at qt-info@nokia.com.
|
jtkorhonen@0
|
38 ** $QT_END_LICENSE$
|
jtkorhonen@0
|
39 **
|
jtkorhonen@0
|
40 ** Copyright (C) Jari Korhonen, 2010 (HgExplorer specific parts, under lgpl)
|
jtkorhonen@0
|
41 *************************************************************************************/
|
jtkorhonen@0
|
42
|
jtkorhonen@0
|
43 #include <QtGui>
|
jtkorhonen@0
|
44 #include <QStringList>
|
jtkorhonen@0
|
45 #include <QDir>
|
jtkorhonen@24
|
46 #include <QNetworkInterface>
|
jtkorhonen@17
|
47 #include <QHostAddress>
|
jtkorhonen@17
|
48 #include <QHostInfo>
|
jtkorhonen@0
|
49
|
jtkorhonen@0
|
50 #include "mainwindow.h"
|
jtkorhonen@0
|
51 #include "settingsdialog.h"
|
jtkorhonen@0
|
52
|
jtkorhonen@0
|
53
|
jtkorhonen@0
|
54 MainWindow::MainWindow()
|
jtkorhonen@0
|
55 {
|
jtkorhonen@0
|
56 QString wndTitle;
|
jtkorhonen@0
|
57
|
jtkorhonen@0
|
58 createActions();
|
jtkorhonen@0
|
59 createMenus();
|
jtkorhonen@0
|
60 createToolBars();
|
jtkorhonen@0
|
61 createStatusBar();
|
jtkorhonen@0
|
62
|
jtkorhonen@0
|
63 timerId = startTimer(200);
|
jtkorhonen@0
|
64 runner = new HgRunner(this);
|
jtkorhonen@0
|
65 runningAction = ACT_NONE;
|
jtkorhonen@0
|
66 statusBar()->addPermanentWidget(runner);
|
jtkorhonen@0
|
67
|
jtkorhonen@0
|
68 wndTitle.sprintf("%s %s", APPNAME, APPVERSION);
|
jtkorhonen@0
|
69 setWindowTitle(wndTitle);
|
jtkorhonen@0
|
70
|
jtkorhonen@0
|
71 remoteRepoPath = "";
|
jtkorhonen@0
|
72 workFolderPath = "";
|
jtkorhonen@0
|
73
|
jtkorhonen@0
|
74 readSettings();
|
jtkorhonen@0
|
75
|
jtkorhonen@0
|
76 tabPage = 0;
|
jtkorhonen@0
|
77 hgExp = new HgExpWidget((QWidget *) this, remoteRepoPath, workFolderPath, initialFileTypesBits);
|
jtkorhonen@0
|
78 setCentralWidget(hgExp);
|
jtkorhonen@0
|
79
|
jtkorhonen@0
|
80 setUnifiedTitleAndToolBarOnMac(true);
|
jtkorhonen@0
|
81 connectActions();
|
jtkorhonen@0
|
82 enableDisableActions();
|
jtkorhonen@0
|
83
|
jtkorhonen@0
|
84 if (firstStart)
|
jtkorhonen@0
|
85 {
|
jtkorhonen@0
|
86 QMessageBox::information(this, tr("First start todo"), tr("Going to \"Settings\" first."));
|
jtkorhonen@0
|
87 settings();
|
jtkorhonen@0
|
88 }
|
jtkorhonen@0
|
89
|
jtkorhonen@0
|
90 hgStat();
|
jtkorhonen@0
|
91 }
|
jtkorhonen@0
|
92
|
jtkorhonen@0
|
93
|
jtkorhonen@0
|
94 void MainWindow::closeEvent(QCloseEvent *)
|
jtkorhonen@0
|
95 {
|
jtkorhonen@0
|
96 writeSettings();
|
jtkorhonen@0
|
97 }
|
jtkorhonen@0
|
98
|
jtkorhonen@0
|
99
|
jtkorhonen@0
|
100 void MainWindow::about()
|
jtkorhonen@0
|
101 {
|
jtkorhonen@0
|
102 QMessageBox::about(this, tr("About HgExplorer"),
|
jtkorhonen@0
|
103 tr("<b>HgExplorer</b> tries to be Mercurial's <b>VSS Explorer:</b> ;-)<br><br>"
|
jtkorhonen@0
|
104 "-Hides command line in normal use<br>"
|
jtkorhonen@0
|
105 "-Makes common operations easier<br><br>"
|
jtkorhonen@0
|
106 "(c) 2010 (lgpl), Jari Korhonen (jtkorhonen@gmail.com)<br><br>"
|
jtkorhonen@0
|
107 "-Needs Mercurial ;-) (thanks Matt Mackall, Bryan O'Sullivan and others !)<br>"
|
jtkorhonen@0
|
108 "-Uses excellent Nuvola icons (c) David Vignoni (Thanks, David !)<br>"
|
jtkorhonen@29
|
109 "-Needs Qt4, mingw (in windows), python, kdiff3 (Thanks to all of you !)<br>"
|
jtkorhonen@29
|
110 "-Windows standalone install uses hg / python / kdiff3 from TortoiseHg (BIG Thanks !)<br>"
|
jtkorhonen@29
|
111 "-Windows standalone install uses InstallJammer setup tool (Thanks, great tool !)<br>"));
|
jtkorhonen@0
|
112 }
|
jtkorhonen@0
|
113
|
jtkorhonen@0
|
114
|
jtkorhonen@0
|
115 void MainWindow::hgStat()
|
jtkorhonen@0
|
116 {
|
jtkorhonen@0
|
117 if (hgStatAct -> isEnabled())
|
jtkorhonen@0
|
118 {
|
jtkorhonen@0
|
119 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
120 {
|
jtkorhonen@0
|
121 QStringList params;
|
jtkorhonen@0
|
122
|
jtkorhonen@0
|
123 QString statFlags = hgExp -> getStatFlags();
|
jtkorhonen@0
|
124 if (statFlags.isEmpty())
|
jtkorhonen@0
|
125 {
|
jtkorhonen@0
|
126 params << "stat";
|
jtkorhonen@0
|
127 }
|
jtkorhonen@0
|
128 else
|
jtkorhonen@0
|
129 {
|
jtkorhonen@0
|
130 params << "stat" << "-" + statFlags;
|
jtkorhonen@0
|
131 }
|
jtkorhonen@0
|
132
|
jtkorhonen@0
|
133
|
jtkorhonen@0
|
134 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
135 runningAction = ACT_STAT;
|
jtkorhonen@0
|
136 }
|
jtkorhonen@0
|
137 }
|
jtkorhonen@0
|
138 }
|
jtkorhonen@0
|
139
|
jtkorhonen@0
|
140 void MainWindow::hgHeads()
|
jtkorhonen@0
|
141 {
|
jtkorhonen@0
|
142 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
143 {
|
jtkorhonen@0
|
144 QStringList params;
|
jtkorhonen@0
|
145 params << "heads";
|
jtkorhonen@0
|
146
|
jtkorhonen@0
|
147 //on empty repos, "hg heads" will fail, don't care of that.
|
jtkorhonen@0
|
148 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
149 runningAction = ACT_HEADS;
|
jtkorhonen@0
|
150 }
|
jtkorhonen@0
|
151 }
|
jtkorhonen@0
|
152
|
jtkorhonen@0
|
153 void MainWindow::hgLog()
|
jtkorhonen@0
|
154 {
|
jtkorhonen@0
|
155 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
156 {
|
jtkorhonen@0
|
157 QStringList params;
|
jtkorhonen@0
|
158 params << "glog" << "--verbose";
|
jtkorhonen@0
|
159
|
jtkorhonen@0
|
160 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
161 runningAction = ACT_LOG;
|
jtkorhonen@0
|
162 }
|
jtkorhonen@0
|
163 }
|
jtkorhonen@0
|
164
|
jtkorhonen@0
|
165
|
jtkorhonen@0
|
166 void MainWindow::hgParents()
|
jtkorhonen@0
|
167 {
|
jtkorhonen@0
|
168 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
169 {
|
jtkorhonen@0
|
170 QStringList params;
|
jtkorhonen@0
|
171 params << "parents";
|
jtkorhonen@0
|
172
|
jtkorhonen@0
|
173 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
174 runningAction = ACT_PARENTS;
|
jtkorhonen@0
|
175 }
|
jtkorhonen@0
|
176 }
|
jtkorhonen@0
|
177
|
jtkorhonen@0
|
178
|
jtkorhonen@0
|
179
|
jtkorhonen@0
|
180 void MainWindow::hgRemove()
|
jtkorhonen@0
|
181 {
|
jtkorhonen@0
|
182 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
183 {
|
jtkorhonen@0
|
184 QStringList params;
|
jtkorhonen@0
|
185 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
186
|
jtkorhonen@0
|
187 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
188 {
|
jtkorhonen@6
|
189 if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
|
jtkorhonen@6
|
190 QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
|
jtkorhonen@6
|
191 {
|
jtkorhonen@6
|
192 params << "remove" << "--after" << "--force" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
193
|
jtkorhonen@6
|
194 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@6
|
195 runningAction = ACT_REMOVE;
|
jtkorhonen@6
|
196 }
|
jtkorhonen@0
|
197 }
|
jtkorhonen@0
|
198 }
|
jtkorhonen@0
|
199 }
|
jtkorhonen@0
|
200
|
jtkorhonen@0
|
201 void MainWindow::hgAnnotate()
|
jtkorhonen@0
|
202 {
|
jtkorhonen@0
|
203 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
204 {
|
jtkorhonen@0
|
205 QStringList params;
|
jtkorhonen@0
|
206 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
207
|
jtkorhonen@0
|
208 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
209 {
|
jtkorhonen@0
|
210 params << "annotate" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
211
|
jtkorhonen@0
|
212 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
213 runningAction = ACT_ANNOTATE;
|
jtkorhonen@0
|
214 }
|
jtkorhonen@0
|
215 }
|
jtkorhonen@0
|
216 }
|
jtkorhonen@0
|
217
|
jtkorhonen@0
|
218
|
jtkorhonen@0
|
219 void MainWindow::hgResolveMark()
|
jtkorhonen@0
|
220 {
|
jtkorhonen@0
|
221 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
222 {
|
jtkorhonen@0
|
223 QStringList params;
|
jtkorhonen@0
|
224 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
225
|
jtkorhonen@0
|
226 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
227 {
|
jtkorhonen@0
|
228 params << "resolve" << "--mark" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
|
jtkorhonen@0
|
229
|
jtkorhonen@0
|
230 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
231 runningAction = ACT_RESOLVE_MARK;
|
jtkorhonen@0
|
232 }
|
jtkorhonen@0
|
233 }
|
jtkorhonen@0
|
234 }
|
jtkorhonen@0
|
235
|
jtkorhonen@0
|
236
|
jtkorhonen@0
|
237
|
jtkorhonen@0
|
238 void MainWindow::hgResolveList()
|
jtkorhonen@0
|
239 {
|
jtkorhonen@0
|
240 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
241 {
|
jtkorhonen@0
|
242 QStringList params;
|
jtkorhonen@0
|
243
|
jtkorhonen@0
|
244 params << "resolve" << "--list";
|
jtkorhonen@0
|
245 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
246 runningAction = ACT_RESOLVE_LIST;
|
jtkorhonen@0
|
247 }
|
jtkorhonen@0
|
248 }
|
jtkorhonen@0
|
249
|
jtkorhonen@0
|
250
|
jtkorhonen@0
|
251
|
jtkorhonen@0
|
252 void MainWindow::hgAdd()
|
jtkorhonen@0
|
253 {
|
jtkorhonen@0
|
254 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
255 {
|
jtkorhonen@0
|
256 QStringList params;
|
jtkorhonen@0
|
257
|
jtkorhonen@5
|
258 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@5
|
259
|
jtkorhonen@17
|
260 if (areAllSelectedUntracked(hgExp -> workFolderFileList))
|
jtkorhonen@5
|
261 {
|
jtkorhonen@17
|
262 //User wants to add selected file(s)
|
jtkorhonen@17
|
263 params << "add";
|
jtkorhonen@17
|
264
|
jtkorhonen@17
|
265 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
266
|
jtkorhonen@17
|
267 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
268 {
|
jtkorhonen@17
|
269 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
270 params.append(tmp.mid(2));
|
jtkorhonen@17
|
271 }
|
jtkorhonen@5
|
272 }
|
jtkorhonen@5
|
273 else
|
jtkorhonen@5
|
274 {
|
jtkorhonen@5
|
275 //Add all untracked files
|
jtkorhonen@5
|
276 params << "add";
|
jtkorhonen@5
|
277 }
|
jtkorhonen@0
|
278
|
jtkorhonen@0
|
279 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
280 runningAction = ACT_ADD;
|
jtkorhonen@0
|
281 }
|
jtkorhonen@0
|
282 }
|
jtkorhonen@0
|
283
|
jtkorhonen@0
|
284 int MainWindow::getCommitComment(QString& comment)
|
jtkorhonen@0
|
285 {
|
jtkorhonen@0
|
286 int ret;
|
jtkorhonen@0
|
287
|
jtkorhonen@0
|
288 QDialog dlg(this);
|
jtkorhonen@0
|
289
|
jtkorhonen@0
|
290 QLabel *commentLabel = new QLabel(tr("Comment:"));
|
jtkorhonen@0
|
291 QLineEdit *commentEdit = new QLineEdit;
|
jtkorhonen@0
|
292 commentEdit -> setFixedWidth(400);
|
jtkorhonen@0
|
293 QHBoxLayout *commentLayout = new QHBoxLayout;
|
jtkorhonen@0
|
294 commentLayout -> addWidget(commentLabel);
|
jtkorhonen@0
|
295 commentLayout -> addWidget(commentEdit);
|
jtkorhonen@0
|
296
|
jtkorhonen@0
|
297 QPushButton *btnOk = new QPushButton(tr("Ok"));
|
jtkorhonen@0
|
298 QPushButton *btnCancel = new QPushButton(tr("Cancel"));
|
jtkorhonen@0
|
299 QHBoxLayout *btnLayout = new QHBoxLayout;
|
jtkorhonen@0
|
300 btnLayout -> addWidget(btnOk);
|
jtkorhonen@0
|
301 btnLayout -> addWidget(btnCancel);
|
jtkorhonen@0
|
302
|
jtkorhonen@0
|
303 QVBoxLayout *mainLayout = new QVBoxLayout;
|
jtkorhonen@0
|
304 mainLayout -> addLayout(commentLayout);
|
jtkorhonen@0
|
305 mainLayout -> addLayout(btnLayout);
|
jtkorhonen@0
|
306
|
jtkorhonen@0
|
307 dlg.setLayout(mainLayout);
|
jtkorhonen@0
|
308
|
jtkorhonen@0
|
309 dlg.setWindowTitle(tr("Save (commit)"));
|
jtkorhonen@0
|
310
|
jtkorhonen@0
|
311 connect(btnOk, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
312 connect(btnCancel, SIGNAL(clicked()), &dlg, SLOT(reject()));
|
jtkorhonen@0
|
313
|
jtkorhonen@0
|
314 ret = dlg.exec();
|
jtkorhonen@0
|
315 comment = commentEdit -> text();
|
jtkorhonen@0
|
316 return ret;
|
jtkorhonen@0
|
317 }
|
jtkorhonen@0
|
318
|
jtkorhonen@0
|
319 void MainWindow::hgCommit()
|
jtkorhonen@0
|
320 {
|
jtkorhonen@0
|
321 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
322 {
|
jtkorhonen@0
|
323 QStringList params;
|
jtkorhonen@0
|
324 QString comment;
|
jtkorhonen@0
|
325
|
jtkorhonen@0
|
326 if (QDialog::Accepted == getCommitComment(comment))
|
jtkorhonen@0
|
327 {
|
jtkorhonen@0
|
328 if (!comment.isEmpty())
|
jtkorhonen@0
|
329 {
|
jtkorhonen@11
|
330 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@11
|
331
|
jtkorhonen@17
|
332 if (areAllSelectedCommitable(hgExp -> workFolderFileList))
|
jtkorhonen@11
|
333 {
|
jtkorhonen@17
|
334 //User wants to commit selected file(s)
|
jtkorhonen@17
|
335 params << "commit" << "--message" << comment << "--user" << userInfo;
|
jtkorhonen@17
|
336
|
jtkorhonen@17
|
337 QList <QListWidgetItem *> selList = hgExp -> workFolderFileList -> selectedItems();
|
jtkorhonen@17
|
338 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
339 {
|
jtkorhonen@17
|
340 QString tmp = selList.at(i)->text();
|
jtkorhonen@17
|
341 params.append(tmp.mid(2));
|
jtkorhonen@17
|
342 }
|
jtkorhonen@11
|
343 }
|
jtkorhonen@11
|
344 else
|
jtkorhonen@11
|
345 {
|
jtkorhonen@11
|
346 //Commit all changes
|
jtkorhonen@11
|
347 params << "commit" << "--message" << comment << "--user" << userInfo;
|
jtkorhonen@11
|
348 }
|
jtkorhonen@0
|
349
|
jtkorhonen@0
|
350 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
351 runningAction = ACT_COMMIT;
|
jtkorhonen@0
|
352 }
|
jtkorhonen@0
|
353 }
|
jtkorhonen@0
|
354 }
|
jtkorhonen@0
|
355 }
|
jtkorhonen@0
|
356
|
jtkorhonen@0
|
357 void MainWindow::hgFileDiff()
|
jtkorhonen@0
|
358 {
|
jtkorhonen@0
|
359 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
360 {
|
jtkorhonen@0
|
361 QStringList params;
|
jtkorhonen@0
|
362
|
jtkorhonen@0
|
363 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
364
|
jtkorhonen@0
|
365 if (!currentFile.isEmpty())
|
jtkorhonen@0
|
366 {
|
jtkorhonen@0
|
367 //Diff parent file against working folder file
|
jtkorhonen@0
|
368 params << "kdiff3" << currentFile.mid(2);
|
jtkorhonen@0
|
369 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
370 runningAction = ACT_FILEDIFF;
|
jtkorhonen@0
|
371 }
|
jtkorhonen@0
|
372 }
|
jtkorhonen@0
|
373 }
|
jtkorhonen@0
|
374
|
jtkorhonen@0
|
375
|
jtkorhonen@0
|
376 void MainWindow::hgFolderDiff()
|
jtkorhonen@0
|
377 {
|
jtkorhonen@0
|
378 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
379 {
|
jtkorhonen@0
|
380 QStringList params;
|
jtkorhonen@0
|
381
|
jtkorhonen@0
|
382 //Diff parent against working folder (folder diff)
|
jtkorhonen@0
|
383 params << "kdiff3";
|
jtkorhonen@0
|
384 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
385 runningAction = ACT_FOLDERDIFF;
|
jtkorhonen@0
|
386 }
|
jtkorhonen@0
|
387 }
|
jtkorhonen@0
|
388
|
jtkorhonen@0
|
389
|
jtkorhonen@0
|
390 void MainWindow::hgChgSetDiff()
|
jtkorhonen@0
|
391 {
|
jtkorhonen@0
|
392 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
393 {
|
jtkorhonen@0
|
394 QStringList params;
|
jtkorhonen@0
|
395
|
jtkorhonen@0
|
396 //Diff 2 history log versions against each other
|
jtkorhonen@0
|
397 QString revA;
|
jtkorhonen@0
|
398 QString revB;
|
jtkorhonen@0
|
399
|
jtkorhonen@0
|
400 hgExp -> getHistoryDiffRevisions(revA, revB);
|
jtkorhonen@0
|
401
|
jtkorhonen@0
|
402 if ((!revA.isEmpty()) && (!revB.isEmpty()))
|
jtkorhonen@0
|
403 {
|
jtkorhonen@0
|
404 params << "kdiff3" << "--rev" << revA << "--rev" << revB;
|
jtkorhonen@0
|
405 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
406 runningAction = ACT_CHGSETDIFF;
|
jtkorhonen@0
|
407 }
|
jtkorhonen@0
|
408 else
|
jtkorhonen@0
|
409 {
|
jtkorhonen@0
|
410 QMessageBox::information(this, tr("Changeset diff"), tr("Please select two changesets from history list or heads list first."));
|
jtkorhonen@0
|
411 }
|
jtkorhonen@0
|
412 }
|
jtkorhonen@0
|
413 }
|
jtkorhonen@0
|
414
|
jtkorhonen@0
|
415
|
jtkorhonen@0
|
416
|
jtkorhonen@0
|
417 void MainWindow::hgUpdate()
|
jtkorhonen@0
|
418 {
|
jtkorhonen@0
|
419 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
420 {
|
jtkorhonen@0
|
421 QStringList params;
|
jtkorhonen@0
|
422
|
jtkorhonen@0
|
423
|
jtkorhonen@0
|
424 params << "update";
|
jtkorhonen@0
|
425
|
jtkorhonen@0
|
426
|
jtkorhonen@0
|
427 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
428 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
429 }
|
jtkorhonen@0
|
430 }
|
jtkorhonen@0
|
431
|
jtkorhonen@0
|
432
|
jtkorhonen@0
|
433 void MainWindow::hgUpdateToRev()
|
jtkorhonen@0
|
434 {
|
jtkorhonen@0
|
435 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
436 {
|
jtkorhonen@0
|
437 QStringList params;
|
jtkorhonen@0
|
438 QString rev;
|
jtkorhonen@0
|
439
|
jtkorhonen@0
|
440 hgExp -> getUpdateToRevRevision(rev);
|
jtkorhonen@0
|
441
|
jtkorhonen@0
|
442 hgExp -> setCurrentIndex(WORKTAB);
|
jtkorhonen@0
|
443 enableDisableActions();
|
jtkorhonen@0
|
444
|
jtkorhonen@0
|
445 params << "update" << "--rev" << rev << "--clean";
|
jtkorhonen@0
|
446
|
jtkorhonen@0
|
447 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
448
|
jtkorhonen@0
|
449 runningAction = ACT_UPDATE;
|
jtkorhonen@0
|
450 }
|
jtkorhonen@0
|
451 }
|
jtkorhonen@0
|
452
|
jtkorhonen@0
|
453
|
jtkorhonen@0
|
454 void MainWindow::hgRevert()
|
jtkorhonen@0
|
455 {
|
jtkorhonen@0
|
456 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
457 {
|
jtkorhonen@0
|
458 QStringList params;
|
jtkorhonen@0
|
459 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@0
|
460
|
jtkorhonen@5
|
461 params << "revert" << "--no-backup" << currentFile.mid(2);
|
jtkorhonen@0
|
462
|
jtkorhonen@0
|
463 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
464 runningAction = ACT_REVERT;
|
jtkorhonen@0
|
465 }
|
jtkorhonen@0
|
466 }
|
jtkorhonen@0
|
467
|
jtkorhonen@0
|
468 void MainWindow::hgMerge()
|
jtkorhonen@0
|
469 {
|
jtkorhonen@0
|
470 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
471 {
|
jtkorhonen@0
|
472 QStringList params;
|
jtkorhonen@0
|
473
|
jtkorhonen@0
|
474 params << "merge";
|
jtkorhonen@0
|
475
|
jtkorhonen@0
|
476 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
477 runningAction = ACT_MERGE;
|
jtkorhonen@0
|
478 }
|
jtkorhonen@0
|
479 }
|
jtkorhonen@0
|
480
|
jtkorhonen@0
|
481
|
jtkorhonen@0
|
482 void MainWindow::hgCloneFromRemote()
|
jtkorhonen@0
|
483 {
|
jtkorhonen@0
|
484 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
485 {
|
jtkorhonen@0
|
486 QStringList params;
|
jtkorhonen@0
|
487
|
jtkorhonen@0
|
488 params << "clone" << remoteRepoPath << workFolderPath;
|
jtkorhonen@0
|
489
|
jtkorhonen@0
|
490 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
491 runningAction = ACT_CLONEFROMREMOTE;
|
jtkorhonen@0
|
492 }
|
jtkorhonen@0
|
493 }
|
jtkorhonen@0
|
494
|
jtkorhonen@0
|
495
|
jtkorhonen@0
|
496 void MainWindow::hgInit()
|
jtkorhonen@0
|
497 {
|
jtkorhonen@0
|
498 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
499 {
|
jtkorhonen@0
|
500 QStringList params;
|
jtkorhonen@0
|
501
|
jtkorhonen@0
|
502 params << "init";
|
jtkorhonen@0
|
503
|
jtkorhonen@0
|
504 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
505 runningAction = ACT_INIT;
|
jtkorhonen@0
|
506 }
|
jtkorhonen@0
|
507 }
|
jtkorhonen@0
|
508
|
jtkorhonen@0
|
509
|
jtkorhonen@0
|
510 void MainWindow::hgIncoming()
|
jtkorhonen@0
|
511 {
|
jtkorhonen@0
|
512 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
513 {
|
jtkorhonen@0
|
514 QStringList params;
|
jtkorhonen@0
|
515
|
jtkorhonen@0
|
516 params << "incoming" << "--newest-first" << remoteRepoPath;
|
jtkorhonen@0
|
517
|
jtkorhonen@0
|
518 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@0
|
519 runningAction = ACT_INCOMING;
|
jtkorhonen@0
|
520 }
|
jtkorhonen@0
|
521 }
|
jtkorhonen@0
|
522
|
jtkorhonen@0
|
523
|
jtkorhonen@0
|
524 void MainWindow::hgPull()
|
jtkorhonen@0
|
525 {
|
jtkorhonen@0
|
526 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
527 {
|
jtkorhonen@0
|
528 QStringList params;
|
jtkorhonen@0
|
529
|
jtkorhonen@0
|
530 params << "pull" << remoteRepoPath;
|
jtkorhonen@0
|
531
|
jtkorhonen@0
|
532 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
533 runningAction = ACT_PULL;
|
jtkorhonen@0
|
534 }
|
jtkorhonen@0
|
535 }
|
jtkorhonen@0
|
536
|
jtkorhonen@0
|
537
|
jtkorhonen@0
|
538 void MainWindow::hgPush()
|
jtkorhonen@0
|
539 {
|
jtkorhonen@0
|
540 if (runningAction == ACT_NONE)
|
jtkorhonen@0
|
541 {
|
jtkorhonen@0
|
542 QStringList params;
|
jtkorhonen@0
|
543
|
jtkorhonen@0
|
544 params << "push" << remoteRepoPath;
|
jtkorhonen@0
|
545
|
jtkorhonen@0
|
546 runner -> startProc(getHgBinaryName(), workFolderPath, params);
|
jtkorhonen@0
|
547 runningAction = ACT_PUSH;
|
jtkorhonen@0
|
548 }
|
jtkorhonen@0
|
549 }
|
jtkorhonen@0
|
550
|
jtkorhonen@0
|
551
|
jtkorhonen@26
|
552
|
jtkorhonen@28
|
553 QString MainWindow::listAllUpIpV4Addresses()
|
jtkorhonen@26
|
554 {
|
jtkorhonen@28
|
555 QString ret;
|
jtkorhonen@26
|
556 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
|
jtkorhonen@26
|
557
|
jtkorhonen@26
|
558 for (int i = 0; i < ifaces.count(); i++)
|
jtkorhonen@26
|
559 {
|
jtkorhonen@26
|
560 QNetworkInterface iface = ifaces.at(i);
|
jtkorhonen@26
|
561
|
jtkorhonen@26
|
562 if (iface.flags().testFlag(QNetworkInterface::IsUp) && !iface.flags().testFlag(QNetworkInterface::IsLoopBack))
|
jtkorhonen@26
|
563 {
|
jtkorhonen@26
|
564 for (int j=0; j<iface.addressEntries().count(); j++)
|
jtkorhonen@26
|
565 {
|
jtkorhonen@28
|
566 QHostAddress tmp = iface.addressEntries().at(j).ip();
|
jtkorhonen@28
|
567 if (QAbstractSocket::IPv4Protocol == tmp.protocol())
|
jtkorhonen@24
|
568 {
|
jtkorhonen@28
|
569 if (!ret.isEmpty())
|
jtkorhonen@28
|
570 {
|
jtkorhonen@28
|
571 ret += " ";
|
jtkorhonen@28
|
572 }
|
jtkorhonen@28
|
573 ret += tmp.toString();
|
jtkorhonen@24
|
574 }
|
jtkorhonen@24
|
575 }
|
jtkorhonen@22
|
576 }
|
jtkorhonen@17
|
577 }
|
jtkorhonen@28
|
578 return ret;
|
jtkorhonen@28
|
579 }
|
jtkorhonen@17
|
580
|
jtkorhonen@17
|
581
|
jtkorhonen@11
|
582 void MainWindow::hgServe()
|
jtkorhonen@11
|
583 {
|
jtkorhonen@11
|
584 if (runningAction == ACT_NONE)
|
jtkorhonen@11
|
585 {
|
jtkorhonen@11
|
586 QStringList params;
|
jtkorhonen@22
|
587 QString msg;
|
jtkorhonen@11
|
588
|
jtkorhonen@28
|
589 QString addrs = listAllUpIpV4Addresses();
|
jtkorhonen@28
|
590 QTextStream(&msg) << "Server running on address(es) (" << addrs << "), port 8000";
|
jtkorhonen@28
|
591 params << "serve";
|
jtkorhonen@11
|
592
|
jtkorhonen@11
|
593 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
|
jtkorhonen@11
|
594 runningAction = ACT_SERVE;
|
jtkorhonen@11
|
595
|
jtkorhonen@17
|
596 QMessageBox::information(this, "Serve", msg, QMessageBox::Close);
|
jtkorhonen@11
|
597 runner -> killProc();
|
jtkorhonen@11
|
598 }
|
jtkorhonen@11
|
599 }
|
jtkorhonen@11
|
600
|
jtkorhonen@11
|
601
|
jtkorhonen@11
|
602
|
jtkorhonen@0
|
603 void MainWindow::settings()
|
jtkorhonen@0
|
604 {
|
jtkorhonen@0
|
605 SettingsDialog *settingsDlg = new SettingsDialog(this);
|
jtkorhonen@0
|
606 settingsDlg->setModal(true);
|
jtkorhonen@0
|
607 settingsDlg->exec();
|
jtkorhonen@0
|
608 hgExp -> clearLists();
|
jtkorhonen@0
|
609 enableDisableActions();
|
jtkorhonen@0
|
610 hgStat();
|
jtkorhonen@0
|
611 }
|
jtkorhonen@0
|
612
|
jtkorhonen@2
|
613 #define STDOUT_NEEDS_BIG_WINDOW 512
|
jtkorhonen@2
|
614 #define SMALL_WND_W 500
|
jtkorhonen@2
|
615 #define SMALL_WND_H 300
|
jtkorhonen@2
|
616
|
jtkorhonen@2
|
617 #define BIG_WND_W 1024
|
jtkorhonen@2
|
618 #define BIG_WND_H 768
|
jtkorhonen@2
|
619
|
jtkorhonen@2
|
620
|
jtkorhonen@2
|
621 void MainWindow::presentLongStdoutToUser(QString stdo)
|
jtkorhonen@0
|
622 {
|
jtkorhonen@2
|
623 if (!stdo.isEmpty())
|
jtkorhonen@2
|
624 {
|
jtkorhonen@2
|
625 QDialog dlg;
|
jtkorhonen@0
|
626
|
jtkorhonen@2
|
627 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
|
jtkorhonen@2
|
628 {
|
jtkorhonen@2
|
629 dlg.setMinimumWidth(BIG_WND_W);
|
jtkorhonen@2
|
630 dlg.setMinimumHeight(BIG_WND_H);
|
jtkorhonen@2
|
631 }
|
jtkorhonen@2
|
632 else
|
jtkorhonen@2
|
633 {
|
jtkorhonen@2
|
634 dlg.setMinimumWidth(SMALL_WND_W);
|
jtkorhonen@2
|
635 dlg.setMinimumHeight(SMALL_WND_H);
|
jtkorhonen@2
|
636 }
|
jtkorhonen@0
|
637
|
jtkorhonen@2
|
638 QVBoxLayout *box = new QVBoxLayout;
|
jtkorhonen@2
|
639 QListWidget *list = new QListWidget;
|
jtkorhonen@2
|
640 list-> addItems(stdo.split("\n"));
|
jtkorhonen@2
|
641 QPushButton *btn = new QPushButton(tr("Ok"));
|
jtkorhonen@2
|
642 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
|
jtkorhonen@0
|
643
|
jtkorhonen@2
|
644 box -> addWidget(list);
|
jtkorhonen@2
|
645 box -> addWidget(btn);
|
jtkorhonen@2
|
646 dlg.setLayout(box);
|
jtkorhonen@2
|
647
|
jtkorhonen@2
|
648 dlg.exec();
|
jtkorhonen@2
|
649 }
|
jtkorhonen@2
|
650 else
|
jtkorhonen@2
|
651 {
|
jtkorhonen@2
|
652 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
|
jtkorhonen@2
|
653 }
|
jtkorhonen@0
|
654 }
|
jtkorhonen@0
|
655
|
jtkorhonen@0
|
656
|
jtkorhonen@17
|
657 bool MainWindow::areAllSelectedCommitable(QListWidget *workList)
|
jtkorhonen@11
|
658 {
|
jtkorhonen@11
|
659 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
660 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@11
|
661 {
|
jtkorhonen@17
|
662 QString tmp = selList.at(i) -> text().mid(0, 1);
|
jtkorhonen@11
|
663 if (tmp == "A")
|
jtkorhonen@11
|
664 {
|
jtkorhonen@11
|
665 //scheduled to be added, ok to commit
|
jtkorhonen@11
|
666 }
|
jtkorhonen@11
|
667 else if (tmp == "M")
|
jtkorhonen@11
|
668 {
|
jtkorhonen@11
|
669 //locally modified, ok to commit
|
jtkorhonen@17
|
670 }
|
jtkorhonen@17
|
671 else if (tmp == "R")
|
jtkorhonen@17
|
672 {
|
jtkorhonen@17
|
673 //user wants to remove from repo, ok to commit
|
jtkorhonen@17
|
674 }
|
jtkorhonen@17
|
675 else
|
jtkorhonen@17
|
676 {
|
jtkorhonen@17
|
677 return false;
|
jtkorhonen@11
|
678 }
|
jtkorhonen@11
|
679 }
|
jtkorhonen@17
|
680 return true;
|
jtkorhonen@11
|
681 }
|
jtkorhonen@11
|
682
|
jtkorhonen@6
|
683 bool MainWindow::isSelectedDeletable(QListWidget *workList)
|
jtkorhonen@0
|
684 {
|
jtkorhonen@0
|
685 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
686 if (selList.count() == 1)
|
jtkorhonen@0
|
687 {
|
jtkorhonen@6
|
688 QString tmp = selList.at(0)->text().mid(0, 1);
|
jtkorhonen@6
|
689 if (tmp == "A")
|
jtkorhonen@0
|
690 {
|
jtkorhonen@6
|
691 //scheduled to be added, ok to remove (won't go to repo)
|
jtkorhonen@6
|
692 return true;
|
jtkorhonen@6
|
693 }
|
jtkorhonen@6
|
694 else if (tmp == "C")
|
jtkorhonen@6
|
695 {
|
jtkorhonen@6
|
696 //Tracked but unchanged, ok to remove
|
jtkorhonen@6
|
697 return true;
|
jtkorhonen@6
|
698 }
|
jtkorhonen@6
|
699 else if (tmp == "M")
|
jtkorhonen@6
|
700 {
|
jtkorhonen@6
|
701 //locally modified, ok to remove from repo
|
jtkorhonen@6
|
702 return true;
|
jtkorhonen@6
|
703 }
|
jtkorhonen@6
|
704 else if (tmp == "!")
|
jtkorhonen@6
|
705 {
|
jtkorhonen@6
|
706 //locally deleted, ok to remove from repo
|
jtkorhonen@0
|
707 return true;
|
jtkorhonen@0
|
708 }
|
jtkorhonen@0
|
709 }
|
jtkorhonen@0
|
710 return false;
|
jtkorhonen@0
|
711 }
|
jtkorhonen@0
|
712
|
jtkorhonen@0
|
713
|
jtkorhonen@17
|
714 bool MainWindow::areAllSelectedUntracked(QListWidget *workList)
|
jtkorhonen@0
|
715 {
|
jtkorhonen@0
|
716 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
717 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@0
|
718 {
|
jtkorhonen@17
|
719 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
720
|
jtkorhonen@17
|
721 if (tmp.mid(0,1) != "?")
|
jtkorhonen@0
|
722 {
|
jtkorhonen@17
|
723 return false;
|
jtkorhonen@0
|
724 }
|
jtkorhonen@0
|
725 }
|
jtkorhonen@17
|
726 return true;
|
jtkorhonen@0
|
727 }
|
jtkorhonen@0
|
728
|
jtkorhonen@0
|
729
|
jtkorhonen@0
|
730 bool MainWindow::isSelectedModified(QListWidget *workList)
|
jtkorhonen@0
|
731 {
|
jtkorhonen@0
|
732 QList<QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@0
|
733 if (selList.count() == 1)
|
jtkorhonen@0
|
734 {
|
jtkorhonen@0
|
735 if (selList.at(0)->text().mid(0, 1) == "M")
|
jtkorhonen@0
|
736 {
|
jtkorhonen@0
|
737 return true;
|
jtkorhonen@0
|
738 }
|
jtkorhonen@0
|
739 }
|
jtkorhonen@0
|
740 return false;
|
jtkorhonen@0
|
741 }
|
jtkorhonen@0
|
742
|
jtkorhonen@17
|
743 void MainWindow::countModifications(QListWidget *workList, int& added, int& modified, int& removed, int& notTracked,
|
jtkorhonen@17
|
744 int& selected,
|
jtkorhonen@17
|
745 int& selectedAdded, int& selectedModified, int& selectedRemoved, int& selectedNotTracked)
|
jtkorhonen@0
|
746 {
|
jtkorhonen@0
|
747 int itemCount = workList -> count();
|
jtkorhonen@0
|
748 if (itemCount > 0)
|
jtkorhonen@0
|
749 {
|
jtkorhonen@0
|
750 int A= 0;
|
jtkorhonen@0
|
751 int M=0;
|
jtkorhonen@0
|
752 int R=0;
|
jtkorhonen@5
|
753 int N=0;
|
jtkorhonen@17
|
754 int S=0;
|
jtkorhonen@17
|
755 int SA=0;
|
jtkorhonen@17
|
756 int SM=0;
|
jtkorhonen@17
|
757 int SR=0;
|
jtkorhonen@17
|
758 int SN=0;
|
jtkorhonen@17
|
759
|
jtkorhonen@0
|
760 for (int i = 0; i < workList -> count(); i++)
|
jtkorhonen@0
|
761 {
|
jtkorhonen@0
|
762 QListWidgetItem *currItem = workList -> item(i);
|
jtkorhonen@0
|
763
|
jtkorhonen@0
|
764 QString tmp = currItem->text().mid(0, 1);
|
jtkorhonen@0
|
765 if (tmp == "M")
|
jtkorhonen@0
|
766 {
|
jtkorhonen@0
|
767 M++;
|
jtkorhonen@0
|
768 }
|
jtkorhonen@0
|
769 else if (tmp == "R")
|
jtkorhonen@0
|
770 {
|
jtkorhonen@0
|
771 R++;
|
jtkorhonen@0
|
772 }
|
jtkorhonen@0
|
773 else if (tmp == "A")
|
jtkorhonen@0
|
774 {
|
jtkorhonen@0
|
775 A++;
|
jtkorhonen@0
|
776 }
|
jtkorhonen@5
|
777 else if (tmp == "?")
|
jtkorhonen@5
|
778 {
|
jtkorhonen@5
|
779 N++;
|
jtkorhonen@5
|
780 }
|
jtkorhonen@0
|
781 }
|
jtkorhonen@0
|
782
|
jtkorhonen@17
|
783 added = A;
|
jtkorhonen@17
|
784 modified = M;
|
jtkorhonen@17
|
785 removed = R;
|
jtkorhonen@17
|
786 notTracked = N;
|
jtkorhonen@17
|
787
|
jtkorhonen@17
|
788 QList <QListWidgetItem *> selList = workList -> selectedItems();
|
jtkorhonen@17
|
789
|
jtkorhonen@17
|
790 S = selList.size();
|
jtkorhonen@17
|
791 for (int i = 0; i < selList.size(); ++i)
|
jtkorhonen@17
|
792 {
|
jtkorhonen@17
|
793 QString tmp = selList.at(i) -> text();
|
jtkorhonen@17
|
794
|
jtkorhonen@17
|
795 if (tmp.mid(0,1) == "A")
|
jtkorhonen@17
|
796 {
|
jtkorhonen@17
|
797 SA++;
|
jtkorhonen@17
|
798 }
|
jtkorhonen@17
|
799 else if (tmp.mid(0,1) == "M")
|
jtkorhonen@17
|
800 {
|
jtkorhonen@17
|
801 SM++;
|
jtkorhonen@17
|
802 }
|
jtkorhonen@17
|
803 else if (tmp.mid(0,1) == "R")
|
jtkorhonen@17
|
804 {
|
jtkorhonen@17
|
805 SR++;
|
jtkorhonen@17
|
806 }
|
jtkorhonen@17
|
807 else if (tmp.mid(0,1) == "?")
|
jtkorhonen@17
|
808 {
|
jtkorhonen@17
|
809 SN++;
|
jtkorhonen@17
|
810 }
|
jtkorhonen@17
|
811 }
|
jtkorhonen@17
|
812
|
jtkorhonen@17
|
813 selected = S;
|
jtkorhonen@17
|
814 selectedAdded = SA;
|
jtkorhonen@17
|
815 selectedModified = SM;
|
jtkorhonen@17
|
816 selectedRemoved = SR;
|
jtkorhonen@17
|
817 selectedNotTracked = SN;
|
jtkorhonen@0
|
818 }
|
jtkorhonen@0
|
819 else
|
jtkorhonen@0
|
820 {
|
jtkorhonen@17
|
821 added = 0;
|
jtkorhonen@17
|
822 modified = 0;
|
jtkorhonen@17
|
823 removed = 0;
|
jtkorhonen@17
|
824 notTracked = 0;
|
jtkorhonen@17
|
825 selected = 0;
|
jtkorhonen@17
|
826 selectedAdded = 0;
|
jtkorhonen@17
|
827 selectedModified = 0;
|
jtkorhonen@17
|
828 selectedRemoved = 0;
|
jtkorhonen@17
|
829 selectedNotTracked = 0;
|
jtkorhonen@0
|
830 }
|
jtkorhonen@0
|
831 }
|
jtkorhonen@0
|
832
|
jtkorhonen@0
|
833
|
jtkorhonen@0
|
834 void MainWindow::timerEvent(QTimerEvent *)
|
jtkorhonen@0
|
835 {
|
jtkorhonen@0
|
836 bool shouldHgStat = false;
|
jtkorhonen@0
|
837
|
jtkorhonen@0
|
838 if (runningAction != ACT_NONE)
|
jtkorhonen@0
|
839 {
|
jtkorhonen@0
|
840 //We are running some hg command...
|
jtkorhonen@0
|
841 if (runner -> isProcRunning() == false)
|
jtkorhonen@0
|
842 {
|
jtkorhonen@0
|
843 //Running has just ended.
|
jtkorhonen@0
|
844 int exitCode = runner -> getExitCode();
|
jtkorhonen@0
|
845
|
jtkorhonen@0
|
846 runner -> hideProgBar();
|
jtkorhonen@0
|
847
|
jtkorhonen@0
|
848 //Clumsy...
|
jtkorhonen@0
|
849 if ((EXITOK(exitCode)) || ((exitCode == 1) && (runningAction == ACT_INCOMING)))
|
jtkorhonen@0
|
850 {
|
jtkorhonen@0
|
851 //Successful running.
|
jtkorhonen@0
|
852 switch(runningAction)
|
jtkorhonen@0
|
853 {
|
jtkorhonen@0
|
854 case ACT_STAT:
|
jtkorhonen@0
|
855 {
|
jtkorhonen@0
|
856 hgExp -> updateWorkFolderFileList(runner -> getStdOut());
|
jtkorhonen@0
|
857 }
|
jtkorhonen@0
|
858 break;
|
jtkorhonen@0
|
859
|
jtkorhonen@0
|
860 case ACT_INCOMING:
|
jtkorhonen@0
|
861 case ACT_ANNOTATE:
|
jtkorhonen@0
|
862 case ACT_RESOLVE_LIST:
|
jtkorhonen@0
|
863 case ACT_RESOLVE_MARK:
|
jtkorhonen@2
|
864 presentLongStdoutToUser(runner -> getStdOut());
|
jtkorhonen@0
|
865 shouldHgStat = true;
|
jtkorhonen@0
|
866 break;
|
jtkorhonen@0
|
867
|
jtkorhonen@0
|
868 case ACT_PULL:
|
jtkorhonen@0
|
869 QMessageBox::information(this, "pull", runner -> getStdOut());
|
jtkorhonen@0
|
870 shouldHgStat = true;
|
jtkorhonen@0
|
871 break;
|
jtkorhonen@0
|
872
|
jtkorhonen@0
|
873 case ACT_PUSH:
|
jtkorhonen@0
|
874 QMessageBox::information(this, "push", runner -> getStdOut());
|
jtkorhonen@0
|
875 shouldHgStat = true;
|
jtkorhonen@0
|
876 break;
|
jtkorhonen@0
|
877
|
jtkorhonen@0
|
878 case ACT_INIT:
|
jtkorhonen@0
|
879 enableDisableActions();
|
jtkorhonen@0
|
880 shouldHgStat = true;
|
jtkorhonen@0
|
881 break;
|
jtkorhonen@0
|
882
|
jtkorhonen@0
|
883 case ACT_CLONEFROMREMOTE:
|
jtkorhonen@0
|
884 QMessageBox::information(this, "clone", runner -> getStdOut());
|
jtkorhonen@0
|
885 enableDisableActions();
|
jtkorhonen@0
|
886 shouldHgStat = true;
|
jtkorhonen@0
|
887 break;
|
jtkorhonen@0
|
888
|
jtkorhonen@0
|
889 case ACT_LOG:
|
jtkorhonen@0
|
890 {
|
jtkorhonen@0
|
891 hgExp -> updateLocalRepoHgLogList(runner -> getStdOut());
|
jtkorhonen@0
|
892 }
|
jtkorhonen@0
|
893 break;
|
jtkorhonen@0
|
894
|
jtkorhonen@0
|
895 case ACT_PARENTS:
|
jtkorhonen@0
|
896 {
|
jtkorhonen@0
|
897 hgExp -> updateLocalRepoParentsList(runner -> getStdOut());
|
jtkorhonen@0
|
898 }
|
jtkorhonen@0
|
899 break;
|
jtkorhonen@0
|
900
|
jtkorhonen@0
|
901 case ACT_HEADS:
|
jtkorhonen@0
|
902 {
|
jtkorhonen@0
|
903 QString stdOut = runner -> getStdOut();
|
jtkorhonen@0
|
904 hgExp -> updateLocalRepoHeadsList(stdOut);
|
jtkorhonen@0
|
905 }
|
jtkorhonen@0
|
906 break;
|
jtkorhonen@0
|
907
|
jtkorhonen@0
|
908 case ACT_REMOVE:
|
jtkorhonen@0
|
909 case ACT_ADD:
|
jtkorhonen@0
|
910 case ACT_COMMIT:
|
jtkorhonen@0
|
911 case ACT_FILEDIFF:
|
jtkorhonen@0
|
912 case ACT_FOLDERDIFF:
|
jtkorhonen@0
|
913 case ACT_CHGSETDIFF:
|
jtkorhonen@0
|
914 case ACT_REVERT:
|
jtkorhonen@11
|
915 case ACT_SERVE:
|
jtkorhonen@0
|
916 shouldHgStat = true;
|
jtkorhonen@0
|
917 break;
|
jtkorhonen@0
|
918
|
jtkorhonen@0
|
919 case ACT_UPDATE:
|
jtkorhonen@0
|
920 QMessageBox::information(this, "update", runner -> getStdOut());
|
jtkorhonen@0
|
921 shouldHgStat = true;
|
jtkorhonen@0
|
922 break;
|
jtkorhonen@0
|
923
|
jtkorhonen@0
|
924 case ACT_MERGE:
|
jtkorhonen@0
|
925 QMessageBox::information(this, "merge", runner -> getStdOut());
|
jtkorhonen@0
|
926 shouldHgStat = true;
|
jtkorhonen@0
|
927 break;
|
jtkorhonen@0
|
928
|
jtkorhonen@0
|
929 default:
|
jtkorhonen@0
|
930 break;
|
jtkorhonen@0
|
931 }
|
jtkorhonen@0
|
932 }
|
jtkorhonen@0
|
933
|
jtkorhonen@0
|
934 //Typical sequence goes stat -> heads -> parents -> log
|
jtkorhonen@0
|
935 if (runningAction == ACT_STAT)
|
jtkorhonen@0
|
936 {
|
jtkorhonen@0
|
937 runningAction = ACT_NONE;
|
jtkorhonen@0
|
938 hgHeads();
|
jtkorhonen@0
|
939 }
|
jtkorhonen@0
|
940 else if (runningAction == ACT_HEADS)
|
jtkorhonen@0
|
941 {
|
jtkorhonen@0
|
942 runningAction = ACT_NONE;
|
jtkorhonen@0
|
943 hgParents();
|
jtkorhonen@0
|
944 }
|
jtkorhonen@0
|
945 else if (runningAction == ACT_PARENTS)
|
jtkorhonen@0
|
946 {
|
jtkorhonen@0
|
947 runningAction = ACT_NONE;
|
jtkorhonen@0
|
948 hgLog();
|
jtkorhonen@0
|
949 }
|
jtkorhonen@0
|
950 else
|
jtkorhonen@0
|
951 {
|
jtkorhonen@0
|
952 runningAction = ACT_NONE;
|
jtkorhonen@0
|
953 if (shouldHgStat)
|
jtkorhonen@0
|
954 {
|
jtkorhonen@0
|
955 hgStat();
|
jtkorhonen@0
|
956 }
|
jtkorhonen@0
|
957 }
|
jtkorhonen@0
|
958 }
|
jtkorhonen@0
|
959 }
|
jtkorhonen@0
|
960 else
|
jtkorhonen@0
|
961 {
|
jtkorhonen@0
|
962 enableDisableActions();
|
jtkorhonen@0
|
963 }
|
jtkorhonen@0
|
964 }
|
jtkorhonen@0
|
965
|
jtkorhonen@0
|
966 void MainWindow::connectActions()
|
jtkorhonen@0
|
967 {
|
jtkorhonen@0
|
968 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
|
jtkorhonen@0
|
969 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
jtkorhonen@0
|
970 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
jtkorhonen@0
|
971
|
jtkorhonen@0
|
972 connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgStat()));
|
jtkorhonen@0
|
973 connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgStat()));
|
jtkorhonen@0
|
974 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
|
jtkorhonen@0
|
975 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
|
jtkorhonen@0
|
976 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
|
jtkorhonen@0
|
977 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
|
jtkorhonen@0
|
978 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
|
jtkorhonen@0
|
979 connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
|
jtkorhonen@0
|
980 connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
|
jtkorhonen@0
|
981 connect(hgRevertAct, SIGNAL(triggered()), this, SLOT(hgRevert()));
|
jtkorhonen@0
|
982 connect(hgMergeAct, SIGNAL(triggered()), this, SLOT(hgMerge()));
|
jtkorhonen@0
|
983
|
jtkorhonen@0
|
984 connect(settingsAct, SIGNAL(triggered()), this, SLOT(settings()));
|
jtkorhonen@0
|
985
|
jtkorhonen@0
|
986 connect(hgInitAct, SIGNAL(triggered()), this, SLOT(hgInit()));
|
jtkorhonen@0
|
987 connect(hgCloneFromRemoteAct, SIGNAL(triggered()), this, SLOT(hgCloneFromRemote()));
|
jtkorhonen@0
|
988 connect(hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
|
jtkorhonen@0
|
989 connect(hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
|
jtkorhonen@0
|
990 connect(hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
|
jtkorhonen@0
|
991
|
jtkorhonen@0
|
992 connect(hgExp, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
|
jtkorhonen@0
|
993
|
jtkorhonen@0
|
994 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
|
jtkorhonen@0
|
995 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
|
jtkorhonen@0
|
996 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
|
jtkorhonen@0
|
997 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
|
jtkorhonen@11
|
998 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
|
jtkorhonen@0
|
999 }
|
jtkorhonen@0
|
1000
|
jtkorhonen@0
|
1001 void MainWindow::tabChanged(int currTab)
|
jtkorhonen@0
|
1002 {
|
jtkorhonen@0
|
1003 tabPage = currTab;
|
jtkorhonen@0
|
1004 }
|
jtkorhonen@0
|
1005
|
jtkorhonen@0
|
1006 void MainWindow::enableDisableActions()
|
jtkorhonen@0
|
1007 {
|
jtkorhonen@0
|
1008 QDir localRepoDir;
|
jtkorhonen@0
|
1009 QDir workFolderDir;
|
jtkorhonen@0
|
1010 bool workFolderExist;
|
jtkorhonen@0
|
1011 bool localRepoExist;
|
jtkorhonen@0
|
1012
|
jtkorhonen@0
|
1013 remoteRepoActionsEnabled = true;
|
jtkorhonen@0
|
1014 if (remoteRepoPath.isEmpty())
|
jtkorhonen@0
|
1015 {
|
jtkorhonen@0
|
1016 remoteRepoActionsEnabled = false;
|
jtkorhonen@0
|
1017 }
|
jtkorhonen@0
|
1018
|
jtkorhonen@0
|
1019 localRepoActionsEnabled = true;
|
jtkorhonen@0
|
1020 if (workFolderPath.isEmpty())
|
jtkorhonen@0
|
1021 {
|
jtkorhonen@0
|
1022 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1023 workFolderExist = false;
|
jtkorhonen@0
|
1024 }
|
jtkorhonen@0
|
1025
|
jtkorhonen@0
|
1026 if (!workFolderDir.exists(workFolderPath))
|
jtkorhonen@0
|
1027 {
|
jtkorhonen@0
|
1028 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1029 workFolderExist = false;
|
jtkorhonen@0
|
1030 }
|
jtkorhonen@0
|
1031 else
|
jtkorhonen@0
|
1032 {
|
jtkorhonen@0
|
1033 workFolderExist = true;
|
jtkorhonen@0
|
1034 }
|
jtkorhonen@0
|
1035
|
jtkorhonen@0
|
1036 if (!localRepoDir.exists(workFolderPath + getHgDirName()))
|
jtkorhonen@0
|
1037 {
|
jtkorhonen@0
|
1038 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1039 localRepoExist = false;
|
jtkorhonen@0
|
1040 }
|
jtkorhonen@0
|
1041
|
jtkorhonen@0
|
1042 hgCloneFromRemoteAct -> setEnabled(remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1043 hgIncomingAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1044 hgPullAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1045 hgPushAct -> setEnabled(remoteRepoActionsEnabled && remoteRepoActionsEnabled);
|
jtkorhonen@0
|
1046
|
jtkorhonen@0
|
1047 if (tabPage != WORKTAB)
|
jtkorhonen@0
|
1048 {
|
jtkorhonen@0
|
1049 localRepoActionsEnabled = false;
|
jtkorhonen@0
|
1050 }
|
jtkorhonen@0
|
1051
|
jtkorhonen@0
|
1052 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
|
jtkorhonen@0
|
1053 hgStatAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1054 hgFileDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1055 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1056 hgRevertAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1057 hgAddAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1058 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1059 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1060 hgCommitAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1061 hgMergeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1062 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1063 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@2
|
1064 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@11
|
1065 hgServeAct -> setEnabled(localRepoActionsEnabled);
|
jtkorhonen@0
|
1066
|
jtkorhonen@0
|
1067 hgExp -> enableDisableOtherTabs();
|
jtkorhonen@0
|
1068
|
jtkorhonen@17
|
1069 int added, modified, removed, notTracked, selected, selectedAdded, selectedModified, selectedRemoved, selectedNotTracked;
|
jtkorhonen@17
|
1070
|
jtkorhonen@17
|
1071 countModifications(hgExp -> workFolderFileList,
|
jtkorhonen@17
|
1072 added, modified, removed, notTracked,
|
jtkorhonen@17
|
1073 selected,
|
jtkorhonen@17
|
1074 selectedAdded, selectedModified, selectedRemoved, selectedNotTracked);
|
jtkorhonen@0
|
1075
|
jtkorhonen@0
|
1076 if (tabPage == WORKTAB)
|
jtkorhonen@0
|
1077 {
|
jtkorhonen@0
|
1078 //Enable / disable actions according to workFolderFileList selections / currentSelection / count
|
jtkorhonen@0
|
1079 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1080 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1081
|
jtkorhonen@0
|
1082 if (localRepoActionsEnabled)
|
jtkorhonen@0
|
1083 {
|
jtkorhonen@17
|
1084 if ((added == 0) && (modified == 0) && (removed == 0))
|
jtkorhonen@0
|
1085 {
|
jtkorhonen@0
|
1086 hgCommitAct -> setEnabled(false);
|
jtkorhonen@0
|
1087 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1088 }
|
jtkorhonen@17
|
1089 else if (selected != 0)
|
jtkorhonen@17
|
1090 {
|
jtkorhonen@17
|
1091 if (selectedNotTracked != 0)
|
jtkorhonen@17
|
1092 {
|
jtkorhonen@17
|
1093 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1094 }
|
jtkorhonen@17
|
1095 else if ((selectedAdded == 0) && (selectedModified == 0) && (selectedRemoved == 0))
|
jtkorhonen@17
|
1096 {
|
jtkorhonen@17
|
1097 hgCommitAct -> setEnabled(false);
|
jtkorhonen@17
|
1098 }
|
jtkorhonen@17
|
1099 }
|
jtkorhonen@0
|
1100
|
jtkorhonen@17
|
1101 if (modified == 0)
|
jtkorhonen@0
|
1102 {
|
jtkorhonen@0
|
1103 hgFolderDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1104 }
|
jtkorhonen@0
|
1105
|
jtkorhonen@0
|
1106 if (!isSelectedModified(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1107 {
|
jtkorhonen@0
|
1108 hgFileDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1109 hgRevertAct -> setEnabled(false);
|
jtkorhonen@0
|
1110 }
|
jtkorhonen@0
|
1111
|
jtkorhonen@5
|
1112 //JK 14.5.2010: Fixed confusing add button. Now this is simple: If we have something to add (any non-tracked files), add is enabled.
|
jtkorhonen@17
|
1113 if (notTracked == 0)
|
jtkorhonen@0
|
1114 {
|
jtkorhonen@0
|
1115 hgAddAct -> setEnabled(false);
|
jtkorhonen@0
|
1116 }
|
jtkorhonen@0
|
1117
|
jtkorhonen@6
|
1118 if (!isSelectedDeletable(hgExp -> workFolderFileList))
|
jtkorhonen@0
|
1119 {
|
jtkorhonen@0
|
1120 hgRemoveAct -> setEnabled(false);
|
jtkorhonen@0
|
1121 }
|
jtkorhonen@0
|
1122
|
jtkorhonen@2
|
1123 hgResolveListAct -> setEnabled(true);
|
jtkorhonen@2
|
1124
|
jtkorhonen@5
|
1125 if (hgExp -> localRepoHeadsList->count() < 2)
|
jtkorhonen@0
|
1126 {
|
jtkorhonen@0
|
1127 hgMergeAct -> setEnabled(false);
|
jtkorhonen@0
|
1128 }
|
jtkorhonen@0
|
1129
|
jtkorhonen@2
|
1130 QString currentFile = hgExp -> getCurrentFileListLine();
|
jtkorhonen@2
|
1131 if (!currentFile.isEmpty())
|
jtkorhonen@2
|
1132 {
|
jtkorhonen@2
|
1133 hgAnnotateAct -> setEnabled(true);
|
jtkorhonen@2
|
1134 hgResolveMarkAct -> setEnabled(true);
|
jtkorhonen@2
|
1135 }
|
jtkorhonen@2
|
1136 else
|
jtkorhonen@2
|
1137 {
|
jtkorhonen@2
|
1138 hgAnnotateAct -> setEnabled(false);
|
jtkorhonen@2
|
1139 hgResolveMarkAct -> setEnabled(false);
|
jtkorhonen@2
|
1140 }
|
jtkorhonen@0
|
1141 }
|
jtkorhonen@0
|
1142 }
|
jtkorhonen@0
|
1143 else
|
jtkorhonen@0
|
1144 {
|
jtkorhonen@0
|
1145 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
1146 QList <QListWidgetItem *> historySelList = hgExp -> localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
1147
|
jtkorhonen@0
|
1148 if ((historySelList.count() == 2) || (headSelList.count() == 2))
|
jtkorhonen@0
|
1149 {
|
jtkorhonen@0
|
1150 hgChgSetDiffAct -> setEnabled(true);
|
jtkorhonen@0
|
1151 }
|
jtkorhonen@0
|
1152 else
|
jtkorhonen@0
|
1153 {
|
jtkorhonen@0
|
1154 hgChgSetDiffAct -> setEnabled(false);
|
jtkorhonen@0
|
1155 }
|
jtkorhonen@0
|
1156
|
jtkorhonen@17
|
1157 if ((added == 0) && (modified == 0) && (removed == 0))
|
jtkorhonen@0
|
1158 {
|
jtkorhonen@0
|
1159 if (historySelList.count() == 1)
|
jtkorhonen@0
|
1160 {
|
jtkorhonen@0
|
1161 hgUpdateToRevAct -> setEnabled(true);
|
jtkorhonen@0
|
1162 }
|
jtkorhonen@0
|
1163 else
|
jtkorhonen@0
|
1164 {
|
jtkorhonen@0
|
1165 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1166 }
|
jtkorhonen@0
|
1167 }
|
jtkorhonen@0
|
1168 else
|
jtkorhonen@0
|
1169 {
|
jtkorhonen@0
|
1170 hgUpdateToRevAct -> setEnabled(false);
|
jtkorhonen@0
|
1171 }
|
jtkorhonen@0
|
1172 }
|
jtkorhonen@0
|
1173 }
|
jtkorhonen@0
|
1174
|
jtkorhonen@0
|
1175 void MainWindow::createActions()
|
jtkorhonen@0
|
1176 {
|
jtkorhonen@0
|
1177 //File actions
|
jtkorhonen@0
|
1178 hgInitAct = new QAction(tr("Init local repository"), this);
|
jtkorhonen@0
|
1179 hgInitAct->setStatusTip(tr("Create an empty local repository in selected folder"));
|
jtkorhonen@0
|
1180
|
jtkorhonen@0
|
1181 hgCloneFromRemoteAct = new QAction(tr("Clone from remote"), this);
|
jtkorhonen@0
|
1182 hgCloneFromRemoteAct->setStatusTip(tr("Clone from remote repository into local repository in selected folder"));
|
jtkorhonen@0
|
1183
|
jtkorhonen@0
|
1184 settingsAct = new QAction(QIcon(":/images/settings.png"), tr("Settings..."), this);
|
jtkorhonen@0
|
1185 settingsAct -> setStatusTip(tr("View and change application settings"));
|
jtkorhonen@0
|
1186 settingsAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1187
|
jtkorhonen@0
|
1188 exitAct = new QAction(QIcon(":/images/exit.png"), tr("Exit"), this);
|
jtkorhonen@0
|
1189 exitAct->setShortcuts(QKeySequence::Quit);
|
jtkorhonen@0
|
1190 exitAct->setStatusTip(tr("Exit application"));
|
jtkorhonen@0
|
1191 exitAct -> setIconVisibleInMenu(true);
|
jtkorhonen@0
|
1192
|
jtkorhonen@0
|
1193 //Repository actions
|
jtkorhonen@0
|
1194 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("View incoming changesets"), this);
|
jtkorhonen@0
|
1195 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
|
jtkorhonen@0
|
1196
|
jtkorhonen@0
|
1197 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull from remote"), this);
|
jtkorhonen@0
|
1198 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
|
jtkorhonen@0
|
1199
|
jtkorhonen@0
|
1200 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push to remote"), this);
|
jtkorhonen@0
|
1201 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
|
jtkorhonen@0
|
1202
|
jtkorhonen@0
|
1203 //Workfolder actions
|
jtkorhonen@0
|
1204 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh status"), this);
|
jtkorhonen@20
|
1205 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
|
jtkorhonen@0
|
1206
|
jtkorhonen@0
|
1207 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("View filediff"), this);
|
jtkorhonen@0
|
1208 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
|
jtkorhonen@0
|
1209
|
jtkorhonen@0
|
1210 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
|
jtkorhonen@0
|
1211 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
|
jtkorhonen@0
|
1212
|
jtkorhonen@0
|
1213 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
|
jtkorhonen@0
|
1214 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
|
jtkorhonen@0
|
1215
|
jtkorhonen@0
|
1216 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this);
|
jtkorhonen@0
|
1217 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
|
jtkorhonen@0
|
1218
|
jtkorhonen@0
|
1219 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this);
|
jtkorhonen@17
|
1220 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)"));
|
jtkorhonen@0
|
1221
|
jtkorhonen@0
|
1222 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this);
|
jtkorhonen@0
|
1223 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
|
jtkorhonen@0
|
1224
|
jtkorhonen@0
|
1225 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this);
|
jtkorhonen@0
|
1226 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
|
jtkorhonen@0
|
1227
|
jtkorhonen@11
|
1228 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save change(s)"), this);
|
jtkorhonen@20
|
1229 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository"));
|
jtkorhonen@0
|
1230
|
jtkorhonen@0
|
1231 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
|
jtkorhonen@0
|
1232 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
|
jtkorhonen@0
|
1233
|
jtkorhonen@0
|
1234 //Advanced actions
|
jtkorhonen@0
|
1235 hgUpdateToRevAct = new QAction(tr("Update to revision"), this);
|
jtkorhonen@0
|
1236 hgUpdateToRevAct -> setStatusTip(tr("Update working folder to version selected from history list"));
|
jtkorhonen@0
|
1237
|
jtkorhonen@0
|
1238 hgAnnotateAct = new QAction(tr("Annotate"), this);
|
jtkorhonen@0
|
1239 hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
|
jtkorhonen@0
|
1240
|
jtkorhonen@0
|
1241 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
|
jtkorhonen@0
|
1242 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
|
jtkorhonen@0
|
1243
|
jtkorhonen@0
|
1244 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
|
jtkorhonen@0
|
1245 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
|
jtkorhonen@0
|
1246
|
jtkorhonen@11
|
1247 hgServeAct = new QAction(tr("Serve (via http)"), this);
|
jtkorhonen@11
|
1248 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
|
jtkorhonen@11
|
1249
|
jtkorhonen@0
|
1250 //Help actions
|
jtkorhonen@0
|
1251 aboutAct = new QAction(tr("About"), this);
|
jtkorhonen@0
|
1252 aboutAct->setStatusTip(tr("Show the application's About box"));
|
jtkorhonen@0
|
1253
|
jtkorhonen@0
|
1254 aboutQtAct = new QAction(tr("About Qt"), this);
|
jtkorhonen@0
|
1255 aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
|
jtkorhonen@0
|
1256 }
|
jtkorhonen@0
|
1257
|
jtkorhonen@0
|
1258 void MainWindow::createMenus()
|
jtkorhonen@0
|
1259 {
|
jtkorhonen@0
|
1260 fileMenu = menuBar()->addMenu(tr("File"));
|
jtkorhonen@0
|
1261 fileMenu -> addAction(hgInitAct);
|
jtkorhonen@0
|
1262 fileMenu -> addAction(hgCloneFromRemoteAct);
|
jtkorhonen@0
|
1263 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1264 fileMenu -> addAction(settingsAct);
|
jtkorhonen@0
|
1265 fileMenu -> addSeparator();
|
jtkorhonen@0
|
1266 fileMenu -> addAction(exitAct);
|
jtkorhonen@0
|
1267
|
jtkorhonen@0
|
1268 advancedMenu = menuBar()->addMenu(tr("Advanced"));
|
jtkorhonen@0
|
1269 advancedMenu -> addAction(hgUpdateToRevAct);
|
jtkorhonen@0
|
1270 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1271 advancedMenu -> addAction(hgAnnotateAct);
|
jtkorhonen@0
|
1272 advancedMenu -> addSeparator();
|
jtkorhonen@0
|
1273 advancedMenu -> addAction(hgResolveListAct);
|
jtkorhonen@0
|
1274 advancedMenu -> addAction(hgResolveMarkAct);
|
jtkorhonen@11
|
1275 advancedMenu -> addSeparator();
|
jtkorhonen@11
|
1276 advancedMenu -> addAction(hgServeAct);
|
jtkorhonen@0
|
1277
|
jtkorhonen@0
|
1278 helpMenu = menuBar()->addMenu(tr("Help"));
|
jtkorhonen@0
|
1279 helpMenu->addAction(aboutAct);
|
jtkorhonen@0
|
1280 helpMenu->addAction(aboutQtAct);
|
jtkorhonen@0
|
1281 }
|
jtkorhonen@0
|
1282
|
jtkorhonen@0
|
1283 void MainWindow::createToolBars()
|
jtkorhonen@0
|
1284 {
|
jtkorhonen@0
|
1285 fileToolBar = addToolBar(tr("File"));
|
jtkorhonen@0
|
1286 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1287 fileToolBar -> addAction(settingsAct);
|
jtkorhonen@0
|
1288 fileToolBar -> addAction(exitAct);
|
jtkorhonen@0
|
1289 fileToolBar -> addSeparator();
|
jtkorhonen@0
|
1290 fileToolBar -> addAction(hgChgSetDiffAct);
|
jtkorhonen@0
|
1291 fileToolBar -> setMovable(false);
|
jtkorhonen@0
|
1292
|
jtkorhonen@0
|
1293 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
|
jtkorhonen@0
|
1294 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1295 repoToolBar->addAction(hgIncomingAct);
|
jtkorhonen@0
|
1296 repoToolBar->addAction(hgPullAct);
|
jtkorhonen@0
|
1297 repoToolBar->addAction(hgPushAct);
|
jtkorhonen@0
|
1298 repoToolBar -> setMovable(false);
|
jtkorhonen@0
|
1299
|
jtkorhonen@0
|
1300 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
|
jtkorhonen@0
|
1301 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
|
jtkorhonen@0
|
1302 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
|
jtkorhonen@0
|
1303 workFolderToolBar->addAction(hgStatAct);
|
jtkorhonen@0
|
1304 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1305 workFolderToolBar->addAction(hgFileDiffAct);
|
jtkorhonen@0
|
1306 workFolderToolBar->addAction(hgFolderDiffAct);
|
jtkorhonen@0
|
1307 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1308 workFolderToolBar->addAction(hgRevertAct);
|
jtkorhonen@0
|
1309 workFolderToolBar->addAction(hgUpdateAct);
|
jtkorhonen@0
|
1310 workFolderToolBar->addAction(hgCommitAct);
|
jtkorhonen@0
|
1311 workFolderToolBar->addAction(hgMergeAct);
|
jtkorhonen@0
|
1312 workFolderToolBar->addSeparator();
|
jtkorhonen@0
|
1313 workFolderToolBar->addAction(hgAddAct);
|
jtkorhonen@0
|
1314 workFolderToolBar->addAction(hgRemoveAct);
|
jtkorhonen@0
|
1315 workFolderToolBar -> setMovable(false);
|
jtkorhonen@0
|
1316
|
jtkorhonen@0
|
1317 }
|
jtkorhonen@0
|
1318
|
jtkorhonen@0
|
1319
|
jtkorhonen@0
|
1320 void MainWindow::createStatusBar()
|
jtkorhonen@0
|
1321 {
|
jtkorhonen@0
|
1322 statusBar()->showMessage(tr("Ready"));
|
jtkorhonen@0
|
1323 }
|
jtkorhonen@0
|
1324
|
jtkorhonen@0
|
1325 void MainWindow::readSettings()
|
jtkorhonen@0
|
1326 {
|
jtkorhonen@0
|
1327 QDir workFolder;
|
jtkorhonen@0
|
1328
|
jtkorhonen@0
|
1329 QSettings settings("hgexplorer", "hgexplorer");
|
jtkorhonen@0
|
1330
|
jtkorhonen@0
|
1331 remoteRepoPath = settings.value("remoterepopath", "").toString() ;
|
jtkorhonen@0
|
1332 workFolderPath = settings.value("workfolderpath", "").toString();
|
jtkorhonen@0
|
1333 if (!workFolder.exists(workFolderPath))
|
jtkorhonen@0
|
1334 {
|
jtkorhonen@0
|
1335 workFolderPath = "";
|
jtkorhonen@0
|
1336 }
|
jtkorhonen@0
|
1337
|
jtkorhonen@0
|
1338 userInfo = settings.value("userinfo", "").toString();
|
jtkorhonen@0
|
1339
|
jtkorhonen@0
|
1340 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
|
jtkorhonen@0
|
1341 QSize size = settings.value("size", QSize(400, 400)).toSize();
|
jtkorhonen@0
|
1342 firstStart = settings.value("firststart", QVariant(true)).toBool();
|
jtkorhonen@0
|
1343
|
jtkorhonen@0
|
1344 initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt();
|
jtkorhonen@0
|
1345 resize(size);
|
jtkorhonen@0
|
1346 move(pos);
|
jtkorhonen@0
|
1347 }
|
jtkorhonen@0
|
1348
|
jtkorhonen@17
|
1349
|
jtkorhonen@0
|
1350 void MainWindow::writeSettings()
|
jtkorhonen@0
|
1351 {
|
jtkorhonen@0
|
1352 QSettings settings("hgexplorer", "hgexplorer");
|
jtkorhonen@0
|
1353 settings.setValue("pos", pos());
|
jtkorhonen@0
|
1354 settings.setValue("size", size());
|
jtkorhonen@0
|
1355 settings.setValue("remoterepopath", remoteRepoPath);
|
jtkorhonen@0
|
1356 settings.setValue("workfolderpath", workFolderPath);
|
jtkorhonen@0
|
1357 settings.setValue("userinfo", userInfo);
|
jtkorhonen@0
|
1358 settings.setValue("firststart", firstStart);
|
jtkorhonen@0
|
1359 settings.setValue("viewFileTypes", hgExp -> getFileTypesBits());
|
jtkorhonen@0
|
1360 }
|
jtkorhonen@0
|
1361
|
jtkorhonen@0
|
1362
|
jtkorhonen@0
|
1363
|
jtkorhonen@0
|
1364
|