diff options
author | Friedemann Kleint <[email protected]> | 2009-08-10 15:46:45 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2009-08-10 15:46:45 +0200 |
commit | 1e64d9f9b25070bdea60dc4b0ae66d969545c732 (patch) | |
tree | e28d5439f1653e0e5346946ad90ca67c6266a3f2 /src/plugins/git | |
parent | 12981d0c6b197d21cefb4936d29dbc10cca28820 (diff) |
Version control: Replace per-VCS output panes with a single one.
...and give it some color and formatting.
Diffstat (limited to 'src/plugins/git')
-rw-r--r-- | src/plugins/git/git.pro | 2 | ||||
-rw-r--r-- | src/plugins/git/gitclient.cpp | 78 | ||||
-rw-r--r-- | src/plugins/git/gitclient.h | 4 | ||||
-rw-r--r-- | src/plugins/git/gitoutputwindow.cpp | 143 | ||||
-rw-r--r-- | src/plugins/git/gitoutputwindow.h | 81 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 32 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.h | 4 |
7 files changed, 34 insertions, 310 deletions
diff --git a/src/plugins/git/git.pro b/src/plugins/git/git.pro index 86556815eb8..fa87f66d3d8 100644 --- a/src/plugins/git/git.pro +++ b/src/plugins/git/git.pro @@ -8,7 +8,6 @@ include(../../plugins/vcsbase/vcsbase.pri) include(../../libs/utils/utils.pri) HEADERS += gitplugin.h \ gitconstants.h \ - gitoutputwindow.h \ gitclient.h \ changeselectiondialog.h \ commitdata.h \ @@ -25,7 +24,6 @@ HEADERS += gitplugin.h \ clonewizard.h \ clonewizardpage.h SOURCES += gitplugin.cpp \ - gitoutputwindow.cpp \ gitclient.cpp \ changeselectiondialog.cpp \ commitdata.cpp \ diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 5c50e52ffdd..4c75d60cd87 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -46,6 +46,7 @@ #include <texteditor/itexteditor.h> #include <utils/qtcassert.h> #include <vcsbase/vcsbaseeditor.h> +#include <vcsbase/vcsbaseoutputwindow.h> #include <QtCore/QRegExp> #include <QtCore/QTemporaryFile> @@ -89,9 +90,8 @@ static inline QString msgParseFilesFailed() // Format a command for the status window static QString formatCommand(const QString &binary, const QStringList &args) { - const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); - //: <timestamp> Executing: <executable> <arguments> - return GitClient::tr("%1 Executing: %2 %3\n").arg(timeStamp, binary, args.join(QString(QLatin1Char(' ')))); + //: Executing: <executable> <arguments> + return GitClient::tr("Executing: %1 %2\n").arg(binary, args.join(QString(QLatin1Char(' ')))); } // ---------------- GitClient @@ -210,20 +210,20 @@ void GitClient::diff(const QString &workingDirectory, if (unstagedFileNames.empty() && stagedFileNames.empty()) { QStringList arguments(commonDiffArgs); arguments << diffArgs; - m_plugin->outputWindow()->append(formatCommand(binary, arguments)); + VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(binary, arguments)); command->addJob(arguments, m_settings.timeout); } else { // Files diff. if (!unstagedFileNames.empty()) { QStringList arguments(commonDiffArgs); arguments << QLatin1String("--") << unstagedFileNames; - m_plugin->outputWindow()->append(formatCommand(binary, arguments)); + VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(binary, arguments)); command->addJob(arguments, m_settings.timeout); } if (!stagedFileNames.empty()) { QStringList arguments(commonDiffArgs); arguments << QLatin1String("--cached") << diffArgs << QLatin1String("--") << stagedFileNames; - m_plugin->outputWindow()->append(formatCommand(binary, arguments)); + VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(binary, arguments)); command->addJob(arguments, m_settings.timeout); } } @@ -360,8 +360,7 @@ bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringLis if (!rc) { const QString errorMessage = tr("Unable to add %n file(s) to %1: %2", 0, files.size()). arg(workingDirectory, QString::fromLocal8Bit(errorText)); - m_plugin->outputWindow()->append(errorMessage); - m_plugin->outputWindow()->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); } return rc; } @@ -371,10 +370,8 @@ bool GitClient::synchronousReset(const QString &workingDirectory, { QString errorMessage; const bool rc = synchronousReset(workingDirectory, files, &errorMessage); - if (!rc) { - m_plugin->outputWindow()->append(errorMessage); - m_plugin->outputWindow()->popup(false); - } + if (!rc) + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); return rc; } @@ -390,8 +387,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory, arguments << QLatin1String("reset") << QLatin1String("HEAD") << QLatin1String("--") << files; const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText); const QString output = QString::fromLocal8Bit(outputText); - m_plugin->outputWindow()->popup(false); - m_plugin->outputWindow()->append(output); + VCSBase::VCSBaseOutputWindow::instance()->append(output); // Note that git exits with 1 even if the operation is successful // Assume real failure if the output does not contain "foo.cpp modified" if (!rc && !output.contains(QLatin1String("modified"))) { @@ -478,12 +474,11 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory, if (Git::Constants::debug) qDebug() << Q_FUNC_INFO << workingDirectory << editor; - GitOutputWindow *outputWindow = m_plugin->outputWindow(); - + VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance(); GitCommand* command = new GitCommand(binary(), workingDirectory, processEnvironment()); if (outputToWindow) { - if (!editor) { // assume that the commands output is the important thing - connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray))); + if (editor) { // assume that the commands output is the important thing + connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendDataSilently(QByteArray))); } else { connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); } @@ -493,7 +488,7 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory, } if (outputWindow) - connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString))); + connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(appendError(QString))); return command; } @@ -504,25 +499,13 @@ void GitClient::executeGit(const QString &workingDirectory, bool outputToWindow, GitCommand::TerminationReportMode tm) { - m_plugin->outputWindow()->append(formatCommand(QLatin1String(Constants::GIT_BINARY), arguments)); + VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(QLatin1String(Constants::GIT_BINARY), arguments)); GitCommand *command = createCommand(workingDirectory, editor, outputToWindow); command->addJob(arguments, m_settings.timeout); command->setTerminationReportMode(tm); command->execute(); } -void GitClient::appendDataAndPopup(const QByteArray &data) -{ - m_plugin->outputWindow()->appendData(data); - m_plugin->outputWindow()->popup(false); -} - -void GitClient::appendAndPopup(const QString &text) -{ - m_plugin->outputWindow()->append(text); - m_plugin->outputWindow()->popup(false); -} - // Return fixed arguments required to run QStringList GitClient::binary() const { @@ -553,7 +536,7 @@ bool GitClient::synchronousGit(const QString &workingDirectory, qDebug() << "synchronousGit" << workingDirectory << arguments; if (logCommandToWindow) - m_plugin->outputWindow()->append(formatCommand(m_binaryPath, arguments)); + VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(m_binaryPath, arguments)); QProcess process; process.setWorkingDirectory(workingDirectory); @@ -602,10 +585,8 @@ GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory) { QString errorMessage; const StashResult sr = ensureStash(workingDirectory, &errorMessage); - if (sr == StashFailed) { - m_plugin->outputWindow()->append(errorMessage); - m_plugin->outputWindow()->popup(); - } + if (sr == StashFailed) + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); return sr; } @@ -810,12 +791,11 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory, QByteArray outputText; QByteArray errorText; const bool rc = synchronousGit(repositoryDirectory, args, &outputText, &errorText); - const QString message = rc ? - tr("Committed %n file(s).\n", 0, checkedFiles.size()) : - tr("Unable to commit %n file(s): %1\n", 0, checkedFiles.size()).arg(QString::fromLocal8Bit(errorText)); - - m_plugin->outputWindow()->append(message); - m_plugin->outputWindow()->popup(false); + if (rc) { + VCSBase::VCSBaseOutputWindow::instance()->append(tr("Committed %n file(s).\n", 0, checkedFiles.size())); + } else { + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Unable to commit %n file(s): %1\n", 0, checkedFiles.size()).arg(QString::fromLocal8Bit(errorText))); + } return rc; } @@ -919,13 +899,11 @@ void GitClient::revert(const QStringList &files) break; case RevertUnchanged: { const QString msg = (isDirectory || files.size() > 1) ? msgNoChangedFiles() : tr("The file is not modified."); - m_plugin->outputWindow()->append(msg); - m_plugin->outputWindow()->popup(); + VCSBase::VCSBaseOutputWindow::instance()->append(msg); } break; case RevertFailed: - m_plugin->outputWindow()->append(errorMessage); - m_plugin->outputWindow()->popup(); + VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage); break; } } @@ -954,12 +932,10 @@ void GitClient::stash(const QString &workingDirectory) executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true); break; case StatusUnchanged: - m_plugin->outputWindow()->append(msgNoChangedFiles()); - m_plugin->outputWindow()->popup(); + VCSBase::VCSBaseOutputWindow::instance()->append(msgNoChangedFiles()); break; case StatusFailed: - m_plugin->outputWindow()->append(errorMessage); - m_plugin->outputWindow()->popup(); + VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage); break; } } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index cfe14269671..6e8eef99b75 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -145,10 +145,6 @@ public: public slots: void show(const QString &source, const QString &id); -private slots: - void appendAndPopup(const QString &text); - void appendDataAndPopup(const QByteArray &data); - private: VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind, QString title, diff --git a/src/plugins/git/gitoutputwindow.cpp b/src/plugins/git/gitoutputwindow.cpp deleted file mode 100644 index b507ebb8adc..00000000000 --- a/src/plugins/git/gitoutputwindow.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation ([email protected]) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** -**************************************************************************/ - -#include "gitoutputwindow.h" - -#include <QtCore/QTextCodec> -#include <QtGui/QKeyEvent> -#include <QtGui/QMouseEvent> -#include <QtGui/QMenu> -#include <QtGui/QAction> -#include <QtGui/QListWidget> - -using namespace Git::Internal; - -GitOutputWindow::GitOutputWindow() - : Core::IOutputPane() -{ - m_outputListWidget = new QListWidget; - m_outputListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_outputListWidget->setFrameStyle(QFrame::NoFrame); - - m_outputListWidget->setWindowTitle(tr("Git Output")); -} - -GitOutputWindow::~GitOutputWindow() -{ - delete m_outputListWidget; -} - -QWidget *GitOutputWindow::outputWidget(QWidget *parent) -{ - m_outputListWidget->setParent(parent); - return m_outputListWidget; -} - -QString GitOutputWindow::name() const -{ - return tr("Git"); -} - -void GitOutputWindow::clearContents() -{ - m_outputListWidget->clear(); -} - -void GitOutputWindow::visibilityChanged(bool b) -{ - if (b) - m_outputListWidget->setFocus(); -} - -bool GitOutputWindow::hasFocus() -{ - return m_outputListWidget->hasFocus(); -} - -bool GitOutputWindow::canFocus() -{ - return false; -} - -void GitOutputWindow::setFocus() -{ -} - -void GitOutputWindow::setText(const QString &text) -{ - clearContents(); - append(text); -} - -void GitOutputWindow::append(const QString &text) -{ - const QStringList lines = text.split(QLatin1Char('\n')); - foreach (const QString &s, lines) - m_outputListWidget->addItem(s); - m_outputListWidget->scrollToBottom(); -} - -void GitOutputWindow::setData(const QByteArray &data) -{ - setText(QTextCodec::codecForLocale()->toUnicode(data)); -} - -void GitOutputWindow::appendData(const QByteArray &data) -{ - append(QTextCodec::codecForLocale()->toUnicode(data)); -} - -int GitOutputWindow::priorityInStatusBar() const -{ - return -1; -} - -bool GitOutputWindow::canNext() -{ - return false; -} - -bool GitOutputWindow::canPrevious() -{ - return false; -} - -void GitOutputWindow::goToNext() -{ -} - -void GitOutputWindow::goToPrev() -{ - -} - -bool GitOutputWindow::canNavigate() -{ - return false; -} diff --git a/src/plugins/git/gitoutputwindow.h b/src/plugins/git/gitoutputwindow.h deleted file mode 100644 index dc6d9d61049..00000000000 --- a/src/plugins/git/gitoutputwindow.h +++ /dev/null @@ -1,81 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation ([email protected]) -** -** Commercial Usage -** -** Licensees holding valid Qt Commercial licenses may use this file in -** accordance with the Qt Commercial License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Nokia. -** -** GNU Lesser General Public License Usage -** -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at http://www.qtsoftware.com/contact. -** -**************************************************************************/ - -#ifndef GITOUTPUTWINDOW_H -#define GITOUTPUTWINDOW_H - -#include <coreplugin/ioutputpane.h> - -#include <QtGui/QAction> -#include <QtGui/QListWidget> -#include <QtGui/QListWidgetItem> - -namespace Git { -namespace Internal { - -class GitOutputWindow : public Core::IOutputPane -{ - Q_OBJECT - -public: - GitOutputWindow(); - ~GitOutputWindow(); - - QWidget *outputWidget(QWidget *parent); - QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); } - - QString name() const; - int priorityInStatusBar() const; - void clearContents(); - void visibilityChanged(bool visible); - - bool canFocus(); - bool hasFocus(); - void setFocus(); - - bool canNext(); - bool canPrevious(); - void goToNext(); - void goToPrev(); - bool canNavigate(); - -public slots: - void setText(const QString &text); - void append(const QString &text); - void setData(const QByteArray &data); - void appendData(const QByteArray &data); - -private: - QListWidget *m_outputListWidget; -}; - -} // namespace Internal -} // namespace Git - -#endif // GITOUTPUTWINDOW_H diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 14e36fcb165..834ce75e1b7 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -54,6 +54,7 @@ #include <vcsbase/basevcseditorfactory.h> #include <vcsbase/vcsbaseeditor.h> #include <vcsbase/basevcssubmiteditorfactory.h> +#include <vcsbase/vcsbaseoutputwindow.h> #include <QtCore/QDebug> #include <QtCore/QDir> @@ -139,7 +140,6 @@ GitPlugin::GitPlugin() : m_branchListAction(0), m_projectExplorer(0), m_gitClient(0), - m_outputWindow(0), m_changeSelectionDialog(0), m_changeTmpFile(0), m_submitActionTriggered(false) @@ -197,10 +197,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) QList<int> globalcontext; globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL); - // Create the output Window - m_outputWindow = new GitOutputWindow(); - addAutoReleasedObject(m_outputWindow); - // Create the settings Page addAutoReleasedObject(new SettingsPage()); @@ -464,8 +460,7 @@ QString GitPlugin::getWorkingDirectory() qDebug() << Q_FUNC_INFO << "file" << workingDirectory; if (workingDirectory.isEmpty()) { - m_outputWindow->append(tr("Could not find working directory")); - m_outputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Could not find working directory")); return QString(); } return workingDirectory; @@ -519,7 +514,7 @@ void GitPlugin::undoFileChanges() QString errorMessage; if (!m_gitClient->synchronousCheckout(workingDirectory, QStringList() << fileName, &errorMessage)) - m_outputWindow->append(errorMessage); + VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage); } @@ -561,8 +556,7 @@ void GitPlugin::startCommit() if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) return; if (m_changeTmpFile) { - m_outputWindow->append(tr("Another submit is currently beeing executed.")); - m_outputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently being executed.")); return; } @@ -575,8 +569,7 @@ void GitPlugin::startCommit() QString errorMessage, commitTemplate; CommitData data; if (!m_gitClient->getCommitData(workingDirectory, &commitTemplate, &data, &errorMessage)) { - m_outputWindow->append(errorMessage); - m_outputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage); return; } @@ -593,8 +586,7 @@ void GitPlugin::startCommit() QTemporaryFile *changeTmpFile = new QTemporaryFile(this); changeTmpFile->setAutoRemove(true); if (!changeTmpFile->open()) { - m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); - m_outputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); delete changeTmpFile; return; } @@ -734,19 +726,14 @@ void GitPlugin::branchList() const QString workingDirectory = getWorkingDirectory(); if (workingDirectory.isEmpty()) return; -#ifndef USE_BRANCHDIALOG QString errorMessage; BranchDialog dialog(m_core->mainWindow()); if (!dialog.init(m_gitClient, workingDirectory, &errorMessage)) { - m_outputWindow->append(errorMessage); - m_outputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); return; } dialog.exec(); -#else - m_gitClient->branchList(workingDirectory); -#endif } void GitPlugin::stashList() @@ -833,11 +820,6 @@ void GitPlugin::showCommit() m_gitClient->show(m_changeSelectionDialog->m_ui.repositoryEdit->text(), change); } -GitOutputWindow *GitPlugin::outputWindow() const -{ - return m_outputWindow; -} - GitSettings GitPlugin::settings() const { return m_gitClient->settings(); diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index d473697cd91..7e9ed981466 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -30,7 +30,6 @@ #ifndef GITPLUGIN_H #define GITPLUGIN_H -#include "gitoutputwindow.h" #include "settingspage.h" #include <coreplugin/editormanager/ieditorfactory.h> @@ -94,8 +93,6 @@ public: QString getWorkingDirectory(); - GitOutputWindow *outputWindow() const; - GitSettings settings() const; void setSettings(const GitSettings &s); @@ -165,7 +162,6 @@ private: ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; GitClient *m_gitClient; - GitOutputWindow *m_outputWindow; ChangeSelectionDialog *m_changeSelectionDialog; QString m_submitRepository; QStringList m_submitOrigCommitFiles; |