annotate hgexpwidget.cpp @ 88:c5e34ed5b791

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