diff options
Diffstat (limited to 'src/libs/installer/component.cpp')
-rw-r--r-- | src/libs/installer/component.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index 6443819d9..af71f2278 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -802,21 +802,6 @@ Operation *Component::createOperation(const QString &operation, const QString &p const QString ¶meter6, const QString ¶meter7, const QString ¶meter8, const QString ¶meter9, const QString ¶meter10) { - Operation *op = KDUpdater::UpdateOperationFactory::instance().create(operation); - if (op == 0) { - const QMessageBox::StandardButton button = - MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), - QLatin1String("OperationDoesNotExistError"), tr("Error"), tr("Error: Operation %1 does not exist") - .arg(operation), QMessageBox::Abort | QMessageBox::Ignore); - if (button == QMessageBox::Abort) - d->m_operationsCreatedSuccessfully = false; - return op; - } - - if (op->name() == QLatin1String("Delete")) - op->setValue(QLatin1String("performUndo"), false); - op->setValue(QLatin1String("installer"), qVariantFromValue(d->m_core)); - QStringList arguments; if (!parameter1.isNull()) arguments.append(parameter1); @@ -838,10 +823,32 @@ Operation *Component::createOperation(const QString &operation, const QString &p arguments.append(parameter9); if (!parameter10.isNull()) arguments.append(parameter10); - op->setArguments(d->m_core->replaceVariables(arguments)); + + return createOperation(operation, arguments); +} + +Operation *Component::createOperation(const QString &operation, const QStringList ¶meters) +{ + Operation *op = KDUpdater::UpdateOperationFactory::instance().create(operation); + if (op == 0) { + const QMessageBox::StandardButton button = + MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(), + QLatin1String("OperationDoesNotExistError"), tr("Error"), tr("Error: Operation %1 does not exist") + .arg(operation), QMessageBox::Abort | QMessageBox::Ignore); + if (button == QMessageBox::Abort) + d->m_operationsCreatedSuccessfully = false; + return op; + } + + if (op->name() == QLatin1String("Delete")) + op->setValue(QLatin1String("performUndo"), false); + op->setValue(QLatin1String("installer"), qVariantFromValue(d->m_core)); + + op->setArguments(d->m_core->replaceVariables(parameters)); return op; } + /*! Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6. The contents of @@ -861,6 +868,16 @@ bool Component::addOperation(const QString &operation, const QString ¶meter1 return false; } +bool Component::addOperation(const QString &operation, const QStringList ¶meters) +{ + if (Operation *op = createOperation(operation, parameters)) { + addOperation(op); + return true; + } + + return false; +} + /*! Creates and adds an installation operation for \a operation. Add any number of \a parameter1, \a parameter2, \a parameter3, \a parameter4, \a parameter5 and \a parameter6. The contents of @@ -882,6 +899,16 @@ bool Component::addElevatedOperation(const QString &operation, const QString &pa return false; } +bool Component::addElevatedOperation(const QString &operation, const QStringList ¶meters) +{ + if (Operation *op = createOperation(operation, parameters)) { + addElevatedOperation(op); + return true; + } + + return false; +} + /*! Specifies whether operations should be automatically created when the installation starts. This would be done by calling #createOperations. If you set this to false, it's completely up to the |