diff options
Diffstat (limited to 'src/libs/installer/createdesktopentryoperation.cpp')
-rw-r--r-- | src/libs/installer/createdesktopentryoperation.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/src/libs/installer/createdesktopentryoperation.cpp b/src/libs/installer/createdesktopentryoperation.cpp index 956060e61..ebe7f7ab3 100644 --- a/src/libs/installer/createdesktopentryoperation.cpp +++ b/src/libs/installer/createdesktopentryoperation.cpp @@ -96,7 +96,8 @@ QString CreateDesktopEntryOperation::absoluteFileName() return QDir(directory).absoluteFilePath(filename); } -CreateDesktopEntryOperation::CreateDesktopEntryOperation() +CreateDesktopEntryOperation::CreateDesktopEntryOperation(PackageManagerCore *core) + : UpdateOperation(core) { setName(QLatin1String("CreateDesktopEntry")); } @@ -121,32 +122,27 @@ void CreateDesktopEntryOperation::backup() } if (!file.copy(value(QLatin1String("backupOfExistingDesktopEntry")).toString())) - setErrorString(tr("Could not backup file %1: %2").arg(filename, file.errorString())); + setErrorString(tr("Cannot backup file \"%1\": %2").arg(QDir::toNativeSeparators(filename), file.errorString())); } bool CreateDesktopEntryOperation::performOperation() { - const QStringList args = arguments(); - if (args.count() != 2) { - setError(InvalidArguments); - setErrorString(tr("Invalid arguments in %0: %1 arguments given, %2 expected%3.") - .arg(name()).arg(arguments().count()).arg(tr("exactly 2"), QLatin1String(""))); + if (!checkArgumentCount(2)) return false; - } const QString filename = absoluteFileName(); - const QString &values = args[1]; + const QString &values = arguments().at(1); QFile file(filename); if (file.exists() && !file.remove()) { setError(UserDefinedError); - setErrorString(tr("Failed to overwrite %1").arg(filename)); + setErrorString(tr("Failed to overwrite file \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } if(!file.open(QIODevice::WriteOnly)) { setError(UserDefinedError); - setErrorString(tr("Could not write Desktop Entry at %1").arg(filename)); + setErrorString(tr("Cannot write desktop entry to \"%1\".").arg(QDir::toNativeSeparators(filename))); return false; } @@ -172,7 +168,7 @@ bool CreateDesktopEntryOperation::undoOperation() // first remove the link QFile file(filename); if (file.exists() && !file.remove()) { - qWarning() << "Could not delete file" << filename << file.errorString(); + qWarning() << "Cannot delete file" << filename << ":" << file.errorString(); return true; } @@ -182,13 +178,13 @@ bool CreateDesktopEntryOperation::undoOperation() QFile backupFile(value(QLatin1String("backupOfExistingDesktopEntry")).toString()); if (!backupFile.exists()) { // do not treat this as a real error: The backup file might have been just nuked by the user. - qWarning() << "Could not restore original desktop entry at" << filename + qWarning() << "Cannot restore original desktop entry at" << filename << ": Backup file" << backupFile.fileName() << "does not exist anymore."; return true; } if (!backupFile.rename(filename)) - qWarning() << "Could not restore the file" << filename << ":" << backupFile.errorString(); + qWarning() << "Cannot restore the file" << filename << ":" << backupFile.errorString(); return true; } @@ -197,8 +193,3 @@ bool CreateDesktopEntryOperation::testOperation() { return true; } - -Operation *CreateDesktopEntryOperation::clone() const -{ - return new CreateDesktopEntryOperation(); -} |