changeset 103:0bd32aedc6f6

* Start to use the confirm-comment dialog for commits; much work still needed
author Chris Cannam
date Wed, 24 Nov 2010 22:44:40 +0000
parents f70ccc15c9d0
children af314dd436d5
files confirmcommentdialog.cpp filestatuswidget.cpp filestatuswidget.h hgtabwidget.cpp hgtabwidget.h mainwindow.cpp mainwindow.h
diffstat 7 files changed, 75 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/confirmcommentdialog.cpp	Wed Nov 24 22:24:55 2010 +0000
+++ b/confirmcommentdialog.cpp	Wed Nov 24 22:44:40 2010 +0000
@@ -55,11 +55,11 @@
     QString text;
     if (files.size() <= 10) {
         text = "<qt>" + introText;
-        text += "<code>";
+        text += "<p><ul>";
         foreach (QString file, files) {
-            text += file + "<br>";
+            text += "<li>" + file + "</li>";
         }
-        text += "</code></qt>";
+        text += "</ul><p>Please enter your comment:</qt>";
     } else {
         text = "<qt>" + introText.arg(files.size());
     }
@@ -72,6 +72,7 @@
                                              QString &comment)
 {
     bool ok = false;
+    //!!! ok, for comments need more than one line
     comment = QInputDialog::getText(parent, title, introText,
                                     QLineEdit::Normal, comment, &ok);
     return ok;
--- a/filestatuswidget.cpp	Wed Nov 24 22:24:55 2010 +0000
+++ b/filestatuswidget.cpp	Wed Nov 24 22:44:40 2010 +0000
@@ -175,6 +175,15 @@
     return files;
 }
 
+QStringList FileStatusWidget::getAllCommittableFiles() const
+{
+    QStringList files;
+    files << m_fileStates.getFilesInState(FileStates::Modified);
+    files << m_fileStates.getFilesInState(FileStates::Added);
+    files << m_fileStates.getFilesInState(FileStates::Removed);
+    return files;
+}
+
 QStringList FileStatusWidget::getSelectedAddableFiles() const
 {
     QStringList files;
@@ -190,6 +199,14 @@
     return files;
 }
 
+QStringList FileStatusWidget::getAllAddableFiles() const
+{
+    QStringList files;
+    files << m_fileStates.getFilesInState(FileStates::Removed);
+    files << m_fileStates.getFilesInState(FileStates::Unknown);
+    return files;
+}
+
 QStringList FileStatusWidget::getSelectedRemovableFiles() const
 {
     QStringList files;
@@ -207,6 +224,16 @@
     return files;
 }
 
+QStringList FileStatusWidget::getAllRemovableFiles() const
+{
+    QStringList files;
+    files << m_fileStates.getFilesInState(FileStates::Clean);
+    files << m_fileStates.getFilesInState(FileStates::Added);
+    files << m_fileStates.getFilesInState(FileStates::Modified);
+    files << m_fileStates.getFilesInState(FileStates::Missing);
+    return files;
+}
+
 void
 FileStatusWidget::setLocalPath(QString p)
 {
--- a/filestatuswidget.h	Wed Nov 24 22:24:55 2010 +0000
+++ b/filestatuswidget.h	Wed Nov 24 22:44:40 2010 +0000
@@ -47,9 +47,15 @@
     bool haveSelection() const;
 
     QStringList getAllSelectedFiles() const;
+
     QStringList getSelectedCommittableFiles() const;
+    QStringList getAllCommittableFiles() const;
+
     QStringList getSelectedAddableFiles() const;
+    QStringList getAllAddableFiles() const;
+
     QStringList getSelectedRemovableFiles() const;
+    QStringList getAllRemovableFiles() const;
 
 signals:
     void selectionChanged();
--- a/hgtabwidget.cpp	Wed Nov 24 22:24:55 2010 +0000
+++ b/hgtabwidget.cpp	Wed Nov 24 22:44:40 2010 +0000
@@ -109,6 +109,21 @@
     return fileStatusWidget->getSelectedRemovableFiles();
 }
 
