comparison mainwindow.cpp @ 5:7189e9994a60

Ver 0.3.8: Fixed confusing add- button. Remove does no backup. Merge- button enable fixed.
author Jari Korhonen <jtkorhonen@gmail.com>
date Fri, 14 May 2010 14:50:07 +0300
parents c19a4f858aab
children 81a32fffee8f
comparison
equal deleted inserted replaced
4:05e11c4ce616 5:7189e9994a60
244 { 244 {
245 if (runningAction == ACT_NONE) 245 if (runningAction == ACT_NONE)
246 { 246 {
247 QStringList params; 247 QStringList params;
248 248
249 params << "add"; 249 QString currentFile = hgExp -> getCurrentFileListLine();
250
251 if (isSelectedUntracked(hgExp -> workFolderFileList))
252 {
253 //User wants to add one file
254 params << "add" << currentFile.mid(2);
255 }
256 else
257 {
258 //Add all untracked files
259 params << "add";
260 }
250 261
251 runner -> startProc(getHgBinaryName(), workFolderPath, params); 262 runner -> startProc(getHgBinaryName(), workFolderPath, params);
252 runningAction = ACT_ADD; 263 runningAction = ACT_ADD;
253 } 264 }
254 } 265 }
410 if (runningAction == ACT_NONE) 421 if (runningAction == ACT_NONE)
411 { 422 {
412 QStringList params; 423 QStringList params;
413 QString currentFile = hgExp -> getCurrentFileListLine(); 424 QString currentFile = hgExp -> getCurrentFileListLine();
414 425
415 params << "revert" << currentFile.mid(2); 426 params << "revert" << "--no-backup" << currentFile.mid(2);
416 427
417 runner -> startProc(getHgBinaryName(), workFolderPath, params); 428 runner -> startProc(getHgBinaryName(), workFolderPath, params);
418 runningAction = ACT_REVERT; 429 runningAction = ACT_REVERT;
419 } 430 }
420 } 431 }
596 } 607 }
597 } 608 }
598 return false; 609 return false;
599 } 610 }
600 611
601 void MainWindow::countAMRModifications(QListWidget *workList, int& a, int& m, int& r) 612 void MainWindow::countAMRNModifications(QListWidget *workList, int& a, int& m, int& r, int& n)
602 { 613 {
603 int itemCount = workList -> count(); 614 int itemCount = workList -> count();
604 if (itemCount > 0) 615 if (itemCount > 0)
605 { 616 {
606 int A= 0; 617 int A= 0;
607 int M=0; 618 int M=0;
608 int R=0; 619 int R=0;
620 int N=0;
609 for (int i = 0; i < workList -> count(); i++) 621 for (int i = 0; i < workList -> count(); i++)
610 { 622 {
611 QListWidgetItem *currItem = workList -> item(i); 623 QListWidgetItem *currItem = workList -> item(i);
612 624
613 QString tmp = currItem->text().mid(0, 1); 625 QString tmp = currItem->text().mid(0, 1);
620 R++; 632 R++;
621 } 633 }
622 else if (tmp == "A") 634 else if (tmp == "A")
623 { 635 {
624 A++; 636 A++;
637 }
638 else if (tmp == "?")
639 {
640 N++;
625 } 641 }
626 } 642 }
627 643
628 a = A; 644 a = A;
629 m = M; 645 m = M;
630 r = R; 646 r = R;
647 n = N;
631 } 648 }
632 else 649 else
633 { 650 {
634 a = 0; 651 a = 0;
635 m = 0; 652 m = 0;
636 r = 0; 653 r = 0;
654 n = 0;
637 } 655 }
638 } 656 }
639 657
640 658
641 void MainWindow::timerEvent(QTimerEvent *) 659 void MainWindow::timerEvent(QTimerEvent *)
868 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled); 886 hgResolveMarkAct -> setEnabled(localRepoActionsEnabled);
869 hgAnnotateAct -> setEnabled(localRepoActionsEnabled); 887 hgAnnotateAct -> setEnabled(localRepoActionsEnabled);
870 888
871 hgExp -> enableDisableOtherTabs(); 889 hgExp -> enableDisableOtherTabs();
872 890
873 int a, m, r; 891 int a, m, r, n;
874 countAMRModifications(hgExp -> workFolderFileList, a, m, r); 892 countAMRNModifications(hgExp -> workFolderFileList, a, m, r, n);
875 893
876 if (tabPage == WORKTAB) 894 if (tabPage == WORKTAB)
877 { 895 {
878 //Enable / disable actions according to workFolderFileList selections / currentSelection / count 896 //Enable / disable actions according to workFolderFileList selections / currentSelection / count
879 hgChgSetDiffAct -> setEnabled(false); 897 hgChgSetDiffAct -> setEnabled(false);
896 { 914 {
897 hgFileDiffAct -> setEnabled(false); 915 hgFileDiffAct -> setEnabled(false);
898 hgRevertAct -> setEnabled(false); 916 hgRevertAct -> setEnabled(false);
899 } 917 }
900 918
901 if (!isSelectedUntracked(hgExp -> workFolderFileList)) 919 //JK 14.5.2010: Fixed confusing add button. Now this is simple: If we have something to add (any non-tracked files), add is enabled.
920 if (n == 0)
902 { 921 {
903 hgAddAct -> setEnabled(false); 922 hgAddAct -> setEnabled(false);
904 } 923 }
905 924
906 if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList)) 925 if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList))
908 hgRemoveAct -> setEnabled(false); 927 hgRemoveAct -> setEnabled(false);
909 } 928 }
910 929
911 hgResolveListAct -> setEnabled(true); 930 hgResolveListAct -> setEnabled(true);
912 931
913 if (hgExp -> localRepoHeadsList->count() == 1) 932 if (hgExp -> localRepoHeadsList->count() < 2)
914 { 933 {
915 hgMergeAct -> setEnabled(false); 934 hgMergeAct -> setEnabled(false);
916 } 935 }
917 936
918 QString currentFile = hgExp -> getCurrentFileListLine(); 937 QString currentFile = hgExp -> getCurrentFileListLine();
1003 1022
1004 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this); 1023 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this);
1005 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)")); 1024 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
1006 1025
1007 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this); 1026 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this);
1008 hgAddAct -> setStatusTip(tr("Add working folder files to local repository (on next commit)")); 1027 hgAddAct -> setStatusTip(tr("Add working folder files (selected one or all yet untracked) to local repository (on next commit)"));
1009 1028
1010 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this); 1029 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this);
1011 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)")); 1030 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
1012 1031
1013 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this); 1032 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this);