comparison mainwindow.cpp @ 331:acfe9390d5c6

Basic implementation of annotate
author Chris Cannam
date Sun, 13 Mar 2011 10:31:32 +0000
parents bf4bbb53e217
children 70ad221e1619
comparison
equal deleted inserted replaced
330:bf4bbb53e217 331:acfe9390d5c6
42 #include "logparser.h" 42 #include "logparser.h"
43 #include "confirmcommentdialog.h" 43 #include "confirmcommentdialog.h"
44 #include "incomingdialog.h" 44 #include "incomingdialog.h"
45 #include "settingsdialog.h" 45 #include "settingsdialog.h"
46 #include "moreinformationdialog.h" 46 #include "moreinformationdialog.h"
47 #include "annotatedialog.h"
47 #include "version.h" 48 #include "version.h"
48 #include "workstatuswidget.h" 49 #include "workstatuswidget.h"
49 50
50 51
51 MainWindow::MainWindow(QString myDirPath) : 52 MainWindow::MainWindow(QString myDirPath) :
355 QStringList params; 356 QStringList params;
356 params << "parents"; 357 params << "parents";
357 m_runner->requestAction(HgAction(ACT_QUERY_PARENTS, m_workFolderPath, params)); 358 m_runner->requestAction(HgAction(ACT_QUERY_PARENTS, m_workFolderPath, params));
358 } 359 }
359 360
360 void MainWindow::hgAnnotate()
361 {
362 QStringList params;
363 QString currentFile;//!!! = m_hgTabs -> getCurrentFileListLine();
364
365 if (!currentFile.isEmpty())
366 {
367 params << "annotate" << "--" << currentFile.mid(2); //Jump over status marker characters (e.g "M ")
368
369 m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params));
370 }
371 }
372
373 void MainWindow::hgAnnotateFiles(QStringList files) 361 void MainWindow::hgAnnotateFiles(QStringList files)
374 { 362 {
375 QStringList params; 363 QStringList params;
376 364
377 if (!files.isEmpty()) { 365 if (!files.isEmpty()) {
378 params << "annotate" << "--" << files; 366 params << "annotate" << "-udc" << "--" << files;
379 m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params)); 367 m_runner->requestAction(HgAction(ACT_ANNOTATE, m_workFolderPath, params));
380 } 368 }
381 } 369 }
382 370
383 void MainWindow::hgResolveList() 371 void MainWindow::hgResolveList()
641 // Diff parent against working folder (folder diff) 629 // Diff parent against working folder (folder diff)
642 630
643 params << "--config" << "extensions.extdiff=" << "extdiff"; 631 params << "--config" << "extensions.extdiff=" << "extdiff";
644 params << "--program" << diff; 632 params << "--program" << diff;
645 633
646 params << files; // may be none: whole dir 634 params << "--" << files; // may be none: whole dir
647 635
648 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params)); 636 m_runner->requestAction(HgAction(ACT_FOLDERDIFF, m_workFolderPath, params));
649 } 637 }
650 638
651 void MainWindow::hgDiffToCurrent(QString id) 639 void MainWindow::hgDiffToCurrent(QString id)
1462 1450
1463 if (settingsDlg->presentationChanged()) { 1451 if (settingsDlg->presentationChanged()) {
1464 m_hgTabs->updateFileStates(); 1452 m_hgTabs->updateFileStates();
1465 updateToolBarStyle(); 1453 updateToolBarStyle();
1466 hgRefresh(); 1454 hgRefresh();
1467 }
1468 }
1469
1470 #define STDOUT_NEEDS_BIG_WINDOW 512
1471 #define SMALL_WND_W 500
1472 #define SMALL_WND_H 300
1473
1474 #define BIG_WND_W 1024
1475 #define BIG_WND_H 768
1476
1477
1478 void MainWindow::presentLongStdoutToUser(QString stdo)
1479 {
1480 if (!stdo.isEmpty())
1481 {
1482 QDialog dlg;
1483
1484 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
1485 {
1486 dlg.setMinimumWidth(BIG_WND_W);
1487 dlg.setMinimumHeight(BIG_WND_H);
1488 }
1489 else
1490 {
1491 dlg.setMinimumWidth(SMALL_WND_W);
1492 dlg.setMinimumHeight(SMALL_WND_H);
1493 }
1494
1495 QVBoxLayout *box = new QVBoxLayout;
1496 QListWidget *list = new QListWidget;
1497 list-> addItems(stdo.split("\n"));
1498 QPushButton *btn = new QPushButton(tr("Ok"));
1499 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
1500
1501 box -> addWidget(list);
1502 box -> addWidget(btn);
1503 dlg.setLayout(box);
1504
1505 dlg.exec();
1506 }
1507 else
1508 {
1509 QMessageBox::information(this, tr("EasyMercurial"), tr("Mercurial command did not return any output."));
1510 } 1455 }
1511 } 1456 }
1512 1457
1513 void MainWindow::updateFileSystemWatcher() 1458 void MainWindow::updateFileSystemWatcher()
1514 { 1459 {
1941 case ACT_INCOMING: 1886 case ACT_INCOMING:
1942 showIncoming(output); 1887 showIncoming(output);
1943 break; 1888 break;
1944 1889
1945 case ACT_ANNOTATE: 1890 case ACT_ANNOTATE:
1946 presentLongStdoutToUser(output); 1891 {
1892 AnnotateDialog dialog(this, output);
1893 dialog.exec();
1947 m_shouldHgStat = true; 1894 m_shouldHgStat = true;
1948 break; 1895 break;
1896 }
1949 1897
1950 case ACT_PULL: 1898 case ACT_PULL:
1951 showPullResult(output); 1899 showPullResult(output);
1952 m_shouldHgStat = true; 1900 m_shouldHgStat = true;
1953 break; 1901 break;
2221 2169
2222 connect(m_hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming())); 2170 connect(m_hgIncomingAct, SIGNAL(triggered()), this, SLOT(hgIncoming()));
2223 connect(m_hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull())); 2171 connect(m_hgPullAct, SIGNAL(triggered()), this, SLOT(hgPull()));
2224 connect(m_hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush())); 2172 connect(m_hgPushAct, SIGNAL(triggered()), this, SLOT(hgPush()));
2225 2173
2226 connect(m_hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
2227 connect(m_hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe())); 2174 connect(m_hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
2228 } 2175 }
2229 2176
2230 void MainWindow::connectTabsSignals() 2177 void MainWindow::connectTabsSignals()
2231 { 2178 {
2362 m_hgAddAct -> setEnabled(m_localRepoActionsEnabled); 2309 m_hgAddAct -> setEnabled(m_localRepoActionsEnabled);
2363 m_hgRemoveAct -> setEnabled(m_localRepoActionsEnabled); 2310 m_hgRemoveAct -> setEnabled(m_localRepoActionsEnabled);
2364 m_hgUpdateAct -> setEnabled(m_localRepoActionsEnabled); 2311 m_hgUpdateAct -> setEnabled(m_localRepoActionsEnabled);
2365 m_hgCommitAct -> setEnabled(m_localRepoActionsEnabled); 2312 m_hgCommitAct -> setEnabled(m_localRepoActionsEnabled);
2366 m_hgMergeAct -> setEnabled(m_localRepoActionsEnabled); 2313 m_hgMergeAct -> setEnabled(m_localRepoActionsEnabled);
2367 m_hgAnnotateAct -> setEnabled(m_localRepoActionsEnabled);
2368 m_hgServeAct -> setEnabled(m_localRepoActionsEnabled); 2314 m_hgServeAct -> setEnabled(m_localRepoActionsEnabled);
2369 m_hgIgnoreAct -> setEnabled(m_localRepoActionsEnabled); 2315 m_hgIgnoreAct -> setEnabled(m_localRepoActionsEnabled);
2370 2316
2371 DEBUG << "m_localRepoActionsEnabled = " << m_localRepoActionsEnabled << endl; 2317 DEBUG << "m_localRepoActionsEnabled = " << m_localRepoActionsEnabled << endl;
2372 DEBUG << "canCommit = " << m_hgTabs->canCommit() << endl; 2318 DEBUG << "canCommit = " << m_hgTabs->canCommit() << endl;
2538 2484
2539 m_hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this); 2485 m_hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
2540 m_hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder")); 2486 m_hgMergeAct->setStatusTip(tr("Merge the two independent sets of changes in the local repository into the working folder"));
2541 2487
2542 //Advanced actions 2488 //Advanced actions
2543 //!!! needs to be modified for number
2544 m_hgAnnotateAct = new QAction(tr("Annotate"), this);
2545 m_hgAnnotateAct -> setStatusTip(tr("Show line-by-line version information for selected file"));
2546 2489
2547 m_hgIgnoreAct = new QAction(tr("Edit .hgignore File"), this); 2490 m_hgIgnoreAct = new QAction(tr("Edit .hgignore File"), this);
2548 m_hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial")); 2491 m_hgIgnoreAct -> setStatusTip(tr("Edit the .hgignore file, containing the names of files that should be ignored by Mercurial"));
2549 2492
2550 m_hgServeAct = new QAction(tr("Serve via HTTP"), this); 2493 m_hgServeAct = new QAction(tr("Serve via HTTP"), this);