Version control: Replace per-VCS output panes with a single one.

...and give it some color and formatting.
This commit is contained in:
Friedemann Kleint
2009-08-10 15:46:45 +02:00
parent 12981d0c6b
commit 1e64d9f9b2
26 changed files with 490 additions and 1161 deletions

View File

@@ -11,7 +11,6 @@ include(../../libs/utils/utils.pri)
HEADERS += annotationhighlighter.h \ HEADERS += annotationhighlighter.h \
cvsplugin.h \ cvsplugin.h \
cvscontrol.h \ cvscontrol.h \
cvsoutputwindow.h \
settingspage.h \ settingspage.h \
cvseditor.h \ cvseditor.h \
cvssubmiteditor.h \ cvssubmiteditor.h \
@@ -24,7 +23,6 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \ SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \ cvsplugin.cpp \
cvscontrol.cpp \ cvscontrol.cpp \
cvsoutputwindow.cpp \
settingspage.cpp \ settingspage.cpp \
cvseditor.cpp \ cvseditor.cpp \
cvssubmiteditor.cpp \ cvssubmiteditor.cpp \

View File

@@ -1,127 +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 "cvsoutputwindow.h"
#include "cvsplugin.h"
#include <QtGui/QListWidget>
#include <QtCore/QDebug>
using namespace CVS::Internal;
CVSOutputWindow::CVSOutputWindow(CVSPlugin *cvsPlugin)
: m_cvsPlugin(cvsPlugin)
{
m_outputListWidget = new QListWidget;
m_outputListWidget->setFrameStyle(QFrame::NoFrame);
m_outputListWidget->setWindowTitle(tr("CVS Output"));
m_outputListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
CVSOutputWindow::~CVSOutputWindow()
{
delete m_outputListWidget;
}
QWidget *CVSOutputWindow::outputWidget(QWidget *parent)
{
m_outputListWidget->setParent(parent);
return m_outputListWidget;
}
QString CVSOutputWindow::name() const
{
return tr("CVS");
}
void CVSOutputWindow::clearContents()
{
m_outputListWidget->clear();
}
int CVSOutputWindow::priorityInStatusBar() const
{
return -1;
}
void CVSOutputWindow::visibilityChanged(bool b)
{
if (b)
m_outputListWidget->setFocus();
}
void CVSOutputWindow::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();
}
bool CVSOutputWindow::canFocus()
{
return false;
}
bool CVSOutputWindow::hasFocus()
{
return m_outputListWidget->hasFocus();
}
void CVSOutputWindow::setFocus()
{
}
bool CVSOutputWindow::canNext()
{
return false;
}
bool CVSOutputWindow::canPrevious()
{
return false;
}
void CVSOutputWindow::goToNext()
{
}
void CVSOutputWindow::goToPrev()
{
}
bool CVSOutputWindow::canNavigate()
{
return false;
}

View File

@@ -1,84 +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 CVSOUTPUTWINDOW_H
#define CVSOUTPUTWINDOW_H
#include <coreplugin/ioutputpane.h>
QT_BEGIN_NAMESPACE
class QListWidget;
QT_END_NAMESPACE
namespace CVS {
namespace Internal {
class CVSPlugin;
class CVSOutputWindow : public Core::IOutputPane
{
Q_OBJECT
public:
CVSOutputWindow(CVSPlugin *cvsPlugin);
~CVSOutputWindow();
QWidget *outputWidget(QWidget *parent);
QList<QWidget*> toolBarWidgets() const {
return QList<QWidget *>();
}
QString name() const;
void clearContents();
int priorityInStatusBar() const;
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 popup = false);
private:
CVSPlugin *m_cvsPlugin;
QListWidget *m_outputListWidget;
};
} // namespace CVS
} // namespace Internal
#endif // CVSOUTPUTWINDOW_H

View File

@@ -30,7 +30,6 @@
#include "cvsplugin.h" #include "cvsplugin.h"
#include "settingspage.h" #include "settingspage.h"
#include "cvseditor.h" #include "cvseditor.h"
#include "cvsoutputwindow.h"
#include "cvssubmiteditor.h" #include "cvssubmiteditor.h"
#include "cvsconstants.h" #include "cvsconstants.h"
#include "cvscontrol.h" #include "cvscontrol.h"
@@ -39,6 +38,7 @@
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
@@ -152,7 +152,6 @@ CVSPlugin *CVSPlugin::m_cvsPluginInstance = 0;
CVSPlugin::CVSPlugin() : CVSPlugin::CVSPlugin() :
m_versionControl(0), m_versionControl(0),
m_changeTmpFile(0), m_changeTmpFile(0),
m_cvsOutputWindow(0),
m_projectExplorer(0), m_projectExplorer(0),
m_addAction(0), m_addAction(0),
m_deleteAction(0), m_deleteAction(0),
@@ -239,9 +238,6 @@ bool CVSPlugin::initialize(const QStringList &arguments, QString *errorMessage)
for (int i = 0; i < editorCount; i++) for (int i = 0; i < editorCount; i++)
addAutoReleasedObject(new CVSEditorFactory(editorParameters + i, this, describeSlotC)); addAutoReleasedObject(new CVSEditorFactory(editorParameters + i, this, describeSlotC));
m_cvsOutputWindow = new CVSOutputWindow(this);
addAutoReleasedObject(m_cvsOutputWindow);
addAutoReleasedObject(new CheckoutWizard); addAutoReleasedObject(new CheckoutWizard);
//register actions //register actions
@@ -644,14 +640,14 @@ void CVSPlugin::startCommit(const QString &source)
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
return; return;
if (m_changeTmpFile) { if (m_changeTmpFile) {
showOutput(tr("Another commit is currently being executed.")); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
return; return;
} }
const QFileInfo sourceFi(source); const QFileInfo sourceFi(source);
const QString sourceDir = sourceFi.isDir() ? source : sourceFi.absolutePath(); const QString sourceDir = sourceFi.isDir() ? source : sourceFi.absolutePath();
const QString topLevel = findTopLevelForDirectory(sourceDir); const QString topLevel = findTopLevelForDirectory(sourceDir);
if (topLevel.isEmpty()) { if (topLevel.isEmpty()) {
showOutput(msgCannotFindTopLevel(source), true); VCSBase::VCSBaseOutputWindow::instance()->appendError(msgCannotFindTopLevel(source));
return; return;
} }
// We need the "Examining <subdir>" stderr output to tell // We need the "Examining <subdir>" stderr output to tell
@@ -673,7 +669,7 @@ void CVSPlugin::startCommit(const QString &source)
qDebug() << Q_FUNC_INFO << '\n' << source << "top" << topLevel; qDebug() << Q_FUNC_INFO << '\n' << source << "top" << topLevel;
if (statusOutput.empty()) { if (statusOutput.empty()) {
showOutput(tr("There are no modified files."), true); VCSBase::VCSBaseOutputWindow::instance()->append(tr("There are no modified files."));
return; return;
} }
@@ -681,7 +677,7 @@ void CVSPlugin::startCommit(const QString &source)
QTemporaryFile *changeTmpFile = new QTemporaryFile(this); QTemporaryFile *changeTmpFile = new QTemporaryFile(this);
changeTmpFile->setAutoRemove(true); changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) { if (!changeTmpFile->open()) {
showOutput(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
delete changeTmpFile; delete changeTmpFile;
return; return;
} }
@@ -807,7 +803,7 @@ void CVSPlugin::slotDescribe(const QString &source, const QString &changeNr)
{ {
QString errorMessage; QString errorMessage;
if (!describe(source, changeNr, &errorMessage)) if (!describe(source, changeNr, &errorMessage))
showOutput(errorMessage, true); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
} }
bool CVSPlugin::describe(const QString &file, const QString &changeNr, QString *errorMessage) bool CVSPlugin::describe(const QString &file, const QString &changeNr, QString *errorMessage)
@@ -1034,12 +1030,11 @@ static inline QString fixFileArgs(QStringList *files)
// Format log entry for command // Format log entry for command
static inline QString msgExecutionLogEntry(const QString &workingDir, const QString &executable, const QStringList &arguments) static inline QString msgExecutionLogEntry(const QString &workingDir, const QString &executable, const QStringList &arguments)
{ {
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); //: Executing: <executable> <arguments>
//: <timestamp> Executing: <executable> <arguments>
const QString args = arguments.join(QString(QLatin1Char(' '))); const QString args = arguments.join(QString(QLatin1Char(' ')));
if (workingDir.isEmpty()) if (workingDir.isEmpty())
return CVSPlugin::tr("%1 Executing: %2 %3\n").arg(timeStamp, executable, args); return CVSPlugin::tr("Executing: %2 %3\n").arg(executable, args);
return CVSPlugin::tr("%1 Executing in %2: %3 %4\n").arg(timeStamp, workingDir, executable, args); return CVSPlugin::tr("Executing in %2: %3 %4\n").arg(workingDir, executable, args);
} }
// Figure out a working directory for the process, // Figure out a working directory for the process,
@@ -1075,7 +1070,7 @@ CVSResponse CVSPlugin::runCVS(const QString &workingDirectory,
const QStringList allArgs = m_settings.addOptions(arguments); const QStringList allArgs = m_settings.addOptions(arguments);
const QString outputText = msgExecutionLogEntry(response.workingDirectory, executable, allArgs); const QString outputText = msgExecutionLogEntry(response.workingDirectory, executable, allArgs);
showOutput(outputText, false); VCSBase::VCSBaseOutputWindow::instance()->appendCommand(outputText);
if (CVS::Constants::debug) if (CVS::Constants::debug)
qDebug() << "runCVS" << timeOut << outputText; qDebug() << "runCVS" << timeOut << outputText;
@@ -1092,12 +1087,13 @@ CVSResponse CVSPlugin::runCVS(const QString &workingDirectory,
process.setStdOutCodec(outputCodec); process.setStdOutCodec(outputCodec);
process.setStdErrBufferedSignalsEnabled(true); process.setStdErrBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_cvsOutputWindow, SLOT(append(QString,bool))); VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
connect(&process, SIGNAL(stdErrBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
// connect stdout to the output window if desired // connect stdout to the output window if desired
if (showStdOutInOutputWindow) { if (showStdOutInOutputWindow) {
process.setStdOutBufferedSignalsEnabled(true); process.setStdOutBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_cvsOutputWindow, SLOT(append(QString,bool))); connect(&process, SIGNAL(stdOutBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
} }
const Core::Utils::SynchronousProcessResponse sp_resp = process.run(executable, allArgs); const Core::Utils::SynchronousProcessResponse sp_resp = process.run(executable, allArgs);
@@ -1123,18 +1119,11 @@ CVSResponse CVSPlugin::runCVS(const QString &workingDirectory,
break; break;
} }
if (response.result != CVSResponse::Ok) if (response.result != CVSResponse::Ok)
m_cvsOutputWindow->append(response.message, true); VCSBase::VCSBaseOutputWindow::instance()->appendError(response.message);
return response; return response;
} }
void CVSPlugin::showOutput(const QString &output, bool bringToForeground)
{
m_cvsOutputWindow->append(output);
if (bringToForeground)
m_cvsOutputWindow->popup();
}
Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QString &output, Core::IEditor * CVSPlugin::showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source, int editorType, const QString &source,
QTextCodec *codec) QTextCodec *codec)

