Mercurial > hg > easyhg
changeset 115:78374cefa10f
* Add useful state message to file status page.
Also add shouldBeFast() method to HgAction; use it to avoid showing progress bar for fast actions
author | Chris Cannam |
---|---|
date | Fri, 26 Nov 2010 21:48:25 +0000 |
parents | bb2d2eecdd60 |
children | 807c79350bf1 |
files | filestatuswidget.cpp filestatuswidget.h hgaction.h hgrunner.cpp hgtabwidget.cpp hgtabwidget.h mainwindow.cpp |
diffstat | 7 files changed, 86 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/filestatuswidget.cpp Fri Nov 26 21:17:24 2010 +0000 +++ b/filestatuswidget.cpp Fri Nov 26 21:48:25 2010 +0000 @@ -16,6 +16,8 @@ */ #include "filestatuswidget.h" +#include "debug.h" +#include "multichoicedialog.h" #include <QLabel> #include <QListWidget> @@ -23,8 +25,7 @@ #include <QFileInfo> #include <QApplication> #include <QDateTime> - -#include "debug.h" +#include <QPushButton> FileStatusWidget::FileStatusWidget(QWidget *parent) : QWidget(parent), @@ -35,6 +36,9 @@ int row = 0; + layout->addItem(new QSpacerItem(1, 1), row, 0); + + ++row; layout->addWidget(new QLabel(tr("Local:")), row, 0); m_localPathLabel = new QLabel; QFont f(m_localPathLabel->font()); @@ -48,13 +52,18 @@ layout->addWidget(m_remoteURLLabel, row, 1); ++row; - layout->addWidget(new QLabel(tr("Branch:")), row, 0); - m_branchLabel = new QLabel; - layout->addWidget(m_branchLabel, row, 1); + layout->addWidget(new QLabel(tr("State:")), row, 0); + m_stateLabel = new QLabel; + layout->addWidget(m_stateLabel, row, 1, 1, 2); layout->setColumnStretch(1, 20); - layout->addWidget(new QLabel("<qt><hr></qt>"), ++row, 0, 1, 2); + layout->addWidget(new QLabel("<qt><hr></qt>"), ++row, 0, 1, 3); + + ++row; + m_noModificationsLabel = new QLabel + (tr("You have made no changes.")); + layout->addWidget(m_noModificationsLabel, row, 1, 1, 2); m_simpleLabels[FileStates::Clean] = tr("Unmodified:"); m_simpleLabels[FileStates::Modified] = tr("Modified:"); @@ -99,7 +108,7 @@ connect(w, SIGNAL(itemSelectionChanged()), this, SLOT(itemSelectionChanged())); - layout->addWidget(box, ++row, 0, 1, 2); + layout->addWidget(box, ++row, 0, 1, 3); box->hide(); } @@ -303,10 +312,10 @@ } void -FileStatusWidget::setBranch(QString b) +FileStatusWidget::setState(QString b) { - m_branch = b; - m_branchLabel->setText(b); + m_state = b; + updateStateLabel(); } void @@ -321,6 +330,8 @@ QSet<QString> selectedFiles; foreach (QString f, m_selectedFiles) selectedFiles.insert(f); + bool haveAnything = false; + foreach (FileStates::State s, m_stateListMap.keys()) { QListWidget *w = m_stateListMap[s]; @@ -368,8 +379,17 @@ setLabelFor(w, s, !highPriority.empty()); - w->parentWidget()->setVisible(!files.empty()); + if (files.empty()) { + w->parentWidget()->hide(); + } else { + w->parentWidget()->show(); + haveAnything = true; + } } + + m_noModificationsLabel->setVisible(!haveAnything); + + updateStateLabel(); } void FileStatusWidget::setLabelFor(QWidget *w, FileStates::State s, bool addHighlight) @@ -379,3 +399,8 @@ QList<QLabel *> ql = p->findChildren<QLabel *>(); if (!ql.empty()) ql[0]->setText(text); } + +void FileStatusWidget::updateStateLabel() +{ + m_stateLabel->setText(m_state); +}
--- a/filestatuswidget.h Fri Nov 26 21:17:24 2010 +0000 +++ b/filestatuswidget.h Fri Nov 26 21:48:25 2010 +0000 @@ -24,6 +24,7 @@ class QLabel; class QListWidget; +class QPushButton; class QFileInfo; class FileStatusWidget : public QWidget @@ -40,8 +41,8 @@ QString remoteURL() const { return m_remoteURL; } void setRemoteURL(QString u); - QString branch() const { return m_branch; } - void setBranch(QString b); + QString state() const { return m_state; } + void setState(QString b); FileStates fileStates() const { return m_fileStates; } void setFileStates(FileStates sp); @@ -79,8 +80,10 @@ QString m_remoteURL; QLabel *m_remoteURLLabel; - QString m_branch; - QLabel *m_branchLabel; + QString m_state; + QLabel *m_stateLabel; + + QLabel *m_noModificationsLabel; FileStates m_fileStates; QMap<FileStates::State, QString> m_simpleLabels; @@ -92,6 +95,7 @@ QStringList m_selectedFiles; void updateWidgets(); + void updateStateLabel(); QString labelFor(FileStates::State, bool addHighlightExplanation = false); void setLabelFor(QWidget *w, FileStates::State, bool addHighlightExplanation); };
--- a/hgaction.h Fri Nov 26 21:17:24 2010 +0000 +++ b/hgaction.h Fri Nov 26 21:48:25 2010 +0000 @@ -30,6 +30,7 @@ ACT_QUERY_HEADS, ACT_QUERY_PARENTS, ACT_LOG, + ACT_LOG_INCREMENTAL, ACT_REMOVE, ACT_ADD, ACT_INCOMING, @@ -70,6 +71,21 @@ a.params == params && a.executable == executable); } + bool shouldBeFast() const { + switch (action) { + case ACT_NONE: + case ACT_QUERY_PATHS: + case ACT_QUERY_BRANCH: + case ACT_STAT: + case ACT_QUERY_HEADS: + case ACT_QUERY_PARENTS: + case ACT_LOG_INCREMENTAL: + return true; + default: + return false; + } + } + bool mayBeInteractive() const { switch (action) { case ACT_INCOMING:
--- a/hgrunner.cpp Fri Nov 26 21:17:24 2010 +0000 +++ b/hgrunner.cpp Fri Nov 26 21:48:25 2010 +0000 @@ -308,7 +308,7 @@ m_isRunning = true; setRange(0, 0); - show(); + if (!action.shouldBeFast()) show(); m_stdout.clear(); m_stderr.clear(); m_realm = "";
--- a/hgtabwidget.cpp Fri Nov 26 21:17:24 2010 +0000 +++ b/hgtabwidget.cpp Fri Nov 26 21:48:25 2010 +0000 @@ -185,7 +185,7 @@ fileStatusWidget->setRemoteURL(remoteRepoPath); } -void HgTabWidget::setBranch(QString branch) +void HgTabWidget::setState(QString state) { - fileStatusWidget->setBranch(branch); + fileStatusWidget->setState(state); }
--- a/hgtabwidget.h Fri Nov 26 21:17:24 2010 +0000 +++ b/hgtabwidget.h Fri Nov 26 21:48:25 2010 +0000 @@ -43,7 +43,7 @@ void updateWorkFolderFileList(QString fileList); void updateLocalRepoHgLogList(QString hgLogList); void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath); - void setBranch(QString branch); + void setState(QString state); FileStates getFileStates() { return fileStates; }
--- a/mainwindow.cpp Fri Nov 26 21:17:24 2010 +0000 +++ b/mainwindow.cpp Fri Nov 26 21:48:25 2010 +0000 @@ -176,7 +176,8 @@ void MainWindow::hgLog() { -//!!! This needs to be incremental, except when we pull or set new repo +//!!! This needs to be incremental, except when we pull or set new repo. + // Be sure to use ACT_LOG_INCREMENTAL for incremental logs QStringList params; params << "log"; params << "--template"; @@ -981,8 +982,7 @@ DEBUG << "Added to file system watcher: " << path << endl; QDir d(path); if (d.exists()) { - d.setFilter(QDir::Files | QDir::Dirs | - QDir::NoDotAndDotDot | QDir::Readable); + d.setFilter(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable); foreach (QString entry, d.entryList()) { if (entry == ".hg") continue; QString entryPath = d.absoluteFilePath(entry); @@ -1077,13 +1077,11 @@ MultiChoiceDialog::addRecentArgument("local", workFolderPath); MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath); hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath); - enableDisableActions(); break; } case ACT_QUERY_BRANCH: currentBranch = output.trimmed(); - hgTabs->setBranch(currentBranch); break; case ACT_STAT: @@ -1259,6 +1257,9 @@ { DEBUG << "MainWindow::enableDisableActions" << endl; + //!!! should also do things like set the status texts for the + //!!! actions appropriately by context + QDir localRepoDir; QDir workFolderDir; bool workFolderExist; @@ -1367,6 +1368,22 @@ } hgMergeAct->setEnabled(localRepoActionsEnabled && canMerge); hgUpdateAct->setEnabled(localRepoActionsEnabled && canUpdate); + + // Set the state field on the file status widget + + QString branchText; + if (currentBranch == "" || currentBranch == "default") { + branchText = tr("the default branch"); + } else { + branchText = tr("branch \"%1\"").arg(currentBranch); + } + if (canUpdate) { + hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); + } else if (canMerge) { + hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText)); + } else { + hgTabs->setState(tr("At the head of %1").arg(branchText)); + } } void MainWindow::createActions()