annotate hgexpwidget.cpp @ 57:f583e44d9d31

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