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@44
|
264 try {
|
cannam@45
|
265 Grapher(scene).layout(csets);
|
Chris@44
|
266 } catch (std::string s) {
|
Chris@44
|
267 std::cerr << "Internal error: Layout failed: " << s << std::endl;
|
Chris@44
|
268 }
|
cannam@45
|
269 panned->scene()->deleteLater();
|
cannam@45
|
270 panned->setScene(scene);
|
cannam@45
|
271 panner->scene()->deleteLater();
|
cannam@45
|
272 panner->setScene(scene);
|
jtkorhonen@0
|
273 }
|
jtkorhonen@0
|
274
|
jtkorhonen@0
|
275
|
Chris@43
|
276
|
jtkorhonen@0
|
277 int HgExpWidget::findLineStart(int nowIndex, QString str)
|
jtkorhonen@0
|
278 {
|
jtkorhonen@0
|
279 if (nowIndex < 0)
|
jtkorhonen@0
|
280 {
|
jtkorhonen@0
|
281 return -1;
|
jtkorhonen@0
|
282 }
|
jtkorhonen@0
|
283
|
jtkorhonen@0
|
284 while(str.at(nowIndex) != '\n')
|
jtkorhonen@0
|
285 {
|
jtkorhonen@0
|
286 if (nowIndex == 0)
|
jtkorhonen@0
|
287 {
|
jtkorhonen@0
|
288 return nowIndex;
|
jtkorhonen@0
|
289 }
|
jtkorhonen@0
|
290 nowIndex--;
|
jtkorhonen@0
|
291 }
|
jtkorhonen@0
|
292 return nowIndex + 1;
|
jtkorhonen@0
|
293 }
|
jtkorhonen@0
|
294
|
jtkorhonen@0
|
295
|
jtkorhonen@0
|
296 QStringList HgExpWidget::splitChangeSets(QString chgSetsStr)
|
jtkorhonen@0
|
297 {
|
Chris@43
|
298 return LogParser(chgSetsStr).split();
|
Chris@43
|
299 /*
|
jtkorhonen@0
|
300 int currChgSet;
|
jtkorhonen@0
|
301 int currChgSetLineStart;
|
jtkorhonen@0
|
302
|
jtkorhonen@0
|
303 int prevChgSet;
|
jtkorhonen@0
|
304 QStringList tmp;
|
jtkorhonen@0
|
305
|
jtkorhonen@0
|
306 currChgSet = chgSetsStr.indexOf(CHGSET);
|
jtkorhonen@0
|
307 currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
|
jtkorhonen@0
|
308 prevChgSet = -1;
|
jtkorhonen@0
|
309 while (currChgSet != -1)
|
jtkorhonen@0
|
310 {
|
jtkorhonen@0
|
311 if (prevChgSet != -1)
|
jtkorhonen@0
|
312 {
|
jtkorhonen@0
|
313 tmp.append(chgSetsStr.mid(prevChgSet, (currChgSetLineStart - prevChgSet - 1)));
|
jtkorhonen@0
|
314 }
|
jtkorhonen@0
|
315
|
jtkorhonen@0
|
316 prevChgSet = currChgSetLineStart;
|
jtkorhonen@0
|
317
|
jtkorhonen@0
|
318 currChgSet = chgSetsStr.indexOf(CHGSET, currChgSet + 1);
|
jtkorhonen@0
|
319 currChgSetLineStart = findLineStart(currChgSet, chgSetsStr);
|
jtkorhonen@0
|
320 }
|
jtkorhonen@0
|
321
|
jtkorhonen@0
|
322 if (prevChgSet != -1)
|
jtkorhonen@0
|
323 {
|
jtkorhonen@0
|
324 //Last changeset
|
jtkorhonen@0
|
325 tmp.append(chgSetsStr.mid(prevChgSet));
|
jtkorhonen@0
|
326 }
|
jtkorhonen@0
|
327 else
|
jtkorhonen@0
|
328 {
|
jtkorhonen@0
|
329 //Only changeset (if any)
|
jtkorhonen@0
|
330 if (!chgSetsStr.isEmpty())
|
jtkorhonen@0
|
331 {
|
jtkorhonen@0
|
332 tmp.append(chgSetsStr.mid(0));
|
jtkorhonen@0
|
333 }
|
jtkorhonen@0
|
334 }
|
jtkorhonen@0
|
335
|
jtkorhonen@0
|
336 return tmp;
|
Chris@43
|
337 */
|
Chris@43
|
338 }
|
Chris@43
|
339
|
Chris@43
|
340 Changesets HgExpWidget::parseChangeSets(QString changeSetsStr)
|
Chris@43
|
341 {
|
Chris@43
|
342 Changesets csets;
|
Chris@43
|
343 LogList log = LogParser(changeSetsStr).parse();
|
Chris@43
|
344 foreach (LogEntry e, log) {
|
Chris@43
|
345 Changeset *cs = new Changeset();
|
Chris@43
|
346 foreach (QString key, e.keys()) {
|
Chris@44
|
347 if (key == "parents") {
|
Chris@44
|
348 QStringList parents = e.value(key).split
|
Chris@44
|
349 (" ", QString::SkipEmptyParts);
|
Chris@44
|
350 cs->setParents(parents);
|
Chris@44
|
351 } else {
|
Chris@44
|
352 cs->setProperty(key.toLocal8Bit().data(), e.value(key));
|
Chris@44
|
353 }
|
Chris@43
|
354 }
|
Chris@43
|
355 csets.push_back(cs);
|
Chris@43
|
356 }
|
Chris@44
|
357 for (int i = 0; i+1 < csets.size(); ++i) {
|
Chris@44
|
358 Changeset *cs = csets[i];
|
Chris@44
|
359 if (cs->parents().empty()) {
|
Chris@44
|
360 QStringList list;
|
Chris@44
|
361 list.push_back(csets[i+1]->id());
|
Chris@44
|
362 cs->setParents(list);
|
Chris@44
|
363 }
|
Chris@44
|
364 }
|
Chris@43
|
365 return csets;
|
jtkorhonen@0
|
366 }
|
jtkorhonen@0
|
367
|
jtkorhonen@0
|
368 QString HgExpWidget::getCurrentFileListLine()
|
jtkorhonen@0
|
369 {
|
jtkorhonen@0
|
370 if (workFolderFileList -> currentItem() != NULL)
|
jtkorhonen@0
|
371 {
|
jtkorhonen@0
|
372 return workFolderFileList -> currentItem()->text();
|
jtkorhonen@0
|
373 }
|
jtkorhonen@0
|
374 return "";
|
jtkorhonen@0
|
375 }
|
jtkorhonen@0
|
376
|
jtkorhonen@0
|
377 void HgExpWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath)
|
jtkorhonen@0
|
378 {
|
jtkorhonen@0
|
379 grpRemoteRepo -> setTitle(tr(REMOTE_REPO_STR) + remoteRepoPath);
|
jtkorhonen@0
|
380 grpLocalRepo -> setTitle(tr(LOCAL_REPO_STR) + workFolderPath + getHgDirName());
|
jtkorhonen@0
|
381 grpWorkFolder -> setTitle(tr(WORKFOLDER_STR) + workFolderPath);
|
jtkorhonen@0
|
382 }
|
jtkorhonen@0
|
383
|
jtkorhonen@0
|
384 #define MERC_SHA1_MARKER_LEN 12
|
jtkorhonen@0
|
385 QString HgExpWidget::findRev(QString itemText, QString & smallRev)
|
jtkorhonen@0
|
386 {
|
jtkorhonen@0
|
387 QString tmp(itemText);
|
jtkorhonen@0
|
388 int i;
|
jtkorhonen@0
|
389 int j;
|
jtkorhonen@0
|
390
|
jtkorhonen@0
|
391 smallRev ="0";
|
jtkorhonen@0
|
392
|
jtkorhonen@0
|
393 i = tmp.indexOf(CHGSET);
|
jtkorhonen@0
|
394 if (i != -1)
|
jtkorhonen@0
|
395 {
|
jtkorhonen@0
|
396 j = i + 10;
|
jtkorhonen@0
|
397 i = tmp.indexOf(":", j); //xx:yyyyyy after changeset:
|
jtkorhonen@0
|
398
|
jtkorhonen@0
|
399 if (i != -1)
|
jtkorhonen@0
|
400 {
|
jtkorhonen@0
|
401 smallRev = tmp.mid(j, (i-j));
|
jtkorhonen@0
|
402 return tmp.mid(i+1, MERC_SHA1_MARKER_LEN);
|
jtkorhonen@0
|
403 }
|
jtkorhonen@0
|
404 }
|
jtkorhonen@0
|
405
|
jtkorhonen@0
|
406 return "";
|
jtkorhonen@0
|
407 }
|
jtkorhonen@0
|
408
|
jtkorhonen@0
|
409 void HgExpWidget::getHistoryDiffRevisions(QString& revA, QString& revB)
|
jtkorhonen@0
|
410 {
|
jtkorhonen@0
|
411 QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
412 QList <QListWidgetItem *> headList = localRepoHeadsList->selectedItems();
|
jtkorhonen@0
|
413
|
jtkorhonen@0
|
414 QString revATmp;
|
jtkorhonen@0
|
415 QString revBTmp;
|
jtkorhonen@0
|
416 QString smallRevA;
|
jtkorhonen@0
|
417 QString smallRevB;
|
jtkorhonen@0
|
418 QString txtA;
|
jtkorhonen@0
|
419 QString txtB;
|
jtkorhonen@0
|
420
|
jtkorhonen@0
|
421 if (histList.count() == REQUIRED_CHGSET_DIFF_COUNT)
|
jtkorhonen@0
|
422 {
|
jtkorhonen@0
|
423 txtA = histList.last()->text();
|
jtkorhonen@0
|
424 txtB = histList.first()->text();
|
jtkorhonen@0
|
425
|
jtkorhonen@0
|
426 }
|
jtkorhonen@0
|
427 else if (headList.count() == REQUIRED_CHGSET_DIFF_COUNT)
|
jtkorhonen@0
|
428 {
|
jtkorhonen@0
|
429 txtA = headList.last()->text();
|
jtkorhonen@0
|
430 txtB = headList.first()->text();
|
jtkorhonen@0
|
431 }
|
jtkorhonen@0
|
432 else
|
jtkorhonen@0
|
433 {
|
jtkorhonen@0
|
434 revA = "";
|
jtkorhonen@0
|
435 revB = "";
|
jtkorhonen@0
|
436 return;
|
jtkorhonen@0
|
437 }
|
jtkorhonen@0
|
438
|
jtkorhonen@0
|
439 revATmp = findRev(txtA, smallRevA);
|
jtkorhonen@0
|
440 revBTmp = findRev(txtB, smallRevB);
|
jtkorhonen@0
|
441
|
jtkorhonen@0
|
442 //Switch order according to repo small revision number (user can select items from list in "wrong" order)
|
jtkorhonen@0
|
443 if (smallRevB.toULongLong() > smallRevA.toULongLong())
|
jtkorhonen@0
|
444 {
|
jtkorhonen@0
|
445 revA = revATmp;
|
jtkorhonen@0
|
446 revB = revBTmp;
|
jtkorhonen@0
|
447 }
|
jtkorhonen@0
|
448 else
|
jtkorhonen@0
|
449 {
|
jtkorhonen@0
|
450 revA = revBTmp;
|
jtkorhonen@0
|
451 revB = revATmp;
|
jtkorhonen@0
|
452 }
|
jtkorhonen@0
|
453 }
|
jtkorhonen@0
|
454
|
jtkorhonen@0
|
455
|
jtkorhonen@0
|
456 void HgExpWidget::getUpdateToRevRevision(QString& rev)
|
jtkorhonen@0
|
457 {
|
jtkorhonen@0
|
458 QList <QListWidgetItem *> histList = localRepoHgLogList->selectedItems();
|
jtkorhonen@0
|
459 QString txt;
|
jtkorhonen@0
|
460 QString smallRev;
|
jtkorhonen@0
|
461
|
jtkorhonen@0
|
462
|
jtkorhonen@0
|
463 if (histList.count() == 1)
|
jtkorhonen@0
|
464 {
|
jtkorhonen@0
|
465 txt = histList.first()->text();
|
jtkorhonen@0
|
466 rev = findRev(txt, smallRev);
|
jtkorhonen@0
|
467 }
|
jtkorhonen@0
|
468 else
|
jtkorhonen@0
|
469 {
|
jtkorhonen@0
|
470 rev = "";
|
jtkorhonen@0
|
471 }
|
jtkorhonen@0
|
472 }
|
jtkorhonen@0
|
473
|
jtkorhonen@0
|
474
|
jtkorhonen@32
|
475 void HgExpWidget::enableDisableOtherTabs(int tabPage)
|
jtkorhonen@32
|
476 {
|
jtkorhonen@32
|
477 static int oldTabPage = -1;
|
jtkorhonen@0
|
478
|
jtkorhonen@32
|
479 if (tabPage != oldTabPage)
|
jtkorhonen@32
|
480 {
|
jtkorhonen@32
|
481 oldTabPage = tabPage;
|
jtkorhonen@32
|
482 if (tabPage == WORKTAB)
|
jtkorhonen@32
|
483 {
|
jtkorhonen@32
|
484 copyCommentAct -> setEnabled(true);
|
jtkorhonen@32
|
485 }
|
jtkorhonen@32
|
486 else
|
jtkorhonen@32
|
487 {
|
jtkorhonen@32
|
488 copyCommentAct -> setEnabled(false);
|
jtkorhonen@32
|
489 }
|
jtkorhonen@32
|
490 }
|
jtkorhonen@32
|
491
|
jtkorhonen@0
|
492 //history list is only interesting when we have something in it ;-)
|
jtkorhonen@0
|
493 if (localRepoHgLogList -> count() < 2)
|
jtkorhonen@0
|
494 {
|
jtkorhonen@0
|
495 setTabEnabled(HISTORYTAB, false);
|
jtkorhonen@0
|
496 }
|
jtkorhonen@0
|
497 else
|
jtkorhonen@0
|
498 {
|
jtkorhonen@0
|
499 setTabEnabled(HISTORYTAB, true);
|
jtkorhonen@0
|
500 }
|
jtkorhonen@0
|
501
|
jtkorhonen@0
|
502 //history list is only interesting when we have something in it ;-)
|
jtkorhonen@0
|
503 if (localRepoHgLogList -> count() < 2)
|
jtkorhonen@0
|
504 {
|
jtkorhonen@0
|
505 setTabEnabled(HISTORYTAB, false);
|
jtkorhonen@0
|
506 }
|
jtkorhonen@0
|
507 else
|
jtkorhonen@0
|
508 {
|
jtkorhonen@0
|
509 setTabEnabled(HISTORYTAB, true);
|
jtkorhonen@0
|
510 }
|
jtkorhonen@0
|
511 }
|
jtkorhonen@0
|
512
|
jtkorhonen@0
|
513
|
jtkorhonen@0
|
514
|
jtkorhonen@0
|
515
|