changeset 361:4cd753e083cc feature_91b

Add Rename and Copy to right-button menu on file status widget. (This is the real feature 91 -- I bungled the feature number with the earlier feature_91 branch, which actually addressed feature 106.)
author Chris Cannam
date Thu, 17 Mar 2011 17:34:23 +0000
parents ea6f76c0aa76
children 73fb5ef55744
files filestates.cpp filestates.h filestatuswidget.cpp filestatuswidget.h hgaction.h hgtabwidget.cpp hgtabwidget.h mainwindow.cpp mainwindow.h
diffstat 9 files changed, 88 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/filestates.cpp	Thu Mar 17 13:52:57 2011 +0000
+++ b/filestates.cpp	Thu Mar 17 17:34:23 2011 +0000
@@ -144,11 +144,11 @@
     switch (s) {
 
     case Modified:
-        a << Annotate << Diff << Commit << Revert << Remove;
+        a << Annotate << Diff << Commit << Revert << Rename << Copy << Remove;
         break;
 
     case Added:
-        a << Commit << Revert << Remove;
+        a << Commit << Revert << Rename << Copy << Remove;
         break;
         
     case Removed:
@@ -168,7 +168,7 @@
         break;
 
     case Clean:
-        a << Annotate << Remove;
+        a << Annotate << Rename << Copy << Remove;
         break;
 
     case Ignored:
@@ -189,9 +189,10 @@
     switch (a) {
     case Annotate: case Diff: return 0;
     case Commit: case Revert: return 1;
-    case Add: case Remove: return 2;
-    case RedoMerge: case MarkResolved: return 3;
-    case Ignore: case UnIgnore: return 4;
+    case Rename: case Copy: return 2;
+    case Add: case Remove: return 3;
+    case RedoMerge: case MarkResolved: return 4;
+    case Ignore: case UnIgnore: return 5;
     }
     return 0;
 }
--- a/filestates.h	Thu Mar 17 13:52:57 2011 +0000
+++ b/filestates.h	Thu Mar 17 17:34:23 2011 +0000
@@ -62,6 +62,9 @@
         Commit,
         Revert,
 
+        Rename,
+        Copy,
+
         Add,
         Remove,
 
--- a/filestatuswidget.cpp	Thu Mar 17 13:52:57 2011 +0000
+++ b/filestatuswidget.cpp	Thu Mar 17 17:34:23 2011 +0000
@@ -61,6 +61,8 @@
     m_actionLabels[FileStates::Diff] = tr("Diff to parent");
     m_actionLabels[FileStates::Commit] = tr("Commit...");
     m_actionLabels[FileStates::Revert] = tr("Revert to last committed state");
+    m_actionLabels[FileStates::Rename] = tr("Rename...");
+    m_actionLabels[FileStates::Copy] = tr("Copy...");
     m_actionLabels[FileStates::Add] = tr("Add to version control");
     m_actionLabels[FileStates::Remove] = tr("Remove from version control");
     m_actionLabels[FileStates::RedoMerge] = tr("Redo merge");
@@ -239,6 +241,8 @@
     case FileStates::Diff: emit diffFiles(files); break;
     case FileStates::Commit: emit commitFiles(files); break;
     case FileStates::Revert: emit revertFiles(files); break;
+    case FileStates::Rename: emit renameFiles(files); break;
+    case FileStates::Copy: emit copyFiles(files); break;
     case FileStates::Add: emit addFiles(files); break;
     case FileStates::Remove: emit removeFiles(files); break;
     case FileStates::RedoMerge: emit redoFileMerges(files); break;
--- a/filestatuswidget.h	Thu Mar 17 13:52:57 2011 +0000
+++ b/filestatuswidget.h	Thu Mar 17 17:34:23 2011 +0000
@@ -62,6 +62,8 @@
     void diffFiles(QStringList);
     void commitFiles(QStringList);
     void revertFiles(QStringList);
+    void renameFiles(QStringList);
+    void copyFiles(QStringList);
     void addFiles(QStringList);
     void removeFiles(QStringList);
     void redoFileMerges(QStringList);
--- a/hgaction.h	Thu Mar 17 13:52:57 2011 +0000
+++ b/hgaction.h	Thu Mar 17 17:34:23 2011 +0000
@@ -56,6 +56,8 @@
     ACT_TAG,
     ACT_NEW_BRANCH,
     ACT_HG_IGNORE,
