diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-08-10 15:46:45 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-08-10 15:46:45 +0200 |
commit | 1e64d9f9b25070bdea60dc4b0ae66d969545c732 (patch) | |
tree | e28d5439f1653e0e5346946ad90ca67c6266a3f2 /src/plugins/perforce | |
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/perforce')
-rw-r--r-- | src/plugins/perforce/perforce.pro | 2 | ||||
-rw-r--r-- | src/plugins/perforce/perforceoutputwindow.cpp | 186 | ||||
-rw-r--r-- | src/plugins/perforce/perforceoutputwindow.h | 90 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.cpp | 100 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.h | 13 |
5 files changed, 23 insertions, 368 deletions
diff --git a/src/plugins/perforce/perforce.pro b/src/plugins/perforce/perforce.pro index 017dda2981..e93e3378d8 100644 --- a/src/plugins/perforce/perforce.pro +++ b/src/plugins/perforce/perforce.pro @@ -6,7 +6,6 @@ include(perforce_dependencies.pri) HEADERS += \ perforceplugin.h \ - perforceoutputwindow.h \ settingspage.h \ perforceeditor.h \ changenumberdialog.h \ @@ -19,7 +18,6 @@ HEADERS += \ perforcesubmiteditorwidget.h SOURCES += perforceplugin.cpp \ - perforceoutputwindow.cpp \ settingspage.cpp \ perforceeditor.cpp \ changenumberdialog.cpp \ diff --git a/src/plugins/perforce/perforceoutputwindow.cpp b/src/plugins/perforce/perforceoutputwindow.cpp deleted file mode 100644 index 3d363710f0..0000000000 --- a/src/plugins/perforce/perforceoutputwindow.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 "perforceoutputwindow.h" -#include "perforceplugin.h" - -#include <QtGui/QKeyEvent> -#include <QtGui/QMouseEvent> -#include <QtGui/QMenu> -#include <QtGui/QAction> -#include <QtGui/QListWidget> - -using namespace Perforce::Internal; - -PerforceOutputWindow::PerforceOutputWindow(PerforcePlugin *p4Plugin) - : m_p4Plugin(p4Plugin) -{ - m_outputListWidget = new QListWidget; - m_outputListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_outputListWidget->setFrameStyle(QFrame::NoFrame); - - m_outputListWidget->setWindowTitle(tr("Perforce Output")); - - m_diffAction = new QAction(tr("Diff"), this); - connect(m_diffAction, SIGNAL(triggered()), this, SLOT(diff())); - - connect(m_outputListWidget, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(openFiles())); -} - -PerforceOutputWindow::~PerforceOutputWindow() -{ - delete m_outputListWidget; -} - -bool PerforceOutputWindow::hasFocus() -{ - return m_outputListWidget->hasFocus(); -} - -bool PerforceOutputWindow::canFocus() -{ - return false; -} - -void PerforceOutputWindow::setFocus() -{ -} - -QWidget *PerforceOutputWindow::outputWidget(QWidget *parent) -{ - m_outputListWidget->setParent(parent); - return m_outputListWidget; -} - -QString PerforceOutputWindow::name() const -{ - return tr("Perforce"); -} - -void PerforceOutputWindow::clearContents() -{ - m_outputListWidget->clear(); -} - -void PerforceOutputWindow::visibilityChanged(bool /* b */) -{ -} - -void PerforceOutputWindow::append(const QString &txt, bool doPopup) -{ - const QStringList lines = txt.split(QLatin1Char('\n')); - foreach (const QString &s, lines) - m_outputListWidget->addItem(s); - m_outputListWidget->scrollToBottom(); - if (doPopup) - popup(); -} - -void PerforceOutputWindow::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu *menu = new QMenu(m_outputListWidget); - menu->addAction(m_diffAction); - menu->exec(event->globalPos()); - delete menu; -} - -void PerforceOutputWindow::diff() -{ - QStringList files; - foreach (QListWidgetItem *i, m_outputListWidget->selectedItems()) { - if (m_outputListWidget->row(i) > 0) - files.append(getFileName(i)); - } - if (files.count() == 0 && m_outputListWidget->row(m_outputListWidget->currentItem()) > 0) - files.append(getFileName(m_outputListWidget->currentItem())); - - m_p4Plugin->p4Diff(files); -} - -QString PerforceOutputWindow::getFileName(const QListWidgetItem *item) -{ - QString fileName; - if (!item || item->text().isEmpty()) - return fileName; - - QString line = item->text(); - QRegExp regExp("(/.+)#\\d+\\s-\\s(.+)$"); - regExp.setMinimal(true); - if (regExp.indexIn(line) > -1 && regExp.numCaptures() >= 1) { - fileName = regExp.cap(1); - QString description; - if (regExp.numCaptures() >= 2) - description = regExp.cap(2); - } - return fileName; -} - -void PerforceOutputWindow::openFiles() -{ - QStringList files; - foreach (QListWidgetItem *i, m_outputListWidget->selectedItems()) { - if (m_outputListWidget->row(i) > 0) - files.append(getFileName(i)); - } - if (files.count() == 0 && m_outputListWidget->row(m_outputListWidget->currentItem()) > 0) - files.append(getFileName(m_outputListWidget->currentItem())); - - m_p4Plugin->openFiles(files); -} - -int PerforceOutputWindow::priorityInStatusBar() const -{ - return -1; -} - -bool PerforceOutputWindow::canNext() -{ - return false; -} - -bool PerforceOutputWindow::canPrevious() -{ - return false; -} - -void PerforceOutputWindow::goToNext() -{ - -} - -void PerforceOutputWindow::goToPrev() -{ - -} - -bool PerforceOutputWindow::canNavigate() -{ - return false; -} diff --git a/src/plugins/perforce/perforceoutputwindow.h b/src/plugins/perforce/perforceoutputwindow.h deleted file mode 100644 index fb610b91cf..0000000000 --- a/src/plugins/perforce/perforceoutputwindow.h +++ /dev/null @@ -1,90 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** 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 PERFORCEOUTPUTWINDOW_H -#define PERFORCEOUTPUTWINDOW_H - -#include <coreplugin/ioutputpane.h> - -#include <QtGui/QAction> -#include <QtGui/QListWidget> -#include <QtGui/QListWidgetItem> - -namespace Perforce { -namespace Internal { - -class PerforcePlugin; - -class PerforceOutputWindow : public Core::IOutputPane -{ - Q_OBJECT - -public: - PerforceOutputWindow(PerforcePlugin *p4Plugin); - ~PerforceOutputWindow(); - - 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 append(const QString &txt, bool doPopup = false); - -private slots: - void diff(); - void openFiles(); - -private: - void contextMenuEvent(QContextMenuEvent *event); - - static QString getFileName(const QListWidgetItem *item); - - PerforcePlugin *m_p4Plugin; - QListWidget *m_outputListWidget; - QAction *m_diffAction; -}; - -} // namespace Perforce -} // namespace Internal - -#endif // PERFORCEOUTPUTWINDOW_H diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 4dfb5ea508..ff28c6a049 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -33,7 +33,6 @@ #include "pendingchangesdialog.h" #include "perforceconstants.h" #include "perforceeditor.h" -#include "perforceoutputwindow.h" #include "perforcesubmiteditor.h" #include "perforceversioncontrol.h" #include "settingspage.h" @@ -52,6 +51,7 @@ #include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/vcsbaseeditor.h> +#include <vcsbase/vcsbaseoutputwindow.h> #include <QtCore/QtPlugin> #include <QtCore/QDebug> @@ -166,8 +166,6 @@ bool CoreListener::editorAboutToClose(Core::IEditor *editor) PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL; PerforcePlugin::PerforcePlugin() : - m_perforceOutputWindow(0), - m_settingsPage(0), m_editAction(0), m_addAction(0), m_deleteAction(0), @@ -192,8 +190,6 @@ PerforcePlugin::PerforcePlugin() : m_undoAction(0), m_redoAction(0), m_changeTmpFile(0), - m_coreListener(0), - m_submitEditorFactory(0), m_versionControl(0) { } @@ -220,28 +216,20 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess if (QSettings *settings = core->settings()) m_settings.fromSettings(settings); - m_perforceOutputWindow = new PerforceOutputWindow(this); - addObject(m_perforceOutputWindow); - - m_settingsPage = new SettingsPage; - addObject(m_settingsPage); + addAutoReleasedObject(new SettingsPage); // Editor factories - m_submitEditorFactory = new PerforceSubmitEditorFactory(&submitParameters); - addObject(m_submitEditorFactory); + addAutoReleasedObject(new PerforceSubmitEditorFactory(&submitParameters)); static const char *describeSlot = SLOT(describe(QString,QString)); const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters); - for (int i = 0; i < editorCount; i++) { - m_editorFactories.push_back(new PerforceEditorFactory(editorParameters + i, this, describeSlot)); - addObject(m_editorFactories.back()); - } + for (int i = 0; i < editorCount; i++) + addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot)); m_versionControl = new PerforceVersionControl(this); - addObject(m_versionControl); + addAutoReleasedObject(m_versionControl); - m_coreListener = new CoreListener(this); - addObject(m_coreListener); + addAutoReleasedObject(new CoreListener(this)); //register actions Core::ActionManager *am = Core::ICore::instance()->actionManager(); @@ -555,19 +543,18 @@ void PerforcePlugin::submit() QString errorMessage; if (!checkP4Configuration(&errorMessage)) { - showOutput(errorMessage, true); + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); return; } if (m_changeTmpFile) { - showOutput(tr("Another submit is currently executed."), true); - m_perforceOutputWindow->popup(false); + VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently executed.")); return; } m_changeTmpFile = new QTemporaryFile(this); if (!m_changeTmpFile->open()) { - showOutput(tr("Cannot create temporary file."), true); + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file.")); cleanChangeTmpFile(); return; } @@ -599,7 +586,7 @@ void PerforcePlugin::submit() depotFileNames.append(line.mid(14)); } if (depotFileNames.isEmpty()) { - showOutput(tr("Project has no files")); + VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Project has no files")); cleanChangeTmpFile(); return; } @@ -804,8 +791,9 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, qDebug() << "PerforcePlugin::runP4Cmd" << args << extraArgs << debugCodec(outputCodec); PerforceResponse response; response.error = true; + VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance(); if (!checkP4Configuration(&response.message)) { - m_perforceOutputWindow->append(response.message, true); + outputWindow->appendError(response.message); return response; } @@ -832,9 +820,8 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, QString command = m_settings.p4Command(); command += blank; command += actualArgs.join(QString(blank)); - const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); - const QString outputText = tr("%1 Executing: %2\n").arg(timeStamp, command); - showOutput(outputText, false); + const QString outputText = tr("Executing: %1\n").arg(command); + outputWindow->appendCommand(outputText); } // Run, connect stderr to the output window @@ -846,13 +833,13 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, // connect stderr to the output window if desired if (logFlags & StdErrToWindow) { process.setStdErrBufferedSignalsEnabled(true); - connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool))); + connect(&process, SIGNAL(stdErrBuffered(QString,bool)), outputWindow, SLOT(append(QString))); } // connect stdout to the output window if desired if (logFlags & StdOutToWindow) { process.setStdOutBufferedSignalsEnabled(true); - connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool))); + connect(&process, SIGNAL(stdOutBuffered(QString,bool)), outputWindow, SLOT(append(QString))); } const Core::Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4Command(), actualArgs); @@ -883,7 +870,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, if (Perforce::Constants::debug) qDebug() << response.message; if (logFlags & ErrorToWindow) - m_perforceOutputWindow->append(response.message, true); + outputWindow->appendError(response.message); } return response; } @@ -1043,7 +1030,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) QByteArray change = m_changeTmpFile->readAll(); QString errorMessage; if (!checkP4Configuration(&errorMessage)) { - showOutput(errorMessage, true); + VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage); return false; } @@ -1054,7 +1041,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) proc.start(m_settings.p4Command(), m_settings.basicP4Args() << QLatin1String("submit") << QLatin1String("-i")); if (!proc.waitForStarted(p4Timeout)) { - showOutput(tr("Cannot execute p4 submit."), true); + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot execute p4 submit.")); QApplication::restoreOverrideCursor(); return false; } @@ -1062,12 +1049,12 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor) proc.closeWriteChannel(); if (!proc.waitForFinished()) { - showOutput(tr("Cannot execute p4 submit."), true); + VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot execute p4 submit.")); QApplication::restoreOverrideCursor(); return false; } - const QString output = QString::fromUtf8(proc.readAll()); - showOutput(output); + const QString output = QString::fromLocal8Bit(proc.readAll()); + VCSBase::VCSBaseOutputWindow::instance()->append(output); if (output.contains(QLatin1String("Out of date files must be resolved or reverted)"))) { QMessageBox::warning(editor->widget(), tr("Pending change"), tr("Could not submit the change, because your workspace was out of date. Created a pending submit instead.")); } @@ -1161,49 +1148,8 @@ QString PerforcePlugin::pendingChangesData() return data; } -void PerforcePlugin::showOutput(const QString &output, bool popup) const -{ - m_perforceOutputWindow->append(output, popup); -} - PerforcePlugin::~PerforcePlugin() { - if (m_settingsPage) { - removeObject(m_settingsPage); - delete m_settingsPage; - m_settingsPage = 0; - } - - if (m_perforceOutputWindow) { - removeObject(m_perforceOutputWindow); - delete m_perforceOutputWindow; - m_perforceOutputWindow = 0; - } - - if (m_submitEditorFactory) { - removeObject(m_submitEditorFactory); - delete m_submitEditorFactory; - m_submitEditorFactory = 0; - } - - if (m_versionControl) { - removeObject(m_versionControl); - delete m_versionControl; - m_versionControl = 0; - } - - if (!m_editorFactories.empty()) { - foreach (Core::IEditorFactory *pf, m_editorFactories) - removeObject(pf); - qDeleteAll(m_editorFactories); - m_editorFactories.clear(); - } - - if (m_coreListener) { - removeObject(m_coreListener); - delete m_coreListener; - m_coreListener = 0; - } } const PerforceSettings& PerforcePlugin::settings() const diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index 423b352e3f..6f2645c782 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -50,7 +50,6 @@ class QTextCodec; QT_END_NAMESPACE namespace Core { - class IEditorFactory; namespace Utils { class ParameterAction; } @@ -59,8 +58,6 @@ namespace Core { namespace Perforce { namespace Internal { -class PerforceOutputWindow; -class SettingsPage; class PerforceVersionControl; class PerforcePlugin; @@ -92,8 +89,6 @@ public: PerforcePlugin(); ~PerforcePlugin(); - SettingsPage *settingsPage() const { return m_settingsPage; } - bool initialize(const QStringList &arguments, QString *error_message); void extensionsInitialized(); @@ -165,16 +160,12 @@ private: QString clientFilePath(const QString &serverFilePath); QString currentFileName(); bool checkP4Configuration(QString *errorMessage = 0) const; - void showOutput(const QString &output, bool popup = false) const; void annotate(const QString &fileName); void filelog(const QString &fileName); void cleanChangeTmpFile(); void updateCheckout(const QStringList &dirs = QStringList()); ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; - PerforceOutputWindow *m_perforceOutputWindow; - SettingsPage *m_settingsPage; - QList<Core::IEditorFactory*> m_editorFactories; Core::Utils::ParameterAction *m_editAction; Core::Utils::ParameterAction *m_addAction; @@ -206,12 +197,8 @@ private: static PerforcePlugin *m_perforcePluginInstance; QString pendingChangesData(); - CoreListener *m_coreListener; - Core::IEditorFactory *m_submitEditorFactory; PerforceVersionControl *m_versionControl; PerforceSettings m_settings; - - friend class PerforceOutputWindow; // needs openFiles() }; } // namespace Perforce |