# HG changeset patch # User Chris Cannam # Date 1290638680 0 # Node ID 0bd32aedc6f684ac3bfadbf16ed38c25be018024 # Parent f70ccc15c9d0610ecae572c1ca4b17f98a82ac9d * Start to use the confirm-comment dialog for commits; much work still needed diff -r f70ccc15c9d0 -r 0bd32aedc6f6 confirmcommentdialog.cpp --- 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 = "" + introText; - text += ""; + text += "

Please enter your comment:"; } else { text = "" + 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; diff -r f70ccc15c9d0 -r 0bd32aedc6f6 filestatuswidget.cpp --- 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) { diff -r f70ccc15c9d0 -r 0bd32aedc6f6 filestatuswidget.h --- 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(); diff -r f70ccc15c9d0 -r 0bd32aedc6f6 hgtabwidget.cpp --- 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); diff -r f70ccc15c9d0 -r 0bd32aedc6f6 hgtabwidget.h --- 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(); diff -r f70ccc15c9d0 -r 0bd32aedc6f6 mainwindow.cpp --- 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); diff -r f70ccc15c9d0 -r 0bd32aedc6f6 mainwindow.h --- 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();