forked from qt-creator/qt-creator
VCS: Simplify editor/command connections
* Move all the connections to setCommand() * Move gotoLine logic to reportCommandFinished Change-Id: I67ad74820b3d20b2b5fa97edad92f0f30111166f Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
706fc6c00d
commit
a63681c1d2
@@ -51,17 +51,6 @@
|
|||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
static void commandFinished(VcsBase::VcsBaseEditorWidget *editor, VcsBase::VcsCommand *cmd)
|
|
||||||
{
|
|
||||||
if (!cmd->lastExecutionSuccess()) {
|
|
||||||
editor->reportCommandFinished(false, cmd->lastExecutionExitCode(), cmd->cookie());
|
|
||||||
} else if (cmd->cookie().type() == QVariant::Int) {
|
|
||||||
const int line = cmd->cookie().toInt();
|
|
||||||
if (line >= 0)
|
|
||||||
editor->gotoLine(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class VcsBase::VcsBaseClient
|
\class VcsBase::VcsBaseClient
|
||||||
|
|
||||||
@@ -131,12 +120,8 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory,
|
|||||||
{
|
{
|
||||||
auto cmd = new VcsCommand(workingDirectory, processEnvironment());
|
auto cmd = new VcsCommand(workingDirectory, processEnvironment());
|
||||||
cmd->setDefaultTimeoutS(vcsTimeoutS());
|
cmd->setDefaultTimeoutS(vcsTimeoutS());
|
||||||
if (editor) {
|
if (editor)
|
||||||
editor->setCommand(cmd);
|
editor->setCommand(cmd);
|
||||||
connect(editor, &QObject::destroyed, cmd, &VcsCommand::abort);
|
|
||||||
connect(cmd, &VcsCommand::finished,
|
|
||||||
editor, [editor, cmd]() { commandFinished(editor, cmd); });
|
|
||||||
}
|
|
||||||
if (mode == VcsWindowOutputBind) {
|
if (mode == VcsWindowOutputBind) {
|
||||||
cmd->addFlags(VcsCommand::ShowStdOut);
|
cmd->addFlags(VcsCommand::ShowStdOut);
|
||||||
if (editor) // assume that the commands output is the important thing
|
if (editor) // assume that the commands output is the important thing
|
||||||
|
|||||||
@@ -1199,10 +1199,15 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const
|
|||||||
void VcsBaseEditorWidget::reportCommandFinished(bool ok, int exitCode, const QVariant &data)
|
void VcsBaseEditorWidget::reportCommandFinished(bool ok, int exitCode, const QVariant &data)
|
||||||
{
|
{
|
||||||
Q_UNUSED(exitCode);
|
Q_UNUSED(exitCode);
|
||||||
Q_UNUSED(data);
|
|
||||||
|
|
||||||
if (!ok)
|
hideProgressIndicator();
|
||||||
|
if (!ok) {
|
||||||
textDocument()->setPlainText(tr("Failed to retrieve data."));
|
textDocument()->setPlainText(tr("Failed to retrieve data."));
|
||||||
|
} else if (data.type() == QVariant::Int) {
|
||||||
|
const int line = data.toInt();
|
||||||
|
if (line >= 0)
|
||||||
|
gotoLine(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParameters *array,
|
const VcsBaseEditorParameters *VcsBaseEditor::findType(const VcsBaseEditorParameters *array,
|
||||||
@@ -1385,11 +1390,10 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
|
|||||||
hideProgressIndicator();
|
hideProgressIndicator();
|
||||||
}
|
}
|
||||||
d->m_command = command;
|
d->m_command = command;
|
||||||
if (d->m_command) {
|
if (command) {
|
||||||
d->m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Large);
|
d->m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Large);
|
||||||
d->m_progressIndicator->attachToWidget(this);
|
d->m_progressIndicator->attachToWidget(this);
|
||||||
connect(d->m_command.data(), &VcsCommand::finished,
|
connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished);
|
||||||
this, &VcsBaseEditorWidget::hideProgressIndicator);
|
|
||||||
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);
|
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user