From 4098be05b23dd20aaf752fb9aec79fe8d90a4220 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 28 May 2019 18:59:45 +0200 Subject: Utils: Extract a CommandLine structure from a QtcProcess We regularly pass around strings or filenames or pairs of strings or filenames and stringlist etc the in the end will be used as a kind of "command line", with quite a bit of ad-hoc user code and QtcProcess::addArg etc to set them up and manipulate them. Let's have a class for that concept. Change-Id: I288ab939d853b32c717135a65242c584c2beab50 Reviewed-by: Christian Kandeler --- src/libs/utils/qtcprocess.h | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/libs/utils/qtcprocess.h') diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 44c5786661..69c79098b4 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -32,16 +32,32 @@ namespace Utils { class AbstractMacroExpander; +class QTCREATOR_UTILS_EXPORT CommandLine +{ +public: + CommandLine() {} + + CommandLine(const FilePath &executable, const QString &arguments) + : m_executable(executable), m_arguments(arguments) + {} + + FilePath executable() const { return m_executable; } + QString arguments() const { return m_arguments; } + +private: + FilePath m_executable; + QString m_arguments; +}; + class QTCREATOR_UTILS_EXPORT QtcProcess : public QProcess { Q_OBJECT public: QtcProcess(QObject *parent = nullptr); - void setEnvironment(const Environment &env) - { m_environment = env; m_haveEnv = true; } - void setCommand(const QString &command, const QString &arguments) - { m_command = command; m_arguments = arguments; } + + void setEnvironment(const Environment &env) { m_environment = env; m_haveEnv = true; } + void setCommand(const CommandLine &cmdLine) { m_commandLine = cmdLine; } void setUseCtrlCStub(bool enabled); void start(); void terminate(); @@ -141,8 +157,7 @@ public: }; private: - QString m_command; - QString m_arguments; + CommandLine m_commandLine; Environment m_environment; bool m_haveEnv = false; bool m_useCtrlCStub = false; -- cgit v1.2.1