Utils: Add CommandLine::prependArgs convenience functions

For clearer code on the user side.

Change-Id: I3adf2e96628f4e59293cd2f0966fb30989e0da9f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2022-05-25 11:52:18 +02:00
parent 743dd442d7
commit ae42604904
2 changed files with 19 additions and 2 deletions

View File

@@ -1485,6 +1485,21 @@ void CommandLine::addArgs(const QString &inArgs, RawType)
ProcessArgs::addArgs(&m_arguments, inArgs);
}
void CommandLine::prependArgs(const QStringList &inArgs)
{
QString oldArgs = m_arguments;
m_arguments.clear();
addArgs(inArgs);
addArgs(oldArgs, Raw);
}
void CommandLine::prependArgs(const QString &inArgs, RawType)
{
QString oldArgs = m_arguments;
m_arguments = inArgs;
addArgs(oldArgs, Raw);
}
QString CommandLine::toUserOutput() const
{
QString res = m_executable.toUserOutput();

View File

@@ -143,12 +143,14 @@ public:
void addArg(const QString &arg);
void addArgs(const QStringList &inArgs);
void addArgs(const QString &inArgs, RawType);
void prependArgs(const QStringList &inArgs);
void prependArgs(const QString &inArgs, RawType);
void addCommandLineAsArgs(const CommandLine &cmd);
void addCommandLineAsArgs(const CommandLine &cmd, RawType);
void addArgs(const QString &inArgs, RawType);
QString toUserOutput() const;
FilePath executable() const { return m_executable; }