Mercurial > hg > easyhg
changeset 286:3b0ff2b96c53 status_outside_tabs
Merge from branch "mainwindow_member_tidy"
author | Chris Cannam |
---|---|
date | Mon, 21 Feb 2011 09:13:33 +0000 |
parents | bc39f2e28da8 (diff) a68801b31ceb (current diff) |
children | 3fbafca196e4 |
files | |
diffstat | 5 files changed, 227 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/easyhg.pro Mon Feb 21 09:08:55 2011 +0000 +++ b/easyhg.pro Mon Feb 21 09:13:33 2011 +0000 @@ -49,7 +49,8 @@ incomingdialog.h \ uncommitteditem.h \ settingsdialog.h \ - clickablelabel.h + clickablelabel.h \ + workstatuswidget.h SOURCES = main.cpp \ mainwindow.cpp \ hgtabwidget.cpp \ @@ -79,7 +80,8 @@ changesetscene.cpp \ incomingdialog.cpp \ uncommitteditem.cpp \ - settingsdialog.cpp + settingsdialog.cpp \ + workstatuswidget.cpp macx-* { SOURCES += common_osx.mm
--- a/filestatuswidget.cpp Mon Feb 21 09:08:55 2011 +0000 +++ b/filestatuswidget.cpp Mon Feb 21 09:13:33 2011 +0000 @@ -18,7 +18,7 @@ #include "filestatuswidget.h" #include "debug.h" #include "multichoicedialog.h" -#include "clickablelabel.h" +#include "workstatuswidget.h" #include <QLabel> #include <QListWidget> @@ -43,35 +43,8 @@ int row = 0; -#ifndef Q_OS_MAC - layout->addItem(new QSpacerItem(1, 1), row, 0); - ++row; -#endif - - layout->addWidget(new QLabel(tr("Local:")), row, 0); - - m_openButton = new ClickableLabel; - QFont f(m_openButton->font()); - f.setBold(true); - m_openButton->setFont(f); - m_openButton->setMouseUnderline(true); - connect(m_openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked())); - layout->addWidget(m_openButton, row, 1, 1, 2, Qt::AlignLeft); - - ++row; - layout->addWidget(new QLabel(tr("Remote:")), row, 0); - m_remoteURLLabel = new QLabel; - layout->addWidget(m_remoteURLLabel, row, 1, 1, 2); - - ++row; - 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, 3); - + m_workStatus = new WorkStatusWidget(this); + layout->addWidget(m_workStatus, row, 0, 1, 3); ++row; m_noModificationsLabel = new QLabel; @@ -162,32 +135,6 @@ delete m_dateReference; } -void FileStatusWidget::openButtonClicked() -{ - QDir d(m_localPath); - if (d.exists()) { - QStringList args; - QString path = d.canonicalPath(); -#if defined Q_OS_WIN32 - // Although the Win32 API is quite happy to have - // forward slashes as directory separators, Windows - // Explorer is not - path = path.replace('/', '\\'); - args << path; - QProcess::execute("c:/windows/explorer.exe", args); -#else - args << path; - QProcess::execute( -#if defined Q_OS_MAC - "/usr/bin/open", -#else - "/usr/bin/xdg-open", -#endif - args); -#endif - } -} - QString FileStatusWidget::labelFor(FileStates::State s, bool addHighlightExplanation) { QSettings settings; @@ -412,11 +359,16 @@ return files; } +QString +FileStatusWidget::localPath() const +{ + return m_workStatus->localPath(); +} + void FileStatusWidget::setLocalPath(QString p) { - m_localPath = p; - m_openButton->setText(p); + m_workStatus->setLocalPath(p); delete m_dateReference; m_dateReference = new QFileInfo(p + "/.hg/dirstate"); if (!m_dateReference->exists() || @@ -429,14 +381,30 @@ delete m_dateReference; m_dateReference = 0; } - m_openButton->setEnabled(QDir(m_localPath).exists()); +} + +QString +FileStatusWidget::remoteURL() const +{ + return m_workStatus->remoteURL(); } void FileStatusWidget::setRemoteURL(QString r) { - m_remoteURL = r; - m_remoteURLLabel->setText(r); + m_workStatus->setRemoteURL(r); +} + +QString +FileStatusWidget::state() const +{ + return m_workStatus->state(); +} + +void +FileStatusWidget::setState(QString b) +{ + m_workStatus->setState(b); } void @@ -447,13 +415,6 @@ } void -FileStatusWidget::setState(QString b) -{ - m_state = b; - updateStateLabel(); -} - -void FileStatusWidget::updateWidgets() { QDateTime lastInteractionTime; @@ -482,7 +443,7 @@ if (s == FileStates::Unknown) { // We want to highlight untracked files that have appeared // since the last interaction with the repo - QString fn(m_localPath + "/" + file); + QString fn(m_workStatus->localPath() + "/" + file); DEBUG << "comparing with " << fn << endl; QFileInfo fi(fn); if (fi.exists() && fi.created() > lastInteractionTime) { @@ -530,7 +491,6 @@ layoutBoxesLinearly(); } - updateStateLabel(); setNoModificationsLabelText(); } @@ -594,7 +554,3 @@ if (!ql.empty()) ql[0]->setText(text); } -void FileStatusWidget::updateStateLabel() -{ - m_stateLabel->setText(m_state); -}
--- a/filestatuswidget.h Mon Feb 21 09:08:55 2011 +0000 +++ b/filestatuswidget.h Mon Feb 21 09:13:33 2011 +0000 @@ -27,9 +27,10 @@ class QListWidget; class QPushButton; class QFileInfo; -class ClickableLabel; class QCheckBox; +class WorkStatusWidget; + class FileStatusWidget : public QWidget { Q_OBJECT @@ -38,16 +39,16 @@ FileStatusWidget(QWidget *parent = 0); ~FileStatusWidget(); - QString localPath() const { return m_localPath; } + QString localPath() const; void setLocalPath(QString p); - QString remoteURL() const { return m_remoteURL; } + QString remoteURL() const; void setRemoteURL(QString u); - QString state() const { return m_state; } + QString state() const; void setState(QString b); - FileStates fileStates() const { return m_fileStates; } + FileStates fileStates() const; void setFileStates(FileStates sp); bool haveChangesToCommit() const; @@ -80,17 +81,9 @@ private slots: void itemSelectionChanged(); - void openButtonClicked(); private: - QString m_localPath; - ClickableLabel *m_openButton; - - QString m_remoteURL; - QLabel *m_remoteURLLabel; - - QString m_state; - QLabel *m_stateLabel; + WorkStatusWidget *m_workStatus; QLabel *m_noModificationsLabel; @@ -112,7 +105,6 @@ void layoutBoxesGridly(int count); void layoutBoxesLinearly(); - void updateStateLabel(); void setNoModificationsLabelText(); QString labelFor(FileStates::State, bool addHighlightExplanation = false); void setLabelFor(QWidget *w, FileStates::State, bool addHighlightExplanation);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/workstatuswidget.cpp Mon Feb 21 09:13:33 2011 +0000 @@ -0,0 +1,124 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + EasyMercurial + + Based on HgExplorer by Jari Korhonen + Copyright (c) 2010 Jari Korhonen + Copyright (c) 2011 Chris Cannam + Copyright (c) 2011 Queen Mary, University of London + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#include "workstatuswidget.h" +#include "debug.h" +#include "clickablelabel.h" + +#include <QGridLayout> +#include <QSpacerItem> +#include <QLabel> +#include <QProcess> +#include <QDir> + +WorkStatusWidget::WorkStatusWidget(QWidget *parent) : + QWidget(parent) +{ + QGridLayout *layout = new QGridLayout; + layout->setMargin(10); + setLayout(layout); + + int row = 0; + +#ifndef Q_OS_MAC + layout->addItem(new QSpacerItem(1, 1), row, 0); + ++row; +#endif + + layout->addWidget(new QLabel(tr("Local:")), row, 0); + + m_openButton = new ClickableLabel; + QFont f(m_openButton->font()); + f.setBold(true); + m_openButton->setFont(f); + m_openButton->setMouseUnderline(true); + connect(m_openButton, SIGNAL(clicked()), this, SLOT(openButtonClicked())); + layout->addWidget(m_openButton, row, 1, 1, 2, Qt::AlignLeft); + + ++row; + layout->addWidget(new QLabel(tr("Remote:")), row, 0); + m_remoteURLLabel = new QLabel; + layout->addWidget(m_remoteURLLabel, row, 1, 1, 2); + + ++row; + layout->addWidget(new QLabel(tr("State:")), row, 0); + m_stateLabel = new QLabel; + layout->addWidget(m_stateLabel, row, 1, 1, 2); + + layout->setColumnStretch(1, 20); + + +} + +WorkStatusWidget::~WorkStatusWidget() +{ +} + +void +WorkStatusWidget::setLocalPath(QString p) +{ + m_localPath = p; + m_openButton->setText(p); + m_openButton->setEnabled(QDir(m_localPath).exists()); +} + +void +WorkStatusWidget::setRemoteURL(QString r) +{ + m_remoteURL = r; + m_remoteURLLabel->setText(r); +} + +void +WorkStatusWidget::setState(QString b) +{ + m_state = b; + updateStateLabel(); +} + +void +WorkStatusWidget::updateStateLabel() +{ + m_stateLabel->setText(m_state); +} + +void +WorkStatusWidget::openButtonClicked() +{ + QDir d(m_localPath); + if (d.exists()) { + QStringList args; + QString path = d.canonicalPath(); +#if defined Q_OS_WIN32 + // Although the Win32 API is quite happy to have + // forward slashes as directory separators, Windows + // Explorer is not + path = path.replace('/', '\\'); + args << path; + QProcess::execute("c:/windows/explorer.exe", args); +#else + args << path; + QProcess::execute( +#if defined Q_OS_MAC + "/usr/bin/open", +#else + "/usr/bin/xdg-open", +#endif + args); +#endif + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/workstatuswidget.h Mon Feb 21 09:13:33 2011 +0000 @@ -0,0 +1,62 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + EasyMercurial + + Based on HgExplorer by Jari Korhonen + Copyright (c) 2010 Jari Korhonen + Copyright (c) 2011 Chris Cannam + Copyright (c) 2011 Queen Mary, University of London + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + +#ifndef WORKSTATUSWIDGET_H +#define WORKSTATUSWIDGET_H + +#include <QWidget> + +class QLabel; +class QPushButton; +class QFileInfo; +class ClickableLabel; +class QCheckBox; + +class WorkStatusWidget : public QWidget +{ + Q_OBJECT + +public: + WorkStatusWidget(QWidget *parent = 0); + ~WorkStatusWidget(); + + QString localPath() const { return m_localPath; } + void setLocalPath(QString p); + + QString remoteURL() const { return m_remoteURL; } + void setRemoteURL(QString u); + + QString state() const { return m_state; } + void setState(QString b); + +private slots: + void openButtonClicked(); + +private: + QString m_localPath; + ClickableLabel *m_openButton; + + QString m_remoteURL; + QLabel *m_remoteURLLabel; + + QString m_state; + QLabel *m_stateLabel; + + void updateStateLabel(); +}; + +#endif