diff options
author | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2015-02-26 12:43:59 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2015-02-27 11:36:07 +0000 |
commit | 80439d01e2feb1342dc470627585559c97805be3 (patch) | |
tree | dbfe2c9c8b77d80e0bf33004021b91861db27762 /src/libs/installer/createshortcutoperation.cpp | |
parent | 78a1e54683e80ee4c029816c7308c94ca85712bd (diff) |
Cleanup
1. Add a checkArgumentCount() helper method.
2. Fix a plural form of the check method.
3. Remove repeating translation for every UpdateOperation subclass.
4. Use always QList.at() for checking arguments,
instead of random usage of first(), last() and at().
5. Fix const corectness.
6. Move isPersistant into #ifdef Q_OS_WIN inside
EnvironmentVariableOperation.
Change-Id: Idaa12265f1816871de0a4ea3ae586512859a04e3
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/createshortcutoperation.cpp')
-rw-r--r-- | src/libs/installer/createshortcutoperation.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp index 060672bd8..2ee7dfbf4 100644 --- a/src/libs/installer/createshortcutoperation.cpp +++ b/src/libs/installer/createshortcutoperation.cpp @@ -179,23 +179,18 @@ void CreateShortcutOperation::backup() bool CreateShortcutOperation::performOperation() { + if (!checkArgumentCount(2, 3, tr("(optional: \"workingDirectory=...\", \"iconPath=...\", \"iconId=...\")"))) + return false; + QStringList args = arguments(); const QString iconId = takeArgument(QString::fromLatin1("iconId="), &args); const QString iconPath = takeArgument(QString::fromLatin1("iconPath="), &args); const QString workingDir = takeArgument(QString::fromLatin1("workingDirectory="), &args); - if (args.count() != 2 && args.count() != 3) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("2 or 3"), - tr(" (optional: 'workingDirectory=...', 'iconPath=...', 'iconId=...')"))); - return false; - } - const QString linkTarget = args.at(0); const QString linkLocation = args.at(1); - const QString targetArguments = args.value(2); //used value because it could be not existing + const QString targetArguments = args.value(2); // value() used since it's optional const QString linkPath = QFileInfo(linkLocation).absolutePath().trimmed(); const bool created = QDir(linkPath).exists() || QDir::root().mkpath(linkPath); |