View File

@@ -58,7 +58,6 @@ namespace ProjectExplorer {
namespace CVS { namespace CVS {
namespace Internal { namespace Internal {
class CVSOutputWindow;
class CVSSubmitEditor; class CVSSubmitEditor;
struct CVSResponse struct CVSResponse
@@ -141,7 +140,6 @@ private:
bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0, bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0,
bool mergeStderr = false); bool mergeStderr = false);
void showOutput(const QString &output, bool bringToForeground = true);
void annotate(const QString &file); void annotate(const QString &file);
bool describe(const QString &source, const QString &changeNr, QString *errorMessage); bool describe(const QString &source, const QString &changeNr, QString *errorMessage);
bool describe(const QString &repository, QList<CVS_LogEntry> entries, QString *errorMessage); bool describe(const QString &repository, QList<CVS_LogEntry> entries, QString *errorMessage);
@@ -157,7 +155,6 @@ private:
Core::IVersionControl *m_versionControl; Core::IVersionControl *m_versionControl;
QTemporaryFile *m_changeTmpFile; QTemporaryFile *m_changeTmpFile;
CVSOutputWindow *m_cvsOutputWindow;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
Core::Utils::ParameterAction *m_addAction; Core::Utils::ParameterAction *m_addAction;

View File

@@ -8,7 +8,6 @@ include(../../plugins/vcsbase/vcsbase.pri)
include(../../libs/utils/utils.pri) include(../../libs/utils/utils.pri)
HEADERS += gitplugin.h \ HEADERS += gitplugin.h \
gitconstants.h \ gitconstants.h \
gitoutputwindow.h \
gitclient.h \ gitclient.h \
changeselectiondialog.h \ changeselectiondialog.h \
commitdata.h \ commitdata.h \
@@ -25,7 +24,6 @@ HEADERS += gitplugin.h \
clonewizard.h \ clonewizard.h \
clonewizardpage.h clonewizardpage.h
SOURCES += gitplugin.cpp \ SOURCES += gitplugin.cpp \
gitoutputwindow.cpp \
gitclient.cpp \ gitclient.cpp \
changeselectiondialog.cpp \ changeselectiondialog.cpp \
commitdata.cpp \ commitdata.cpp \

View File

@@ -46,6 +46,7 @@
#include <texteditor/itexteditor.h> #include <texteditor/itexteditor.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <QtCore/QRegExp> #include <QtCore/QRegExp>
#include <QtCore/QTemporaryFile> #include <QtCore/QTemporaryFile>
@@ -89,9 +90,8 @@ static inline QString msgParseFilesFailed()
// Format a command for the status window // Format a command for the status window
static QString formatCommand(const QString &binary, const QStringList &args) static QString formatCommand(const QString &binary, const QStringList &args)
{ {
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); //: Executing: <executable> <arguments>
//: <timestamp> Executing: <executable> <arguments> return GitClient::tr("Executing: %1 %2\n").arg(binary, args.join(QString(QLatin1Char(' '))));
return GitClient::tr("%1 Executing: %2 %3\n").arg(timeStamp, binary, args.join(QString(QLatin1Char(' '))));
} }
// ---------------- GitClient // ---------------- GitClient
@@ -210,20 +210,20 @@ void GitClient::diff(const QString &workingDirectory,
if (unstagedFileNames.empty() && stagedFileNames.empty()) { if (unstagedFileNames.empty() && stagedFileNames.empty()) {
QStringList arguments(commonDiffArgs); QStringList arguments(commonDiffArgs);
arguments << diffArgs; arguments << diffArgs;
m_plugin->outputWindow()->append(formatCommand(binary, arguments)); VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(binary, arguments));
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
} else { } else {
// Files diff. // Files diff.
if (!unstagedFileNames.empty()) { if (!unstagedFileNames.empty()) {
QStringList arguments(commonDiffArgs); QStringList arguments(commonDiffArgs);
arguments << QLatin1String("--") << unstagedFileNames; arguments << QLatin1String("--") << unstagedFileNames;
m_plugin->outputWindow()->append(formatCommand(binary, arguments)); VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(binary, arguments));
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
} }
if (!stagedFileNames.empty()) { if (!stagedFileNames.empty()) {
QStringList arguments(commonDiffArgs); QStringList arguments(commonDiffArgs);
arguments << QLatin1String("--cached") << diffArgs << QLatin1String("--") << stagedFileNames; 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); command->addJob(arguments, m_settings.timeout);
} }
} }
@@ -360,8 +360,7 @@ bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringLis
if (!rc) { if (!rc) {
const QString errorMessage = tr("Unable to add %n file(s) to %1: %2", 0, files.size()). const QString errorMessage = tr("Unable to add %n file(s) to %1: %2", 0, files.size()).
arg(workingDirectory, QString::fromLocal8Bit(errorText)); arg(workingDirectory, QString::fromLocal8Bit(errorText));
m_plugin->outputWindow()->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
m_plugin->outputWindow()->popup(false);
} }
return rc; return rc;
} }
@@ -371,10 +370,8 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
{ {
QString errorMessage; QString errorMessage;
const bool rc = synchronousReset(workingDirectory, files, &errorMessage); const bool rc = synchronousReset(workingDirectory, files, &errorMessage);
if (!rc) { if (!rc)
m_plugin->outputWindow()->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
m_plugin->outputWindow()->popup(false);
}
return rc; return rc;
} }
@@ -390,8 +387,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory,
arguments << QLatin1String("reset") << QLatin1String("HEAD") << QLatin1String("--") << files; arguments << QLatin1String("reset") << QLatin1String("HEAD") << QLatin1String("--") << files;
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText); const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
const QString output = QString::fromLocal8Bit(outputText); const QString output = QString::fromLocal8Bit(outputText);
m_plugin->outputWindow()->popup(false); VCSBase::VCSBaseOutputWindow::instance()->append(output);
m_plugin->outputWindow()->append(output);
// Note that git exits with 1 even if the operation is successful // Note that git exits with 1 even if the operation is successful
// Assume real failure if the output does not contain "foo.cpp modified" // Assume real failure if the output does not contain "foo.cpp modified"
if (!rc && !output.contains(QLatin1String("modified"))) { if (!rc && !output.contains(QLatin1String("modified"))) {
@@ -478,12 +474,11 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory,
if (Git::Constants::debug) if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << workingDirectory << editor; qDebug() << Q_FUNC_INFO << workingDirectory << editor;
GitOutputWindow *outputWindow = m_plugin->outputWindow(); VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
GitCommand* command = new GitCommand(binary(), workingDirectory, processEnvironment()); GitCommand* command = new GitCommand(binary(), workingDirectory, processEnvironment());
if (outputToWindow) { if (outputToWindow) {
if (!editor) { // assume that the commands output is the important thing if (editor) { // assume that the commands output is the important thing
connect(command, SIGNAL(outputData(QByteArray)), this, SLOT(appendDataAndPopup(QByteArray))); connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendDataSilently(QByteArray)));
} else { } else {
connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray))); connect(command, SIGNAL(outputData(QByteArray)), outputWindow, SLOT(appendData(QByteArray)));
} }
@@ -493,7 +488,7 @@ GitCommand *GitClient::createCommand(const QString &workingDirectory,
} }
if (outputWindow) if (outputWindow)
connect(command, SIGNAL(errorText(QString)), this, SLOT(appendAndPopup(QString))); connect(command, SIGNAL(errorText(QString)), outputWindow, SLOT(appendError(QString)));
return command; return command;
} }
@@ -504,25 +499,13 @@ void GitClient::executeGit(const QString &workingDirectory,
bool outputToWindow, bool outputToWindow,
GitCommand::TerminationReportMode tm) 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); GitCommand *command = createCommand(workingDirectory, editor, outputToWindow);
command->addJob(arguments, m_settings.timeout); command->addJob(arguments, m_settings.timeout);
command->setTerminationReportMode(tm); command->setTerminationReportMode(tm);
command->execute(); 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 // Return fixed arguments required to run
QStringList GitClient::binary() const QStringList GitClient::binary() const
{ {
@@ -553,7 +536,7 @@ bool GitClient::synchronousGit(const QString &workingDirectory,
qDebug() << "synchronousGit" << workingDirectory << arguments; qDebug() << "synchronousGit" << workingDirectory << arguments;
if (logCommandToWindow) if (logCommandToWindow)
m_plugin->outputWindow()->append(formatCommand(m_binaryPath, arguments)); VCSBase::VCSBaseOutputWindow::instance()->appendCommand(formatCommand(m_binaryPath, arguments));
QProcess process; QProcess process;
process.setWorkingDirectory(workingDirectory); process.setWorkingDirectory(workingDirectory);
@@ -602,10 +585,8 @@ GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory)
{ {
QString errorMessage; QString errorMessage;
const StashResult sr = ensureStash(workingDirectory, &errorMessage); const StashResult sr = ensureStash(workingDirectory, &errorMessage);
if (sr == StashFailed) { if (sr == StashFailed)
m_plugin->outputWindow()->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
m_plugin->outputWindow()->popup();
}
return sr; return sr;
} }
@@ -810,12 +791,11 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
QByteArray outputText; QByteArray outputText;
QByteArray errorText; QByteArray errorText;
const bool rc = synchronousGit(repositoryDirectory, args, &outputText, &errorText); const bool rc = synchronousGit(repositoryDirectory, args, &outputText, &errorText);
const QString message = rc ? if (rc) {
tr("Committed %n file(s).\n", 0, checkedFiles.size()) : VCSBase::VCSBaseOutputWindow::instance()->append(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)); } else {
VCSBase::VCSBaseOutputWindow::instance()->appendError(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);
return rc; return rc;
} }
@@ -919,13 +899,11 @@ void GitClient::revert(const QStringList &files)
break; break;
case RevertUnchanged: { case RevertUnchanged: {
const QString msg = (isDirectory || files.size() > 1) ? msgNoChangedFiles() : tr("The file is not modified."); const QString msg = (isDirectory || files.size() > 1) ? msgNoChangedFiles() : tr("The file is not modified.");
m_plugin->outputWindow()->append(msg); VCSBase::VCSBaseOutputWindow::instance()->append(msg);
m_plugin->outputWindow()->popup();
} }
break; break;
case RevertFailed: case RevertFailed:
m_plugin->outputWindow()->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage);
m_plugin->outputWindow()->popup();
break; break;
} }
} }
@@ -954,12 +932,10 @@ void GitClient::stash(const QString &workingDirectory)
executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true); executeGit(workingDirectory, QStringList(QLatin1String("stash")), 0, true);
break; break;
case StatusUnchanged: case StatusUnchanged:
m_plugin->outputWindow()->append(msgNoChangedFiles()); VCSBase::VCSBaseOutputWindow::instance()->append(msgNoChangedFiles());
m_plugin->outputWindow()->popup();
break; break;
case StatusFailed: case StatusFailed:
m_plugin->outputWindow()->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage);
m_plugin->outputWindow()->popup();
break; break;
} }
} }

