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