summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@digia.com>2013-11-22 20:16:48 +0100
committerKarsten Heimrich <karsten.heimrich@digia.com>2013-11-25 16:33:52 +0100
commit42255f8756c5c92bc3312dce2d672bb2c4d6f2b7 (patch)
tree7e9afe5da4ab8992586be9d359eb43556959bf23 /src
parent8eabcaca2c9eba3a377e14d99e9649e184b0fee6 (diff)
Implement factory to be able to insert pages dynamically.
Change-Id: Ic358a820148670da85a1b374abd08103eaa995de Reviewed-by: Tim Jenssen <tim.jenssen@digia.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/installer/installer.pro6
-rw-r--r--src/libs/installer/packagemanagerpagefactory.cpp57
-rw-r--r--src/libs/installer/packagemanagerpagefactory.h72
-rw-r--r--src/libs/installer/productkeycheck.cpp8
-rw-r--r--src/libs/installer/productkeycheck.h2
-rw-r--r--src/libs/kdtools/kdgenericfactory.h31
-rw-r--r--src/sdk/installerbasecommons.cpp5
7 files changed, 170 insertions, 11 deletions
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 197e853c3..149287428 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -103,7 +103,8 @@ HEADERS += packagemanagercore.h \
globals.h \
graph.h \
settingsoperation.h \
- testrepository.h
+ testrepository.h \
+ packagemanagerpagefactory.h
SOURCES += packagemanagercore.cpp \
packagemanagercore_p.cpp \
@@ -167,7 +168,8 @@ HEADERS += packagemanagercore.h \
applyproductkeyoperation.cpp \
globals.cpp \
settingsoperation.cpp \
- testrepository.cpp
+ testrepository.cpp \
+ packagemanagerpagefactory.cpp
RESOURCES += resources/patch_file_lists.qrc \
resources/installer.qrc
diff --git a/src/libs/installer/packagemanagerpagefactory.cpp b/src/libs/installer/packagemanagerpagefactory.cpp
new file mode 100644
index 000000000..ddfb5b6d4
--- /dev/null
+++ b/src/libs/installer/packagemanagerpagefactory.cpp
@@ -0,0 +1,57 @@
+/**************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#include <packagemanagerpagefactory.h>
+
+namespace QInstaller {
+
+PackageManagerPageFactory &PackageManagerPageFactory::instance()
+{
+ static PackageManagerPageFactory factory;
+ return factory;
+}
+
+PackageManagerPage *PackageManagerPageFactory::create(int id, PackageManagerCore *core) const
+{
+ return KDGenericFactory<PackageManagerPage, int, PackageManagerCore*>::createWithArg(id, core);
+}
+
+}
diff --git a/src/libs/installer/packagemanagerpagefactory.h b/src/libs/installer/packagemanagerpagefactory.h
new file mode 100644
index 000000000..001fb6cd5
--- /dev/null
+++ b/src/libs/installer/packagemanagerpagefactory.h
@@ -0,0 +1,72 @@
+/**************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Installer Framework.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+**************************************************************************/
+
+#ifndef PACKAGEMANAGERPAGEFACTORY_H
+#define PACKAGEMANAGERPAGEFACTORY_H
+
+#include <kdgenericfactory.h>
+#include <packagemanagergui.h>
+
+namespace QInstaller {
+
+class PackageManagerCore;
+class PackageManagerPage;
+
+class INSTALLER_EXPORT PackageManagerPageFactory : public KDGenericFactory<PackageManagerPage,
+ int, QInstaller::PackageManagerCore*>
+{
+ Q_DISABLE_COPY(PackageManagerPageFactory)
+
+public:
+ static PackageManagerPageFactory &instance();
+ template<typename T> void registerPackageManagerPage(int id)
+ {
+ registerProductWithArg<T>(id);
+ }
+ PackageManagerPage *create(int id, QInstaller::PackageManagerCore *core) const;
+
+private:
+ PackageManagerPageFactory() {}
+};
+
+} // namespace QInstaller
+
+#endif // PACKAGEMANAGERPAGEFACTORY_H
diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp
index a4af2b6d3..9a9010d60 100644
--- a/src/libs/installer/productkeycheck.cpp
+++ b/src/libs/installer/productkeycheck.cpp
@@ -89,9 +89,13 @@ bool ProductKeyCheck::isValidLicenseTextFile(const QString &/*fileName*/)
return true;
}
-
bool ProductKeyCheck::isValidRepository(const QInstaller::Repository &repository) const
{
Q_UNUSED(repository)
return true;
-} \ No newline at end of file
+}
+
+QList<int> ProductKeyCheck::registeredPages() const
+{
+ return QList<int>();
+}
diff --git a/src/libs/installer/productkeycheck.h b/src/libs/installer/productkeycheck.h
index 6d72089e2..d5772629a 100644
--- a/src/libs/installer/productkeycheck.h
+++ b/src/libs/installer/productkeycheck.h
@@ -64,6 +64,8 @@ public:
// to filter repositories not matching the license
bool isValidRepository(const QInstaller::Repository &repository) const;
+ QList<int> registeredPages() const;
+
private:
ProductKeyCheck();
ProductKeyCheckPrivate *const d;
diff --git a/src/libs/kdtools/kdgenericfactory.h b/src/libs/kdtools/kdgenericfactory.h
index 349c5ee92..696c91c1c 100644
--- a/src/libs/kdtools/kdgenericfactory.h
+++ b/src/libs/kdtools/kdgenericfactory.h
@@ -46,23 +46,19 @@
#include <QtCore/QHash>
-template <typename T_Product, typename T_Identifier = QString>
+template <typename T_Product, typename T_Identifier = QString, typename T_Argument = QString>
class KDGenericFactory
{
public:
virtual ~KDGenericFactory() {}
typedef T_Product *(*FactoryFunction)();
+ typedef T_Product *(*FactoryFunctionWithArg)(const T_Argument &arg);
template <typename T>
void registerProduct(const T_Identifier &name)
{
-#ifdef Q_CC_MSVC
- FactoryFunction function = &KDGenericFactory::create<T>;
-#else // compile fix for old gcc
- FactoryFunction function = &create<T>;
-#endif
- map.insert(name, function);
+ map.insert(name, &KDGenericFactory::create<T>);
}
T_Product *create(const T_Identifier &name) const
@@ -73,6 +69,20 @@ public:
return (*it)();
}
+ template <typename T>
+ void registerProductWithArg(const T_Identifier &name)
+ {
+ map2.insert(name, &KDGenericFactory::create<T>);
+ }
+
+ T_Product *createWithArg(const T_Identifier &name, const T_Argument &arg) const
+ {
+ const typename QHash<T_Identifier, FactoryFunctionWithArg>::const_iterator it = map2.find(name);
+ if (it == map2.end())
+ return 0;
+ return (*it)(arg);
+ }
+
private:
template <typename T>
static T_Product *create()
@@ -80,7 +90,14 @@ private:
return new T;
}
+ template <typename T>
+ static T_Product *create(const T_Argument &arg)
+ {
+ return new T(arg);
+ }
+
QHash<T_Identifier, FactoryFunction> map;
+ QHash<T_Identifier, FactoryFunctionWithArg> map2;
};
#endif
diff --git a/src/sdk/installerbasecommons.cpp b/src/sdk/installerbasecommons.cpp
index a4e5047d0..ab5a745a4 100644
--- a/src/sdk/installerbasecommons.cpp
+++ b/src/sdk/installerbasecommons.cpp
@@ -43,6 +43,7 @@
#include <component.h>
#include <messageboxhandler.h>
#include <packagemanagercore.h>
+#include <packagemanagerpagefactory.h>
#include <settings.h>
#include <productkeycheck.h>
@@ -502,6 +503,10 @@ bool TargetDirectoryPageImpl::validatePage()
InstallerGui::InstallerGui(PackageManagerCore *core)
: PackageManagerGui(core, 0)
{
+ ProductKeyCheck *checker = ProductKeyCheck::instance(core);
+ foreach (const int id, checker->registeredPages())
+ setPage(id, PackageManagerPageFactory::instance().create(id, core));
+
setPage(PackageManagerCore::Introduction, new IntroductionPageImpl(core));
setPage(PackageManagerCore::TargetDirectory, new TargetDirectoryPageImpl(core));
setPage(PackageManagerCore::ComponentSelection, new ComponentSelectionPage(core));