View File

@@ -145,10 +145,6 @@ public:
public slots: public slots:
void show(const QString &source, const QString &id); void show(const QString &source, const QString &id);
private slots:
void appendAndPopup(const QString &text);
void appendDataAndPopup(const QByteArray &data);
private: private:
VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind, VCSBase::VCSBaseEditor *createVCSEditor(const QString &kind,
QString title, QString title,

View File

@@ -1,143 +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 "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;
}

View File

@@ -1,81 +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 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

View File

@@ -54,6 +54,7 @@
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <QtCore/QDebug> #include <QtCore/QDebug>
#include <QtCore/QDir> #include <QtCore/QDir>
@@ -139,7 +140,6 @@ GitPlugin::GitPlugin() :
m_branchListAction(0), m_branchListAction(0),
m_projectExplorer(0), m_projectExplorer(0),
m_gitClient(0), m_gitClient(0),
m_outputWindow(0),
m_changeSelectionDialog(0), m_changeSelectionDialog(0),
m_changeTmpFile(0), m_changeTmpFile(0),
m_submitActionTriggered(false) m_submitActionTriggered(false)
@@ -197,10 +197,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
QList<int> globalcontext; QList<int> globalcontext;
globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL); globalcontext << m_core->uniqueIDManager()->uniqueIdentifier(Core::Constants::C_GLOBAL);
// Create the output Window
m_outputWindow = new GitOutputWindow();
addAutoReleasedObject(m_outputWindow);
// Create the settings Page // Create the settings Page
addAutoReleasedObject(new SettingsPage()); addAutoReleasedObject(new SettingsPage());
@@ -464,8 +460,7 @@ QString GitPlugin::getWorkingDirectory()
qDebug() << Q_FUNC_INFO << "file" << workingDirectory; qDebug() << Q_FUNC_INFO << "file" << workingDirectory;
if (workingDirectory.isEmpty()) { if (workingDirectory.isEmpty()) {
m_outputWindow->append(tr("Could not find working directory")); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Could not find working directory"));
m_outputWindow->popup(false);
return QString(); return QString();
} }
return workingDirectory; return workingDirectory;
@@ -519,7 +514,7 @@ void GitPlugin::undoFileChanges()
QString errorMessage; QString errorMessage;
if (!m_gitClient->synchronousCheckout(workingDirectory, QStringList() << fileName, &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()) if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
return; return;
if (m_changeTmpFile) { if (m_changeTmpFile) {
m_outputWindow->append(tr("Another submit is currently beeing executed.")); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently being executed."));
m_outputWindow->popup(false);
return; return;
} }
@@ -575,8 +569,7 @@ void GitPlugin::startCommit()
QString errorMessage, commitTemplate; QString errorMessage, commitTemplate;
CommitData data; CommitData data;
if (!m_gitClient->getCommitData(workingDirectory, &commitTemplate, &data, &errorMessage)) { if (!m_gitClient->getCommitData(workingDirectory, &commitTemplate, &data, &errorMessage)) {
m_outputWindow->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->append(errorMessage);
m_outputWindow->popup(false);
return; return;
} }
@@ -593,8 +586,7 @@ void GitPlugin::startCommit()
QTemporaryFile *changeTmpFile = new QTemporaryFile(this); QTemporaryFile *changeTmpFile = new QTemporaryFile(this);
changeTmpFile->setAutoRemove(true); changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) { if (!changeTmpFile->open()) {
m_outputWindow->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); VCSBase::VCSBaseOutputWindow::instance()->append(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
m_outputWindow->popup(false);
delete changeTmpFile; delete changeTmpFile;
return; return;
} }
@@ -734,19 +726,14 @@ void GitPlugin::branchList()
const QString workingDirectory = getWorkingDirectory(); const QString workingDirectory = getWorkingDirectory();
if (workingDirectory.isEmpty()) if (workingDirectory.isEmpty())
return; return;
#ifndef USE_BRANCHDIALOG
QString errorMessage; QString errorMessage;
BranchDialog dialog(m_core->mainWindow()); BranchDialog dialog(m_core->mainWindow());
if (!dialog.init(m_gitClient, workingDirectory, &errorMessage)) { if (!dialog.init(m_gitClient, workingDirectory, &errorMessage)) {
m_outputWindow->append(errorMessage); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
m_outputWindow->popup(false);
return; return;
} }
dialog.exec(); dialog.exec();
#else
m_gitClient->branchList(workingDirectory);
#endif
} }
void GitPlugin::stashList() void GitPlugin::stashList()
@@ -833,11 +820,6 @@ void GitPlugin::showCommit()
m_gitClient->show(m_changeSelectionDialog->m_ui.repositoryEdit->text(), change); m_gitClient->show(m_changeSelectionDialog->m_ui.repositoryEdit->text(), change);
} }
GitOutputWindow *GitPlugin::outputWindow() const
{
return m_outputWindow;
}
GitSettings GitPlugin::settings() const GitSettings GitPlugin::settings() const
{ {
return m_gitClient->settings(); return m_gitClient->settings();

View File

@@ -30,7 +30,6 @@
#ifndef GITPLUGIN_H #ifndef GITPLUGIN_H
#define GITPLUGIN_H #define GITPLUGIN_H
#include "gitoutputwindow.h"
#include "settingspage.h" #include "settingspage.h"
#include <coreplugin/editormanager/ieditorfactory.h> #include <coreplugin/editormanager/ieditorfactory.h>
@@ -94,8 +93,6 @@ public:
QString getWorkingDirectory(); QString getWorkingDirectory();
GitOutputWindow *outputWindow() const;
GitSettings settings() const; GitSettings settings() const;
void setSettings(const GitSettings &s); void setSettings(const GitSettings &s);
@@ -165,7 +162,6 @@ private:
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
GitClient *m_gitClient; GitClient *m_gitClient;
GitOutputWindow *m_outputWindow;
ChangeSelectionDialog *m_changeSelectionDialog; ChangeSelectionDialog *m_changeSelectionDialog;
QString m_submitRepository; QString m_submitRepository;
QStringList m_submitOrigCommitFiles; QStringList m_submitOrigCommitFiles;

View File

@@ -6,7 +6,6 @@ include(perforce_dependencies.pri)
HEADERS += \ HEADERS += \
perforceplugin.h \ perforceplugin.h \
perforceoutputwindow.h \
settingspage.h \ settingspage.h \
perforceeditor.h \ perforceeditor.h \
changenumberdialog.h \ changenumberdialog.h \
@@ -19,7 +18,6 @@ HEADERS += \
perforcesubmiteditorwidget.h perforcesubmiteditorwidget.h
SOURCES += perforceplugin.cpp \ SOURCES += perforceplugin.cpp \
perforceoutputwindow.cpp \
settingspage.cpp \ settingspage.cpp \
perforceeditor.cpp \ perforceeditor.cpp \
changenumberdialog.cpp \ changenumberdialog.cpp \

View File

@@ -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;
}

View File

@@ -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

View File

@@ -33,7 +33,6 @@
#include "pendingchangesdialog.h" #include "pendingchangesdialog.h"
#include "perforceconstants.h" #include "perforceconstants.h"
#include "perforceeditor.h" #include "perforceeditor.h"
#include "perforceoutputwindow.h"
#include "perforcesubmiteditor.h" #include "perforcesubmiteditor.h"
#include "perforceversioncontrol.h" #include "perforceversioncontrol.h"
#include "settingspage.h" #include "settingspage.h"
@@ -52,6 +51,7 @@
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <QtCore/QtPlugin> #include <QtCore/QtPlugin>
#include <QtCore/QDebug> #include <QtCore/QDebug>
@@ -166,8 +166,6 @@ bool CoreListener::editorAboutToClose(Core::IEditor *editor)
PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL; PerforcePlugin *PerforcePlugin::m_perforcePluginInstance = NULL;
PerforcePlugin::PerforcePlugin() : PerforcePlugin::PerforcePlugin() :
m_perforceOutputWindow(0),
m_settingsPage(0),
m_editAction(0), m_editAction(0),
m_addAction(0), m_addAction(0),
m_deleteAction(0), m_deleteAction(0),
@@ -192,8 +190,6 @@ PerforcePlugin::PerforcePlugin() :
m_undoAction(0), m_undoAction(0),
m_redoAction(0), m_redoAction(0),
m_changeTmpFile(0), m_changeTmpFile(0),
m_coreListener(0),
m_submitEditorFactory(0),
m_versionControl(0) m_versionControl(0)
{ {
} }
@@ -220,28 +216,20 @@ bool PerforcePlugin::initialize(const QStringList &arguments, QString *errorMess
if (QSettings *settings = core->settings()) if (QSettings *settings = core->settings())
m_settings.fromSettings(settings); m_settings.fromSettings(settings);
m_perforceOutputWindow = new PerforceOutputWindow(this); addAutoReleasedObject(new SettingsPage);
addObject(m_perforceOutputWindow);
m_settingsPage = new SettingsPage;
addObject(m_settingsPage);
// Editor factories // Editor factories
m_submitEditorFactory = new PerforceSubmitEditorFactory(&submitParameters); addAutoReleasedObject(new PerforceSubmitEditorFactory(&submitParameters));
addObject(m_submitEditorFactory);
static const char *describeSlot = SLOT(describe(QString,QString)); static const char *describeSlot = SLOT(describe(QString,QString));
const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters); const int editorCount = sizeof(editorParameters)/sizeof(VCSBase::VCSBaseEditorParameters);
for (int i = 0; i < editorCount; i++) { for (int i = 0; i < editorCount; i++)
m_editorFactories.push_back(new PerforceEditorFactory(editorParameters + i, this, describeSlot)); addAutoReleasedObject(new PerforceEditorFactory(editorParameters + i, this, describeSlot));
addObject(m_editorFactories.back());
}
m_versionControl = new PerforceVersionControl(this); m_versionControl = new PerforceVersionControl(this);
addObject(m_versionControl); addAutoReleasedObject(m_versionControl);
m_coreListener = new CoreListener(this); addAutoReleasedObject(new CoreListener(this));
addObject(m_coreListener);
//register actions //register actions
Core::ActionManager *am = Core::ICore::instance()->actionManager(); Core::ActionManager *am = Core::ICore::instance()->actionManager();
@@ -555,19 +543,18 @@ void PerforcePlugin::submit()
QString errorMessage; QString errorMessage;
if (!checkP4Configuration(&errorMessage)) { if (!checkP4Configuration(&errorMessage)) {
showOutput(errorMessage, true); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
return; return;
} }
if (m_changeTmpFile) { if (m_changeTmpFile) {
showOutput(tr("Another submit is currently executed."), true); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another submit is currently executed."));
m_perforceOutputWindow->popup(false);
return; return;
} }
m_changeTmpFile = new QTemporaryFile(this); m_changeTmpFile = new QTemporaryFile(this);
if (!m_changeTmpFile->open()) { if (!m_changeTmpFile->open()) {
showOutput(tr("Cannot create temporary file."), true); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file."));
cleanChangeTmpFile(); cleanChangeTmpFile();
return; return;
} }
@@ -599,7 +586,7 @@ void PerforcePlugin::submit()
depotFileNames.append(line.mid(14)); depotFileNames.append(line.mid(14));
} }
if (depotFileNames.isEmpty()) { if (depotFileNames.isEmpty()) {
showOutput(tr("Project has no files")); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Project has no files"));
cleanChangeTmpFile(); cleanChangeTmpFile();
return; return;
} }
@@ -804,8 +791,9 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
qDebug() << "PerforcePlugin::runP4Cmd" << args << extraArgs << debugCodec(outputCodec); qDebug() << "PerforcePlugin::runP4Cmd" << args << extraArgs << debugCodec(outputCodec);
PerforceResponse response; PerforceResponse response;
response.error = true; response.error = true;
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
if (!checkP4Configuration(&response.message)) { if (!checkP4Configuration(&response.message)) {
m_perforceOutputWindow->append(response.message, true); outputWindow->appendError(response.message);
return response; return response;
} }
@@ -832,9 +820,8 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
QString command = m_settings.p4Command(); QString command = m_settings.p4Command();
command += blank; command += blank;
command += actualArgs.join(QString(blank)); command += actualArgs.join(QString(blank));
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); const QString outputText = tr("Executing: %1\n").arg(command);
const QString outputText = tr("%1 Executing: %2\n").arg(timeStamp, command); outputWindow->appendCommand(outputText);
showOutput(outputText, false);
} }
// Run, connect stderr to the output window // 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 // connect stderr to the output window if desired
if (logFlags & StdErrToWindow) { if (logFlags & StdErrToWindow) {
process.setStdErrBufferedSignalsEnabled(true); 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 // connect stdout to the output window if desired
if (logFlags & StdOutToWindow) { if (logFlags & StdOutToWindow) {
process.setStdOutBufferedSignalsEnabled(true); 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); 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) if (Perforce::Constants::debug)
qDebug() << response.message; qDebug() << response.message;
if (logFlags & ErrorToWindow) if (logFlags & ErrorToWindow)
m_perforceOutputWindow->append(response.message, true); outputWindow->appendError(response.message);
} }
return response; return response;
} }
@@ -1043,7 +1030,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
QByteArray change = m_changeTmpFile->readAll(); QByteArray change = m_changeTmpFile->readAll();
QString errorMessage; QString errorMessage;
if (!checkP4Configuration(&errorMessage)) { if (!checkP4Configuration(&errorMessage)) {
showOutput(errorMessage, true); VCSBase::VCSBaseOutputWindow::instance()->appendError(errorMessage);
return false; return false;
} }
@@ -1054,7 +1041,7 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
proc.start(m_settings.p4Command(), proc.start(m_settings.p4Command(),
m_settings.basicP4Args() << QLatin1String("submit") << QLatin1String("-i")); m_settings.basicP4Args() << QLatin1String("submit") << QLatin1String("-i"));
if (!proc.waitForStarted(p4Timeout)) { if (!proc.waitForStarted(p4Timeout)) {
showOutput(tr("Cannot execute p4 submit."), true); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot execute p4 submit."));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
return false; return false;
} }
@@ -1062,12 +1049,12 @@ bool PerforcePlugin::editorAboutToClose(Core::IEditor *editor)
proc.closeWriteChannel(); proc.closeWriteChannel();
if (!proc.waitForFinished()) { if (!proc.waitForFinished()) {
showOutput(tr("Cannot execute p4 submit."), true); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot execute p4 submit."));
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
return false; return false;
} }
const QString output = QString::fromUtf8(proc.readAll()); const QString output = QString::fromLocal8Bit(proc.readAll());
showOutput(output); VCSBase::VCSBaseOutputWindow::instance()->append(output);
if (output.contains(QLatin1String("Out of date files must be resolved or reverted)"))) { 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.")); 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; return data;
} }
void PerforcePlugin::showOutput(const QString &output, bool popup) const
{
m_perforceOutputWindow->append(output, popup);
}
PerforcePlugin::~PerforcePlugin() 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 const PerforceSettings& PerforcePlugin::settings() const

