summaryrefslogtreecommitdiffstats
path: root/src/libs/kdtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/kdtools')
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperation.cpp18
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperation.h6
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperationfactory.cpp13
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperationfactory.h6
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperations.cpp21
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperations.h14
6 files changed, 40 insertions, 38 deletions
diff --git a/src/libs/kdtools/kdupdaterupdateoperation.cpp b/src/libs/kdtools/kdupdaterupdateoperation.cpp
index 4c6237ddb..6ede07ae7 100644
--- a/src/libs/kdtools/kdupdaterupdateoperation.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperation.cpp
@@ -89,9 +89,13 @@ static QString backupFileName(const QString &templateName)
/*!
\internal
*/
-UpdateOperation::UpdateOperation()
+UpdateOperation::UpdateOperation(QInstaller::PackageManagerCore *core)
: m_error(0)
-{}
+ , m_core(core)
+{
+ // Store the value for compatibility reasons.
+ m_values[QLatin1String("installer")] = QVariant::fromValue(core);
+}
/*!
\internal
@@ -312,14 +316,12 @@ QStringList UpdateOperation::filesForDelayedDeletion() const
return m_delayedDeletionFiles;
}
+/*!
+ Returns the package manager core this operation belongs to.
+*/
QInstaller::PackageManagerCore *UpdateOperation::packageManager() const
{
- return value(QLatin1String("installer")).value<QInstaller::PackageManagerCore*>();
-}
-
-void UpdateOperation::setPackageManager(QInstaller::PackageManagerCore *core)
-{
- setValue(QLatin1String("installer"), QVariant::fromValue(core));
+ return m_core;
}
/*!
diff --git a/src/libs/kdtools/kdupdaterupdateoperation.h b/src/libs/kdtools/kdupdaterupdateoperation.h
index 1b5e37c85..76b6fc6eb 100644
--- a/src/libs/kdtools/kdupdaterupdateoperation.h
+++ b/src/libs/kdtools/kdupdaterupdateoperation.h
@@ -43,7 +43,7 @@
#include <QtXml/QDomDocument>
namespace QInstaller {
- class PackageManagerCore;
+class PackageManagerCore;
}
namespace KDUpdater {
@@ -59,7 +59,7 @@ public:
UserDefinedError = 128
};
- UpdateOperation();
+ explicit UpdateOperation(QInstaller::PackageManagerCore *core);
virtual ~UpdateOperation();
QString name() const;
@@ -79,7 +79,6 @@ public:
QStringList filesForDelayedDeletion() const;
QInstaller::PackageManagerCore *packageManager() const;
- void setPackageManager(QInstaller::PackageManagerCore *core);
virtual void backup() = 0;
virtual bool performOperation() = 0;
@@ -106,6 +105,7 @@ private:
int m_error;
QVariantMap m_values;
QStringList m_delayedDeletionFiles;
+ QInstaller::PackageManagerCore *m_core;
};
} // namespace KDUpdater
diff --git a/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp b/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
index 3268facbe..a74658cc2 100644
--- a/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperationfactory.cpp
@@ -35,10 +35,8 @@
#include "kdupdaterupdateoperationfactory.h"
#include "kdupdaterupdateoperations.h"
-#include "packagemanagercore.h"
using namespace KDUpdater;
-using namespace QInstaller;
/*!
\inmodule kdupdater
@@ -64,10 +62,13 @@ using namespace QInstaller;
*/
/*!
+ \obsolete
\fn void KDUpdater::UpdateOperationFactory::registerUpdateOperation(const QString &name)
Registers a new update operation with the factory based on \a name. When create() is called
with that \a name, the update operation is constructed using its default constructor.
+
+ Deprecated. Use registerProduct() instead.
*/
/*!
@@ -93,11 +94,3 @@ UpdateOperationFactory::UpdateOperationFactory()
registerUpdateOperation<AppendFileOperation>(QLatin1String("AppendFile"));
registerUpdateOperation<PrependFileOperation>(QLatin1String("PrependFile"));
}
-
-UpdateOperation *UpdateOperationFactory::create(const QString &name, PackageManagerCore *core) const
-{
- UpdateOperation *operation = KDGenericFactory<UpdateOperation>::create(name);
- if (operation)
- operation->setPackageManager(core);
- return operation;
-}
diff --git a/src/libs/kdtools/kdupdaterupdateoperationfactory.h b/src/libs/kdtools/kdupdaterupdateoperationfactory.h
index 9fc5554a2..03a2ba047 100644
--- a/src/libs/kdtools/kdupdaterupdateoperationfactory.h
+++ b/src/libs/kdtools/kdupdaterupdateoperationfactory.h
@@ -47,7 +47,8 @@ namespace KDUpdater {
class UpdateOperation;
-class KDTOOLS_EXPORT UpdateOperationFactory : public KDGenericFactory<UpdateOperation>
+class KDTOOLS_EXPORT UpdateOperationFactory : public KDGenericFactory<UpdateOperation, QString,
+ QInstaller::PackageManagerCore*>
{
Q_DISABLE_COPY(UpdateOperationFactory)
@@ -59,9 +60,8 @@ public:
{
registerProduct<T>(name);
}
- UpdateOperation *create(const QString &name, QInstaller::PackageManagerCore *core) const;
-protected:
+private:
UpdateOperationFactory();
};
diff --git a/src/libs/kdtools/kdupdaterupdateoperations.cpp b/src/libs/kdtools/kdupdaterupdateoperations.cpp
index 093733337..cc5c5ba8d 100644
--- a/src/libs/kdtools/kdupdaterupdateoperations.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperations.cpp
@@ -99,7 +99,8 @@ static QString backupFileName(const QString &templateName)
// KDUpdater::CopyOperation
////////////////////////////////////////////////////////////////////////////
-CopyOperation::CopyOperation()
+CopyOperation::CopyOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("Copy"));
}
@@ -240,7 +241,8 @@ bool CopyOperation::testOperation()
// KDUpdater::MoveOperation
////////////////////////////////////////////////////////////////////////////
-MoveOperation::MoveOperation()
+MoveOperation::MoveOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("Move"));
}
@@ -342,7 +344,8 @@ bool MoveOperation::testOperation()
// KDUpdater::DeleteOperation
////////////////////////////////////////////////////////////////////////////
-DeleteOperation::DeleteOperation()
+DeleteOperation::DeleteOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("Delete"));
}
@@ -414,7 +417,8 @@ QDomDocument DeleteOperation::toXml() const
// KDUpdater::MkdirOperation
////////////////////////////////////////////////////////////////////////////
-MkdirOperation::MkdirOperation()
+MkdirOperation::MkdirOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("Mkdir"));
}
@@ -506,7 +510,8 @@ bool KDUpdater::MkdirOperation::testOperation()
// KDUpdater::RmdirOperation
////////////////////////////////////////////////////////////////////////////
-RmdirOperation::RmdirOperation()
+RmdirOperation::RmdirOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("Rmdir"));
setValue(QLatin1String("removed"), false);
@@ -569,7 +574,8 @@ bool RmdirOperation::testOperation()
// KDUpdater::AppendFileOperation
////////////////////////////////////////////////////////////////////////////
-AppendFileOperation::AppendFileOperation()
+AppendFileOperation::AppendFileOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("AppendFile"));
}
@@ -675,7 +681,8 @@ bool AppendFileOperation::testOperation()
// KDUpdater::PrependFileOperation
////////////////////////////////////////////////////////////////////////////
-PrependFileOperation::PrependFileOperation()
+PrependFileOperation::PrependFileOperation(QInstaller::PackageManagerCore *core)
+ : UpdateOperation(core)
{
setName(QLatin1String("PrependFile"));
}
diff --git a/src/libs/kdtools/kdupdaterupdateoperations.h b/src/libs/kdtools/kdupdaterupdateoperations.h
index c04105c82..5114196a9 100644
--- a/src/libs/kdtools/kdupdaterupdateoperations.h
+++ b/src/libs/kdtools/kdupdaterupdateoperations.h
@@ -42,7 +42,7 @@ namespace KDUpdater {
class KDTOOLS_EXPORT CopyOperation : public UpdateOperation
{
public:
- CopyOperation();
+ explicit CopyOperation(QInstaller::PackageManagerCore *core = 0);
~CopyOperation();
void backup();
@@ -59,7 +59,7 @@ private:
class KDTOOLS_EXPORT MoveOperation : public UpdateOperation
{
public:
- MoveOperation();
+ explicit MoveOperation(QInstaller::PackageManagerCore *core = 0);
~MoveOperation();
void backup();
@@ -71,7 +71,7 @@ public:
class KDTOOLS_EXPORT DeleteOperation : public UpdateOperation
{
public:
- DeleteOperation();
+ explicit DeleteOperation(QInstaller::PackageManagerCore *core = 0);
~DeleteOperation();
void backup();
@@ -85,7 +85,7 @@ public:
class KDTOOLS_EXPORT MkdirOperation : public UpdateOperation
{
public:
- MkdirOperation();
+ explicit MkdirOperation(QInstaller::PackageManagerCore *core = 0);
void backup();
bool performOperation();
@@ -96,7 +96,7 @@ public:
class KDTOOLS_EXPORT RmdirOperation : public UpdateOperation
{
public:
- RmdirOperation();
+ RmdirOperation(QInstaller::PackageManagerCore *core = 0);
void backup();
bool performOperation();
@@ -107,7 +107,7 @@ public:
class KDTOOLS_EXPORT AppendFileOperation : public UpdateOperation
{
public:
- AppendFileOperation();
+ explicit AppendFileOperation(QInstaller::PackageManagerCore *core = 0);
void backup();
bool performOperation();
@@ -118,7 +118,7 @@ public:
class KDTOOLS_EXPORT PrependFileOperation : public UpdateOperation
{
public:
- PrependFileOperation();
+ explicit PrependFileOperation(QInstaller::PackageManagerCore *core = 0);
void backup();
bool performOperation();