+QStringList HgTabWidget::getAllCommittableFiles() const
+{
+    return fileStatusWidget->getAllCommittableFiles();
+}
+
+QStringList HgTabWidget::getAllAddableFiles() const
+{
+    return fileStatusWidget->getAllAddableFiles();
+}
+
+QStringList HgTabWidget::getAllRemovableFiles() const
+{
+    return fileStatusWidget->getAllRemovableFiles();
+}
+
 void HgTabWidget::updateWorkFolderFileList(QString fileList)
 {
     fileStates.parseStates(fileList);
--- a/hgtabwidget.h	Wed Nov 24 22:24:55 2010 +0000
+++ b/hgtabwidget.h	Wed Nov 24 22:44:40 2010 +0000
@@ -52,9 +52,15 @@
     bool canDoDiff() const;
 
     QStringList getAllSelectedFiles() const;
+
     QStringList getSelectedCommittableFiles() const;
+    QStringList getAllCommittableFiles() const;
+
     QStringList getSelectedAddableFiles() const;
+    QStringList getAllAddableFiles() const;
+
     QStringList getSelectedRemovableFiles() const;
+    QStringList getAllRemovableFiles() const;
 
 signals:
     void selectionChanged();
--- a/mainwindow.cpp	Wed Nov 24 22:24:55 2010 +0000
+++ b/mainwindow.cpp	Wed Nov 24 22:44:40 2010 +0000
@@ -37,6 +37,7 @@
 #include "colourset.h"
 #include "debug.h"
 #include "logparser.h"
+#include "confirmcommentdialog.h"
 
 
 MainWindow::MainWindow()
@@ -316,17 +317,6 @@
     }
 }
 
-
-bool MainWindow::getCommentOrTag(QString& commentOrTag,
-                                 QString question,
-                                 QString dlgTitle)
-{
-    bool ok = false;
-    QString text = QInputDialog::getText(this, dlgTitle, question, QLineEdit::Normal, commentOrTag, &ok);
-    commentOrTag = text;
-    return ok;
-}
-
 void MainWindow::hgCommit()
 {
     //!!! Now that hg actions can be fired asynchronously (e.g. from
@@ -337,14 +327,20 @@
     {
         QStringList params;
         QString comment;
-        
-        if (getCommentOrTag(comment, tr("Comment:"), tr("Save (commit)")))
-        {
+
+        QStringList files = hgTabs->getSelectedCommittableFiles();
+        if (files.empty()) files = hgTabs->getAllCommittableFiles();
+
+        if (ConfirmCommentDialog::confirmAndComment(this,
+                                                    tr("Commit files"),
+                                                    tr("About to commit the following files:"),
+                                                    tr("About to commit %1 files."),
+                                                    files,
+                                                    comment)) {
+
             //!!! do something more sensible when the comment is empty
             // (i.e. tell the user about it?)
 
-            QStringList files = hgTabs->getSelectedCommittableFiles();
-
             if ((justMerged == false) && //!!! review usage of justMerged
                 !files.empty()) {
                 // User wants to commit selected file(s) (and this is not merge commit, which would fail if we selected files)
@@ -384,9 +380,11 @@
         QStringList params;
         QString tag;
 
-        if (getCommentOrTag(tag, tr("Tag:"), tr("Tag")))
-        {
-            if (!tag.isEmpty())
+        if (ConfirmCommentDialog::confirmAndComment(this,
+                                                    tr("Tag"),
+                                                    tr("Enter tag:"),
+                                                    tag)) {
+            if (!tag.isEmpty()) //!!! do something better if it is empty
             {
                 params << "tag" << "--user" << getUserInfo() << filterTag(tag);
 
--- a/mainwindow.h	Wed Nov 24 22:24:55 2010 +0000
+++ b/mainwindow.h	Wed Nov 24 22:44:40 2010 +0000
@@ -132,7 +132,6 @@
     void createStatusBar();
     void readSettings();
     void splitChangeSets(QStringList *list, QString hgLogOutput);
-    bool getCommentOrTag(QString& commentOrTag, QString question, QString dlgTitle);
     void presentLongStdoutToUser(QString stdo);
 
     QString listAllUpIpV4Addresses();