View File

@@ -50,7 +50,6 @@ class QTextCodec;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core { namespace Core {
class IEditorFactory;
namespace Utils { namespace Utils {
class ParameterAction; class ParameterAction;
} }
@@ -59,8 +58,6 @@ namespace Core {
namespace Perforce { namespace Perforce {
namespace Internal { namespace Internal {
class PerforceOutputWindow;
class SettingsPage;
class PerforceVersionControl; class PerforceVersionControl;
class PerforcePlugin; class PerforcePlugin;
@@ -92,8 +89,6 @@ public:
PerforcePlugin(); PerforcePlugin();
~PerforcePlugin(); ~PerforcePlugin();
SettingsPage *settingsPage() const { return m_settingsPage; }
bool initialize(const QStringList &arguments, QString *error_message); bool initialize(const QStringList &arguments, QString *error_message);
void extensionsInitialized(); void extensionsInitialized();
@@ -165,16 +160,12 @@ private:
QString clientFilePath(const QString &serverFilePath); QString clientFilePath(const QString &serverFilePath);
QString currentFileName(); QString currentFileName();
bool checkP4Configuration(QString *errorMessage = 0) const; bool checkP4Configuration(QString *errorMessage = 0) const;
void showOutput(const QString &output, bool popup = false) const;
void annotate(const QString &fileName); void annotate(const QString &fileName);
void filelog(const QString &fileName); void filelog(const QString &fileName);
void cleanChangeTmpFile(); void cleanChangeTmpFile();
void updateCheckout(const QStringList &dirs = QStringList()); void updateCheckout(const QStringList &dirs = QStringList());
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
PerforceOutputWindow *m_perforceOutputWindow;
SettingsPage *m_settingsPage;
QList<Core::IEditorFactory*> m_editorFactories;
Core::Utils::ParameterAction *m_editAction; Core::Utils::ParameterAction *m_editAction;
Core::Utils::ParameterAction *m_addAction; Core::Utils::ParameterAction *m_addAction;
@@ -206,12 +197,8 @@ private:
static PerforcePlugin *m_perforcePluginInstance; static PerforcePlugin *m_perforcePluginInstance;
QString pendingChangesData(); QString pendingChangesData();
CoreListener *m_coreListener;
Core::IEditorFactory *m_submitEditorFactory;
PerforceVersionControl *m_versionControl; PerforceVersionControl *m_versionControl;
PerforceSettings m_settings; PerforceSettings m_settings;
friend class PerforceOutputWindow; // needs openFiles()
}; };
} // namespace Perforce } // namespace Perforce

View File

@@ -11,7 +11,6 @@ include(../../libs/utils/utils.pri)
HEADERS += annotationhighlighter.h \ HEADERS += annotationhighlighter.h \
subversionplugin.h \ subversionplugin.h \
subversioncontrol.h \ subversioncontrol.h \
subversionoutputwindow.h \
settingspage.h \ settingspage.h \
subversioneditor.h \ subversioneditor.h \
subversionsubmiteditor.h \ subversionsubmiteditor.h \
@@ -22,7 +21,6 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \ SOURCES += annotationhighlighter.cpp \
subversionplugin.cpp \ subversionplugin.cpp \
subversioncontrol.cpp \ subversioncontrol.cpp \
subversionoutputwindow.cpp \
settingspage.cpp \ settingspage.cpp \
subversioneditor.cpp \ subversioneditor.cpp \
subversionsubmiteditor.cpp \ subversionsubmiteditor.cpp \

View File

@@ -1,127 +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 "subversionoutputwindow.h"
#include "subversionplugin.h"
#include <QtGui/QListWidget>
#include <QtCore/QDebug>
using namespace Subversion::Internal;
SubversionOutputWindow::SubversionOutputWindow(SubversionPlugin *svnPlugin)
: m_svnPlugin(svnPlugin)
{
m_outputListWidget = new QListWidget;
m_outputListWidget->setFrameStyle(QFrame::NoFrame);
m_outputListWidget->setWindowTitle(tr("Subversion Output"));
m_outputListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
SubversionOutputWindow::~SubversionOutputWindow()
{
delete m_outputListWidget;
}
QWidget *SubversionOutputWindow::outputWidget(QWidget *parent)
{
m_outputListWidget->setParent(parent);
return m_outputListWidget;
}
QString SubversionOutputWindow::name() const
{
return tr("Subversion");
}
void SubversionOutputWindow::clearContents()
{
m_outputListWidget->clear();
}
int SubversionOutputWindow::priorityInStatusBar() const
{
return -1;
}
void SubversionOutputWindow::visibilityChanged(bool b)
{
if (b)
m_outputListWidget->setFocus();
}
void SubversionOutputWindow::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();
}
bool SubversionOutputWindow::canFocus()
{
return false;
}
bool SubversionOutputWindow::hasFocus()
{
return m_outputListWidget->hasFocus();
}
void SubversionOutputWindow::setFocus()
{
}
bool SubversionOutputWindow::canNext()
{
return false;
}
bool SubversionOutputWindow::canPrevious()
{
return false;
}
void SubversionOutputWindow::goToNext()
{
}
void SubversionOutputWindow::goToPrev()
{
}
bool SubversionOutputWindow::canNavigate()
{
return false;
}

View File

@@ -1,84 +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 SUBVERSIONOUTPUTWINDOW_H
#define SUBVERSIONOUTPUTWINDOW_H
#include <coreplugin/ioutputpane.h>
QT_BEGIN_NAMESPACE
class QListWidget;
QT_END_NAMESPACE
namespace Subversion {
namespace Internal {
class SubversionPlugin;
class SubversionOutputWindow : public Core::IOutputPane
{
Q_OBJECT
public:
SubversionOutputWindow(SubversionPlugin *svnPlugin);
~SubversionOutputWindow();
QWidget *outputWidget(QWidget *parent);
QList<QWidget*> toolBarWidgets() const {
return QList<QWidget *>();
}
QString name() const;
void clearContents();
int priorityInStatusBar() const;
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 popup = false);
private:
SubversionPlugin *m_svnPlugin;
QListWidget *m_outputListWidget;
};
} // namespace Subversion
} // namespace Internal
#endif // SUBVERSIONOUTPUTWINDOW_H

View File

@@ -32,7 +32,6 @@
#include "settingspage.h" #include "settingspage.h"
#include "subversioneditor.h" #include "subversioneditor.h"
#include "subversionoutputwindow.h"
#include "subversionsubmiteditor.h" #include "subversionsubmiteditor.h"
#include "subversionconstants.h" #include "subversionconstants.h"
#include "subversioncontrol.h" #include "subversioncontrol.h"
@@ -41,6 +40,7 @@
#include <vcsbase/basevcseditorfactory.h> #include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcsbaseeditor.h> #include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseoutputwindow.h>
#include <utils/synchronousprocess.h> #include <utils/synchronousprocess.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
@@ -181,7 +181,6 @@ SubversionPlugin::SubversionPlugin() :
m_svnDirectories(svnDirectories()), m_svnDirectories(svnDirectories()),
m_versionControl(0), m_versionControl(0),
m_changeTmpFile(0), m_changeTmpFile(0),
m_subversionOutputWindow(0),
m_projectExplorer(0), m_projectExplorer(0),
m_addAction(0), m_addAction(0),
m_deleteAction(0), m_deleteAction(0),
@@ -267,9 +266,6 @@ bool SubversionPlugin::initialize(const QStringList &arguments, QString *errorMe
for (int i = 0; i < editorCount; i++) for (int i = 0; i < editorCount; i++)
addAutoReleasedObject(new SubversionEditorFactory(editorParameters + i, this, describeSlot)); addAutoReleasedObject(new SubversionEditorFactory(editorParameters + i, this, describeSlot));
m_subversionOutputWindow = new SubversionOutputWindow(this);
addAutoReleasedObject(m_subversionOutputWindow);
addAutoReleasedObject(new CheckoutWizard); addAutoReleasedObject(new CheckoutWizard);
//register actions //register actions
@@ -663,7 +659,7 @@ void SubversionPlugin::startCommit(const QStringList &files)
if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor()) if (VCSBase::VCSBaseSubmitEditor::raiseSubmitEditor())
return; return;
if (m_changeTmpFile) { if (m_changeTmpFile) {
showOutput(tr("Another commit is currently being executed.")); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("Another commit is currently being executed."));
return; return;
} }
@@ -678,7 +674,7 @@ void SubversionPlugin::startCommit(const QStringList &files)
// Get list of added/modified/deleted files // Get list of added/modified/deleted files
const StatusList statusOutput = parseStatusOutput(response.stdOut); const StatusList statusOutput = parseStatusOutput(response.stdOut);
if (statusOutput.empty()) { if (statusOutput.empty()) {
showOutput(tr("There are no modified files."), true); VCSBase::VCSBaseOutputWindow::instance()->appendWarning(tr("There are no modified files."));
return; return;
} }
@@ -686,7 +682,7 @@ void SubversionPlugin::startCommit(const QStringList &files)
QTemporaryFile *changeTmpFile = new QTemporaryFile(this); QTemporaryFile *changeTmpFile = new QTemporaryFile(this);
changeTmpFile->setAutoRemove(true); changeTmpFile->setAutoRemove(true);
if (!changeTmpFile->open()) { if (!changeTmpFile->open()) {
showOutput(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString())); VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("Cannot create temporary file: %1").arg(changeTmpFile->errorString()));
delete changeTmpFile; delete changeTmpFile;
return; return;
} }
@@ -923,11 +919,11 @@ SubversionResponse SubversionPlugin::runSvn(const QStringList &arguments,
} }
const QStringList allArgs = m_settings.addOptions(arguments); const QStringList allArgs = m_settings.addOptions(arguments);
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
// Hide passwords, etc in the log window // Hide passwords, etc in the log window
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); //: Executing: <executable> <arguments>
//: <timestamp> Executing: <executable> <arguments> const QString outputText = tr("Executing: %1 %2\n").arg(executable, SubversionSettings::formatArguments(allArgs));
const QString outputText = tr("%1 Executing: %2 %3\n").arg(timeStamp, executable, SubversionSettings::formatArguments(allArgs)); outputWindow->appendCommand(outputText);
showOutput(outputText, false);
if (Subversion::Constants::debug) if (Subversion::Constants::debug)
qDebug() << "runSvn" << timeOut << outputText; qDebug() << "runSvn" << timeOut << outputText;
@@ -938,12 +934,12 @@ SubversionResponse SubversionPlugin::runSvn(const QStringList &arguments,
process.setStdOutCodec(outputCodec); process.setStdOutCodec(outputCodec);
process.setStdErrBufferedSignalsEnabled(true); process.setStdErrBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_subversionOutputWindow, SLOT(append(QString,bool))); connect(&process, SIGNAL(stdErrBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
// connect stdout to the output window if desired // connect stdout to the output window if desired
if (showStdOutInOutputWindow) { if (showStdOutInOutputWindow) {
process.setStdOutBufferedSignalsEnabled(true); process.setStdOutBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_subversionOutputWindow, SLOT(append(QString,bool))); connect(&process, SIGNAL(stdOutBuffered(QString,bool)), outputWindow, SLOT(append(QString)));
} }
const Core::Utils::SynchronousProcessResponse sp_resp = process.run(executable, allArgs); const Core::Utils::SynchronousProcessResponse sp_resp = process.run(executable, allArgs);
@@ -968,18 +964,11 @@ SubversionResponse SubversionPlugin::runSvn(const QStringList &arguments,
break; break;
} }
if (response.error) if (response.error)
m_subversionOutputWindow->append(response.message, true); outputWindow->appendError(response.message);
return response; return response;
} }
void SubversionPlugin::showOutput(const QString &output, bool bringToForeground)
{
m_subversionOutputWindow->append(output);
if (bringToForeground)
m_subversionOutputWindow->popup();
}
Core::IEditor * SubversionPlugin::showOutputInEditor(const QString& title, const QString &output, Core::IEditor * SubversionPlugin::showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source, int editorType, const QString &source,
QTextCodec *codec) QTextCodec *codec)

