jtkorhonen@30
|
1 /****************************************************************************
|
jtkorhonen@30
|
2 ** Copyright (C) Jari Korhonen, 2010 (under lgpl)
|
jtkorhonen@30
|
3 ****************************************************************************/
|
jtkorhonen@0
|
4
|
jtkorhonen@0
|
5 #include "hgexpwidget.h"
|
jtkorhonen@0
|
6 #include "common.h"
|
Chris@43
|
7 #include "logparser.h"
|
Chris@43
|
8 #include "changeset.h"
|
Chris@43
|
9 #include "changesetitem.h"
|
Chris@44
|
10 #include "grapher.h"
|
cannam@45
|
11 #include "panner.h"
|
cannam@45
|
12 #include "panned.h"
|
Chris@44
|
13
|
Chris@50
|
14 #include <QClipboard>
|
Chris@50
|
15 #include <QContextMenuEvent>
|
Chris@50
|
16 #include <QApplication>
|
Chris@50
|
17
|
Chris@44
|
18 #include <iostream>
|
jtkorhonen@0
|
19
|
jtkorhonen@0
|
20 #define REMOTE_REPO_STR "Remote repository: "
|
jtkorhonen@0
|
21 #define LOCAL_REPO_STR "Local repository: "
|
jtkorhonen@0
|
22 #define WORKFOLDER_STR "Working folder: "
|
jtkorhonen@0
|
23
|
jtkorhonen@0
|
24
|
jtkorhonen@0
|
25 const char hgStatViewOptions[NUM_STAT_FILE_TYPES] = {'m','a','r','d','u','c','i'};
|
jtkorhonen@0
|
26
|
jtkorhonen@0
|
27 const char *statFilesStr[NUM_STAT_FILE_TYPES] = { "M: Modified",
|
jtkorhonen@0
|
28 "A: To be added on next commit",
|
jtkorhonen@0
|
29 "R: To be removed on next commit",
|
jtkorhonen@0
|
30 "!: Tracked, locally deleted",
|
jtkorhonen@0
|
31 "?: Unknown, not yet tracked",
|
jtkorhonen@0
|
32 "C: Clean (not changed)",
|
jtkorhonen@0
|
33 "I: Ignored (via .hgignore file)"};
|
jtkorhonen@0
|
34
|
jtkorhonen@0
|
35
|
jtkorhonen@0
|
36 HgExpWidget::HgExpWidget(QWidget *parent, QString remoteRepo, QString workFolderPath, unsigned char viewFileTypesBits): QTabWidget(parent)
|
jtkorhonen@0
|
37 {
|
jtkorhonen@0
|
38 //Work page
|
jtkorhonen@0
|
39 //Work page
|
jtkorhonen@0
|
40 //Work page
|
jtkorhonen@0
|
41
|
jtkorhonen@0
|
42 //Remote repo
|
jtkorhonen@0
|
43 grpRemoteRepo = new QGroupBox(tr(REMOTE_REPO_STR) + remoteRepo);
|
jtkorhonen@0
|
44 grpRemoteRepo -> setMinimumHeight(24);
|
jtkorhonen@0
|
45
|
jtkorhonen@0
|
46 //Local Repo
|
jtkorhonen@0
|
47 grpLocalRepo = new QGroupBox(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName());
|
jtkorhonen@0
|
48 parentsLabel = new QLabel(tr("Working folder parent(s):"));
|
jtkorhonen@0
|
49 localRepoHgParentsList = new QListWidget;
|
jtkorhonen@0
|
50 localRepoHgParentsList -> setSelectionMode(QAbstractItemView::NoSelection);
|
jtkorhonen@0
|
51 parentsLayout = new QVBoxLayout;
|
jtkorhonen@0
|
52 parentsLayout -> addWidget(parentsLabel);
|
jtkorhonen@0
|
53 parentsLayout -> addWidget(localRepoHgParentsList);
|
jtkorhonen@0
|
54 grpLocalRepo -> setLayout(parentsLayout);
|
jtkorhonen@32
|
55 copyCommentAct = new QAction("Copy comment", localRepoHgParentsList);
|
jtkorhonen@32
|
56 userListMenu = new QMenu(localRepoHgParentsList);
|
jtkorhonen@32
|
57 userListMenu -> addAction(copyCommentAct);
|
jtkorhonen@32
|
58 connect(copyCommentAct, SIGNAL(triggered()), this, SLOT(copyComment()));
|
jtkorhonen@0
|
59
|
jtkorhonen@0
|
60 //Workfolder
|
jtkorhonen@0
|
61 grpWorkFolder = new QGroupBox(tr(WORKFOLDER_STR) + workFolderPath);
|
jtkorhonen@0
|
62 workFolderLayout = new QHBoxLayout;
|
jtkorhonen@0
|
63 workFolderFileList = new QListWidget;
|
jtkorhonen@19
|
64 workFolderFileList -> setSelectionMode(QAbstractItemView::ExtendedSelection);
|
jtkorhonen@0
|
65 grpViewFileTypes = new QGroupBox;
|
jtkorhonen@0
|
66 fileTypesLayout = new QVBoxLayout;
|
jtkorhonen@0
|
67
|
jtkorhonen@0
|
68 for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
|
jtkorhonen@0
|
69 {
|
jtkorhonen@0
|
70 chkViewFileTypes[i] = new QCheckBox(statFilesStr[i]);
|
jtkorhonen@0
|
71 if ((1U << i) & viewFileTypesBits)
|
jtkorhonen@0
|
72 {
|
jtkorhonen@0
|
73 chkViewFileTypes[i]->setChecked(true);
|
jtkorhonen@0
|
74 }
|
jtkorhonen@0
|
75 else
|
jtkorhonen@0
|
76 {
|
jtkorhonen@0
|
77 chkViewFileTypes[i]->setChecked(false);
|
jtkorhonen@0
|
78 }
|
jtkorhonen@0
|
79 connect(chkViewFileTypes[i], SIGNAL(stateChanged(int)), this, SIGNAL(workFolderViewTypesChanged()));
|
jtkorhonen@0
|
80 fileTypesLayout -> addWidget(chkViewFileTypes[i]);
|
jtkorhonen@0
|
81 }
|
jtkorhonen@0
|
82
|
jtkorhonen@0
|
83 grpViewFileTypes -> setLayout(fileTypesLayout);
|
jtkorhonen@0
|
84 workFolderLayout->addWidget(workFolderFileList, 3);
|
jtkorhonen@0
|
85 workFolderLayout->addWidget(grpViewFileTypes, 1);
|
jtkorhonen@0
|
86 grpWorkFolder -> setLayout(workFolderLayout);
|
jtkorhonen@0
|
87
|
jtkorhonen@0
|
88 workPageWidget = new QWidget;
|
jtkorhonen@0
|
89 mainLayout = new QVBoxLayout(workPageWidget);
|
jtkorhonen@0
|
90 mainLayout -> addWidget(grpRemoteRepo, 1);
|
jtkorhonen@0
|
91 mainLayout -> addWidget(grpLocalRepo, 8);
|
jtkorhonen@0
|
92 mainLayout -> addWidget(grpWorkFolder, 12);
|
jtkorhonen@0
|
93 addTab(workPageWidget, tr("Work"));
|
jtkorhonen@0
|
94
|
Chris@43
|
95 // History graph page
|
cannam@45
|
96 historyGraphPageWidget = new QWidget;
|
cannam@45
|
97 Panned *panned = new Panned;
|
cannam@45
|
98 Panner *panner = new Panner;
|
cannam@45
|
99 historyGraphWidget = panned;
|
cannam@45
|
100 historyGraphPanner = panner;
|
cannam@45
|
101 QGridLayout *layout = new QGridLayout;
|
cannam@45
|
102 layout->addWidget(historyGraphWidget, 0, 0);
|
cannam@45
|
103 layout->addWidget(historyGraphPanner, 0, 1);
|
cannam@45
|
104 panner->setMaximumWidth(80);
|
cannam@45
|
105 panner->connectToPanned(panned);
|
cannam@45
|
106 historyGraphPageWidget->setLayout(layout);
|
Chris@43
|
107 addTab(historyGraphPageWidget, tr("History (graph)"));
|
Chris@43
|
108
|
Chris@43
|
109
|
jtkorhonen@0
|
110 //History page
|
jtkorhonen@0
|
111 //History page
|
jtkorhonen@0
|
112 //History page
|
jtkorhonen@0
|
113 historyPageWidget = new QWidget;
|
jtkorhonen@0
|
114 localRepoHgLogList = new QListWidget;
|
jtkorhonen@0
|
115 localRepoHgLogList->setFont(QFont("Courier New"));
|
jtkorhonen@0
|
116 localRepoHgLogList -> setSelectionMode(QAbstractItemView::ExtendedSelection);
|
jtkorhonen@0
|
117
|
jtkorhonen@0
|
118 historyLayout = new QVBoxLayout(historyPageWidget);
|
jtkorhonen@0
|
119 historyLayout->addWidget(localRepoHgLogList);
|
jtkorhonen@0
|
120 addTab(historyPageWidget, tr("History (log)"));
|
jtkorhonen@0
|
121
|
jtkorhonen@0
|
122 //Heads page
|
jtkorhonen@0
|
123 //Heads page
|
jtkorhonen@0
|
124 //Heads page
|
jtkorhonen@0
|
125 headsPageWidget = new QWidget;
|
jtkorhonen@0
|
126 localRepoHeadsList = new QListWidget;
|
jtkorhonen@0
|
127 localRepoHeadsList -> setSelectionMode(QAbstractItemView::ExtendedSelection);
|
jtkorhonen@0
|
128
|
jtkorhonen@0
|
129 headsLayout = new QVBoxLayout(headsPageWidget);
|
jtkorhonen@0
|
130 headsLayout->addWidget(localRepoHeadsList);
|
jtkorhonen@0
|
131 addTab(headsPageWidget, tr("Heads"));
|
jtkorhonen@0
|
132
|
jtkorhonen@0
|
133 //Initially, only work page is active
|
jtkorhonen@0
|
134 setTabEnabled(HEADSTAB, false);
|
jtkorhonen@0
|
135 setTabEnabled(HISTORYTAB, false);
|
jtkorhonen@0
|
136 }
|
jtkorhonen@0
|
137
|
jtkorhonen@32
|
138 void HgExpWidget::contextMenuEvent(QContextMenuEvent * event)
|
jtkorhonen@32
|
139 {
|
jtkorhonen@32
|
140 if (copyCommentAct -> isEnabled())
|
jtkorhonen@32
|
141 {
|
jtkorhonen@32
|
142 QPoint topL;
|
jtkorhonen@32
|
143 QPoint bottomR;
|
jtkorhonen@32
|
144
|
jtkorhonen@32
|
145 topL = localRepoHgParentsList->
|
jtkorhonen@32
|
146 mapToGlobal(QPoint(0, 0));
|
jtkorhonen@32
|
147 bottomR = localRepoHgParentsList->
|
jtkorhonen@32
|
148 mapToGlobal(QPoint(localRepoHgParentsList -> width(), localRepoHgParentsList -> height()));
|
jtkorhonen@32
|
149
|
jtkorhonen@32
|
150 if ((event -> globalPos().x() > topL.x()) && (event -> globalPos().x() < bottomR.x()))
|
jtkorhonen@32
|
151 {
|
jtkorhonen@32
|
152 if ((event -> globalPos().y() > topL.y()) && (event -> globalPos().y() < bottomR.y()))
|
jtkorhonen@32
|
153 {
|
jtkorhonen@32
|
154 userListMenu->exec(event -> globalPos());
|
jtkorhonen@32
|
155 }
|
jtkorhonen@32
|
156 }
|
jtkorhonen@32
|
157 }
|
jtkorhonen@32
|
158 }
|
jtkorhonen@32
|
159
|
jtkorhonen@32
|
160 void HgExpWidget::copyComment()
|
jtkorhonen@32
|
161 {
|
jtkorhonen@32
|
162 if (localRepoHgParentsList -> count() >= 1)
|
jtkorhonen@32
|
163 {
|
jtkorhonen@32
|
164 QListWidgetItem *it = localRepoHgParentsList -> item(0);
|
jtkorhonen@32
|
165 QString tmp = it -> text();
|
jtkorhonen@32
|
166 int ind = tmp.indexOf("summary:");
|
jtkorhonen@32
|
167 if (ind != -1)
|
jtkorhonen@32
|
168 {
|
jtkorhonen@32
|
169 QString comment;
|
jtkorhonen@32
|
170 ind += 11; //jump over word "summary:"
|
jtkorhonen@32
|
171
|
jtkorhonen@32
|
172 comment = tmp.mid(ind);
|
jtkorhonen@32
|
173
|
jtkorhonen@32
|
174 QClipboard *clipboard = QApplication::clipboard();
|
jtkorhonen@32
|
175 clipboard->setText(comment);
|
jtkorhonen@32
|
176 }
|
jtkorhonen@32
|
177 }
|
jtkorhonen@32
|
178 }
|
jtkorhonen@32
|
179
|
jtkorhonen@32
|
180
|
jtkorhonen@0
|
181
|
jtkorhonen@0
|
182 QString HgExpWidget::getStatFlags()
|
jtkorhonen@0
|
183 {
|
jtkorhonen@0
|
184 QString ret;
|
jtkorhonen@0
|
185
|
jtkorhonen@0
|
186 for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
|
jtkorhonen@0
|
187 {
|
jtkorhonen@0
|
188 if (Qt::Checked == chkViewFileTypes[i]->checkState())
|
jtkorhonen@0
|
189 {
|
jtkorhonen@0
|
190 ret += hgStatViewOptions[i];
|
jtkorhonen@0
|
191 }
|
jtkorhonen@0
|
192 }
|
jtkorhonen@0
|
193
|
jtkorhonen@0
|
194 return ret;
|
jtkorhonen@0
|
195 }
|
jtkorhonen@0
|
196
|
jtkorhonen@0
|
197
|
jtkorhonen@0
|
198 unsigned char HgExpWidget::getFileTypesBits()
|
jtkorhonen@0
|
199 {
|
jtkorhonen@0
|
200 unsigned char ret;
|
jtkorhonen@0
|
201
|
jtkorhonen@0
|
202 ret = 0;
|
jtkorhonen@0
|
203
|
jtkorhonen@0
|
204 for(int i = 0; i < NUM_STAT_FILE_TYPES; i++)
|
jtkorhonen@0
|
205 {
|
jtkorhonen@0
|
206 if (Qt::Checked == chkViewFileTypes[i]->checkState())
|
jtkorhonen@0
|
207 {
|
jtkorhonen@0
|
208 ret |= (1U << i);
|
jtkorhonen@0
|
209 }
|
jtkorhonen@0
|
210 }
|
jtkorhonen@0
|
211
|
jtkorhonen@0
|
212 return ret;
|
jtkorhonen@0
|
213 }
|
jtkorhonen@0
|
214
|
jtkorhonen@0
|
215
|
jtkorhonen@0
|
216 void HgExpWidget::updateWorkFolderFileList(QString fileList)
|
jtkorhonen@0
|
217 {
|
jtkorhonen@0
|
218 workFolderFileList-> clear();
|
jtkorhonen@0
|
219 workFolderFileList -> addItems(fileList.split("\n"));
|
jtkorhonen@0
|
220 }
|
jtkorhonen@0
|
221
|
jtkorhonen@0
|
222 void HgExpWidget::updateLocalRepoHeadsList(QString headList)
|
jtkorhonen@0
|
223 {
|
jtkorhonen@0
|
224 localRepoHeadsList-> clear();
|
jtkorhonen@0
|
225 localRepoHeadsList -> addItems(splitChangeSets(headList));
|
jtkorhonen@0
|
226
|
jtkorhonen@0
|
227 //heads list is interesting only when we have 2 or more
|
jtkorhonen@0
|
228 if (localRepoHeadsList-> count() < 2)
|
jtkorhonen@0
|
229 {
|
jtkorhonen@0
|
230 setTabEnabled(HEADSTAB, false);
|
jtkorhonen@0
|
231 }
|
jtkorhonen@0
|
232 else
|
jtkorhonen@0
|
233 {
|
jtkorhonen@0
|
234 setTabEnabled(HEADSTAB, true);
|
jtkorhonen@0
|
235 }
|
jtkorhonen@0
|
236 }
|
jtkorhonen@0
|
237
|
jtkorhonen@0
|
238
|
jtkorhonen@0
|
239 void HgExpWidget::clearLists()
|
jtkorhonen@0
|
240 {
|
jtkorhonen@0
|
241 localRepoHeadsList-> clear();
|
jtkorhonen@0
|
242 localRepoHgParentsList-> clear();
|
jtkorhonen@0
|
243 workFolderFileList-> clear();
|
jtkorhonen@0
|
244 localRepoHgLogList -> clear();
|
jtkorhonen@0
|
245 }
|
jtkorhonen@0
|
246
|
jtkorhonen@0
|
247 void HgExpWidget::updateLocalRepoParentsList(QString parentsList)
|
jtkorhonen@0
|
248 {
|
jtkorhonen@0
|
249 localRepoHgParentsList-> clear();
|
jtkorhonen@0
|
250 localRepoHgParentsList -> addItems(splitChangeSets(parentsList));
|
jtkorhonen@0
|
251 }
|
jtkorhonen@0
|
252
|
jtkorhonen@0
|
253 void HgExpWidget::updateLocalRepoHgLogList(QString hgLogList)
|
jtkorhonen@0
|
254 {
|
jtkorhonen@0
|
255 localRepoHgLogList -> clear();
|
jtkorhonen@0
|
256 localRepoHgLogList -> addItems(splitChangeSets(hgLogList));
|
jtkorhonen@0
|
257
|
Chris@43
|
258 //!!!
|
cannam@45
|
259 Panned *panned = static_cast<Panned *>(historyGraphWidget);
|
cannam@45
|
260 Panner *panner = static_cast<Panner *>(historyGraphPanner);
|
Chris@43
|
261 QGraphicsScene *scene = new QGraphicsScene();
|
Chris@43
|
262 Changesets csets = parseChangeSets(hgLogList);
|
Chris@44
|
263 if (csets.empty()) return;
|
Chris@53
|
264 Grapher g(scene);
|
Chris@44
|
265 try {
|
Chris@53
|
266 g.layout(csets);
|
Chris@44
|
267 } catch (std::string s) {
|
Chris@44
|
268 std::cerr << "Internal error: Layout failed: " << s << std::endl;
|
Chris@44
|
269 }
|
cannam@45
|
270 panned->scene()->deleteLater();
|
cannam@45
|
271 panned->setScene(scene);
|
cannam@45
|
272 panner->scene()->deleteLater();
|
cannam@45
|
273 panner->setScene(scene);
|
Chris@53
|
274 ChangesetItem *tipItem = g.getItemFor(csets[0]);
|
Chris@53
|
275 if (tipItem) tipItem->ensureVisible();
|
jtkorhonen@0
|
276 }
|
jtkorhonen@0
|
277
|
jtkorhonen@0
|
278
|
Chris@43
|
279
|
jtkorhonen@0
|
280 int HgExpWidget::findLineStart(int nowIndex, QString str)
|
jtkorhonen@0
|
281 {
|
jtkorhonen@0
|
282 if (nowIndex < 0)
|
jtkorhonen@0
|
283 {
|
jtkorhonen@0
|
284 return -1;
|
jtkorhonen@0
|
285 }
|
jtkorhonen@0
|
286
|
jtkorhonen@0
|
287 while(str.at(nowIndex) != '\n')
|
jtkorhonen@0
|
288 {
|
jtkorhonen@0
|
289 if (nowIndex == 0)
|
jtkorhonen@0
|
290 {
|
jtkorhonen@0
|
291 return nowIndex;
|
jtkorhonen@0
|
292 }
|
jtkorhonen@0
|
293 nowIndex--;
|
jtkorhonen@0
|
294 }
|
jtkorhonen@0
|
295 return nowIndex + 1;
|
jtkorhonen@0
|
296 }
|
jtkorhonen@0
|
297
|
jtkorhonen@0
|
298
|
jtkorhonen@0
|
299 QStringList HgExpWidget::splitChangeSets(QString chgSetsStr)
|
jtkorhonen@0
|
300 {
|
Chris@43
|
301 return LogParser(chgSetsStr).split();
|
Chris@43
|
302 /*
|
jtkorhonen@0
|
303 int currChgSet;
|
jtkorhonen@0
|
304 int currChgSetLineStart;
|
jtkorhonen@0
|
305
|
jtkorhonen@0
|
306 int prevChgSet;
|
jtkorhonen@0
|
307 QStringList tmp;
|
jtkorhonen@0
|
308
|
jtkorhonen@0
|
309 currChgSet = chgSetsStr.indexOf(CHGSET);
|
jtkorhonen@0
|
310 currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
|
jtkorhonen@0
|
311 prevChgSet = -1;
|
jtkorhonen@0
|
312 while (currChgSet != -1)
|
jtkorhonen@0
|
313 {
|
jtkorhonen@0
|
314 if (prevChgSet != -1)
|
jtkorhonen@0
|
315 {
|
jtkorhonen@0
|
316 tmp.append(chgSetsStr.mid(prevChgSet, (currChgSetLineStart - prevChgSet - 1)));
|
jtkorhonen@0
|
317 }
|
jtkorhonen@0
|
318
|
jtkorhonen@0
|
319 prevChgSet = currChgSetLineStart;
|
jtkorhonen@0
|
320
|
jtkorhonen@0
|
321 currChgSet = chgSetsStr.indexOf(CHGSET, currChgSet + 1);
|
jtkorhonen@0
|
322 currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
|
jtkorhonen@0
|
323 }
|
jtkorhonen@0
|
324
|
jtkorhonen@0
|
325 if (prevChgSet != -1)
|
jtkorhonen@0
|
326 {
|
jtkorhonen@0
|
327 //Last changeset
|
jtkorhonen@0
|
328 tmp.append(chgSetsStr.mid(prevChgSet));
|
jtkorhonen@0
|
329 }
|
jtkorhonen@0
|
330 else
|
jtkorhonen@0
|
331 {
|
jtkorhonen@0
|
332 //Only changeset (if any)
|
jtkorhonen@0
|
333 if (!chgSetsStr.isEmpty())
|
jtkorhonen@0
|
334 {
|
jtkorhonen@0
|
335 tmp.append(chgSetsStr.mid(0));
|
jtkorhonen@0
|
336 }
|
jtkorhonen@0
|
337 }
|
jtkorhonen@0
|
338
|
jtkorhonen@0
|
339 return tmp;
|
Chris@43
|
340 */
|
Chris@43
|
341 }
|
Chris@43
|
342
|
Chris@43
|
343 Changesets HgExpWidget::parseChangeSets(QString changeSetsStr)
|
Chris@43
|
344 {
|
Chris@43
|
345 Changesets csets;
|
Chris@43
|
346 LogList log = LogParser(changeSetsStr).parse();
|
Chris@43
|
347 foreach (LogEntry e, log) {
|
Chris@43
|
348 Changeset *cs = new Changeset();
|
Chris@43
|
349 foreach (QString key, e.keys()) {
|
Chris@44
|
350 if (key == "parents") {
|
Chris@44
|
351 QStringList parents = e.value(key).split
|
Chris@44
|
352 (" ", QString::SkipEmptyParts);
|
Chris@44
|
353 cs->setParents(parents);
|
Chris@52
|
354 } else if (key == "timestamp") {
|
Chris@52
|
355 cs->setTimestamp(e.value(key).split(" ")[0].toULongLong());
|
Chris@44
|
356 } else {
|
Chris@44
|
357 cs->setProperty(key.toLocal8Bit().data(), e.value(key));
|
Chris@44
|
358 }
|
Chris@43
|
359 }
|
Chris@43
|
360 csets.push_back(cs);
|
Chris@43
|
361 }
|
Chris@44
|
362 for (int i = 0; i+1 < csets.size(); ++i) {
|
Chris@44
|
363 Changeset *cs = csets[i];
|
Chris@44
|
364 if (cs->parents().empty()) {
|
Chris@44
|
365 QStringList list;
|
Chris@44
|
366 list.push_back(csets[i+1]->id());
|
Chris@44
|
367 cs->setParents(list);
|
Chris@44
|
368 }
|
Chris@44
|
369 }
|
Chris@43
|
370 return csets;
|
jtkorhonen@0
|
371 }
|
jtkorhonen@0
|
372
|
jtkorhonen@0
|
373 QString HgExpWidget::getCurrentFileListLine()
|
jtkorhonen@0
|
374 {
|
jtkorhonen@0
|
375 if (workFolderFileList -> currentItem() != NULL)
|
jtkorhonen@0
|
376 {
|
jtkorhonen@0
|
377 return workFolderFileList -> currentItem()->text();
|
jtkorhonen@0
|
378 }
|
jtkorhonen@0
|
379 return "";
|
jtkorhonen@0
|
380 }
|
jtkorhonen@0
|
381
|
jtkorhonen@0
|
382 void HgExpWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
383 {
|
jtkorhonen@0
|
384 grpRemoteRepo -> setTitle(tr(REMOTE_REPO_STR) + remoteRepoPath);
|
jtkorhonen@0
|
385 grpLocalRepo -> setTitle(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName());
|
jtkorhonen@0
|
386 grpWorkFolder -> setTitle(tr(WORKFOLDER_STR) + workFolderPath);
|
jtkorhonen@0
|
387 }
|
jtkorhonen@0
|
388
|
jtkorhonen@0
|
389 #define MERC_SHA1_MARKER_LEN 12
|
jtkorhonen@0
|
390 QString HgExpWidget::findRev(QString itemText, QString & smallRev)
|
jtkorhonen@0
|
391 {
|
jtkorhonen@0
|
392 QString tmp(itemText);
|
jtkorhonen@0
|
393 int i;
|
jtkorhonen@0
|
394 int j;
|
jtkorhonen@0
|
395
|
jtkorhonen@0
|
396 smallRev ="0";
|
jtkorhonen@0
|
397
|
jtkorhonen@0
|
398 i = tmp.indexOf(CHGSET);
|
jtkorhonen@0
|
399 if (i != -1)
|
jtkorhonen@0
|
400 {
|
jtkorhonen@0
|
401 j = i + 10;
|
jtkorhonen@0
|
402 i = tmp.indexOf(":", j); //xx:yyyyyy after changeset:
|
jtkorhonen@0
|
403
|
jtkorhonen@0
|
404 if (i != -1)
|
jtkorhonen@0
|
405 {
|
jtkorhonen@0
|
406 smallRev = tmp.mid(j, (i-j));
|
jtkorhonen@0
|
407 return tmp.mid(i+1, MERC_SHA1_MARKER_LEN);
|
jtkorhonen@0
|
408 }
|
jtkorhonen@0
|
409 }
|
jtkorhonen@0
|
410
|
jtkorhonen@0
|
411 return "";
|
jtkorhonen@0
|
412 }
|
jtkorhonen@0
|
413
|
jtkorhonen@0
|
414 void HgExpWidget::getHistoryDiffRevisions(QString& revA, QString& revB)
|
jtkorhonen@0
|
415 {
|
jtkorhonen@0
|
416 QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
417 QList <QListWidgetItem *> headList = localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
418
|
jtkorhonen@0
|
419 QString revATmp;
|
jtkorhonen@0
|
420 QString revBTmp;
|
jtkorhonen@0
|
421 QString smallRevA;
|
jtkorhonen@0
|
422 QString smallRevB;
|
jtkorhonen@0
|
423 QString txtA;
|
jtkorhonen@0
|
424 QString txtB;
|
jtkorhonen@0
|
425
|
jtkorhonen@0
|
426 if (histList.count() == REQUIRED_CHGSET_DIFF_COUNT)
|
jtkorhonen@0
|
427 {
|
jtkorhonen@0
|
428 txtA = histList.last()->text();
|
jtkorhonen@0
|
429 txtB = histList.first()->text();
|
jtkorhonen@0
|
430
|
jtkorhonen@0
|
431 }
|
jtkorhonen@0
|
432 else if (headList.count() == REQUIRED_CHGSET_DIFF_COUNT)
|
jtkorhonen@0
|
433 {
|
jtkorhonen@0
|
434 txtA = headList.last()->text();
|
jtkorhonen@0
|
435 txtB = headList.first()->text();
|
jtkorhonen@0
|
436 }
|
jtkorhonen@0
|
437 else
|
jtkorhonen@0
|
438 {
|
jtkorhonen@0
|
439 revA = "";
|
jtkorhonen@0
|
440 revB = "";
|
jtkorhonen@0
|
441 return;
|
jtkorhonen@0
|
442 }
|
jtkorhonen@0
|
443
|
jtkorhonen@0
|
444 revATmp = findRev(txtA, smallRevA);
|
jtkorhonen@0
|
445 revBTmp = findRev(txtB, smallRevB);
|
jtkorhonen@0
|
446
|
jtkorhonen@0
|
447 //Switch order according to repo small revision number (user can select items from list in "wrong" order)
|
jtkorhonen@0
|
448 if (smallRevB.toULongLong() > smallRevA.toULongLong())
|
jtkorhonen@0
|
449 {
|
jtkorhonen@0
|
450 revA = revATmp;
|
jtkorhonen@0
|
451 revB = revBTmp;
|
jtkorhonen@0
|
452 }
|
jtkorhonen@0
|
453 else
|
jtkorhonen@0
|
454 {
|
jtkorhonen@0
|
455 revA = revBTmp;
|
jtkorhonen@0
|
456 revB = revATmp;
|
jtkorhonen@0
|
457 }
|
jtkorhonen@0
|
458 }
|
jtkorhonen@0
|
459
|
jtkorhonen@0
|
460
|
jtkorhonen@0
|
461 void HgExpWidget::getUpdateToRevRevision(QString& rev)
|
jtkorhonen@0
|
462 {
|
jtkorhonen@0
|
463 QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
464 QString txt;
|
jtkorhonen@0
|
465 QString smallRev;
|
jtkorhonen@0
|
466
|
jtkorhonen@0
|
467
|
jtkorhonen@0
|
468 if (histList.count() == 1)
|
jtkorhonen@0
|
469 {
|
jtkorhonen@0
|
470 txt = histList.first()->text();
|
jtkorhonen@0
|
471 rev = findRev(txt, smallRev);
|
jtkorhonen@0
|
472 }
|
jtkorhonen@0
|
473 else
|
jtkorhonen@0
|
474 {
|
jtkorhonen@0
|
475 rev = "";
|
jtkorhonen@0
|
476 }
|
jtkorhonen@0
|
477 }
|
jtkorhonen@0
|
478
|
jtkorhonen@0
|
479
|
jtkorhonen@32
|
480 void HgExpWidget::enableDisableOtherTabs(int tabPage)
|
jtkorhonen@32
|
481 {
|
jtkorhonen@32
|
482 static int oldTabPage = -1;
|
jtkorhonen@0
|
483
|
jtkorhonen@32
|
484 if (tabPage != oldTabPage)
|
jtkorhonen@32
|
485 {
|
jtkorhonen@32
|
486 oldTabPage = tabPage;
|
jtkorhonen@32
|
487 if (tabPage == WORKTAB)
|
jtkorhonen@32
|
488 {
|
jtkorhonen@32
|
489 copyCommentAct -> setEnabled(true);
|
jtkorhonen@32
|
490 }
|
jtkorhonen@32
|
491 else
|
jtkorhonen@32
|
492 {
|
jtkorhonen@32
|
493 copyCommentAct -> setEnabled(false);
|
jtkorhonen@32
|
494 }
|
jtkorhonen@32
|
495 }
|
jtkorhonen@32
|
496
|
jtkorhonen@0
|
497 //history list is only interesting when we have something in it ;-)
|
jtkorhonen@0
|
498 if (localRepoHgLogList -> count() < 2)
|
jtkorhonen@0
|
499 {
|
jtkorhonen@0
|
500 setTabEnabled(HISTORYTAB, false);
|
jtkorhonen@0
|
501 }
|
jtkorhonen@0
|
502 else
|
jtkorhonen@0
|
503 {
|
jtkorhonen@0
|
504 setTabEnabled(HISTORYTAB, true);
|
jtkorhonen@0
|
505 }
|
jtkorhonen@0
|
506
|
jtkorhonen@0
|
507 //history list is only interesting when we have something in it ;-)
|
jtkorhonen@0
|
508 if (localRepoHgLogList -> count() < 2)
|
jtkorhonen@0
|
509 {
|
jtkorhonen@0
|
510 setTabEnabled(HISTORYTAB, false);
|
jtkorhonen@0
|
511 }
|
jtkorhonen@0
|
512 else
|
jtkorhonen@0
|
513 {
|
jtkorhonen@0
|
514 setTabEnabled(HISTORYTAB, true);
|
jtkorhonen@0
|
515 }
|
jtkorhonen@0
|
516 }
|
jtkorhonen@0
|
517
|
jtkorhonen@0
|
518
|
jtkorhonen@0
|
519
|
jtkorhonen@0
|
520
|