+    ACT_COPY_FILE,
+    ACT_RENAME_FILE
 };
 
 struct HgAction
--- a/hgtabwidget.cpp	Thu Mar 17 13:52:57 2011 +0000
+++ b/hgtabwidget.cpp	Thu Mar 17 17:34:23 2011 +0000
@@ -52,6 +52,12 @@
     connect(m_fileStatusWidget, SIGNAL(revertFiles(QStringList)),
             this, SIGNAL(revertFiles(QStringList)));
 
+    connect(m_fileStatusWidget, SIGNAL(renameFiles(QStringList)),
+            this, SIGNAL(renameFiles(QStringList)));
+
+    connect(m_fileStatusWidget, SIGNAL(copyFiles(QStringList)),
+            this, SIGNAL(copyFiles(QStringList)));
+
     connect(m_fileStatusWidget, SIGNAL(addFiles(QStringList)),
             this, SIGNAL(addFiles(QStringList)));
 
--- a/hgtabwidget.h	Thu Mar 17 13:52:57 2011 +0000
+++ b/hgtabwidget.h	Thu Mar 17 17:34:23 2011 +0000
@@ -92,6 +92,8 @@
     void diffFiles(QStringList);
     void commitFiles(QStringList);
     void revertFiles(QStringList);
+    void renameFiles(QStringList);
+    void copyFiles(QStringList);
     void addFiles(QStringList);
     void removeFiles(QStringList);
     void redoFileMerges(QStringList);
--- a/mainwindow.cpp	Thu Mar 17 13:52:57 2011 +0000
+++ b/mainwindow.cpp	Thu Mar 17 17:34:23 2011 +0000
@@ -781,6 +781,60 @@
 }
 
 
+void MainWindow::hgRenameFiles(QStringList files)
+{
+    QString renameTo;
+
+    QString file;
+    if (files.empty()) return;
+    file = files[0];
+
+    if (ConfirmCommentDialog::confirmAndGetShortComment
+        (this,
+         tr("Rename"),
+         tr("Rename <code>%1</code> to:").arg(xmlEncode(file)),
+         renameTo,
+         tr("Rename"))) {
+        
+        if (renameTo != "" && renameTo != file) {
+
+            QStringList params;
+
+            params << "rename" << "--" << file << renameTo;
+
+            m_runner->requestAction(HgAction(ACT_RENAME_FILE, m_workFolderPath, params));
+        }
+    }
+}
+
+
+void MainWindow::hgCopyFiles(QStringList files)
+{
+    QString copyTo;
+
+    QString file;
+    if (files.empty()) return;
+    file = files[0];
+
+    if (ConfirmCommentDialog::confirmAndGetShortComment
+        (this,
+         tr("Copy"),
+         tr("Copy <code>%1</code> to:").arg(xmlEncode(file)),
+         copyTo,
+         tr("Copy"))) {
+        
+        if (copyTo != "" && copyTo != file) {
+
+            QStringList params;
+
+            params << "copy" << "--" << file << copyTo;
+
+            m_runner->requestAction(HgAction(ACT_COPY_FILE, m_workFolderPath, params));
+        }
+    }
+}
+
+
 void MainWindow::hgMarkFilesResolved(QStringList files)
 {
     QStringList params;
@@ -2302,6 +2356,12 @@
     connect(m_hgTabs, SIGNAL(revertFiles(QStringList)),
             this, SLOT(hgRevertFiles(QStringList)));
 
+    connect(m_hgTabs, SIGNAL(renameFiles(QStringList)),
+            this, SLOT(hgRenameFiles(QStringList)));
+
+    connect(m_hgTabs, SIGNAL(copyFiles(QStringList)),
+            this, SLOT(hgCopyFiles(QStringList)));
+
     connect(m_hgTabs, SIGNAL(addFiles(QStringList)),
             this, SLOT(hgAddFiles(QStringList)));
 
--- a/mainwindow.h	Thu Mar 17 13:52:57 2011 +0000
+++ b/mainwindow.h	Thu Mar 17 17:34:23 2011 +0000
@@ -97,6 +97,8 @@
     void hgDiffFiles(QStringList);
     void hgCommitFiles(QStringList);
     void hgRevertFiles(QStringList);
+    void hgRenameFiles(QStringList);
+    void hgCopyFiles(QStringList);
     void hgAddFiles(QStringList);
     void hgRemoveFiles(QStringList);
     void hgRedoFileMerges(QStringList);