diff options
Diffstat (limited to 'src/libs/installer/installiconsoperation.cpp')
-rw-r--r-- | src/libs/installer/installiconsoperation.cpp | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/src/libs/installer/installiconsoperation.cpp b/src/libs/installer/installiconsoperation.cpp index e5622dc2e..a91b644b8 100644 --- a/src/libs/installer/installiconsoperation.cpp +++ b/src/libs/installer/installiconsoperation.cpp @@ -91,7 +91,8 @@ QString InstallIconsOperation::targetDirectory() return directory; } -InstallIconsOperation::InstallIconsOperation() +InstallIconsOperation::InstallIconsOperation(PackageManagerCore *core) + : UpdateOperation(core) { setName(QLatin1String("InstallIcons")); } @@ -108,20 +109,16 @@ void InstallIconsOperation::backup() bool InstallIconsOperation::performOperation() { - const QStringList args = arguments(); - if ((args.count() != 1) && (args.count() != 2)) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("1 or 2"), tr(" (Sourcepath, [Vendorprefix])"))); + if (!checkArgumentCount(1, 2, tr("<source path> [vendor prefix]"))) return false; - } + const QStringList args = arguments(); const QString source = args.at(0); - const QString vendor = args.value(1); + const QString vendor = args.value(1); // value() used since it's optional if (source.isEmpty()) { setError(InvalidArguments); - setErrorString(tr("Invalid Argument: source folder must not be empty.")); + setErrorString(tr("Invalid Argument: source directory must not be empty.")); return false; } @@ -132,7 +129,7 @@ bool InstallIconsOperation::performOperation() QStringList backupFiles; QStringList createdDirectories; - PackageManagerCore *const core = value(QLatin1String("installer")).value<PackageManagerCore*>(); + PackageManagerCore *const core = packageManager(); // iterate a second time to get the actual work done QDirIterator it(sourceDir.path(), QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot, @@ -170,7 +167,8 @@ bool InstallIconsOperation::performOperation() QFile bf(target); if (!bf.copy(backup)) { setError(UserDefinedError); - setErrorString(tr("Could not backup file %1: %2").arg(target, bf.errorString())); + setErrorString(tr("Cannot backup file \"%1\": %2").arg( + QDir::toNativeSeparators(target), bf.errorString())); undoOperation(); return false; } @@ -183,7 +181,8 @@ bool InstallIconsOperation::performOperation() QString errStr; if (!deleteFileNowOrLater(target, &errStr)) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1: %2").arg(target, errStr)); + setErrorString(tr("Failed to overwrite \"%1\": %2").arg( + QDir::toNativeSeparators(target), errStr)); undoOperation(); return false; } @@ -194,7 +193,8 @@ bool InstallIconsOperation::performOperation() QFile cf(source); if (!cf.copy(target)) { setError(UserDefinedError); - setErrorString(tr("Failed to copy file %1: %2").arg(target, cf.errorString())); + setErrorString(tr("Failed to copy file \"%1\": %2").arg( + QDir::toNativeSeparators(target), cf.errorString())); undoOperation(); return false; } @@ -204,7 +204,8 @@ bool InstallIconsOperation::performOperation() setValue(QLatin1String("files"), files); } else if (fi.isDir() && !QDir(target).exists()) { if (!QDir().mkpath(target)) { - setErrorString(tr("Could not create folder at %1: %2").arg(target, qt_error_string())); + setErrorString(tr("Cannot create directory \"%1\": %2").arg( + QDir::toNativeSeparators(target), qt_error_string())); undoOperation(); return false; } @@ -236,7 +237,7 @@ bool InstallIconsOperation::undoOperation() QFile installedTarget(target); if (installedTarget.exists() && !(installedTarget.copy(source) && installedTarget.remove())) { - warningMessages << QString::fromLatin1("Could not move file from '%1' to '%2', error: %3)").arg( + warningMessages << QString::fromLatin1("Cannot move file from \"%1\" to \"%2\": %3)").arg( target, source, installedTarget.errorString()); } } @@ -252,13 +253,13 @@ bool InstallIconsOperation::undoOperation() deleteFileNowOrLater(target); // then copy the backup onto the target if (!QFile::copy(backup, target)) { - warningMessages << QString::fromLatin1("Could not restore the backup '%1' to '%2'").arg( + warningMessages << QString::fromLatin1("Cannot restore the backup \"%1\" to \"%2\".").arg( backup, target); } // finally remove the backp if (!deleteFileNowOrLater(backup)) - warningMessages << QString::fromLatin1("Could not remove the backup '%1'").arg(backup); + warningMessages << QString::fromLatin1("Cannot remove the backup \"%1\".").arg(backup); } @@ -268,14 +269,14 @@ bool InstallIconsOperation::undoOperation() const QDir dir(*it); removeSystemGeneratedFiles(dir.absolutePath()); if (dir.exists() && !QDir::root().rmdir(dir.path())) - warningMessages << QString::fromLatin1("Could not remove directory '%1'").arg(dir.path()); + warningMessages << QString::fromLatin1("Cannot remove directory \"%1\".").arg(dir.path()); } if (!warningMessages.isEmpty()) { - qWarning() << QString::fromLatin1("Undo of operation '%1' with arguments '%2' had some problems.").arg( - name(), arguments().join(QLatin1String(", "))); + qWarning() << "Undo of operation" << name() << "with arguments" + << arguments().join(QLatin1String(", ")) << "had some problems."; foreach (const QString &message, warningMessages) { - qWarning() << message; + qWarning().noquote() << message; } } @@ -286,8 +287,3 @@ bool InstallIconsOperation::testOperation() { return true; } - -Operation *InstallIconsOperation::clone() const -{ - return new InstallIconsOperation(); -} |