comparison mainwindow.cpp @ 11:45c4ac1323b2

Version 0.4.2: Added hg serve. Can commit one file.
author Jari Korhonen <jtkorhonen@gmail.com>
date Sat, 15 May 2010 17:34:23 +0300
parents 81a32fffee8f
children 59e03acf84fd
comparison
equal deleted inserted replaced
10:efb7b1654af4 11:45c4ac1323b2
312 312
313 if (QDialog::Accepted == getCommitComment(comment)) 313 if (QDialog::Accepted == getCommitComment(comment))
314 { 314 {
315 if (!comment.isEmpty()) 315 if (!comment.isEmpty())
316 { 316 {
317 params << "commit" << "--message" << comment << "--user" << userInfo; 317 QString currentFile = hgExp -> getCurrentFileListLine();
318
319 if (isSelectedCommitable(hgExp -> workFolderFileList))
320 {
321 //User wants to commit only one file
322 params << "commit" << "--message" << comment << "--user" << userInfo << currentFile.mid(2);
323 }
324 else
325 {
326 //Commit all changes
327 params << "commit" << "--message" << comment << "--user" << userInfo;
328 }
318 329
319 runner -> startProc(getHgBinaryName(), workFolderPath, params); 330 runner -> startProc(getHgBinaryName(), workFolderPath, params);
320 runningAction = ACT_COMMIT; 331 runningAction = ACT_COMMIT;
321 } 332 }
322 } 333 }
514 525
515 runner -> startProc(getHgBinaryName(), workFolderPath, params); 526 runner -> startProc(getHgBinaryName(), workFolderPath, params);
516 runningAction = ACT_PUSH; 527 runningAction = ACT_PUSH;
517 } 528 }
518 } 529 }
530
531
532 void MainWindow::hgServe()
533 {
534 if (runningAction == ACT_NONE)
535 {
536 QStringList params;
537
538 params << "serve";
539
540 runner -> startProc(getHgBinaryName(), workFolderPath, params, false);
541 runningAction = ACT_SERVE;
542
543 QMessageBox::information(this, "Serve", "Server running", QMessageBox::Close);
544 runner -> killProc();
545 }
546 }
547
519 548
520 549
521 void MainWindow::settings() 550 void MainWindow::settings()
522 { 551 {
523 SettingsDialog *settingsDlg = new SettingsDialog(this); 552 SettingsDialog *settingsDlg = new SettingsDialog(this);
569 { 598 {
570 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output.")); 599 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
571 } 600 }
572 } 601 }
573 602
603
604 bool MainWindow::isSelectedCommitable(QListWidget *workList)
605 {
606 QList<QListWidgetItem *> selList = workList -> selectedItems();
607 if (selList.count() == 1)
608 {
609 QString tmp = selList.at(0)->text().mid(0, 1);
610 if (tmp == "A")
611 {
612 //scheduled to be added, ok to commit
613 return true;
614 }
615 else if (tmp == "M")
616 {
617 //locally modified, ok to commit
618 return true;
619 }
620 }
621 return false;
622 }
574 623
575 bool MainWindow::isSelectedDeletable(QListWidget *workList) 624 bool MainWindow::isSelectedDeletable(QListWidget *workList)
576 { 625 {
577 QList<QListWidgetItem *> selList = workList -> selectedItems(); 626 QList<QListWidgetItem *> selList = workList -> selectedItems();
578 if (selList.count() == 1) 627 if (selList.count() == 1)
756 case ACT_COMMIT: 805 case ACT_COMMIT:
757 case ACT_FILEDIFF: 806 case ACT_FILEDIFF:
758 case ACT_FOLDERDIFF: 807 case ACT_FOLDERDIFF:
759 case ACT_CHGSETDIFF: 808 case ACT_CHGSETDIFF:
760 case ACT_REVERT: 809 case ACT_REVERT:
810 case ACT_SERVE:
761 shouldHgStat = true; 811 shouldHgStat = true;
762 break; 812 break;
763 813
764 case ACT_UPDATE: 814 case ACT_UPDATE:
765 QMessageBox::information(this, "update", runner -> getStdOut()); 815 QMessageBox::information(this, "update", runner -> getStdOut());
838 888
839 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev())); 889 connect(hgUpdateToRevAct, SIGNAL(triggered()), this, SLOT(hgUpdateToRev()));
840 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate())); 890 connect(hgAnnotateAct, SIGNAL(triggered()), this, SLOT(hgAnnotate()));
841 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList())); 891 connect(hgResolveListAct, SIGNAL(triggered()), this, SLOT(hgResolveList()));
842 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark())); 892 connect(hgResolveMarkAct, SIGNAL(triggered()), this, SLOT(hgResolveMark()));
893 connect(hgServeAct, SIGNAL(triggered()), this, SLOT(hgServe()));
843 } 894 }
844 895
845 void MainWindow::tabChanged(int currTab) 896 void MainWindow::tabChanged(int currTab)
846 { 897 {
847 tabPage = currTab; 898 tabPage = currTab;
904 hgCommitAct -> setEnabled(localRepoActionsEnabled); 955 hgCommitAct -> setEnabled(localRepoActionsEnabled);
905 hgMergeAct -> setEnabled(localRepoActionsEnabled); 956 hgMergeAct -> setEnabled(localRepoActionsEnabled);
906 hgResolveListAct -> setEnabled(localRepoActionsEnabled); 957 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
907 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled); 958 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
908 hgAnnotateAct -> setEnabled(localRepoActionsEnabled); 959 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
960 hgServeAct -> setEnabled(localRepoActionsEnabled);
909 961
910 hgExp -> enableDisableOtherTabs(); 962 hgExp -> enableDisableOtherTabs();
911 963
912 int a, m, r, n; 964 int a, m, r, n;
913 countAMRNModifications(hgExp -> workFolderFileList, a, m, r, n); 965 countAMRNModifications(hgExp -> workFolderFileList, a, m, r, n);
1051 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)")); 1103 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
1052 1104
1053 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this); 1105 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this);
1054 hgUpdateAct->setStatusTip(tr("Update working folder from local repository")); 1106 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
1055 1107
1056 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save changes"), this); 1108 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save change(s)"), this);
1057 hgCommitAct->setStatusTip(tr("Save all changes in working folder (and all subfolders) to local repository")); 1109 hgCommitAct->setStatusTip(tr("Save (selected file or all changed files working folder (and all subfolders)) to local repository"));
1058 1110
1059 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this); 1111 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
1060 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder")); 1112 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
1061 1113
1062 //Advanced actions 1114 //Advanced actions
1069 hgResolveListAct = new QAction(tr("Resolve (list)"), this); 1121 hgResolveListAct = new QAction(tr("Resolve (list)"), this);
1070 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge")); 1122 hgResolveListAct -> setStatusTip(tr("Resolve (list): Show list of files needing merge"));
1071 1123
1072 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this); 1124 hgResolveMarkAct = new QAction(tr("Resolve (mark)"), this);
1073 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved")); 1125 hgResolveMarkAct -> setStatusTip(tr("Resolve (mark): Mark selected file status as resolved"));
1126
1127 hgServeAct = new QAction(tr("Serve (via http)"), this);
1128 hgServeAct -> setStatusTip(tr("Serve local repository via http for workgroup access"));
1074 1129
1075 //Help actions 1130 //Help actions
1076 aboutAct = new QAction(tr("About"), this); 1131 aboutAct = new QAction(tr("About"), this);
1077 aboutAct->setStatusTip(tr("Show the application's About box")); 1132 aboutAct->setStatusTip(tr("Show the application's About box"));
1078 1133
1095 advancedMenu -> addSeparator(); 1150 advancedMenu -> addSeparator();
1096 advancedMenu -> addAction(hgAnnotateAct); 1151 advancedMenu -> addAction(hgAnnotateAct);
1097 advancedMenu -> addSeparator(); 1152 advancedMenu -> addSeparator();
1098 advancedMenu -> addAction(hgResolveListAct); 1153 advancedMenu -> addAction(hgResolveListAct);
1099 advancedMenu -> addAction(hgResolveMarkAct); 1154 advancedMenu -> addAction(hgResolveMarkAct);
1155 advancedMenu -> addSeparator();
1156 advancedMenu -> addAction(hgServeAct);
1100 1157
1101 helpMenu = menuBar()->addMenu(tr("Help")); 1158 helpMenu = menuBar()->addMenu(tr("Help"));
1102 helpMenu->addAction(aboutAct); 1159 helpMenu->addAction(aboutAct);
1103 helpMenu->addAction(aboutQtAct); 1160 helpMenu->addAction(aboutQtAct);
1104 } 1161 }