# HG changeset patch # User Chris Cannam # Date 1298286441 0 # Node ID 3fbafca196e403791bddd01a334075e84dcf66e2 # Parent 3b0ff2b96c53e8361a0bb4f6573d17bec4874c03 Move work-folder state area outside tabs widget diff -r 3b0ff2b96c53 -r 3fbafca196e4 filestatuswidget.cpp --- a/filestatuswidget.cpp Mon Feb 21 09:13:33 2011 +0000 +++ b/filestatuswidget.cpp Mon Feb 21 11:07:21 2011 +0000 @@ -18,7 +18,6 @@ #include "filestatuswidget.h" #include "debug.h" #include "multichoicedialog.h" -#include "workstatuswidget.h" #include #include @@ -43,10 +42,6 @@ int row = 0; - m_workStatus = new WorkStatusWidget(this); - layout->addWidget(m_workStatus, row, 0, 1, 3); - ++row; - m_noModificationsLabel = new QLabel; setNoModificationsLabelText(); layout->addWidget(m_noModificationsLabel, row, 1, 1, 2); @@ -362,13 +357,13 @@ QString FileStatusWidget::localPath() const { - return m_workStatus->localPath(); + return m_localPath; } void FileStatusWidget::setLocalPath(QString p) { - m_workStatus->setLocalPath(p); + m_localPath = p; delete m_dateReference; m_dateReference = new QFileInfo(p + "/.hg/dirstate"); if (!m_dateReference->exists() || @@ -383,30 +378,6 @@ } } -QString -FileStatusWidget::remoteURL() const -{ - return m_workStatus->remoteURL(); -} - -void -FileStatusWidget::setRemoteURL(QString r) -{ - m_workStatus->setRemoteURL(r); -} - -QString -FileStatusWidget::state() const -{ - return m_workStatus->state(); -} - -void -FileStatusWidget::setState(QString b) -{ - m_workStatus->setState(b); -} - void FileStatusWidget::setFileStates(FileStates p) { @@ -443,7 +414,7 @@ if (s == FileStates::Unknown) { // We want to highlight untracked files that have appeared // since the last interaction with the repo - QString fn(m_workStatus->localPath() + "/" + file); + QString fn(m_localPath + "/" + file); DEBUG << "comparing with " << fn << endl; QFileInfo fi(fn); if (fi.exists() && fi.created() > lastInteractionTime) { diff -r 3b0ff2b96c53 -r 3fbafca196e4 filestatuswidget.h --- a/filestatuswidget.h Mon Feb 21 09:13:33 2011 +0000 +++ b/filestatuswidget.h Mon Feb 21 11:07:21 2011 +0000 @@ -29,8 +29,6 @@ class QFileInfo; class QCheckBox; -class WorkStatusWidget; - class FileStatusWidget : public QWidget { Q_OBJECT @@ -42,12 +40,6 @@ QString localPath() const; void setLocalPath(QString p); - QString remoteURL() const; - void setRemoteURL(QString u); - - QString state() const; - void setState(QString b); - FileStates fileStates() const; void setFileStates(FileStates sp); @@ -83,8 +75,7 @@ void itemSelectionChanged(); private: - WorkStatusWidget *m_workStatus; - + QString m_localPath; QLabel *m_noModificationsLabel; QCheckBox *m_showAllFiles; diff -r 3b0ff2b96c53 -r 3fbafca196e4 hgtabwidget.cpp --- a/hgtabwidget.cpp Mon Feb 21 09:13:33 2011 +0000 +++ b/hgtabwidget.cpp Mon Feb 21 11:07:21 2011 +0000 @@ -27,14 +27,12 @@ #include HgTabWidget::HgTabWidget(QWidget *parent, - QString remoteRepo, QString workFolderPath) : QTabWidget(parent) { // Work page m_fileStatusWidget = new FileStatusWidget; m_fileStatusWidget->setLocalPath(workFolderPath); - m_fileStatusWidget->setRemoteURL(remoteRepo); connect(m_fileStatusWidget, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); connect(m_fileStatusWidget, SIGNAL(showAllChanged(bool)), @@ -240,15 +238,9 @@ } } -void HgTabWidget::setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath) +void HgTabWidget::setLocalPath(QString workFolderPath) { m_fileStatusWidget->setLocalPath(workFolderPath); - m_fileStatusWidget->setRemoteURL(remoteRepoPath); -} - -void HgTabWidget::setState(QString state) -{ - m_fileStatusWidget->setState(state); } void HgTabWidget::showWorkTab() diff -r 3b0ff2b96c53 -r 3fbafca196e4 hgtabwidget.h --- a/hgtabwidget.h Mon Feb 21 09:13:33 2011 +0000 +++ b/hgtabwidget.h Mon Feb 21 11:07:21 2011 +0000 @@ -38,15 +38,14 @@ Q_OBJECT public: - HgTabWidget(QWidget *parent, QString remoteRepo, QString workFolderPath); + HgTabWidget(QWidget *parent, QString workFolderPath); void updateWorkFolderFileList(QString fileList); void setNewLog(QString hgLogList); void addIncrementalLog(QString hgLogList); - void setWorkFolderAndRepoNames(QString workFolderPath, QString remoteRepoPath); - void setState(QString state); + void setLocalPath(QString workFolderPath); void setCurrent(QStringList ids, QString branch); diff -r 3b0ff2b96c53 -r 3fbafca196e4 mainwindow.cpp --- a/mainwindow.cpp Mon Feb 21 09:13:33 2011 +0000 +++ b/mainwindow.cpp Mon Feb 21 11:07:21 2011 +0000 @@ -44,6 +44,7 @@ #include "incomingdialog.h" #include "settingsdialog.h" #include "version.h" +#include "workstatuswidget.h" MainWindow::MainWindow(QString myDirPath) : @@ -88,20 +89,21 @@ QWidget *central = new QWidget(this); setCentralWidget(central); - m_hgTabs = new HgTabWidget(central, m_remoteRepoPath, m_workFolderPath); - connectTabsSignals(); - - // Instead of setting the tab widget as our central widget - // directly, put it in a layout, so that we can have some space - // around it on the Mac where it looks very strange without - QGridLayout *cl = new QGridLayout(central); - cl->addWidget(m_hgTabs, 0, 0); + int row = 0; #ifndef Q_OS_MAC cl->setMargin(0); #endif + m_workStatus = new WorkStatusWidget(this); + cl->addWidget(m_workStatus, row++, 0); + + m_hgTabs = new HgTabWidget(central, m_workFolderPath); + connectTabsSignals(); + + cl->addWidget(m_hgTabs, row++, 0); + connect(m_hgTabs, SIGNAL(selectionChanged()), this, SLOT(enableDisableActions())); connect(m_hgTabs, SIGNAL(showAllChanged(bool)), @@ -260,7 +262,7 @@ // We have to do this here, because commandCompleted won't be called MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); hgQueryBranch(); return; @@ -815,7 +817,7 @@ params << "clone" << m_remoteRepoPath << m_workFolderPath; - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); m_hgTabs->updateWorkFolderFileList(""); m_runner->requestAction(HgAction(ACT_CLONEFROMREMOTE, m_workFolderPath, params)); @@ -1776,7 +1778,7 @@ } MultiChoiceDialog::addRecentArgument("local", m_workFolderPath); MultiChoiceDialog::addRecentArgument("remote", m_remoteRepoPath); - m_hgTabs->setWorkFolderAndRepoNames(m_workFolderPath, m_remoteRepoPath); + updateWorkFolderAndRepoNames(); break; } @@ -2239,34 +2241,34 @@ if (m_stateUnknown) { if (m_workFolderPath == "") { - m_hgTabs->setState(tr("No repository open")); + m_workStatus->setState(tr("No repository open")); } else { - m_hgTabs->setState(tr("(Examining repository)")); + m_workStatus->setState(tr("(Examining repository)")); } } else if (emptyRepo) { - m_hgTabs->setState(tr("Nothing committed to this repository yet")); + m_workStatus->setState(tr("Nothing committed to this repository yet")); } else if (noWorkingCopy) { - m_hgTabs->setState(tr("No working copy yet: consider updating")); + m_workStatus->setState(tr("No working copy yet: consider updating")); } else if (canMerge) { - m_hgTabs->setState(tr("Awaiting merge on %1").arg(branchText)); + m_workStatus->setState(tr("Awaiting merge on %1").arg(branchText)); } else if (!m_hgTabs->getAllUnresolvedFiles().empty()) { - m_hgTabs->setState(tr("Have unresolved files following merge on %1").arg(branchText)); + m_workStatus->setState(tr("Have unresolved files following merge on %1").arg(branchText)); } else if (haveMerge) { - m_hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText)); + m_workStatus->setState(tr("Have merged but not yet committed on %1").arg(branchText)); } else if (newBranch) { - m_hgTabs->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); + m_workStatus->setState(tr("On %1. New branch: has not yet been committed").arg(branchText)); } else if (canUpdate) { if (m_hgTabs->haveChangesToCommit()) { // have uncommitted changes - m_hgTabs->setState(tr("On %1. Not at the head of the branch").arg(branchText)); + m_workStatus->setState(tr("On %1. Not at the head of the branch").arg(branchText)); } else { // no uncommitted changes - m_hgTabs->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); + m_workStatus->setState(tr("On %1. Not at the head of the branch: consider updating").arg(branchText)); } } else if (m_currentBranchHeads > 1) { - m_hgTabs->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); + m_workStatus->setState(tr("At one of %n heads of %1", "", m_currentBranchHeads).arg(branchText)); } else { - m_hgTabs->setState(tr("At the head of %1").arg(branchText)); + m_workStatus->setState(tr("At the head of %1").arg(branchText)); } } @@ -2413,14 +2415,19 @@ } } +void MainWindow::updateWorkFolderAndRepoNames() +{ + m_hgTabs->setLocalPath(m_workFolderPath); + + m_workStatus->setLocalPath(m_workFolderPath); + m_workStatus->setRemoteURL(m_remoteRepoPath); +} + void MainWindow::createStatusBar() { statusBar()->showMessage(tr("Ready")); } - -//!!! review these: - void MainWindow::readSettings() { QDir workFolder; @@ -2438,12 +2445,10 @@ QSize size = settings.value("size", QSize(400, 400)).toSize(); m_firstStart = settings.value("firststart", QVariant(true)).toBool(); -//!!! initialFileTypesBits = (unsigned char) settings.value("viewFileTypes", QVariant(DEFAULT_HG_STAT_BITS)).toInt(); resize(size); move(pos); } - void MainWindow::writeSettings() { QSettings settings; @@ -2452,7 +2457,6 @@ settings.setValue("remoterepopath", m_remoteRepoPath); settings.setValue("workfolderpath", m_workFolderPath); settings.setValue("firststart", m_firstStart); - //!!!settings.setValue("viewFileTypes", m_hgTabs -> getFileTypesBits()); } diff -r 3b0ff2b96c53 -r 3fbafca196e4 mainwindow.h --- a/mainwindow.h Mon Feb 21 09:13:33 2011 +0000 +++ b/mainwindow.h Mon Feb 21 11:07:21 2011 +0000 @@ -34,6 +34,8 @@ class QTimer; QT_END_NAMESPACE +class WorkStatusWidget; + class MainWindow : public QMainWindow { Q_OBJECT @@ -149,6 +151,9 @@ void suspendFileSystemWatcher(); void restoreFileSystemWatcher(); + void updateWorkFolderAndRepoNames(); + + WorkStatusWidget *m_workStatus; HgTabWidget *m_hgTabs; QString m_remoteRepoPath;