ProjectExplorer: Create a ToolRunSupport base class

This is meant to be a base for tool-specific additions to the
target-specific RunControls providing a common base and convenience
interface for the various *{Debug,Analyze,*}Support classes.

Code in the current support classes in intended to be split
in bits suitable to be handled by the target run controls
and in target-independent bits in the pure tool implementation,
making the ToolRunSupport derived instances as slim as possible.



Change-Id: I2bc3f4ad246f6ea81b19458ee5a4392609e4fd2d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-03-24 17:06:13 +01:00
parent 9250c19007
commit eb0b0f9443
2 changed files with 46 additions and 2 deletions

View File

@@ -519,6 +519,7 @@ public:
~RunControlPrivate() ~RunControlPrivate()
{ {
delete toolRunner;
delete outputFormatter; delete outputFormatter;
} }
@@ -528,8 +529,9 @@ public:
Connection connection; Connection connection;
Core::Id runMode; Core::Id runMode;
Utils::Icon icon; Utils::Icon icon;
const QPointer<RunConfiguration> runConfiguration; const QPointer<RunConfiguration> runConfiguration; // Not owned.
QPointer<Project> project; QPointer<Project> project; // Not owned.
QPointer<ToolRunner> toolRunner; // Owned. QPointer as "extra safety" for now.
Utils::OutputFormatter *outputFormatter = nullptr; Utils::OutputFormatter *outputFormatter = nullptr;
// A handle to the actual application process. // A handle to the actual application process.
@@ -617,6 +619,16 @@ void RunControl::setConnection(const Connection &connection)
d->connection = connection; d->connection = connection;
} }
ToolRunner *RunControl::toolRunner() const
{
return d->toolRunner;
}
void RunControl::setToolRunner(ToolRunner *tool)
{
d->toolRunner = tool;
}
QString RunControl::displayName() const QString RunControl::displayName() const
{ {
return d->displayName; return d->displayName;
@@ -964,4 +976,17 @@ void SimpleRunControl::onProcessFinished(int exitCode, QProcess::ExitStatus stat
reportApplicationStop(); reportApplicationStop();
} }
// ToolRunner
ToolRunner::ToolRunner(RunControl *runControl)
: m_runControl(runControl)
{
runControl->setToolRunner(this);
}
RunControl *ToolRunner::runControl() const
{
return m_runControl;
}
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -49,6 +49,7 @@ class IRunConfigurationAspect;
class RunConfiguration; class RunConfiguration;
class RunConfigWidget; class RunConfigWidget;
class RunControl; class RunControl;
class ToolRunner;
class Target; class Target;
namespace Internal { namespace Internal {
@@ -397,6 +398,9 @@ public:
const Connection &connection() const; const Connection &connection() const;
void setConnection(const Connection &connection); void setConnection(const Connection &connection);
ToolRunner *toolRunner() const;
void setToolRunner(ToolRunner *tool);
virtual void appendMessage(const QString &msg, Utils::OutputFormat format); virtual void appendMessage(const QString &msg, Utils::OutputFormat format);
virtual void bringApplicationToForeground(); virtual void bringApplicationToForeground();
@@ -444,4 +448,19 @@ private:
Internal::SimpleRunControlPrivate * const d; Internal::SimpleRunControlPrivate * const d;
}; };
/**
* A base for tool-specific additions to target-specific RunControl.
*/
class PROJECTEXPLORER_EXPORT ToolRunner : public QObject
{
public:
explicit ToolRunner(RunControl *runControl);
RunControl *runControl() const;
private:
QPointer<RunControl> m_runControl;
};
} // namespace ProjectExplorer } // namespace ProjectExplorer