diff --git a/src/libs/ssh/sftpsession.cpp b/src/libs/ssh/sftpsession.cpp index c187072db8b..80762a643e7 100644 --- a/src/libs/ssh/sftpsession.cpp +++ b/src/libs/ssh/sftpsession.cpp @@ -30,7 +30,7 @@ #include "sshsettings.h" #include -#include +#include #include #include diff --git a/src/libs/ssh/sftptransfer.cpp b/src/libs/ssh/sftptransfer.cpp index 3b26f0fae88..c7561e611ae 100644 --- a/src/libs/ssh/sftptransfer.cpp +++ b/src/libs/ssh/sftptransfer.cpp @@ -36,7 +36,7 @@ #include #include -#include +#include using namespace Utils; diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp index 3d1ef6a81e0..fdfe76e9b29 100644 --- a/src/libs/ssh/sshremoteprocess.cpp +++ b/src/libs/ssh/sshremoteprocess.cpp @@ -28,7 +28,7 @@ #include "sshlogging_p.h" #include "sshsettings.h" -#include +#include #include #include diff --git a/src/libs/ssh/sshremoteprocess.h b/src/libs/ssh/sshremoteprocess.h index d1d62d76fad..16793d1c013 100644 --- a/src/libs/ssh/sshremoteprocess.h +++ b/src/libs/ssh/sshremoteprocess.h @@ -28,7 +28,9 @@ #include "ssh_global.h" #include "sshprocess.h" -#include +namespace Utils { +class CommandLine; +} namespace QSsh { class SshConnection; diff --git a/src/libs/utils/CMakeLists.txt b/src/libs/utils/CMakeLists.txt index a46314045c3..4bddb17fc4b 100644 --- a/src/libs/utils/CMakeLists.txt +++ b/src/libs/utils/CMakeLists.txt @@ -24,6 +24,7 @@ add_qtc_library(Utils checkablemessagebox.cpp checkablemessagebox.h classnamevalidatinglineedit.cpp classnamevalidatinglineedit.h codegeneration.cpp codegeneration.h + commandline.cpp commandline.h completinglineedit.cpp completinglineedit.h completingtextedit.cpp completingtextedit.h consoleprocess.cpp consoleprocess.h @@ -115,7 +116,6 @@ add_qtc_library(Utils porting.h portlist.cpp portlist.h predicates.h - processargs.cpp processargs.h processhandle.cpp processhandle.h progressindicator.cpp progressindicator.h projectintropage.cpp projectintropage.h projectintropage.ui diff --git a/src/libs/utils/processargs.cpp b/src/libs/utils/commandline.cpp similarity index 96% rename from src/libs/utils/processargs.cpp rename to src/libs/utils/commandline.cpp index ec7402fadfd..3ae7984275f 100644 --- a/src/libs/utils/processargs.cpp +++ b/src/libs/utils/commandline.cpp @@ -23,7 +23,7 @@ ** ****************************************************************************/ -#include "processargs.h" +#include "commandline.h" #include "environment.h" #include "qtcassert.h" @@ -1409,4 +1409,74 @@ QString ProcessArgs::toString() const return ProcessArgs::joinArgs(m_unixArgs, OsTypeLinux); } +/*! + \class Utils::CommandLine + + \brief The CommandLine class represents a command line of a QProcess or + similar utility. + */ + +CommandLine::CommandLine() = default; + +CommandLine::CommandLine(const QString &executable) + : m_executable(FilePath::fromString(executable)) +{} + +CommandLine::CommandLine(const FilePath &executable) + : m_executable(executable) +{} + +CommandLine::CommandLine(const QString &exe, const QStringList &args) + : CommandLine(FilePath::fromString(exe), args) +{} + +CommandLine::CommandLine(const FilePath &exe, const QStringList &args) + : m_executable(exe) +{ + addArgs(args); +} + +CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType) + : m_executable(exe) +{ + addArgs(args, Raw); +} + +void CommandLine::addArg(const QString &arg, OsType osType) +{ + ProcessArgs::addArg(&m_arguments, arg, osType); +} + +void CommandLine::addArgs(const QStringList &inArgs, OsType osType) +{ + for (const QString &arg : inArgs) + addArg(arg, osType); +} + +// Adds cmd's executable and arguments one by one to this commandline. +// Useful for 'sudo', 'nice', etc +void CommandLine::addArgs(const CommandLine &cmd, OsType osType) +{ + addArg(cmd.executable().toString()); + addArgs(cmd.splitArguments(osType)); +} + +void CommandLine::addArgs(const QString &inArgs, RawType) +{ + ProcessArgs::addArgs(&m_arguments, inArgs); +} + +QString CommandLine::toUserOutput() const +{ + QString res = m_executable.toUserOutput(); + if (!m_arguments.isEmpty()) + res += ' ' + m_arguments; + return res; +} + +QStringList CommandLine::splitArguments(OsType osType) const +{ + return ProcessArgs::splitArgs(m_arguments, osType); +} + } // namespace Utils diff --git a/src/libs/utils/processargs.h b/src/libs/utils/commandline.h similarity index 84% rename from src/libs/utils/processargs.h rename to src/libs/utils/commandline.h index 62c40d6ace6..473c2677206 100644 --- a/src/libs/utils/processargs.h +++ b/src/libs/utils/commandline.h @@ -27,6 +27,7 @@ #include "utils_global.h" +#include "fileutils.h" #include "hostosinfo.h" #include @@ -130,4 +131,35 @@ private: bool m_isWindows; }; +class QTCREATOR_UTILS_EXPORT CommandLine +{ +public: + enum RawType { Raw }; + + CommandLine(); + explicit CommandLine(const QString &executable); + explicit CommandLine(const FilePath &executable); + CommandLine(const QString &exe, const QStringList &args); + CommandLine(const FilePath &exe, const QStringList &args); + CommandLine(const FilePath &exe, const QString &unparsedArgs, RawType); + + void addArg(const QString &arg, OsType osType = HostOsInfo::hostOs()); + void addArgs(const QStringList &inArgs, OsType osType = HostOsInfo::hostOs()); + void addArgs(const CommandLine &cmd, OsType osType = HostOsInfo::hostOs()); + + void addArgs(const QString &inArgs, RawType); + + QString toUserOutput() const; + + FilePath executable() const { return m_executable; } + QString arguments() const { return m_arguments; } + QStringList splitArguments(OsType osType = HostOsInfo::hostOs()) const; + +private: + FilePath m_executable; + QString m_arguments; +}; + } // namespace Utils + +Q_DECLARE_METATYPE(Utils::CommandLine) diff --git a/src/libs/utils/consoleprocess.cpp b/src/libs/utils/consoleprocess.cpp index 5b63b07d18d..19f5f3a79f0 100644 --- a/src/libs/utils/consoleprocess.cpp +++ b/src/libs/utils/consoleprocess.cpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 9e60f9cded1..87b30749389 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -27,7 +27,7 @@ #include "savefile.h" #include "algorithm.h" -#include "processargs.h" +#include "commandline.h" #include "qtcassert.h" #include @@ -65,76 +65,6 @@ namespace Utils { static DeviceFileHooks s_deviceHooks; -/*! \class Utils::CommandLine - - \brief The CommandLine class represents a command line of a QProcess - or similar utility. - -*/ - -CommandLine::CommandLine() = default; - -CommandLine::CommandLine(const QString &executable) - : m_executable(FilePath::fromString(executable)) -{} - -CommandLine::CommandLine(const FilePath &executable) - : m_executable(executable) -{} - -CommandLine::CommandLine(const QString &exe, const QStringList &args) - : CommandLine(FilePath::fromString(exe), args) -{} - -CommandLine::CommandLine(const FilePath &exe, const QStringList &args) - : m_executable(exe) -{ - addArgs(args); -} - -CommandLine::CommandLine(const FilePath &exe, const QString &args, RawType) - : m_executable(exe) -{ - addArgs(args, Raw); -} - -void CommandLine::addArg(const QString &arg, OsType osType) -{ - ProcessArgs::addArg(&m_arguments, arg, osType); -} - -void CommandLine::addArgs(const QStringList &inArgs, OsType osType) -{ - for (const QString &arg : inArgs) - addArg(arg, osType); -} - -// Adds cmd's executable and arguments one by one to this commandline. -// Useful for 'sudo', 'nice', etc -void CommandLine::addArgs(const CommandLine &cmd, OsType osType) -{ - addArg(cmd.executable().toString()); - addArgs(cmd.splitArguments(osType)); -} - -void CommandLine::addArgs(const QString &inArgs, RawType) -{ - ProcessArgs::addArgs(&m_arguments, inArgs); -} - -QString CommandLine::toUserOutput() const -{ - QString res = m_executable.toUserOutput(); - if (!m_arguments.isEmpty()) - res += ' ' + m_arguments; - return res; -} - -QStringList CommandLine::splitArguments(OsType osType) const -{ - return ProcessArgs::splitArgs(m_arguments, osType); -} - /*! \class Utils::FileUtils \brief The FileUtils class contains file and directory related convenience diff --git a/src/libs/utils/fileutils.h b/src/libs/utils/fileutils.h index 459b7b8c740..77e52eedaa4 100644 --- a/src/libs/utils/fileutils.h +++ b/src/libs/utils/fileutils.h @@ -172,35 +172,6 @@ QTCREATOR_UTILS_EXPORT QTextStream &operator<<(QTextStream &s, const FilePath &f using FilePaths = QList; -class QTCREATOR_UTILS_EXPORT CommandLine -{ -public: - enum RawType { Raw }; - - CommandLine(); - explicit CommandLine(const QString &executable); - explicit CommandLine(const FilePath &executable); - CommandLine(const QString &exe, const QStringList &args); - CommandLine(const FilePath &exe, const QStringList &args); - CommandLine(const FilePath &exe, const QString &unparsedArgs, RawType); - - void addArg(const QString &arg, OsType osType = HostOsInfo::hostOs()); - void addArgs(const QStringList &inArgs, OsType osType = HostOsInfo::hostOs()); - void addArgs(const CommandLine &cmd, OsType osType = HostOsInfo::hostOs()); - - void addArgs(const QString &inArgs, RawType); - - QString toUserOutput() const; - - FilePath executable() const { return m_executable; } - QString arguments() const { return m_arguments; } - QStringList splitArguments(OsType osType = HostOsInfo::hostOs()) const; - -private: - FilePath m_executable; - QString m_arguments; -}; - class QTCREATOR_UTILS_EXPORT FileUtils { public: #ifdef QT_GUI_LIB @@ -402,4 +373,3 @@ template<> struct QTCREATOR_UTILS_EXPORT hash } // namespace std Q_DECLARE_METATYPE(Utils::FilePath) -Q_DECLARE_METATYPE(Utils::CommandLine) diff --git a/src/libs/utils/macroexpander.cpp b/src/libs/utils/macroexpander.cpp index 1b365ea56cf..ddf74bff316 100644 --- a/src/libs/utils/macroexpander.cpp +++ b/src/libs/utils/macroexpander.cpp @@ -27,7 +27,7 @@ #include "algorithm.h" #include "fileutils.h" -#include "processargs.h" +#include "commandline.h" #include "qtcassert.h" #include "stringutils.h" diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index 61bb5925461..1e5bdcbd82c 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -28,7 +28,7 @@ #include "stringutils.h" #include "executeondestruction.h" #include "hostosinfo.h" -#include "processargs.h" +#include "commandline.h" #include "qtcassert.h" #include diff --git a/src/libs/utils/qtcprocess.h b/src/libs/utils/qtcprocess.h index 08eb1d07bed..63449ce1a6b 100644 --- a/src/libs/utils/qtcprocess.h +++ b/src/libs/utils/qtcprocess.h @@ -28,7 +28,7 @@ #include "utils_global.h" #include "environment.h" -#include "processargs.h" +#include "commandline.h" #include #include diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index 7442348aeae..b4e5d3d31ae 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -34,7 +34,7 @@ SOURCES += \ $$PWD/namevalueitem.cpp \ $$PWD/namevaluemodel.cpp \ $$PWD/namevaluesdialog.cpp \ - $$PWD/processargs.cpp \ + $$PWD/commandline.cpp \ $$PWD/qrcparser.cpp \ $$PWD/qtcprocess.cpp \ $$PWD/reloadpromptutils.cpp \ @@ -156,7 +156,7 @@ HEADERS += \ $$PWD/namevalueitem.h \ $$PWD/namevaluemodel.h \ $$PWD/namevaluesdialog.h \ - $$PWD/processargs.h \ + $$PWD/commandline.h \ $$PWD/qrcparser.h \ $$PWD/qtcprocess.h \ $$PWD/span.h \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 9d60438489d..b55476ca483 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -64,6 +64,8 @@ Project { "classnamevalidatinglineedit.h", "codegeneration.cpp", "codegeneration.h", + "commandline.cpp", + "commandline.h", "completinglineedit.cpp", "completinglineedit.h", "completingtextedit.cpp", @@ -203,8 +205,6 @@ Project { "porting.h", "portlist.cpp", "portlist.h", - "processargs.cpp", - "processargs.h", "processhandle.cpp", "processhandle.h", "progressindicator.cpp", diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 82681fc0a92..647636b8f1a 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index a6dea044a3f..0f9cc1d3c8b 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp index 753c0a2de3f..4116d0dfea5 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/plugins/languageclient/languageclientsettings.h b/src/plugins/languageclient/languageclientsettings.h index be190987ef6..5ee567b0718 100644 --- a/src/plugins/languageclient/languageclientsettings.h +++ b/src/plugins/languageclient/languageclientsettings.h @@ -29,9 +29,8 @@ #include -#include - #include +#include #include #include #include @@ -44,6 +43,7 @@ class QLineEdit; QT_END_NAMESPACE namespace Utils { +class CommandLine; class FilePath; class PathChooser; class FancyLineEdit; diff --git a/src/plugins/mesonprojectmanager/exewrappers/toolwrapper.h b/src/plugins/mesonprojectmanager/exewrappers/toolwrapper.h index b03f8d4816f..a2000677453 100644 --- a/src/plugins/mesonprojectmanager/exewrappers/toolwrapper.h +++ b/src/plugins/mesonprojectmanager/exewrappers/toolwrapper.h @@ -27,6 +27,7 @@ #include "versionhelper.h" +#include #include #include #include diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index 9a324af31bf..283b3ed730b 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -29,6 +29,10 @@ #include +namespace Utils { +class CommandLine; +} + namespace ProjectExplorer { class ProcessParameters; diff --git a/src/plugins/projectexplorer/buildsystem.h b/src/plugins/projectexplorer/buildsystem.h index 8171300980a..bedaa7d5ee5 100644 --- a/src/plugins/projectexplorer/buildsystem.h +++ b/src/plugins/projectexplorer/buildsystem.h @@ -33,6 +33,10 @@ #include +namespace Utils { +class CommandLine; +} + namespace ProjectExplorer { class BuildConfiguration; diff --git a/src/plugins/projectexplorer/processparameters.h b/src/plugins/projectexplorer/processparameters.h index 94d1bd88839..08f2cf7e271 100644 --- a/src/plugins/projectexplorer/processparameters.h +++ b/src/plugins/projectexplorer/processparameters.h @@ -27,6 +27,7 @@ #include "projectexplorer_export.h" +#include #include #include diff --git a/src/plugins/projectexplorer/target.cpp b/src/plugins/projectexplorer/target.cpp index 8c1fb785335..d44a2944428 100644 --- a/src/plugins/projectexplorer/target.cpp +++ b/src/plugins/projectexplorer/target.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/src/plugins/qmakeprojectmanager/qmakestep.h b/src/plugins/qmakeprojectmanager/qmakestep.h index 3679186297a..b439108436d 100644 --- a/src/plugins/qmakeprojectmanager/qmakestep.h +++ b/src/plugins/qmakeprojectmanager/qmakestep.h @@ -30,7 +30,7 @@ #include #include -#include +#include #include diff --git a/src/tools/sdktool/CMakeLists.txt b/src/tools/sdktool/CMakeLists.txt index 6a67d8e4062..dc2320a92c4 100644 --- a/src/tools/sdktool/CMakeLists.txt +++ b/src/tools/sdktool/CMakeLists.txt @@ -86,7 +86,6 @@ extend_qtc_executable(sdktool persistentsettings.cpp persistentsettings.h porting.h qtcassert.cpp qtcassert.h - processargs.cpp processargs.h savefile.cpp savefile.h stringutils.cpp stringutils.h ) diff --git a/src/tools/sdktool/sdktool.pro b/src/tools/sdktool/sdktool.pro index 66cd49652e1..0b58755a1e5 100644 --- a/src/tools/sdktool/sdktool.pro +++ b/src/tools/sdktool/sdktool.pro @@ -38,7 +38,7 @@ SOURCES += \ $$UTILS/namevalueitem.cpp \ $$UTILS/persistentsettings.cpp \ $$UTILS/qtcassert.cpp \ - $$UTILS/processargs.cpp \ + $$UTILS/commandline.cpp \ $$UTILS/savefile.cpp \ $$UTILS/stringutils.cpp @@ -71,7 +71,7 @@ HEADERS += \ $$UTILS/namevalueitem.h \ $$UTILS/persistentsettings.h \ $$UTILS/qtcassert.h \ - $$UTILS/processargs.h \ + $$UTILS/commandline.h \ $$UTILS/savefile.h \ $$UTILS/porting.h diff --git a/src/tools/sdktool/sdktool.qbs b/src/tools/sdktool/sdktool.qbs index 13b57709d48..a6fd9ed8b84 100644 --- a/src/tools/sdktool/sdktool.qbs +++ b/src/tools/sdktool/sdktool.qbs @@ -68,6 +68,7 @@ QtcTool { name: "Utils" prefix: libsDir + "/utils/" files: [ + "commandline.cpp", "commandline.h", "environment.cpp", "environment.h", "fileutils.cpp", "fileutils.h", "hostosinfo.cpp", "hostosinfo.h", @@ -75,7 +76,6 @@ QtcTool { "namevalueitem.cpp", "namevalueitem.h", "persistentsettings.cpp", "persistentsettings.h", "porting.h", - "processargs.cpp", "processargs.h", "qtcassert.cpp", "qtcassert.h", "savefile.cpp", "savefile.h", "stringutils.cpp"