View File

@@ -56,7 +56,6 @@ namespace ProjectExplorer {
namespace Subversion { namespace Subversion {
namespace Internal { namespace Internal {
class SubversionOutputWindow;
class SubversionSubmitEditor; class SubversionSubmitEditor;
struct SubversionResponse struct SubversionResponse
@@ -120,7 +119,6 @@ private:
QTextCodec *codec); QTextCodec *codec);
SubversionResponse runSvn(const QStringList &arguments, int timeOut, SubversionResponse runSvn(const QStringList &arguments, int timeOut,
bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0); bool showStdOutInOutputWindow, QTextCodec *outputCodec = 0);
void showOutput(const QString &output, bool bringToForeground = true);
void annotate(const QString &file); void annotate(const QString &file);
void filelog(const QString &file); void filelog(const QString &file);
bool managesDirectory(const QDir &directory) const; bool managesDirectory(const QDir &directory) const;
@@ -136,7 +134,6 @@ private:
Core::IVersionControl *m_versionControl; Core::IVersionControl *m_versionControl;
QTemporaryFile *m_changeTmpFile; QTemporaryFile *m_changeTmpFile;
SubversionOutputWindow *m_subversionOutputWindow;
ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer; ProjectExplorer::ProjectExplorerPlugin *m_projectExplorer;
Core::Utils::ParameterAction *m_addAction; Core::Utils::ParameterAction *m_addAction;
@@ -159,8 +156,6 @@ private:
bool m_submitActionTriggered; bool m_submitActionTriggered;
static SubversionPlugin *m_subversionPluginInstance; static SubversionPlugin *m_subversionPluginInstance;
friend class SubversionOutputWindow;
}; };
// Just a proxy for SubversionPlugin // Just a proxy for SubversionPlugin

View File

@@ -22,7 +22,8 @@ HEADERS += vcsbase_global.h \
checkoutwizarddialog.h \ checkoutwizarddialog.h \
checkoutprogresswizardpage.h \ checkoutprogresswizardpage.h \
checkoutjobs.h \ checkoutjobs.h \
basecheckoutwizardpage.h basecheckoutwizardpage.h \
vcsbaseoutputwindow.h
SOURCES += vcsbaseplugin.cpp \ SOURCES += vcsbaseplugin.cpp \
baseannotationhighlighter.cpp \ baseannotationhighlighter.cpp \
@@ -41,7 +42,8 @@ SOURCES += vcsbaseplugin.cpp \
checkoutwizarddialog.cpp \ checkoutwizarddialog.cpp \
checkoutprogresswizardpage.cpp \ checkoutprogresswizardpage.cpp \
checkoutjobs.cpp \ checkoutjobs.cpp \
basecheckoutwizardpage.cpp basecheckoutwizardpage.cpp \
vcsbaseoutputwindow.cpp
RESOURCES += vcsbase.qrc RESOURCES += vcsbase.qrc

View File

@@ -0,0 +1,295 @@
/**************************************************************************
**
** 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 "vcsbaseoutputwindow.h"
#include <utils/qtcassert.h>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextCharFormat>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include <QtCore/QPointer>
#include <QtCore/QTextCodec>
#include <QtCore/QTime>
namespace VCSBase {
namespace Internal {
// A plain text edit with a special context menu containing "Clear" and
// and functions to append specially formatted entries.
class OutputWindowPlainTextEdit : public QPlainTextEdit {
public:
explicit OutputWindowPlainTextEdit(QWidget *parent);
void appendLines(QString s);
// Append red error text and pop up.
void appendError(const QString &text);
// Append warning error text and pop up.
void appendWarning(const QString &text);
// Append a bold command "10:00 " + "Executing: vcs -diff"
void appendCommand(const QString &text);
protected:
virtual void contextMenuEvent(QContextMenuEvent *event);
private:
const QTextCharFormat m_defaultFormat;
QTextCharFormat m_errorFormat;
QTextCharFormat m_warningFormat;
QTextCharFormat m_commandFormat;
};
OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) :
QPlainTextEdit(parent),
m_defaultFormat(currentCharFormat()),
m_errorFormat(m_defaultFormat),
m_warningFormat(m_defaultFormat),
m_commandFormat(m_defaultFormat)
{
setReadOnly(true);
setFrameStyle(QFrame::NoFrame);
m_errorFormat.setForeground(Qt::red);
m_warningFormat.setForeground(Qt::darkYellow);
m_commandFormat.setFontWeight(QFont::Bold);
}
void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addSeparator();
QAction *clearAction = menu->addAction(VCSBaseOutputWindow::tr("Clear"));
connect(clearAction, SIGNAL(triggered()), this, SLOT(clear()));
menu->exec(event->globalPos());
delete menu;
}
void OutputWindowPlainTextEdit::appendLines(QString s)
{
if (s.isEmpty())
return;
// Avoid additional new line character generated by appendPlainText
if (s.endsWith(QLatin1Char('\n')))
s.truncate(s.size() - 1);
appendPlainText(s);
// Scroll down
moveCursor(QTextCursor::End);
ensureCursorVisible();
}
void OutputWindowPlainTextEdit::appendError(const QString &text)
{
setCurrentCharFormat(m_errorFormat);
appendLines(text);
setCurrentCharFormat(m_defaultFormat);
}
void OutputWindowPlainTextEdit::appendWarning(const QString &text)
{
setCurrentCharFormat(m_warningFormat);
appendLines(text);
setCurrentCharFormat(m_defaultFormat);
}
// Append command with new line and log time stamp
void OutputWindowPlainTextEdit::appendCommand(const QString &text)
{
setCurrentCharFormat(m_commandFormat);
const QString timeStamp = QTime::currentTime().toString(QLatin1String("\nHH:mm "));
appendLines(timeStamp + text);
setCurrentCharFormat(m_defaultFormat);
}
} // namespace Internal
// ------------------- VCSBaseOutputWindowPrivate
struct VCSBaseOutputWindowPrivate {
static VCSBaseOutputWindow *instance;
QPointer<Internal::OutputWindowPlainTextEdit> plainTextEdit;
};
VCSBaseOutputWindow *VCSBaseOutputWindowPrivate::instance = 0;
VCSBaseOutputWindow::VCSBaseOutputWindow() :
d(new VCSBaseOutputWindowPrivate)
{
VCSBaseOutputWindowPrivate::instance = this;
}
VCSBaseOutputWindow::~VCSBaseOutputWindow()
{
VCSBaseOutputWindowPrivate::instance = 0;
delete d;
}
QWidget *VCSBaseOutputWindow::outputWidget(QWidget *parent)
{
if (!d->plainTextEdit)
d->plainTextEdit = new Internal::OutputWindowPlainTextEdit(parent);
return d->plainTextEdit;
}
QWidgetList VCSBaseOutputWindow::toolBarWidgets() const
{
return QWidgetList();
}
QString VCSBaseOutputWindow::name() const
{
return tr("Version Control");
}
int VCSBaseOutputWindow::priorityInStatusBar() const
{
return -1;
}
void VCSBaseOutputWindow::clearContents()
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->clear();
}
void VCSBaseOutputWindow::visibilityChanged(bool visible)
{
if (visible && d->plainTextEdit)
d->plainTextEdit->setFocus();
}
void VCSBaseOutputWindow::setFocus()
{
}
bool VCSBaseOutputWindow::hasFocus()
{
return false;
}
bool VCSBaseOutputWindow::canFocus()
{
return false;
}
bool VCSBaseOutputWindow::canNavigate()
{
return false;
}
bool VCSBaseOutputWindow::canNext()
{
return false;
}
bool VCSBaseOutputWindow::canPrevious()
{
return false;
}
void VCSBaseOutputWindow::goToNext()
{
}
void VCSBaseOutputWindow::goToPrev()
{
}
void VCSBaseOutputWindow::setText(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->setPlainText(text);
}
void VCSBaseOutputWindow::setData(const QByteArray &data)
{
setText(QTextCodec::codecForLocale()->toUnicode(data));
}
void VCSBaseOutputWindow::appendSilently(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->appendLines(text);
}
void VCSBaseOutputWindow::append(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
appendSilently(text);
// Pop up without focus
if (!d->plainTextEdit->isVisible())
popup(false);
}
void VCSBaseOutputWindow::appendError(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->appendError(text);
if (!d->plainTextEdit->isVisible())
popup(false); // Pop up without focus
}
void VCSBaseOutputWindow::appendWarning(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->appendWarning(text);
if (!d->plainTextEdit->isVisible())
popup(false); // Pop up without focus
}
void VCSBaseOutputWindow::appendCommand(const QString &text)
{
QTC_ASSERT(d->plainTextEdit, return)
d->plainTextEdit->appendCommand(text);
}
void VCSBaseOutputWindow::appendData(const QByteArray &data)
{
QTC_ASSERT(d->plainTextEdit, return)
appendDataSilently(data);
if (!d->plainTextEdit->isVisible())
popup(false); // Pop up without focus
}
void VCSBaseOutputWindow::appendDataSilently(const QByteArray &data)
{
append(QTextCodec::codecForLocale()->toUnicode(data));
}
VCSBaseOutputWindow *VCSBaseOutputWindow::instance()
{
if (!VCSBaseOutputWindowPrivate::instance) {
VCSBaseOutputWindow *w = new VCSBaseOutputWindow;
Q_UNUSED(w)
}
return VCSBaseOutputWindowPrivate::instance;
}
} // namespace VCSBase

View File

@@ -0,0 +1,107 @@
/**************************************************************************
**
** 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 VCSBASEOUTPUTWINDOW_H
#define VCSBASEOUTPUTWINDOW_H
#include "vcsbase_global.h"
#include <coreplugin/ioutputpane.h>
namespace VCSBase {
struct VCSBaseOutputWindowPrivate;
/* Common OutputWindow for Version Control System command and other output.
* Installed by the base plugin and accessible for the other plugins
* via static instance()-accessor. Provides slots to append output with
* special formatting. */
class VCSBASE_EXPORT VCSBaseOutputWindow : public Core::IOutputPane
{
Q_OBJECT
public:
virtual ~VCSBaseOutputWindow();
virtual QWidget *outputWidget(QWidget *parent);
virtual QWidgetList toolBarWidgets() const;
virtual QString name() const;
virtual int priorityInStatusBar() const;
virtual void clearContents();
virtual void visibilityChanged(bool visible);
virtual void setFocus();
virtual bool hasFocus();
virtual bool canFocus();
virtual bool canNavigate();
virtual bool canNext();
virtual bool canPrevious();
virtual void goToNext();
virtual void goToPrev();
static VCSBaseOutputWindow *instance();
public slots:
// Set the whole text.
void setText(const QString &text);
// Set text from QProcess' output data using the Locale's converter.
void setData(const QByteArray &data);
// Append text and pop up.
void append(const QString &text);
// Append data using the Locale's converter and pop up.
void appendData(const QByteArray &data);
// Silently append text, do not pop up.
void appendSilently(const QString &text);
// Silently append data using the Locale's converter, do not pop up.
void appendDataSilently(const QByteArray &data);
// Append red error text and pop up.
void appendError(const QString &text);
// Append dark-yellow warning text and pop up.
void appendWarning(const QString &text);
// Append a command, prepended by a log time stamp. "Executing: vcs -diff"
// will result in "10:00 Executing: vcs -diff" in bold
void appendCommand(const QString &text);
private:
VCSBaseOutputWindow();
VCSBaseOutputWindowPrivate *d;
};
} // namespace VCSBase
#endif // VCSBASEOUTPUTWINDOW_H

View File

@@ -31,6 +31,7 @@
#include "diffhighlighter.h" #include "diffhighlighter.h"
#include "vcsbasesettingspage.h" #include "vcsbasesettingspage.h"
#include "nicknamedialog.h" #include "nicknamedialog.h"
#include "vcsbaseoutputwindow.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h> #include <coreplugin/coreconstants.h>
@@ -68,6 +69,7 @@ bool VCSBasePlugin::initialize(const QStringList &arguments, QString *errorMessa
m_settingsPage = new VCSBaseSettingsPage; m_settingsPage = new VCSBaseSettingsPage;
addAutoReleasedObject(m_settingsPage); addAutoReleasedObject(m_settingsPage);
addAutoReleasedObject(VCSBaseOutputWindow::instance());
connect(m_settingsPage, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings)), connect(m_settingsPage, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings)),
this, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings))); this, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings)));
connect(m_settingsPage, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings)), connect(m_settingsPage, SIGNAL(settingsChanged(VCSBase::Internal::VCSBaseSettings)),