comparison mainwindow.cpp @ 2:c19a4f858aab

Made annotate/resolvelist/resolvemark enable/disable logic better.
author Jari Korhonen <jtkorhonen@gmail.com>
date Sat, 24 Apr 2010 15:12:12 +0300
parents a9098eba2ee5
children 7189e9994a60
comparison
equal deleted inserted replaced
0:a9098eba2ee5 2:c19a4f858aab
511 hgExp -> clearLists(); 511 hgExp -> clearLists();
512 enableDisableActions(); 512 enableDisableActions();
513 hgStat(); 513 hgStat();
514 } 514 }
515 515
516 void MainWindow::presentLongStdoutToUser(QString stdo, int w, int h) 516 #define STDOUT_NEEDS_BIG_WINDOW 512
517 { 517 #define SMALL_WND_W 500
518 QDialog dlg; 518 #define SMALL_WND_H 300
519 dlg.setMinimumWidth(w); 519
520 dlg.setMinimumHeight(h); 520 #define BIG_WND_W 1024
521 521 #define BIG_WND_H 768
522 QVBoxLayout *box = new QVBoxLayout; 522
523 QListWidget *list = new QListWidget; 523
524 list-> addItems(stdo.split("\n")); 524 void MainWindow::presentLongStdoutToUser(QString stdo)
525 QPushButton *btn = new QPushButton(tr("Ok")); 525 {
526 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept())); 526 if (!stdo.isEmpty())
527 527 {
528 box -> addWidget(list); 528 QDialog dlg;
529 box -> addWidget(btn); 529
530 dlg.setLayout(box); 530 if (stdo.length() > STDOUT_NEEDS_BIG_WINDOW)
531 531 {
532 dlg.exec(); 532 dlg.setMinimumWidth(BIG_WND_W);
533 dlg.setMinimumHeight(BIG_WND_H);
534 }
535 else
536 {
537 dlg.setMinimumWidth(SMALL_WND_W);
538 dlg.setMinimumHeight(SMALL_WND_H);
539 }
540
541 QVBoxLayout *box = new QVBoxLayout;
542 QListWidget *list = new QListWidget;
543 list-> addItems(stdo.split("\n"));
544 QPushButton *btn = new QPushButton(tr("Ok"));
545 connect(btn, SIGNAL(clicked()), &dlg, SLOT(accept()));
546
547 box -> addWidget(list);
548 box -> addWidget(btn);
549 dlg.setLayout(box);
550
551 dlg.exec();
552 }
553 else
554 {
555 QMessageBox::information(this, tr("HgExplorer"), tr("Mercurial command did not return any output."));
556 }
533 } 557 }
534 558
535 559
536 bool MainWindow::isSelectedLocallyDeleted(QListWidget *workList) 560 bool MainWindow::isSelectedLocallyDeleted(QListWidget *workList)
537 { 561 {
642 666
643 case ACT_INCOMING: 667 case ACT_INCOMING:
644 case ACT_ANNOTATE: 668 case ACT_ANNOTATE:
645 case ACT_RESOLVE_LIST: 669 case ACT_RESOLVE_LIST:
646 case ACT_RESOLVE_MARK: 670 case ACT_RESOLVE_MARK:
647 presentLongStdoutToUser(runner -> getStdOut(), 1024, 768); 671 presentLongStdoutToUser(runner -> getStdOut());
648 shouldHgStat = true; 672 shouldHgStat = true;
649 break; 673 break;
650 674
651 case ACT_PULL: 675 case ACT_PULL:
652 QMessageBox::information(this, "pull", runner -> getStdOut()); 676 QMessageBox::information(this, "pull", runner -> getStdOut());
838 hgAddAct -> setEnabled(localRepoActionsEnabled); 862 hgAddAct -> setEnabled(localRepoActionsEnabled);
839 hgRemoveAct -> setEnabled(localRepoActionsEnabled); 863 hgRemoveAct -> setEnabled(localRepoActionsEnabled);
840 hgUpdateAct -> setEnabled(localRepoActionsEnabled); 864 hgUpdateAct -> setEnabled(localRepoActionsEnabled);
841 hgCommitAct -> setEnabled(localRepoActionsEnabled); 865 hgCommitAct -> setEnabled(localRepoActionsEnabled);
842 hgMergeAct -> setEnabled(localRepoActionsEnabled); 866 hgMergeAct -> setEnabled(localRepoActionsEnabled);
867 hgResolveListAct -> setEnabled(localRepoActionsEnabled);
868 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
869 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
843 870
844 hgExp -> enableDisableOtherTabs(); 871 hgExp -> enableDisableOtherTabs();
845 872
846 int a, m, r; 873 int a, m, r;
847 countAMRModifications(hgExp -> workFolderFileList, a, m, r); 874 countAMRModifications(hgExp -> workFolderFileList, a, m, r);
879 if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList)) 906 if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList))
880 { 907 {
881 hgRemoveAct -> setEnabled(false); 908 hgRemoveAct -> setEnabled(false);
882 } 909 }
883 910
911 hgResolveListAct -> setEnabled(true);
912
884 if (hgExp -> localRepoHeadsList->count() == 1) 913 if (hgExp -> localRepoHeadsList->count() == 1)
885 { 914 {
886 hgMergeAct -> setEnabled(false); 915 hgMergeAct -> setEnabled(false);
887 } 916 }
888 917
918 QString currentFile = hgExp -> getCurrentFileListLine();
919 if (!currentFile.isEmpty())
920 {
921 hgAnnotateAct -> setEnabled(true);
922 hgResolveMarkAct -> setEnabled(true);
923 }
924 else
925 {
926 hgAnnotateAct -> setEnabled(false);
927 hgResolveMarkAct -> setEnabled(false);
928 }
889 } 929 }
890 } 930 }
891 else 931 else
892 { 932 {
893 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems(); 933 QList <QListWidgetItem *> headSelList = hgExp -> localRepoHeadsList->selectedItems();