comparison mainwindow.cpp @ 120:c92f5859c707

* Add incremental log (though not incremental relayout)
author Chris Cannam
date Mon, 29 Nov 2010 11:01:19 +0000
parents 807c79350bf1
children 6ce2ceb2c3a5
comparison
equal deleted inserted replaced
119:005a54380502 120:c92f5859c707
62 remoteRepoPath = ""; 62 remoteRepoPath = "";
63 workFolderPath = ""; 63 workFolderPath = "";
64 64
65 readSettings(); 65 readSettings();
66 66
67 // tabPage = 0;
68 justMerged = false; 67 justMerged = false;
69 hgTabs = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath); 68 hgTabs = new HgTabWidget((QWidget *) this, remoteRepoPath, workFolderPath);
70 setCentralWidget(hgTabs); 69 setCentralWidget(hgTabs);
71 70
72 connect(hgTabs, SIGNAL(selectionChanged()), 71 connect(hgTabs, SIGNAL(selectionChanged()),
73 this, SLOT(enableDisableActions())); 72 this, SLOT(enableDisableActions()));
74 73
75 setUnifiedTitleAndToolBarOnMac(true); 74 setUnifiedTitleAndToolBarOnMac(true);
76 connectActions(); 75 connectActions();
76 clearState();
77 enableDisableActions(); 77 enableDisableActions();
78 78
79 if (firstStart) { 79 if (firstStart) {
80 startupDialog(); 80 startupDialog();
81 } 81 }
143 void MainWindow::clearSelections() 143 void MainWindow::clearSelections()
144 { 144 {
145 hgTabs->clearSelections(); 145 hgTabs->clearSelections();
146 } 146 }
147 147
148 void MainWindow::hgRefresh()
149 {
150 clearState();
151 hgQueryPaths();
152 }
153
148 void MainWindow::hgStat() 154 void MainWindow::hgStat()
149 { 155 {
150 QStringList params; 156 QStringList params;
151 params << "stat" << "-ardum"; 157 params << "stat" << "-ardum";
152 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params)); 158 runner->requestAction(HgAction(ACT_STAT, workFolderPath, params));
174 runner->requestAction(HgAction(ACT_QUERY_HEADS, workFolderPath, params)); 180 runner->requestAction(HgAction(ACT_QUERY_HEADS, workFolderPath, params));
175 } 181 }
176 182
177 void MainWindow::hgLog() 183 void MainWindow::hgLog()
178 { 184 {
179 //!!! This needs to be incremental, except when we pull or set new repo.
180 // Be sure to use ACT_LOG_INCREMENTAL for incremental logs
181 QStringList params; 185 QStringList params;
182 params << "log"; 186 params << "log";
183 params << "--template"; 187 params << "--template";
184 params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n"; 188 params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
185 189
186 runner->requestAction(HgAction(ACT_LOG, workFolderPath, params)); 190 runner->requestAction(HgAction(ACT_LOG, workFolderPath, params));
187 } 191 }
188 192
193 void MainWindow::hgLogIncremental()
194 {
195 QStringList params;
196 params << "log";
197
198 foreach (Changeset *head, currentHeads) {
199 int n = head->number();
200 params << "--prune" << QString("%1").arg(n);
201 }
202
203 params << "--template";
204 params << "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
205
206 runner->requestAction(HgAction(ACT_LOG_INCREMENTAL, workFolderPath, params));
207 }
189 208
190 void MainWindow::hgQueryParents() 209 void MainWindow::hgQueryParents()
191 { 210 {
192 QStringList params; 211 QStringList params;
193 params << "parents"; 212 params << "parents";
611 } 630 }
612 } 631 }
613 return ret; 632 return ret;
614 } 633 }
615 634
635 void MainWindow::clearState()
636 {
637 foreach (Changeset *cs, currentParents) delete cs;
638 currentParents.clear();
639 foreach (Changeset *cs, currentHeads) delete cs;
640 currentHeads.clear();
641 currentBranch = "";
642 needNewLog = true;
643 }
616 644
617 void MainWindow::hgServe() 645 void MainWindow::hgServe()
618 { 646 {
619 QStringList params; 647 QStringList params;
620 QString msg; 648 QString msg;
678 result = openInit(arg); 706 result = openInit(arg);
679 } 707 }
680 708
681 if (result) { 709 if (result) {
682 enableDisableActions(); 710 enableDisableActions();
711 clearState();
683 hgQueryPaths(); 712 hgQueryPaths();
684 done = true; 713 done = true;
685 } 714 }
686 715
687 } else { 716 } else {
996 this, SLOT(fsFileChanged(QString))); 1025 this, SLOT(fsFileChanged(QString)));
997 } 1026 }
998 1027
999 void MainWindow::fsDirectoryChanged(QString) 1028 void MainWindow::fsDirectoryChanged(QString)
1000 { 1029 {
1001 //!!! should just queue one of these!
1002 hgStat(); 1030 hgStat();
1003 } 1031 }
1004 1032
1005 void MainWindow::fsFileChanged(QString) 1033 void MainWindow::fsFileChanged(QString)
1006 { 1034 {
1007 //!!! should just queue one of these!
1008 hgStat(); 1035 hgStat();
1036 }
1037
1038 void MainWindow::showIncoming(QString output)
1039 {
1040 runner->hide();
1041 QMessageBox::information(this, "Incoming", output);
1042 }
1043
1044 void MainWindow::showPushResult(QString output)
1045 {
1046 runner->hide();
1047 QMessageBox::information(this, "Push", output);
1048 }
1049
1050 void MainWindow::showPullResult(QString output)
1051 {
1052 runner->hide();
1053 QMessageBox::information(this, "Pull", output);
1009 } 1054 }
1010 1055
1011 void MainWindow::commandFailed(HgAction action, QString stderr) 1056 void MainWindow::commandFailed(HgAction action, QString stderr)
1012 { 1057 {
1013 DEBUG << "MainWindow::commandFailed" << endl; 1058 DEBUG << "MainWindow::commandFailed" << endl;
1088 hgTabs->updateWorkFolderFileList(output); 1133 hgTabs->updateWorkFolderFileList(output);
1089 updateFileSystemWatcher(); 1134 updateFileSystemWatcher();
1090 break; 1135 break;
1091 1136
1092 case ACT_INCOMING: 1137 case ACT_INCOMING:
1138 showIncoming(output);
1139 break;
1140
1093 case ACT_ANNOTATE: 1141 case ACT_ANNOTATE:
1094 case ACT_RESOLVE_LIST: 1142 case ACT_RESOLVE_LIST:
1095 case ACT_RESOLVE_MARK: 1143 case ACT_RESOLVE_MARK:
1096 presentLongStdoutToUser(output); 1144 presentLongStdoutToUser(output);
1097 shouldHgStat = true; 1145 shouldHgStat = true;
1098 break; 1146 break;
1099 1147
1100 case ACT_PULL: 1148 case ACT_PULL:
1101 QMessageBox::information(this, "Pull", output); 1149 showPullResult(output);
1102 shouldHgStat = true; 1150 shouldHgStat = true;
1103 break; 1151 break;
1104 1152
1105 case ACT_PUSH: 1153 case ACT_PUSH:
1106 QMessageBox::information(this, "Push", output); 1154 showPushResult(output);
1107 shouldHgStat = true;
1108 break; 1155 break;
1109 1156
1110 case ACT_INIT: 1157 case ACT_INIT:
1111 MultiChoiceDialog::addRecentArgument("init", workFolderPath); 1158 MultiChoiceDialog::addRecentArgument("init", workFolderPath);
1112 MultiChoiceDialog::addRecentArgument("local", workFolderPath); 1159 MultiChoiceDialog::addRecentArgument("local", workFolderPath);
1122 enableDisableActions(); 1169 enableDisableActions();
1123 shouldHgStat = true; 1170 shouldHgStat = true;
1124 break; 1171 break;
1125 1172
1126 case ACT_LOG: 1173 case ACT_LOG:
1127 hgTabs -> updateLocalRepoHgLogList(output); 1174 hgTabs->setNewLog(output);
1175 needNewLog = false;
1176 break;
1177
1178 case ACT_LOG_INCREMENTAL:
1179 hgTabs->addIncrementalLog(output);
1128 break; 1180 break;
1129 1181
1130 case ACT_QUERY_PARENTS: 1182 case ACT_QUERY_PARENTS:
1131 foreach (Changeset *cs, currentParents) delete cs; 1183 foreach (Changeset *cs, currentParents) delete cs;
1132 currentParents = Changeset::parseChangesets(output); 1184 currentParents = Changeset::parseChangesets(output);
1185 } else if (action == ACT_STAT) { 1237 } else if (action == ACT_STAT) {
1186 hgQueryHeads(); 1238 hgQueryHeads();
1187 } else if (action == ACT_QUERY_HEADS) { 1239 } else if (action == ACT_QUERY_HEADS) {
1188 hgQueryParents(); 1240 hgQueryParents();
1189 } else if (action == ACT_QUERY_PARENTS) { 1241 } else if (action == ACT_QUERY_PARENTS) {
1190 hgLog(); 1242 if (needNewLog) {
1243 hgLog();
1244 } else {
1245 hgLogIncremental();
1246 }
1191 } else 1247 } else
1192 /* Move to commandFailed 1248 /* Move to commandFailed
1193 if ((runningAction == ACT_MERGE) && (exitCode != 0)) 1249 if ((runningAction == ACT_MERGE) && (exitCode != 0))
1194 { 1250 {
1195 // If we had a failed merge, offer to retry 1251 // If we had a failed merge, offer to retry
1216 { 1272 {
1217 connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); 1273 connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
1218 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); 1274 connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
1219 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt())); 1275 connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
1220 1276
1221 connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgQueryPaths())); 1277 connect(hgRefreshAct, SIGNAL(triggered()), this, SLOT(hgRefresh()));
1222 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove())); 1278 connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
1223 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd())); 1279 connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
1224 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit())); 1280 connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
1225 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff())); 1281 connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
1226 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff())); 1282 connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
1303 } 1359 }
1304 */ 1360 */
1305 bool haveDiff = (diffBinaryName != ""); 1361 bool haveDiff = (diffBinaryName != "");
1306 1362
1307 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true)); 1363 hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
1308 hgStatAct -> setEnabled(localRepoActionsEnabled); 1364 hgRefreshAct -> setEnabled(localRepoActionsEnabled);
1309 hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff); 1365 hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
1310 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff); 1366 hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
1311 hgRevertAct -> setEnabled(localRepoActionsEnabled); 1367 hgRevertAct -> setEnabled(localRepoActionsEnabled);
1312 hgAddAct -> setEnabled(localRepoActionsEnabled); 1368 hgAddAct -> setEnabled(localRepoActionsEnabled);
1313 hgRemoveAct -> setEnabled(localRepoActionsEnabled); 1369 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
1411 exitAct->setShortcuts(QKeySequence::Quit); 1467 exitAct->setShortcuts(QKeySequence::Quit);
1412 exitAct->setStatusTip(tr("Exit application")); 1468 exitAct->setStatusTip(tr("Exit application"));
1413 exitAct -> setIconVisibleInMenu(true); 1469 exitAct -> setIconVisibleInMenu(true);
1414 1470
1415 //Repository actions 1471 //Repository actions
1416 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this); 1472 hgRefreshAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
1417 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files")); 1473 hgRefreshAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
1418 1474
1419 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this); 1475 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
1420 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)")); 1476 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
1421 1477
1422 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this); 1478 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
1525 void MainWindow::createToolBars() 1581 void MainWindow::createToolBars()
1526 { 1582 {
1527 fileToolBar = addToolBar(tr("File")); 1583 fileToolBar = addToolBar(tr("File"));
1528 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); 1584 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
1529 fileToolBar -> addAction(openAct); 1585 fileToolBar -> addAction(openAct);
1530 fileToolBar -> addAction(hgStatAct); 1586 fileToolBar -> addAction(hgRefreshAct);
1531 fileToolBar -> addSeparator(); 1587 fileToolBar -> addSeparator();
1532 // fileToolBar -> addAction(hgChgSetDiffAct); 1588 // fileToolBar -> addAction(hgChgSetDiffAct);
1533 fileToolBar -> setMovable(false); 1589 fileToolBar -> setMovable(false);
1534 1590
1535 repoToolBar = addToolBar(tr(REPOMENU_TITLE)); 1591 repoToolBar = addToolBar(tr(REPOMENU_TITLE));