summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/installer/addqtcreatorarrayvalueoperation.h6
-rw-r--r--src/libs/installer/adminauthorization_win.cpp6
-rw-r--r--src/libs/installer/adminauthorization_x11.cpp2
-rw-r--r--src/libs/installer/binaryformat.h2
-rw-r--r--src/libs/installer/component.cpp59
-rw-r--r--src/libs/installer/component.h8
-rw-r--r--src/libs/installer/component_p.cpp51
-rw-r--r--src/libs/installer/component_p.h4
-rw-r--r--src/libs/installer/componentmodel.cpp450
-rw-r--r--src/libs/installer/componentmodel.h51
-rw-r--r--src/libs/installer/constants.h1
-rw-r--r--src/libs/installer/createshortcutoperation.cpp12
-rw-r--r--src/libs/installer/errors.h5
-rw-r--r--src/libs/installer/fileutils.cpp2
-rw-r--r--src/libs/installer/fsengineclient.cpp2
-rw-r--r--src/libs/installer/fsengineserver.cpp2
-rw-r--r--src/libs/installer/getrepositoriesmetainfojob.cpp1
-rw-r--r--src/libs/installer/getrepositorymetainfojob.cpp11
-rw-r--r--src/libs/installer/globals.cpp47
-rw-r--r--src/libs/installer/globals.h54
-rw-r--r--src/libs/installer/init.cpp9
-rw-r--r--src/libs/installer/installer.pro10
-rw-r--r--src/libs/installer/lib7z_facade.cpp11
-rw-r--r--src/libs/installer/lib7z_facade.h15
-rw-r--r--src/libs/installer/link.h2
-rw-r--r--src/libs/installer/macreplaceinstallnamesoperation.h6
-rw-r--r--src/libs/installer/messageboxhandler.cpp23
-rw-r--r--src/libs/installer/messageboxhandler.h2
-rw-r--r--src/libs/installer/packagemanagercore.cpp87
-rw-r--r--src/libs/installer/packagemanagercore.h2
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp19
-rw-r--r--src/libs/installer/packagemanagercore_p.h17
-rw-r--r--src/libs/installer/packagemanagercoredata.cpp2
-rw-r--r--src/libs/installer/packagemanagergui.cpp241
-rw-r--r--src/libs/installer/packagemanagergui.h8
-rw-r--r--src/libs/installer/packagemanagerproxyfactory.h2
-rw-r--r--src/libs/installer/performinstallationform.h2
-rw-r--r--src/libs/installer/productkeycheck.cpp6
-rw-r--r--src/libs/installer/progresscoordinator.h6
-rw-r--r--src/libs/installer/qinstallerglobal.h8
-rw-r--r--src/libs/installer/registerqtincreatorqnxoperation.cpp (renamed from src/libs/installer/registerqtvqnxoperation.cpp)2
-rw-r--r--src/libs/installer/registerqtincreatorqnxoperation.h (renamed from src/libs/installer/registerqtvqnxoperation.h)6
-rw-r--r--src/libs/installer/settings.cpp124
-rw-r--r--src/libs/installer/settings.h8
-rw-r--r--src/libs/installer/utils.h2
-rw-r--r--src/libs/kdtools/kdsysinfo_win.cpp2
-rw-r--r--src/libs/kdtools/kdtools.pri3
-rw-r--r--src/libs/kdtools/kdupdaterapplication.h2
-rw-r--r--src/libs/kdtools/kdupdaterpackagesinfo.cpp8
-rw-r--r--src/libs/kdtools/kdupdaterupdatefinder.cpp4
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperation.cpp2
-rw-r--r--src/libs/kdtools/kdupdaterupdateoperations.cpp2
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfo.cpp44
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfo_p.h18
-rw-r--r--src/libs/kdtools/kdupdaterupdatesinfodata_p.h59
55 files changed, 801 insertions, 739 deletions
diff --git a/src/libs/installer/addqtcreatorarrayvalueoperation.h b/src/libs/installer/addqtcreatorarrayvalueoperation.h
index 6792b8e88..670dccff8 100644
--- a/src/libs/installer/addqtcreatorarrayvalueoperation.h
+++ b/src/libs/installer/addqtcreatorarrayvalueoperation.h
@@ -39,8 +39,8 @@
**
**************************************************************************/
-#ifndef ADDQTCREATORVALUEOPERATION_H
-#define ADDQTCREATORVALUEOPERATION_H
+#ifndef ADDQTCREATORARRAYVALUEOPERATION_H
+#define ADDQTCREATORARRAYVALUEOPERATION_H
#include "qinstallerglobal.h"
@@ -60,4 +60,4 @@ public:
} // namespace QInstaller
-#endif // ADDQTCREATORVALUEOPERATION_H
+#endif // ADDQTCREATORARRAYVALUEOPERATION_H
diff --git a/src/libs/installer/adminauthorization_win.cpp b/src/libs/installer/adminauthorization_win.cpp
index 20420cef0..151fef953 100644
--- a/src/libs/installer/adminauthorization_win.cpp
+++ b/src/libs/installer/adminauthorization_win.cpp
@@ -91,9 +91,9 @@ bool AdminAuthorization::hasAdminRights()
&adminGroup))
return false;
- BOOL isInAdminGroup = FALSE;
- if (!CheckTokenMembership(0, adminGroup, &isInAdminGroup))
- isInAdminGroup = FALSE;
+ bool isInAdminGroup = false;
+ if (!CheckTokenMembership(0, adminGroup, (int*)&isInAdminGroup))
+ isInAdminGroup = false;
FreeSid(adminGroup);
return isInAdminGroup;
diff --git a/src/libs/installer/adminauthorization_x11.cpp b/src/libs/installer/adminauthorization_x11.cpp
index 71a66cd83..6d5a52357 100644
--- a/src/libs/installer/adminauthorization_x11.cpp
+++ b/src/libs/installer/adminauthorization_x11.cpp
@@ -194,7 +194,7 @@ bool AdminAuthorization::execute(QWidget *parent, const QString &program, const
const QString line = QString::fromLatin1(buf, bytes);
if (re.indexIn(line) != -1) {
const QString password = getPassword(parent);
- if (password == QString()) {
+ if (password.isEmpty()) {
QByteArray pwd = password.toLatin1();
for (int i = 0; i < 3; ++i) {
::write(masterFD, pwd.data(), pwd.length());
diff --git a/src/libs/installer/binaryformat.h b/src/libs/installer/binaryformat.h
index 49be60a06..d255ea8a9 100644
--- a/src/libs/installer/binaryformat.h
+++ b/src/libs/installer/binaryformat.h
@@ -203,7 +203,7 @@ class INSTALLER_EXPORT BinaryContentPrivate : public QSharedData
{
public:
BinaryContentPrivate();
- BinaryContentPrivate(const QString &path);
+ explicit BinaryContentPrivate(const QString &path);
BinaryContentPrivate(const BinaryContentPrivate &other);
~BinaryContentPrivate();
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp
index f9e809565..76c7d6ef3 100644
--- a/src/libs/installer/component.cpp
+++ b/src/libs/installer/component.cpp
@@ -43,9 +43,9 @@
#include "errors.h"
#include "fileutils.h"
#include "fsengineclient.h"
+#include "globals.h"
#include "lib7z_facade.h"
#include "packagemanagercore.h"
-#include "qinstallerglobal.h"
#include "messageboxhandler.h"
#include <kdupdaterupdatesourcesinfo.h>
@@ -182,13 +182,13 @@ void Component::loadDataFromPackage(const Package &package)
}
setLocalTempPath(QInstaller::pathFromUrl(package.sourceInfo().url));
- const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString().split(scCommaRegExp,
- QString::SkipEmptyParts);
+ const QStringList uis = package.data(QLatin1String("UserInterfaces")).toString()
+ .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (!uis.isEmpty())
loadUserInterfaces(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), uis);
- const QStringList qms = package.data(QLatin1String("Translations")).toString().split(scCommaRegExp,
- QString::SkipEmptyParts);
+ const QStringList qms = package.data(QLatin1String("Translations")).toString()
+ .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (!qms.isEmpty())
loadTranslations(QDir(QString::fromLatin1("%1/%2").arg(localTempPath(), name())), qms);
@@ -308,23 +308,22 @@ void Component::removeComponent(Component *component)
}
/*!
- Returns a list of child components. If \a recursive is set to true, the returned list
- contains not only the direct children, but all ancestors. Note: The returned list does include ALL
- children, non virtual components as well as virtual components.
+ Returns a list of child components. If \a kind is set to DirectChildrenOnly, the returned list contains
+ only the direct children, if set to Descendants it will also include all descendants of the components
+ children. Note: The returned list does include ALL children, non virtual components as well as virtual
+ components.
*/
-QList<Component*> Component::childComponents(bool recursive, RunMode runMode) const
+QList<Component *> Component::childComponents(Kind kind) const
{
- QList<Component*> result;
- if (runMode == UpdaterMode)
- return result;
+ if (d->m_core->isUpdater())
+ return QList<Component*>();
- if (!recursive)
- return d->m_allChildComponents;
+ QList<Component *> result = d->m_allChildComponents;
+ if (kind == DirectChildrenOnly)
+ return result;
- foreach (Component *component, d->m_allChildComponents) {
- result.append(component);
- result += component->childComponents(true, runMode);
- }
+ foreach (Component *component, d->m_allChildComponents)
+ result += component->childComponents(kind);
return result;
}
@@ -456,7 +455,7 @@ void Component::loadTranslations(const QDir &directory, const QStringList &qms)
QScopedPointer<QTranslator> translator(new QTranslator(this));
if (!translator->load(filename))
- throw Error(tr("Could not open the requested translation file at %1").arg(filename));
+ throw Error(tr("Could not open the requested translation file '%1'.").arg(filename));
qApp->installTranslator(translator.take());
}
}
@@ -480,15 +479,23 @@ void Component::loadUserInterfaces(const QDir &directory, const QStringList &uis
while (it.hasNext()) {
QFile file(it.next());
if (!file.open(QIODevice::ReadOnly)) {
- throw Error(tr("Could not open the requested UI file at %1: %2").arg(it.fileName(),
+ throw Error(tr("Could not open the requested UI file '%1'. Error: %2").arg(it.fileName(),
file.errorString()));
}
static QUiLoader loader;
loader.setTranslationEnabled(true);
loader.setLanguageChangeEnabled(true);
- QWidget *const w = loader.load(&file, MessageBoxHandler::currentBestSuitParent());
- d->m_userInterfaces.insert(w->objectName(), w);
+ QWidget *const widget = loader.load(&file, MessageBoxHandler::currentBestSuitParent());
+ if (!widget) {
+ throw Error(tr("Could not load the requested UI file '%1'. Error: %2").arg(it.fileName(),
+#if QT_VERSION < 0x050000
+ tr("An error has occurred while reading the UI file.")));
+#else
+ loader.errorString()));
+#endif
+ }
+ d->m_userInterfaces.insert(widget->objectName(), widget);
}
}
@@ -513,7 +520,7 @@ void Component::loadLicenses(const QString &directory, const QHash<QString, QVar
qDebug("Unable to open translated license file. Using untranslated fallback.");
file.setFileName(directory + fileName);
if (!file.open(QIODevice::ReadOnly)) {
- throw Error(tr("Could not open the requested license file at %1: %2").arg(fileName,
+ throw Error(tr("Could not open the requested license file '%1'. Error: %2").arg(fileName,
file.errorString()));
}
}
@@ -977,7 +984,7 @@ bool Component::validatePage()
void Component::setSelected(bool selected)
{
Q_UNUSED(selected)
- qDebug() << Q_FUNC_INFO << QString::fromLatin1("on \"%1\" is deprecated!!!").arg(d->m_componentName);
+ qDebug() << Q_FUNC_INFO << QString::fromLatin1("on '%1' is deprecated.").arg(d->m_componentName);
}
void Component::addDependency(const QString &newDependency)
@@ -996,13 +1003,13 @@ void Component::addDependency(const QString &newDependency)
*/
QStringList Component::dependencies() const
{
- return d->m_vars.value(scDependencies).split(scCommaRegExp, QString::SkipEmptyParts);
+ return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
}
QStringList Component::autoDependencies() const
{
QStringList autoDependencyStringList =
- d->m_vars.value(scAutoDependOn).split(scCommaRegExp, QString::SkipEmptyParts);
+ d->m_vars.value(scAutoDependOn).split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
autoDependencyStringList.removeAll(QLatin1String("script"));
return autoDependencyStringList;
}
diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h
index 1c8712145..343e1a3af 100644
--- a/src/libs/installer/component.h
+++ b/src/libs/installer/component.h
@@ -85,6 +85,12 @@ class INSTALLER_EXPORT Component : public QObject, public QScriptable, public Co
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
public:
+ enum Kind
+ {
+ Descendants = 0x1000, // all descendants of the current component (children, grandchildren, etc.)
+ DirectChildrenOnly = 0x2000 // all child components of the current component
+ };
+
explicit Component(PackageManagerCore *core);
~Component();
@@ -117,7 +123,7 @@ public:
Component *parentComponent() const;
void appendComponent(Component *component);
void removeComponent(Component *component);
- QList<Component*> childComponents(bool recursive, RunMode runMode) const;
+ QList<Component*> childComponents(Component::Kind kind) const;
void loadComponentScript();
diff --git a/src/libs/installer/component_p.cpp b/src/libs/installer/component_p.cpp
index 162b62c54..7af7a43b2 100644
--- a/src/libs/installer/component_p.cpp
+++ b/src/libs/installer/component_p.cpp
@@ -202,8 +202,8 @@ ComponentModelHelper::ComponentModelHelper()
}
/*!
- Returns the number of child components. Depending if virtual components are visible or not the count might
- differ from what one will get if calling Component::childComponents(...).count().
+ Returns the number of child components. Depending if virtual components are visible or not,
+ the count might differ from what one will get if calling Component::childComponents(...).count().
*/
int ComponentModelHelper::childCount() const
{
@@ -213,49 +213,38 @@ int ComponentModelHelper::childCount() const
}
/*!
- Returns the index of this component as seen from it's parent.
+ Returns the component at index position in the list. Index must be a valid position in
+ the list (i.e., index >= 0 && index < childCount()). Otherwise it returns 0.
*/
-int ComponentModelHelper::indexInParent() const
+Component *ComponentModelHelper::childAt(int index) const
{
- int index = 0;
- if (Component *parent = m_componentPrivate->m_parentComponent->parentComponent())
- index = parent->childComponents(false, AllMode).indexOf(m_componentPrivate->m_parentComponent);
- return (index >= 0 ? index : 0);
+ if (index < 0 && index >= childCount())
+ return 0;
+
+ if (m_componentPrivate->m_core->virtualComponentsVisible())
+ return m_componentPrivate->m_allChildComponents.value(index, 0);
+ return m_componentPrivate->m_childComponents.value(index, 0);
}
/*!
- Returns all children and whose children depending if virtual components are visible or not.
+ Returns all descendants of this component depending if virtual components are visible or not.
*/
-QList<Component*> ComponentModelHelper::childs() const
+QList<Component*> ComponentModelHelper::childItems() const
{
QList<Component*> *components = &m_componentPrivate->m_childComponents;
if (m_componentPrivate->m_core->virtualComponentsVisible())
components = &m_componentPrivate->m_allChildComponents;
QList<Component*> result;
- foreach (Component *component, *components) {
+ foreach (Component *const component, *components) {
result.append(component);
- result += component->childs();
+ result += component->childItems();
}
return result;
}
/*!
- Returns the component at index position in the list. Index must be a valid position in
- the list (i.e., index >= 0 && index < childCount()). Otherwise it returns 0.
-*/
-Component *ComponentModelHelper::childAt(int index) const
-{
- if (index >= 0 && index < childCount()) {
- if (m_componentPrivate->m_core->virtualComponentsVisible())
- return m_componentPrivate->m_allChildComponents.value(index, 0);
- return m_componentPrivate->m_childComponents.value(index, 0);
- }
- return 0;
-}
-
-/*!
- Determines if the components installations status can be changed. The default value is true.
+ Determines if the installation status of the component can be changed. The default value is true.
*/
bool ComponentModelHelper::isEnabled() const
{
@@ -263,7 +252,7 @@ bool ComponentModelHelper::isEnabled() const
}
/*!
- Enables oder disables ability to change the components installations status.
+ Enables or disables the ability to change the installation status of the components.
*/
void ComponentModelHelper::setEnabled(bool enabled)
{
@@ -271,7 +260,7 @@ void ComponentModelHelper::setEnabled(bool enabled)
}
/*!
- Returns whether the component is tristate; that is, if it's checkable with three separate states.
+ Returns whether the component is tri-state; that is, if it's checkable with three separate states.
The default value is false.
*/
bool ComponentModelHelper::isTristate() const
@@ -280,10 +269,10 @@ bool ComponentModelHelper::isTristate() const
}
/*!
- Sets whether the component is tristate. If tristate is true, the component is checkable with three
+ Sets whether the component is tri-state. If tri-state is true, the component is checkable with three
separate states; otherwise, the component is checkable with two states.
- (Note that this also requires that the component is checkable; see isCheckable().)
+ Note: this also requires that the component is checkable. \sa isCheckable()
*/
void ComponentModelHelper::setTristate(bool tristate)
{
diff --git a/src/libs/installer/component_p.h b/src/libs/installer/component_p.h
index 241888a3f..9101021ae 100644
--- a/src/libs/installer/component_p.h
+++ b/src/libs/installer/component_p.h
@@ -125,10 +125,8 @@ public:
explicit ComponentModelHelper();
int childCount() const;
- int indexInParent() const;
-
- QList<Component*> childs() const;
Component* childAt(int index) const;
+ QList<Component*> childItems() const;
bool isEnabled() const;
void setEnabled(bool enabled);
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp
index a87f59c00..f65611ffe 100644
--- a/src/libs/installer/componentmodel.cpp
+++ b/src/libs/installer/componentmodel.cpp
@@ -47,17 +47,18 @@
namespace QInstaller {
/*!
- \fn void defaultCheckStateChanged(bool changed)
+ \fn void checkStateChanged(const QModelIndex &index)
- This signal is emitted whenever the default check state of a model is changed. The \a changed value
- indicates whether the model has it's initial checked state or some components changed it's checked state.
+ This signal is emitted whenever the check state of a component is changed. The \a index value indicates
+ the QModelIndex representation of the component as seen from the model.
*/
/*!
- \fn void checkStateChanged(const QModelIndex &index)
+ \fn void checkStateChanged(QInstaller::ComponentModel::ModelState state)
- This signal is emitted whenever the default check state of a component is changed. The \a index value
- indicates the QModelIndex representation of the component as seen from the model.
+ This signal is emitted whenever the check state of a model is changed after all check state
+ calculations have taken place. The \a state value indicates whether the model has its default checked
+ state, all components are checked/ unchecked or some individual components checked state has changed.
*/
@@ -67,12 +68,10 @@ namespace QInstaller {
ComponentModel::ComponentModel(int columns, PackageManagerCore *core)
: QAbstractItemModel(core)
, m_core(core)
- , m_rootIndex(0)
+ , m_modelState(DefaultChecked)
{
m_headerData.insert(0, columns, QVariant());
-
connect(this, SIGNAL(modelReset()), this, SLOT(slotModelReset()));
- connect(this, SIGNAL(checkStateChanged(QModelIndex)), this, SLOT(slotCheckStateChanged(QModelIndex)));
}
/*!
@@ -83,8 +82,25 @@ ComponentModel::~ComponentModel()
}
/*!
- Returns the number of items under the given \a parent. When the parent is valid it means that rowCount is
- returning the number of items of parent.
+ Returns the item flags for the given \a index.
+
+ The class implementation returns a combination of flags that enables the item (Qt::ItemIsEnabled), allows
+ it to be selected (Qt::ItemIsSelectable) and to be checked (Qt::ItemIsUserCheckable).
+*/
+Qt::ItemFlags ComponentModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::NoItemFlags;
+
+ if (Component *component = componentFromIndex(index))
+ return component->flags();
+
+ return Qt::ItemFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
+}
+
+/*!
+ Returns the number of items under the given \a parent. When the parent is valid it means that rowCount
+ is returning the number of items of parent.
*/
int ComponentModel::rowCount(const QModelIndex &parent) const
{
@@ -160,9 +176,9 @@ QVariant ComponentModel::data(const QModelIndex &index, int role) const
}
/*!
- Sets the \a role data for the item at \a index to \a value. Returns true if successful; otherwise returns
- false. The dataChanged() signal is emitted if the data was successfully set. The checkStateChanged() and
- defaultCheckStateChanged() signal are emitted in addition if the check state of the item is set.
+ Sets the \a role data for the item at \a index to \a value. Returns true if successful;
+ otherwise returns false. The dataChanged() signal is emitted if the data was successfully set.
+ The checkStateChanged() signals are emitted in addition if the check state of the item is set.
*/
bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
@@ -173,14 +189,17 @@ bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, in
if (!component)
return false;
- component->setData(value, role);
-
- emit dataChanged(index, index);
if (role == Qt::CheckStateRole) {
- emit checkStateChanged(index);
- foreach (Component* comp, m_rootComponentList) {
- comp->updateUncompressedSize();
+ ComponentSet nodes = component->childItems().toSet();
+ QSet<QModelIndex> changed = updateCheckedState(nodes << component, Qt::CheckState(value.toInt()));
+ foreach (const QModelIndex &index, changed) {
+ emit dataChanged(index, index);
+ emit checkStateChanged(index);
}
+ updateAndEmitModelState(); // update the internal state
+ } else {
+ component->setData(value, role);
+ emit dataChanged(index, index);
}
return true;
@@ -217,72 +236,69 @@ bool ComponentModel::setHeaderData(int section, Qt::Orientation orientation, con
}
/*!
- Returns the item flags for the given \a index.
-
- The class implementation returns a combination of flags that enables the item (Qt::ItemIsEnabled), allows
- it to be selected (Qt::ItemIsSelectable) and to be checked (Qt::ItemIsUserCheckable).
+ Returns a list of checked components.
*/
-Qt::ItemFlags ComponentModel::flags(const QModelIndex &index) const
+QSet<Component *> ComponentModel::checked() const
{
- if (!index.isValid())
- return Qt::NoItemFlags;
-
- if (Component *component = componentFromIndex(index))
- return component->flags();
+ return m_currentCheckedState[Qt::Checked];
+}
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable;
+/*!
+ Returns a list of partially checked components.
+*/
+QSet<Component *> ComponentModel::partially() const
+{
+ return m_currentCheckedState[Qt::PartiallyChecked];
}
/*!
- Returns a pointer to the PackageManagerCore this model belongs to.
+ Returns a list of unchecked components.
*/
-PackageManagerCore *ComponentModel::packageManagerCore() const
+QSet<Component *> ComponentModel::unchecked() const
{
- return m_core;
+ return m_currentCheckedState[Qt::Unchecked];
}
/*!
- Returns true if no changes to the components checked state have been done, otherwise returns false.
+ Returns a list of components whose check state can't be changed. If package manager core is run with no
+ forced installation argument, the list will always be empty.
*/
-bool ComponentModel::defaultCheckState() const
+QSet<Component *> ComponentModel::uncheckable() const
{
- return m_initialCheckedSet == m_currentCheckedSet;
+ return m_uncheckable;
}
/*!
- Returns true if this model has checked components, otherwise returns false.
+ Returns a pointer to the PackageManagerCore this model belongs to.
*/
-bool ComponentModel::hasCheckedComponents() const
+PackageManagerCore *ComponentModel::core() const
{
- return !m_currentCheckedSet.isEmpty();
+ return m_core;
}
/*!
- Returns a list of checked components.
+ Returns the current state check state of the model.
*/
-QList<Component*> ComponentModel::checkedComponents() const
+ComponentModel::ModelState ComponentModel::checkedState() const
{
- QList<Component*> list;
- foreach (const QString &name, m_currentCheckedSet)
- list.append(componentFromIndex(indexFromComponentName(name)));
- return list;
+ return m_modelState;
}
/*!
- Translates between a given component \a name and it's associated QModelIndex. Returns the QModelIndex that
- represents the component or an invalid QModelIndex if the component does not exist in the model.
+ Translates between a given component \a name and its associated QModelIndex. Returns the QModelIndex
+ that represents the component or an invalid QModelIndex if the component does not exist in the model.
*/
QModelIndex ComponentModel::indexFromComponentName(const QString &name) const
{
if (m_indexByNameCache.isEmpty()) {
for (int i = 0; i < m_rootComponentList.count(); ++i)
- updateCache(index(i, 0, QModelIndex()));
+ collectComponents(m_rootComponentList.at(i), index(i, 0, QModelIndex()));
}
return m_indexByNameCache.value(name, QModelIndex());
}
/*!
- Translates between a given QModelIndex \a index and it's associated Component. Returns the Component if
+ Translates between a given QModelIndex \a index and its associated Component. Returns the component if
the index is valid or 0 if an invalid QModelIndex is given.
*/
Component *ComponentModel::componentFromIndex(const QModelIndex &index) const
@@ -292,242 +308,218 @@ Component *ComponentModel::componentFromIndex(const QModelIndex &index) const
return 0;
}
-// -- public slots
-
-/*!
- Invoking this slot results in an checked state for every component the has a visual representation in the
- model. Note that components are not changed if they are not checkable. The checkStateChanged() and
- defaultCheckStateChanged() signal are emitted.
-*/
-void ComponentModel::selectAll()
-{
- m_currentCheckedSet = m_currentCheckedSet.unite(select(Qt::Checked));
- emit defaultCheckStateChanged(m_initialCheckedSet != m_currentCheckedSet);
-}
-/*!
- Invoking this slot results in an unchecked state for every component the has a visual representation in
- the model. Note that components are not changed if they are not checkable. The checkStateChanged() and
- defaultCheckStateChanged() signal are emitted.
-*/
-void ComponentModel::deselectAll()
-{
- m_currentCheckedSet = m_currentCheckedSet.subtract(select(Qt::Unchecked));
- emit defaultCheckStateChanged(m_initialCheckedSet != m_currentCheckedSet);
-}
+// -- public slots
/*!
- Invoking this slot results in an checked state for every component the has a visual representation in the
- model when the model was setup during setRootComponents() or appendRootComponents(). Note that components
- are not changed it they are not checkable. The checkStateChanged() and defaultCheckStateChanged() signal
- are emitted.
-*/
-void ComponentModel::selectDefault()
-{
- m_currentCheckedSet = m_currentCheckedSet.subtract(select(Qt::Unchecked));
- foreach (const QString &name, m_initialCheckedSet)
- setData(indexFromComponentName(name), Qt::Checked, Qt::CheckStateRole);
- emit defaultCheckStateChanged(m_initialCheckedSet != m_currentCheckedSet);
-}
+ Sets the passed \a rootComponents to be the list of currently shown components.
-/*!
- Set's the passed \a rootComponents to be list of currently shown components. The model is repopulated and
- the individual component checked state is used to show the check mark in front of the visual component
- representation. The modelAboutToBeReset() and modelReset() signals are emitted.
+ The model is repopulated and the individual component checked state is used to show the check mark in
+ front of the visual component representation. The modelAboutToBeReset() and modelReset() signals are
+ emitted.
*/
void ComponentModel::setRootComponents(QList<QInstaller::Component*> rootComponents)
{
beginResetModel();
+ m_uncheckable.clear();
m_indexByNameCache.clear();
- m_rootComponentList.clear();
- m_initialCheckedSet.clear();
- m_currentCheckedSet.clear();
-
- m_rootIndex = 0;
- m_rootComponentList = rootComponents;
-
+ m_initialCheckedState.clear();
+ m_currentCheckedState.clear();
+ m_modelState = DefaultChecked;
+
+ // show virtual components only in case we run as updater or if the core engine is set to show them
+ const bool showVirtuals = m_core->isUpdater() || m_core->virtualComponentsVisible();
+ foreach (Component *const component, rootComponents) {
+ if ((!showVirtuals) && component->isVirtual())
+ continue;
+ m_rootComponentList.append(component);
+ }
endResetModel();
}
/*!
- Appends the passed \a rootComponents to the currently shown list of components. The model is repopulated
- and the individual component checked state is used to show the check mark in front of the visual component
- representation. Already changed check states on the previous model are preserved. The modelAboutToBeReset()
- and modelReset() signals are emitted.
+ Sets the check state of every component in the model to be \a state.
+
+ The ComponentModel::PartiallyChecked flag is ignored by this function. Note that components are not
+ changed if they are not checkable. The dataChanged() and checkStateChanged() signals are emitted.
*/
-void ComponentModel::appendRootComponents(QList<QInstaller::Component*> rootComponents)
+void ComponentModel::setCheckedState(QInstaller::ComponentModel::ModelStateFlag state)
{
- beginResetModel();
-
- m_indexByNameCache.clear();
+ QSet<QModelIndex> changed;
+ switch (state) {
+ case AllChecked:
+ changed = updateCheckedState(m_currentCheckedState[Qt::Unchecked], Qt::Checked);
+ break;
+ case AllUnchecked:
+ changed = updateCheckedState(m_currentCheckedState[Qt::Checked], Qt::Unchecked);
+ break;
+ case DefaultChecked:
+ // record all changes, to be able to update the UI properly
+ changed = updateCheckedState(m_currentCheckedState[Qt::Checked], Qt::Unchecked);
+ changed += updateCheckedState(m_initialCheckedState[Qt::Checked], Qt::Checked);
+ break;
+ default:
+ break;
+ }
- m_rootIndex = m_rootComponentList.count() - 1;
- m_rootComponentList += rootComponents;
+ if (changed.isEmpty())
+ return;
- endResetModel();
+ // notify about changes done to the model
+ foreach (const QModelIndex &index, changed) {
+ emit dataChanged(index, index);
+ emit checkStateChanged(index);
+ }
+ updateAndEmitModelState(); // update the internal state
}
+
// -- private slots
void ComponentModel::slotModelReset()
{
- QList<QInstaller::Component*> components = m_rootComponentList;
- if (m_core->runMode() == QInstaller::AllMode) {
- for (int i = m_rootIndex; i < m_rootComponentList.count(); ++i)
- components.append(m_rootComponentList.at(i)->childs());
+ ComponentList components = m_rootComponentList;
+ if (!m_core->isUpdater()) {
+ foreach (Component *const component, m_rootComponentList)
+ components += component->childItems();
+ }
+
+ ComponentSet checked;
+ foreach (Component *const component, components) {
+ if (component->checkState() == Qt::Checked)
+ checked.insert(component);
}
- foreach (Component *child, components) {
- if (child->checkState() == Qt::Checked && !child->isTristate())
- m_initialCheckedSet.insert(child->name());
+ updateCheckedState(checked, Qt::Checked);
+ foreach (Component *const component, components) {
+ if (!component->isCheckable())
+ m_uncheckable.insert(component);
+ m_initialCheckedState[component->checkState()].insert(component);
+ }
+
+ m_currentCheckedState = m_initialCheckedState;
+ updateAndEmitModelState(); // update the internal state
+}
+
+
+// -- private
+
+void ComponentModel::updateAndEmitModelState()
+{
+ m_modelState = ComponentModel::DefaultChecked;
+ if (m_initialCheckedState != m_currentCheckedState)
+ m_modelState = ComponentModel::PartiallyChecked;
+
+ if (checked().count() == 0 && partially().count() == 0) {
+ m_modelState |= ComponentModel::AllUnchecked;
+ m_modelState &= ~ComponentModel::PartiallyChecked;
}
- m_currentCheckedSet += m_initialCheckedSet;
- if (m_core->runMode() == QInstaller::AllMode)
- select(Qt::Unchecked);
+ if (unchecked().count() == 0 && partially().count() == 0) {
+ m_modelState |= ComponentModel::AllChecked;
+ m_modelState &= ~ComponentModel::PartiallyChecked;
+ }
- foreach (const QString &name, m_currentCheckedSet)
- setData(indexFromComponentName(name), Qt::Checked, Qt::CheckStateRole);
+ emit checkStateChanged(m_modelState);
+}
+void ComponentModel::collectComponents(Component *const component, const QModelIndex &parent) const
+{
+ m_indexByNameCache.insert(component->name(), parent);
+ for (int i = 0; i < component->childCount(); ++i)
+ collectComponents(component->childAt(i), index(i, 0, parent));
}
+namespace ComponentModelPrivate {
+
+struct NameGreaterThan
+{
+ bool operator() (const Component *lhs, const Component *rhs) const
+ {
+ return lhs->name() > rhs->name();
+ }
+};
+
static Qt::CheckState verifyPartiallyChecked(Component *component)
{
int checked = 0;
int unchecked = 0;
- int virtualChilds = 0;
const int count = component->childCount();
for (int i = 0; i < count; ++i) {
- Component *const child = component->childAt(i);
- if (!child->isVirtual()) {
- switch (component->childAt(i)->checkState()) {
- case Qt::Checked: {
- ++checked;
- } break;
- case Qt::Unchecked: {
- ++unchecked;
- } break;
- default:
- break;
- }
- } else {
- ++virtualChilds;
+ switch (component->childAt(i)->checkState()) {
+ case Qt::Checked: {
+ ++checked;
+ } break;
+ case Qt::Unchecked: {
+ ++unchecked;
+ } break;
+ default:
+ break;
}
}
- if ((checked + virtualChilds) == count)
+ if (checked == count)
return Qt::Checked;
- if ((unchecked + virtualChilds) == count)
+ if (unchecked == count)
return Qt::Unchecked;
return Qt::PartiallyChecked;
}
-void ComponentModel::slotCheckStateChanged(const QModelIndex &index)
-{
- Component *component = componentFromIndex(index);
- if (!component)
- return;
-
- if (component->checkState() == Qt::Checked && !component->isTristate())
- m_currentCheckedSet.insert(component->name());
- else if (component->checkState() == Qt::Unchecked && !component->isTristate())
- m_currentCheckedSet.remove(component->name());
- emit defaultCheckStateChanged(m_initialCheckedSet != m_currentCheckedSet);
-
- if (component->isVirtual())
- return;
-
- const Qt::CheckState state = component->checkState();
- if (component->isTristate()) {
- if (state == Qt::PartiallyChecked) {
- component->setCheckState(verifyPartiallyChecked(component));
- return;
- }
-
- QModelIndexList notCheckable;
- foreach (Component *child, component->childs()) {
- const QModelIndex &idx = indexFromComponentName(child->name());
- if (child->isCheckable()) {
- if (child->checkState() != state && !child->isVirtual())
- setData(idx, state, Qt::CheckStateRole);
- } else {
- notCheckable.append(idx);
- }
- }
-
- if (state == Qt::Unchecked && !notCheckable.isEmpty()) {
- foreach (const QModelIndex &idx, notCheckable)
- setData(idx, idx.data(Qt::CheckStateRole), Qt::CheckStateRole);
- }
- } else {
- QList<Component*> parents;
- while (0 != component->parentComponent()) {
- parents.append(component->parentComponent());
- component = parents.last();
- }
-
- foreach (Component *parent, parents) {
- if (parent->isCheckable()) {
- const QModelIndex &idx = indexFromComponentName(parent->name());
- if (parent->checkState() == Qt::PartiallyChecked) {
- setData(idx, verifyPartiallyChecked(parent), Qt::CheckStateRole);
- } else {
- setData(idx, Qt::PartiallyChecked, Qt::CheckStateRole);
- }
- }
- }
- }
-}
-
-// -- private
+} // namespace ComponentModelPrivate
-QSet<QString> ComponentModel::select(Qt::CheckState state)
+QSet<QModelIndex> ComponentModel::updateCheckedState(const ComponentSet &components, Qt::CheckState state)
{
- QSet<QString> changed;
- for (int i = 0; i < m_rootComponentList.count(); ++i) {
- QSet<QString> tmp;
- QList<Component*> children = m_rootComponentList.at(i)->childs();
- children.prepend(m_rootComponentList.at(i)); // we need to take the root item into account as well
- foreach (Component *child, children) {
- if (child->isCheckable() && !child->isTristate() && child->checkState() != state) {
- tmp.insert(child->name());
- child->setCheckState(state);
+ // get all parent nodes for the components we're going to update
+ ComponentSet nodes = components;
+ foreach (Component *const component, components) {
+ if (Component *parent = component->parentComponent()) {
+ nodes.insert(parent);
+ while (parent->parentComponent() != 0) {
+ parent = parent->parentComponent();
+ nodes.insert(parent);
}
}
- if (!tmp.isEmpty()) {
- changed += tmp;
- setData(index(i, 0, QModelIndex()), state, Qt::CheckStateRole);
- }
}
- return changed;
-}
-void ComponentModel::updateCache(const QModelIndex &parent) const
-{
- const QModelIndexList &list = collectComponents(parent);
- foreach (const QModelIndex &index, list) {
- if (Component *component = componentFromIndex(index))
- m_indexByNameCache.insert(component->name(), index);
- }
- m_indexByNameCache.insert((static_cast<Component*> (parent.internalPointer()))->name(), parent);
-}
-
-QModelIndexList ComponentModel::collectComponents(const QModelIndex &parent) const
-{
- QModelIndexList list;
- for (int i = 0; i < rowCount(parent) ; ++i) {
- const QModelIndex &next = index(i, 0, parent);
- if (Component *component = componentFromIndex(next)) {
- if (component->childCount() > 0)
- list += collectComponents(next);
+ QSet<QModelIndex> changed;
+ // sort the nodes, so we can start in descending order to check node and tri-state nodes properly
+ ComponentList sortedNodes = nodes.toList();
+ std::sort(sortedNodes.begin(), sortedNodes.end(), ComponentModelPrivate::NameGreaterThan());
+ foreach (Component *const node, sortedNodes) {
+ if (!node->isCheckable())
+ continue;
+
+ Qt::CheckState newState = state;
+ const Qt::CheckState recentState = node->checkState();
+ if (node->isTristate())
+ newState = ComponentModelPrivate::verifyPartiallyChecked(node);
+ if (recentState == newState)
+ continue;
+
+ node->setCheckState(newState);
+ changed.insert(indexFromComponentName(node->name()));
+
+ m_currentCheckedState[Qt::Checked].remove(node);
+ m_currentCheckedState[Qt::Unchecked].remove(node);
+ m_currentCheckedState[Qt::PartiallyChecked].remove(node);
+
+ switch (newState) {
+ case Qt::Checked:
+ m_currentCheckedState[Qt::Checked].insert(node);
+ break;
+ case Qt::Unchecked:
+ m_currentCheckedState[Qt::Unchecked].insert(node);
+ break;
+ case Qt::PartiallyChecked:
+ m_currentCheckedState[Qt::PartiallyChecked].insert(node);
+ break;
}
- list.append(next);
}
- return list;
+ return changed;
}
} // namespace QInstaller
diff --git a/src/libs/installer/componentmodel.h b/src/libs/installer/componentmodel.h
index b43bfc75a..a691906a4 100644
--- a/src/libs/installer/componentmodel.h
+++ b/src/libs/installer/componentmodel.h
@@ -57,11 +57,23 @@ class PackageManagerCore;
class INSTALLER_EXPORT ComponentModel : public QAbstractItemModel
{
Q_OBJECT
+ typedef QSet<Component *> ComponentSet;
+ typedef QList<Component *> ComponentList;
public:
+ enum ModelStateFlag {
+ AllChecked = 0x01,
+ AllUnchecked = 0x02,
+ DefaultChecked = 0x04,
+ PartiallyChecked = 0x08
+ };
+ Q_DECLARE_FLAGS(ModelState, ModelStateFlag);
+
explicit ComponentModel(int columns, PackageManagerCore *core = 0);
~ComponentModel();
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -75,49 +87,50 @@ public:
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
int role = Qt::EditRole);
- Qt::ItemFlags flags(const QModelIndex &index) const;
- PackageManagerCore *packageManagerCore() const;
+ QSet<Component *> checked() const;
+ QSet<Component *> partially() const;
+ QSet<Component *> unchecked() const;
+ QSet<Component *> uncheckable() const;
- bool defaultCheckState() const;
- bool hasCheckedComponents() const;
- QList<Component*> checkedComponents() const;
+ PackageManagerCore *core() const;
+ ComponentModel::ModelState checkedState() const;
QModelIndex indexFromComponentName(const QString &name) const;
Component* componentFromIndex(const QModelIndex &index) const;
public Q_SLOTS:
- void selectAll();
- void deselectAll();
- void selectDefault();
-
void setRootComponents(QList<QInstaller::Component*> rootComponents);
- void appendRootComponents(QList<QInstaller::Component*> rootComponents);
+ void setCheckedState(QInstaller::ComponentModel::ModelStateFlag state);
Q_SIGNALS:
- void defaultCheckStateChanged(bool changed);
void checkStateChanged(const QModelIndex &index);
+ void checkStateChanged(QInstaller::ComponentModel::ModelState state);
private Q_SLOTS:
void slotModelReset();
- void slotCheckStateChanged(const QModelIndex &index);
private:
- QSet<QString> select(Qt::CheckState state);
- void updateCache(const QModelIndex &parent) const;
- QModelIndexList collectComponents(const QModelIndex &parent) const;
+ void updateAndEmitModelState();
+ void collectComponents(Component *const component, const QModelIndex &parent) const;
+ QSet<QModelIndex> updateCheckedState(const ComponentSet &components, Qt::CheckState state);
private:
PackageManagerCore *m_core;
- int m_rootIndex;
+ ModelState m_modelState;
+ ComponentSet m_uncheckable;
QVector<QVariant> m_headerData;
- QSet<QString> m_initialCheckedSet;
- QSet<QString> m_currentCheckedSet;
- QList<Component*> m_rootComponentList;
+ ComponentList m_rootComponentList;
+ QHash<Qt::CheckState, ComponentSet> m_initialCheckedState;
+ QHash<Qt::CheckState, ComponentSet> m_currentCheckedState;
mutable QHash<QString, QPersistentModelIndex> m_indexByNameCache;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(ComponentModel::ModelState);
} // namespace QInstaller
+Q_DECLARE_METATYPE(QInstaller::ComponentModel::ModelState);
+Q_DECLARE_METATYPE(QInstaller::ComponentModel::ModelStateFlag);
+
#endif // COMPONENTMODEL_H
diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h
index 3929681a7..7ea73bbb9 100644
--- a/src/libs/installer/constants.h
+++ b/src/libs/installer/constants.h
@@ -80,6 +80,7 @@ static const QLatin1String scSortingPriority("SortingPriority");
static const QLatin1String scTitle("Title");
static const QLatin1String scPublisher("Publisher");
static const QLatin1String scRunProgram("RunProgram");
+static const QLatin1String scRunProgramArguments("RunProgramArguments");
static const QLatin1String scStartMenuDir("StartMenuDir");
static const QLatin1String scRemoveTargetDir("RemoveTargetDir");
static const QLatin1String scRunProgramDescription("RunProgramDescription");
diff --git a/src/libs/installer/createshortcutoperation.cpp b/src/libs/installer/createshortcutoperation.cpp
index 62f7cfa82..2f2696fcd 100644
--- a/src/libs/installer/createshortcutoperation.cpp
+++ b/src/libs/installer/createshortcutoperation.cpp
@@ -107,8 +107,9 @@ static QString takeWorkingDirArgument(QStringList &args)
static bool createLink(const QString &fileName, const QString &linkName, QString workingDir,
QString arguments = QString())
{
- bool success = QFile::link(fileName, linkName);
#ifdef Q_OS_WIN
+ bool success = QFile::link(fileName, linkName);
+
if (!success)
return success;
@@ -131,7 +132,7 @@ static bool createLink(const QString &fileName, const QString &linkName, QString
IPersistFile *ppf = NULL;
if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile, (void **)&ppf))) {
- ppf->Save((wchar_t*)QDir::toNativeSeparators(linkName).utf16(), TRUE);
+ ppf->Save((wchar_t*)QDir::toNativeSeparators(linkName).utf16(), true);
ppf->Release();
}
psl->Release();
@@ -145,11 +146,16 @@ static bool createLink(const QString &fileName, const QString &linkName, QString
SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_IDLIST, pidl, 0);
CoTaskMemFree(pidl);
}
+
+ return success;
#else
Q_UNUSED(arguments)
Q_UNUSED(workingDir)
+ Q_UNUSED(fileName)
+ Q_UNUSED(linkName)
+
+ return true;
#endif
- return success;
}
diff --git a/src/libs/installer/errors.h b/src/libs/installer/errors.h
index 7f5cc9071..18b8ead8f 100644
--- a/src/libs/installer/errors.h
+++ b/src/libs/installer/errors.h
@@ -54,7 +54,10 @@ class Error : public std::runtime_error
public:
explicit Error(const QString &message)
: std::runtime_error(message.toStdString())
- , m_message (message) { qDebug() << "create Error-Exception:" << message; }
+ , m_message (message)
+ {
+ qDebug() << "create Error-Exception:" << message;
+ }
virtual ~Error() throw() {}
QString message() const { return m_message; }
diff --git a/src/libs/installer/fileutils.cpp b/src/libs/installer/fileutils.cpp
index ab7ad6df4..87d46282d 100644
--- a/src/libs/installer/fileutils.cpp
+++ b/src/libs/installer/fileutils.cpp
@@ -455,7 +455,7 @@ QString QInstaller::createTemporaryDirectory(const QString &templ)
if (!f.open())
throw Error(QObject::tr("Could not create temporary folder for template %1: %2").arg(t, f.errorString()));
const QString path = f.fileName() + QLatin1String("meta");
- qDebug() << "Creating meta data directory at" << path;
+ qDebug() << "\nCreating meta data directory at" << path;
QInstaller::mkpath(path);
return path;
diff --git a/src/libs/installer/fsengineclient.cpp b/src/libs/installer/fsengineclient.cpp
index c9aff560f..7822ed65b 100644
--- a/src/libs/installer/fsengineclient.cpp
+++ b/src/libs/installer/fsengineclient.cpp
@@ -753,7 +753,7 @@ void FSEngineClientHandler::setActive(bool active)
}
/*!
- Returns, wheter this FSEngineClientHandler is active or not.
+ Returns true when this FSEngineClientHandler is active.
*/
bool FSEngineClientHandler::isActive() const
{
diff --git a/src/libs/installer/fsengineserver.cpp b/src/libs/installer/fsengineserver.cpp
index 991681b95..76992c241 100644
--- a/src/libs/installer/fsengineserver.cpp
+++ b/src/libs/installer/fsengineserver.cpp
@@ -75,7 +75,7 @@ bool startDetached(const QString &program, const QStringList &args, const QStrin
const QString arguments = QInstaller::createCommandline(program, args);
const bool success = CreateProcess(0, (wchar_t*)arguments.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
+ 0, 0, false, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE,
0, (wchar_t*)workingDirectory.utf16(),
&startupInfo, &pinfo);
diff --git a/src/libs/installer/getrepositoriesmetainfojob.cpp b/src/libs/installer/getrepositoriesmetainfojob.cpp
index 996bf4692..7604bcf06 100644
--- a/src/libs/installer/getrepositoriesmetainfojob.cpp
+++ b/src/libs/installer/getrepositoriesmetainfojob.cpp
@@ -43,7 +43,6 @@
#include "getrepositorymetainfojob.h"
#include "packagemanagercore_p.h"
-#include "qinstallerglobal.h"
#include <QtCore/QDebug>
diff --git a/src/libs/installer/getrepositorymetainfojob.cpp b/src/libs/installer/getrepositorymetainfojob.cpp
index bbf3afe25..20b312376 100644
--- a/src/libs/installer/getrepositorymetainfojob.cpp
+++ b/src/libs/installer/getrepositorymetainfojob.cpp
@@ -44,22 +44,13 @@
#include "lib7z_facade.h"
#include "messageboxhandler.h"
#include "packagemanagercore_p.h"
-#include "qinstallerglobal.h"
#include "utils.h"
#include "kdupdaterfiledownloader.h"
#include "kdupdaterfiledownloaderfactory.h"
-#include <QtCore/QFile>
-#include <QtCore/QTimer>
-#include <QtCore/QUrl>
+#include <QTimer>
-#include <QMessageBox>
-
-#include <QtNetwork/QAuthenticator>
-
-#include <QtXml/QDomDocument>
-#include <QtXml/QDomElement>
using namespace KDUpdater;
using namespace QInstaller;
diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp
new file mode 100644
index 000000000..f0910372d
--- /dev/null
+++ b/src/libs/installer/globals.cpp
@@ -0,0 +1,47 @@
+/**************************************************************************
+**
+** 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 "globals.h"
+
+Q_GLOBAL_STATIC_WITH_ARGS(QRegExp, staticCommaRegExp, (QLatin1String("\\b(,|, )\\b")));
+QRegExp QInstaller::commaRegExp()
+{
+ return *staticCommaRegExp();
+}
diff --git a/src/libs/installer/globals.h b/src/libs/installer/globals.h
new file mode 100644
index 000000000..858c856d5
--- /dev/null
+++ b/src/libs/installer/globals.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+**
+** 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 GLOBALS_H
+#define GLOBALS_H
+
+#include "installer_global.h"
+
+#include <QRegExp>
+
+namespace QInstaller {
+
+QRegExp INSTALLER_EXPORT commaRegExp();
+
+} // QInstaller
+
+#endif // GLOBALS_H
diff --git a/src/libs/installer/init.cpp b/src/libs/installer/init.cpp
index 40c396ab4..f5053d952 100644
--- a/src/libs/installer/init.cpp
+++ b/src/libs/installer/init.cpp
@@ -67,7 +67,7 @@
#include "setpluginpathonqtcoreoperation.h"
#include "setimportspathonqtcoreoperation.h"
#include "setpathonqtcoreoperation.h"
-#include "registerqtvqnxoperation.h"
+#include "registerqtincreatorqnxoperation.h"
#include "setqtcreatorvalueoperation.h"
#include "addqtcreatorarrayvalueoperation.h"
#include "registertoolchainoperation.h"
@@ -205,8 +205,9 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
{
QByteArray ba = trimAndPrepend(type, msg.toLocal8Bit());
if (type != QtDebugMsg) {
- ba += QByteArray(" (") + context.file + QByteArray(":").append(context.line) + QByteArray(", ")
- + context.function + QByteArray(")");
+ ba += QString(QStringLiteral(" (%1:%2, %3)")).arg(
+ QString::fromLatin1(context.file)).arg(context.line).arg(
+ QString::fromLatin1(context.function)).toLocal8Bit();
}
#endif
@@ -229,8 +230,8 @@ void messageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
void QInstaller::init()
{
-#if defined(QT_STATIC)
::initArchives();
+#if defined(QT_STATIC)
::initResources();
#endif
diff --git a/src/libs/installer/installer.pro b/src/libs/installer/installer.pro
index 3308876fb..79500b2d5 100644
--- a/src/libs/installer/installer.pro
+++ b/src/libs/installer/installer.pro
@@ -58,7 +58,6 @@ HEADERS += packagemanagercore.h \
replaceoperation.h \
linereplaceoperation.h \
registertoolchainoperation.h \
- registerqtvqnxoperation.h \
setqtcreatorvalueoperation.h \
addqtcreatorarrayvalueoperation.h \
copydirectoryoperation.h \
@@ -104,7 +103,9 @@ HEADERS += packagemanagercore.h \
link.h \
createlinkoperation.h \
packagemanagercoredata.h \
- applyproductkeyoperation.h
+ registerqtincreatorqnxoperation.h \
+ applyproductkeyoperation.h \
+ globals.h
SOURCES += packagemanagercore.cpp \
packagemanagercore_p.cpp \
@@ -129,7 +130,6 @@ HEADERS += packagemanagercore.h \
replaceoperation.cpp \
linereplaceoperation.cpp \
registertoolchainoperation.cpp \
- registerqtvqnxoperation.cpp \
setqtcreatorvalueoperation.cpp \
addqtcreatorarrayvalueoperation.cpp \
copydirectoryoperation.cpp \
@@ -173,7 +173,9 @@ HEADERS += packagemanagercore.h \
link.cpp \
createlinkoperation.cpp \
packagemanagercoredata.cpp \
- applyproductkeyoperation.cpp
+ registerqtincreatorqnxoperation.cpp \
+ applyproductkeyoperation.cpp \
+ globals.cpp
RESOURCES += resources/patch_file_lists.qrc \
resources/installer.qrc
diff --git a/src/libs/installer/lib7z_facade.cpp b/src/libs/installer/lib7z_facade.cpp
index 3695c0038..962a9d46a 100644
--- a/src/libs/installer/lib7z_facade.cpp
+++ b/src/libs/installer/lib7z_facade.cpp
@@ -17,12 +17,13 @@
#include "Windows/PropVariant.h"
#include "Windows/PropVariantConversions.h"
-#include <QtCore/QDir>
-#include <QtCore/QFileInfo>
-#include <QtCore/QIODevice>
+#include <QDir>
+#include <QFileInfo>
+#include <QIODevice>
#include <QtCore/QMutexLocker>
-#include <QtCore/QPointer>
-#include <QtCore/QTemporaryFile>
+#include <QPointer>
+#include <QTemporaryFile>
+#include <QReadWriteLock>
#ifdef _MSC_VER
#pragma warning(disable:4297)
diff --git a/src/libs/installer/lib7z_facade.h b/src/libs/installer/lib7z_facade.h
index 515d63bba..35f4ff126 100644
--- a/src/libs/installer/lib7z_facade.h
+++ b/src/libs/installer/lib7z_facade.h
@@ -3,15 +3,14 @@
#include "installer_global.h"
+#include <QCoreApplication>
#include <QDateTime>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QFile>
-#include <QtCore/QPoint>
-#include <QtCore/QRunnable>
-#include <QtCore/QString>
-#include <QtCore/QVector>
-#include <QtCore/QVariant>
-#include <QtCore/QReadWriteLock>
+#include <QFile>
+#include <QPoint>
+#include <QRunnable>
+#include <QString>
+#include <QVariant>
+#include <QVector>
#include "Common/MyWindows.h"
diff --git a/src/libs/installer/link.h b/src/libs/installer/link.h
index fc8d8fee3..e359c8f91 100644
--- a/src/libs/installer/link.h
+++ b/src/libs/installer/link.h
@@ -47,7 +47,7 @@
class Link
{
public:
- Link(const QString &path);
+ explicit Link(const QString &path);
static Link create(const QString &link, const QString &targetPath);
QString targetPath() const;
bool targetExists();
diff --git a/src/libs/installer/macreplaceinstallnamesoperation.h b/src/libs/installer/macreplaceinstallnamesoperation.h
index 635f60054..f4b76de6d 100644
--- a/src/libs/installer/macreplaceinstallnamesoperation.h
+++ b/src/libs/installer/macreplaceinstallnamesoperation.h
@@ -39,8 +39,8 @@
**
**************************************************************************/
-#ifndef MACREPLACEINSTALLNAMEOPERATION_H
-#define MACREPLACEINSTALLNAMEOPERATION_H
+#ifndef MACREPLACEINSTALLNAMESOPERATION_H
+#define MACREPLACEINSTALLNAMESOPERATION_H
#include "qinstallerglobal.h"
@@ -85,4 +85,4 @@ private:
} // namespace QInstaller
-#endif // MACREPLACEINSTALLNAMEOPERATION_H
+#endif // MACREPLACEINSTALLNAMESOPERATION_H
diff --git a/src/libs/installer/messageboxhandler.cpp b/src/libs/installer/messageboxhandler.cpp
index cb9a845ff..832a96e85 100644
--- a/src/libs/installer/messageboxhandler.cpp
+++ b/src/libs/installer/messageboxhandler.cpp
@@ -47,8 +47,8 @@
#include <QDialogButtonBox>
#include <QPushButton>
-#include <QtScript/QScriptEngine>
-#include <QtScript/QScriptValue>
+#include <QScriptEngine>
+#include <QScriptValue>
QScriptValue QInstaller::registerMessageBox(QScriptEngine *scriptEngine)
{
@@ -151,6 +151,19 @@ QWidget *MessageBoxHandler::currentBestSuitParent()
return qApp->activeWindow();
}
+QList<QMessageBox::Button> MessageBoxHandler::orderedButtons()
+{
+ static QList<QMessageBox::Button> buttons;
+ if (!buttons.isEmpty())
+ return buttons;
+ buttons << QMessageBox::YesToAll << QMessageBox::Yes << QMessageBox::Ok << QMessageBox::Apply
+ << QMessageBox::SaveAll << QMessageBox::Save <<QMessageBox::Retry << QMessageBox::Ignore
+ << QMessageBox::Help << QMessageBox::RestoreDefaults << QMessageBox::Reset << QMessageBox::Open
+ << QMessageBox::Cancel << QMessageBox::Close << QMessageBox::Abort << QMessageBox::Discard
+ << QMessageBox::No << QMessageBox::NoToAll;
+ return buttons;
+}
+
void MessageBoxHandler::setDefaultAction(DefaultAction defaultAction)
{
if (m_defaultAction == defaultAction)
@@ -159,11 +172,7 @@ void MessageBoxHandler::setDefaultAction(DefaultAction defaultAction)
m_buttonOrder.clear();
if (m_defaultAction != AskUser) {
- m_buttonOrder << QMessageBox::YesToAll << QMessageBox::Yes << QMessageBox::Ok << QMessageBox::Apply
- << QMessageBox::SaveAll << QMessageBox::Save <<QMessageBox::Retry << QMessageBox::Ignore
- << QMessageBox::Help << QMessageBox::RestoreDefaults << QMessageBox::Reset << QMessageBox::Open
- << QMessageBox::Cancel << QMessageBox::Close << QMessageBox::Abort << QMessageBox::Discard
- << QMessageBox::No << QMessageBox::NoToAll;
+ m_buttonOrder = orderedButtons();
}
if (m_defaultAction == Reject) {
diff --git a/src/libs/installer/messageboxhandler.h b/src/libs/installer/messageboxhandler.h
index b0b0fb6f2..197a51d85 100644
--- a/src/libs/installer/messageboxhandler.h
+++ b/src/libs/installer/messageboxhandler.h
@@ -110,6 +110,8 @@ public:
QMessageBox::StandardButtons buttons = QMessageBox::Ok,
QMessageBox::StandardButton button = QMessageBox::NoButton) const;
+ static QList<QMessageBox::Button> orderedButtons();
+
private Q_SLOTS:
//this removes the slot from the script area
virtual void deleteLater() {
diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp
index cb957f9aa..6bd90051a 100644
--- a/src/libs/installer/packagemanagercore.cpp
+++ b/src/libs/installer/packagemanagercore.cpp
@@ -39,6 +39,7 @@
**
**************************************************************************/
#include "packagemanagercore.h"
+#include "packagemanagercore_p.h"
#include "adminauthorization.h"
#include "binaryformat.h"
@@ -47,12 +48,11 @@
#include "downloadarchivesjob.h"
#include "errors.h"
#include "fsengineclient.h"
+#include "globals.h"
#include "getrepositoriesmetainfojob.h"
#include "messageboxhandler.h"
-#include "packagemanagercore_p.h"
#include "packagemanagerproxyfactory.h"
#include "progresscoordinator.h"
-#include "qinstallerglobal.h"
#include "qprocesswrapper.h"
#include "qsettingswrapper.h"
#include "settings.h"
@@ -87,9 +87,9 @@
using namespace QInstaller;
-static QMutex sModelMutex;
+Q_GLOBAL_STATIC(QMutex, globalModelMutex);
static QFont *sVirtualComponentsFont = 0;
-static QMutex sVirtualComponentsFontMutex;
+Q_GLOBAL_STATIC(QMutex, globalVirtualComponentsFontMutex);
static bool sNoForceInstallation = false;
static bool sVirtualComponentsVisible = false;
@@ -131,12 +131,12 @@ Component *PackageManagerCore::subComponentByName(const QInstaller::PackageManag
if (check != 0 && componentMatches(check, name, version))
return check;
- if (installer->runMode() == AllMode) {
+ if (!installer->isUpdater()) {
QList<Component*> rootComponents;
if (check == 0)
rootComponents = installer->rootComponents();
else
- rootComponents = check->childComponents(false, AllMode);
+ rootComponents = check->childComponents(Component::DirectChildrenOnly);
foreach (QInstaller::Component *component, rootComponents) {
Component *const result = subComponentByName(installer, name, version, component);
@@ -487,7 +487,7 @@ void PackageManagerCore::rollBackInstallation()
if (!componentName.isEmpty()) {
Component *component = componentByName(componentName);
if (!component)
- component = d->componentsToReplace(runMode()).value(componentName).second;
+ component = d->componentsToReplace().value(componentName).second;
if (component) {
component->setUninstalled();
packages.removePackage(component->name());
@@ -550,12 +550,16 @@ PackageManagerCore::~PackageManagerCore()
QInstaller::VerboseWriter::instance()->setOutputStream(logFileName);
}
delete d;
+
+ QMutexLocker _(globalVirtualComponentsFontMutex());
+ delete sVirtualComponentsFont;
+ sVirtualComponentsFont = 0;
}
/* static */
QFont PackageManagerCore::virtualComponentsFont()
{
- QMutexLocker _(&sVirtualComponentsFontMutex);
+ QMutexLocker _(globalVirtualComponentsFontMutex());
if (!sVirtualComponentsFont)
sVirtualComponentsFont = new QFont;
return *sVirtualComponentsFont;
@@ -564,7 +568,7 @@ QFont PackageManagerCore::virtualComponentsFont()
/* static */
void PackageManagerCore::setVirtualComponentsFont(const QFont &font)
{
- QMutexLocker _(&sVirtualComponentsFontMutex);
+ QMutexLocker _(globalVirtualComponentsFontMutex());
if (sVirtualComponentsFont)
delete sVirtualComponentsFont;
sVirtualComponentsFont = new QFont(font);
@@ -606,11 +610,6 @@ void PackageManagerCore::setCreateLocalRepositoryFromBinary(bool create)
sCreateLocalRepositoryFromBinary = create;
}
-RunMode PackageManagerCore::runMode() const
-{
- return isUpdater() ? UpdaterMode : AllMode;
-}
-
bool PackageManagerCore::fetchLocalPackagesTree()
{
d->setStatus(Running);
@@ -725,7 +724,7 @@ bool PackageManagerCore::fetchRemotePackagesTree()
return false;
bool success = false;
- if (runMode() == AllMode)
+ if (!isUpdater())
success = fetchAllPackages(packages, installedPackages);
else {
success = fetchUpdaterPackages(packages, installedPackages);
@@ -934,7 +933,7 @@ QList<Component*> PackageManagerCore::availableComponents() const
QList<Component*> result = d->m_rootComponents;
foreach (QInstaller::Component *component, d->m_rootComponents)
- result += component->childComponents(true, AllMode);
+ result += component->childComponents(Component::Descendants);
return result + d->m_rootDependencyReplacements;
}
@@ -968,21 +967,23 @@ bool PackageManagerCore::calculateComponentsToInstall() const
if (!d->m_componentsToInstallCalculated) {
d->clearComponentsToInstall();
QList<Component*> components;
- if (runMode() == UpdaterMode) {
+ if (isUpdater()) {
foreach (Component *component, updaterComponents()) {
if (component->updateRequested())
components.append(component);
}
- } else if (runMode() == AllMode) {
+ } else if (!isUpdater()) {
// relevant means all components which are not replaced
QList<Component*> relevantComponents = rootComponents();
foreach (QInstaller::Component *component, rootComponents())
- relevantComponents += component->childComponents(true, AllMode);
+ relevantComponents += component->childComponents(Component::Descendants);
foreach (Component *component, relevantComponents) {
// ask for all components which will be installed to get all dependencies
- // even dependencies wich are changed without an increased version
- if (component->installationRequested() || (component->isInstalled() && !component->uninstallationRequested()))
- components.append(component);
+ // even dependencies which are changed without an increased version
+ if (component->installationRequested() || (component->isInstalled()
+ && !component->uninstallationRequested())) {
+ components.append(component);
+ }
}
}
@@ -1005,10 +1006,10 @@ QList<Component*> PackageManagerCore::orderedComponentsToInstall() const
*/
bool PackageManagerCore::calculateComponentsToUninstall() const
{
- if (runMode() == UpdaterMode)
+ if (isUpdater())
return true;
- // hack to avoid removeing needed dependencies
+ // hack to avoid removing needed dependencies
QSet<Component*> componentsToInstall = d->m_orderedComponentsToInstall.toSet();
QList<Component*> components;
@@ -1046,7 +1047,7 @@ QString PackageManagerCore::installReason(Component *component) const
}
/*!
- Returns a list of components that dependend on \a component. The list can be empty. Note: Auto
+ Returns a list of components that depend on \a component. The list can be empty. Note: Auto
installed dependencies are not resolved.
*/
QList<Component*> PackageManagerCore::dependees(const Component *_component) const
@@ -1090,7 +1091,7 @@ QList<Component*> PackageManagerCore::dependencies(const Component *component, Q
ComponentModel *PackageManagerCore::defaultComponentModel() const
{
- QMutexLocker _(&sModelMutex);
+ QMutexLocker _(globalModelMutex());
if (!d->m_defaultModel) {
d->m_defaultModel = componentModel(const_cast<PackageManagerCore*> (this),
QLatin1String("AllComponentsModel"));
@@ -1100,7 +1101,7 @@ ComponentModel *PackageManagerCore::defaultComponentModel() const
ComponentModel *PackageManagerCore::updaterComponentModel() const
{
- QMutexLocker _(&sModelMutex);
+ QMutexLocker _(globalModelMutex());
if (!d->m_updaterModel) {
d->m_updaterModel = componentModel(const_cast<PackageManagerCore*> (this),
QLatin1String("UpdaterComponentsModel"));
@@ -1263,12 +1264,13 @@ bool PackageManagerCore::executeDetached(const QString &program, const QStringLi
*/
QString PackageManagerCore::environmentVariable(const QString &name) const
{
+ if (name.isEmpty())
+ return QString();
+
#ifdef Q_OS_WIN
- const LPCWSTR n = (LPCWSTR) name.utf16();
- LPTSTR buff = (LPTSTR) malloc(4096 * sizeof(TCHAR));
- DWORD getenvret = GetEnvironmentVariable(n, buff, 4096);
- QString value = getenvret != 0 ? QString::fromUtf16((const unsigned short *) buff) : QString();
- free(buff);
+ static TCHAR buffer[32767];
+ DWORD size = GetEnvironmentVariable(LPCWSTR(name.utf16()), buffer, 32767);
+ QString value = QString::fromUtf16((const unsigned short *) buffer, size);
if (value.isEmpty()) {
static QLatin1String userEnvironmentRegistryPath("HKEY_CURRENT_USER\\Environment");
@@ -1281,8 +1283,7 @@ QString PackageManagerCore::environmentVariable(const QString &name) const
}
return value;
#else
- const char *pPath = name.isEmpty() ? 0 : getenv(name.toLatin1());
- return pPath ? QLatin1String(pPath) : QString();
+ return QString::fromUtf8(qgetenv(name.toLatin1()));
#endif
}
@@ -1646,7 +1647,7 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo
// add downloadable archive from xml
const QStringList downloadableArchives = data.package->data(scDownloadableArchives).toString()
- .split(scCommaRegExp, QString::SkipEmptyParts);
+ .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (component->isFromOnlineRepository()) {
foreach (const QString downloadableArchive, downloadableArchives)
@@ -1654,7 +1655,7 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo
}
const QStringList componentsToReplace = data.package->data(scReplaces).toString()
- .split(scCommaRegExp, QString::SkipEmptyParts);
+ .split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
if (!componentsToReplace.isEmpty()) {
// Store the component (this is a component that replaces others) and all components that
@@ -1711,14 +1712,14 @@ void PackageManagerCore::storeReplacedComponents(QHash<QString, Component *> &co
qWarning() << componentName << "- Does not exist in the repositories anymore.";
continue;
}
- if (!component && !d->componentsToReplace(data.runMode).contains(componentName)) {
+ if (!component && !d->componentsToReplace().contains(componentName)) {
component = new Component(this);
component->setValue(scName, componentName);
} else {
component->loadComponentScript();
- d->replacementDependencyComponents(data.runMode).append(component);
+ d->replacementDependencyComponents().append(component);
}
- d->componentsToReplace(data.runMode).insert(componentName, qMakePair(it.key(), component));
+ d->componentsToReplace().insert(componentName, qMakePair(it.key(), component));
}
}
}
@@ -1731,7 +1732,6 @@ bool PackageManagerCore::fetchAllPackages(const PackagesList &remotes, const Loc
QHash<QString, QInstaller::Component*> components;
Data data;
- data.runMode = AllMode;
data.components = &components;
data.installedPackages = &locals;
@@ -1775,7 +1775,6 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const
QHash<QString, QInstaller::Component *> components;
Data data;
- data.runMode = UpdaterMode;
data.components = &components;
data.installedPackages = &locals;
@@ -1804,7 +1803,8 @@ bool PackageManagerCore::fetchUpdaterPackages(const PackagesList &remotes, const
bool isValidUpdate = locals.contains(name);
if (!isValidUpdate && !replaces.isEmpty()) {
- const QStringList possibleNames = replaces.split(scCommaRegExp, QString::SkipEmptyParts);
+ const QStringList possibleNames = replaces.split(QInstaller::commaRegExp(),
+ QString::SkipEmptyParts);
foreach (const QString &possibleName, possibleNames) {
if (locals.contains(possibleName)) {
isValidUpdate = true;
@@ -1976,7 +1976,8 @@ ComponentModel *PackageManagerCore::componentModel(PackageManagerCore *core, con
ComponentModel::tr("Size"));
connect(this, SIGNAL(setRootComponents(QList<QInstaller::Component*>)), model,
SLOT(setRootComponents(QList<QInstaller::Component*>)));
- connect(model, SIGNAL(defaultCheckStateChanged(bool)), this, SLOT(componentsToInstallNeedsRecalculation()));
+ connect(model, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
+ SLOT(componentsToInstallNeedsRecalculation()));
return model;
}
diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h
index 50eb63184..df77cd115 100644
--- a/src/libs/installer/packagemanagercore.h
+++ b/src/libs/installer/packagemanagercore.h
@@ -121,7 +121,6 @@ public:
bool fetchRemotePackagesTree();
bool run();
- RunMode runMode() const;
void reset(const QHash<QString, QString> &params);
Q_INVOKABLE void setDependsOnLocalInstallerBinary();
@@ -297,7 +296,6 @@ Q_SIGNALS:
private:
struct Data {
- RunMode runMode;
Package *package;
QHash<QString, Component*> *components;
const LocalPackagesHash *installedPackages;
diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp
index c0c1c78b4..cd413c5b0 100644
--- a/src/libs/installer/packagemanagercore_p.cpp
+++ b/src/libs/installer/packagemanagercore_p.cpp
@@ -47,6 +47,7 @@
#include "errors.h"
#include "fileutils.h"
#include "fsengineclient.h"
+#include "globals.h"
#include "messageboxhandler.h"
#include "packagemanagercore.h"
#include "progresscoordinator.h"
@@ -422,14 +423,14 @@ void PackageManagerCorePrivate::clearUpdaterComponentLists()
m_componentsToInstallCalculated = false;
}
-QList<Component *> &PackageManagerCorePrivate::replacementDependencyComponents(RunMode mode)
+QList<Component *> &PackageManagerCorePrivate::replacementDependencyComponents()
{
- return mode == AllMode ? m_rootDependencyReplacements : m_updaterDependencyReplacements;
+ return (!isUpdater()) ? m_rootDependencyReplacements : m_updaterDependencyReplacements;
}
-QHash<QString, QPair<Component*, Component*> > &PackageManagerCorePrivate::componentsToReplace(RunMode mode)
+QHash<QString, QPair<Component*, Component*> > &PackageManagerCorePrivate::componentsToReplace()
{
- return mode == AllMode ? m_componentsToReplaceAllMode : m_componentsToReplaceUpdaterMode;
+ return (!isUpdater()) ? m_componentsToReplaceAllMode : m_componentsToReplaceUpdaterMode;
}
void PackageManagerCorePrivate::clearComponentsToInstall()
@@ -453,7 +454,7 @@ bool PackageManagerCorePrivate::appendComponentsToInstall(const QList<Component
relevantComponentForAutoDependOn = m_updaterComponents + m_updaterComponentsDeps;
else {
foreach (QInstaller::Component *component, m_rootComponents)
- relevantComponentForAutoDependOn += component->childComponents(true, AllMode);
+ relevantComponentForAutoDependOn += component->childComponents(Component::Descendants);
}
QList<Component*> notAppendedComponents; // for example components with unresolved dependencies
@@ -773,7 +774,7 @@ void PackageManagerCorePrivate::writeMaintenanceConfigFiles()
QVariantHash variables;
QSettingsWrapper cfg(iniPath, QSettingsWrapper::IniFormat);
foreach (const QString &key, m_data.keys()) {
- if (key != scRunProgramDescription && key != scRunProgram)
+ if (key != scRunProgramDescription && key != scRunProgram && key != scRunProgramArguments)
variables.insert(key, m_data.value(key));
}
cfg.setValue(QLatin1String("Variables"), variables);
@@ -2006,7 +2007,7 @@ void PackageManagerCorePrivate::runUndoOperations(const OperationList &undoOpera
if (!componentName.isEmpty()) {
Component *component = m_core->componentByName(componentName);
if (!component)
- component = componentsToReplace(m_core->runMode()).value(componentName).second;
+ component = componentsToReplace().value(componentName).second;
if (component) {
component->setUninstalled();
packages.removePackage(component->name());
@@ -2283,8 +2284,8 @@ bool PackageManagerCorePrivate::appendComponentsToUninstall(const QList<Componen
foreach (Component *c, installedComponents) {
const QString replaces = c->value(scReplaces);
- QStringList possibleNames = replaces.split(scCommaRegExp, QString::SkipEmptyParts);
- possibleNames.append(c->name());
+ const QStringList possibleNames = replaces.split(QInstaller::commaRegExp(),
+ QString::SkipEmptyParts) << c->name();
foreach (const QString &possibleName, possibleNames)
autoDependencies.removeAll(possibleName);
}
diff --git a/src/libs/installer/packagemanagercore_p.h b/src/libs/installer/packagemanagercore_p.h
index 9d4a6abab..e77bff18f 100644
--- a/src/libs/installer/packagemanagercore_p.h
+++ b/src/libs/installer/packagemanagercore_p.h
@@ -43,18 +43,15 @@
#define PACKAGEMANAGERCORE_P_H
#include "getrepositoriesmetainfojob.h"
-#include "settings.h"
#include "packagemanagercore.h"
#include "packagemanagercoredata.h"
+#include "qinstallerglobal.h"
-#include <kdsysinfo.h>
-#include <kdupdaterapplication.h>
-#include <kdupdaterupdatefinder.h>
+#include "kdsysinfo.h"
+#include "kdupdaterapplication.h"
+#include "kdupdaterfiledownloaderfactory.h"
-#include <QtCore/QHash>
-#include <QtCore/QObject>
-#include <QtCore/QPair>
-#include <QtCore/QPointer>
+#include <QObject>
class FSEngineClientHandler;
class KDJob;
@@ -117,8 +114,8 @@ public:
void clearAllComponentLists();
void clearUpdaterComponentLists();
- QList<Component*> &replacementDependencyComponents(RunMode mode);
- QHash<QString, QPair<Component*, Component*> > &componentsToReplace(RunMode mode);
+ QList<Component*> &replacementDependencyComponents();
+ QHash<QString, QPair<Component*, Component*> > &componentsToReplace();
void clearComponentsToInstall();
bool appendComponentsToInstall(const QList<Component*> &components);
diff --git a/src/libs/installer/packagemanagercoredata.cpp b/src/libs/installer/packagemanagercoredata.cpp
index 7dbdf4e1a..efc83f520 100644
--- a/src/libs/installer/packagemanagercoredata.cpp
+++ b/src/libs/installer/packagemanagercoredata.cpp
@@ -90,6 +90,7 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va
m_variables.insert(scTargetConfigurationFile, m_settings.configurationFileName());
m_variables.insert(QLatin1String("LogoPixmap"), m_settings.logo());
m_variables.insert(QLatin1String("WatermarkPixmap"), m_settings.watermark());
+ m_variables.insert(QLatin1String("BannerPixmap"), m_settings.banner());
const QString description = m_settings.runProgramDescription();
if (!description.isEmpty())
@@ -97,6 +98,7 @@ PackageManagerCoreData::PackageManagerCoreData(const QHash<QString, QString> &va
m_variables.insert(scTargetDir, replaceVariables(m_settings.targetDir()));
m_variables.insert(scRunProgram, replaceVariables(m_settings.runProgram()));
+ m_variables.insert(scRunProgramArguments, replaceVariables(m_settings.runProgramArguments()));
m_variables.insert(scRemoveTargetDir, replaceVariables(m_settings.removeTargetDir()));
}
diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp
index 1e01e69ff..25b4cafac 100644
--- a/src/libs/installer/packagemanagergui.cpp
+++ b/src/libs/installer/packagemanagergui.cpp
@@ -46,7 +46,6 @@
#include "fileutils.h"
#include "messageboxhandler.h"
#include "packagemanagercore.h"
-#include "qinstallerglobal.h"
#include "progresscoordinator.h"
#include "performinstallationform.h"
#include "settings.h"
@@ -134,6 +133,7 @@ public:
setObjectName(QLatin1String("Dynamic") + widget->objectName());
setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
+ setPixmap(QWizard::BannerPixmap, QPixmap());
setLayout(new QVBoxLayout);
setSubTitle(QString());
@@ -244,7 +244,7 @@ PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
setWindowTitle(tr("Maintain %1").arg(m_core->value(scTitle)));
#ifndef Q_OS_MAC
- setWindowIcon(QIcon(m_core->settings().icon()));
+ setWindowIcon(QIcon(m_core->settings().installerWindowIcon()));
#else
setPixmap(QWizard::BackgroundPixmap, m_core->settings().background());
#endif
@@ -461,7 +461,6 @@ bool PackageManagerGui::event(QEvent *event)
void PackageManagerGui::showEvent(QShowEvent *event)
{
-#ifndef Q_OS_LINUX
if (!event->spontaneous()) {
foreach (int id, pageIds()) {
const QString subTitle = page(id)->subTitle();
@@ -472,7 +471,6 @@ void PackageManagerGui::showEvent(QShowEvent *event)
}
}
}
-#endif
QWizard::showEvent(event);
QMetaObject::invokeMethod(this, "dependsOnLocalInstallerBinary", Qt::QueuedConnection);
}
@@ -692,6 +690,9 @@ PackageManagerPage::PackageManagerPage(PackageManagerCore *core)
, m_core(core)
, validatorComponent(0)
{
+ setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
+ setPixmap(QWizard::BannerPixmap, bannerPixmap());
+ setPixmap(QWizard::LogoPixmap, logoPixmap());
}
PackageManagerCore *PackageManagerPage::packageManagerCore() const
@@ -699,44 +700,14 @@ PackageManagerCore *PackageManagerPage::packageManagerCore() const
return m_core;
}
-QVariantHash PackageManagerPage::elementsForPage(const QString &pageName) const
-{
- const QVariant variant = m_core->settings().value(pageName);
-
- QVariantHash hash;
- if (variant.canConvert<QVariantHash>())
- hash = variant.value<QVariantHash>();
- return hash;
-}
-
-QString PackageManagerPage::titleForPage(const QString &pageName, const QString &value) const
-{
- return titleFromHash(m_core->settings().titlesForPage(pageName), value);
-}
-
-QString PackageManagerPage::subTitleForPage(const QString &pageName, const QString &value) const
-{
- return titleFromHash(m_core->settings().subTitlesForPage(pageName), value);
-}
-
-QString PackageManagerPage::titleFromHash(const QVariantHash &hash, const QString &value) const
+QPixmap PackageManagerPage::watermarkPixmap() const
{
- QString defaultValue = hash.value(QLatin1String("Default")).toString();
- if (defaultValue.isEmpty())
- defaultValue = value;
-
- if (m_core->isUpdater())
- return hash.value(QLatin1String("Updater"), defaultValue).toString();
- if (m_core->isInstaller())
- return hash.value(QLatin1String("Installer"), defaultValue).toString();
- if (m_core->isPackageManager())
- return hash.value(QLatin1String("PackageManager"), defaultValue).toString();
- return hash.value(QLatin1String("Uninstaller"), defaultValue).toString();
+ return QPixmap(m_core->value(QLatin1String("WatermarkPixmap")));
}
-QPixmap PackageManagerPage::watermarkPixmap() const
+QPixmap PackageManagerPage::bannerPixmap() const
{
- return QPixmap(m_core->value(QLatin1String("WatermarkPixmap")));
+ return QPixmap(m_core->value(QLatin1String("BannerPixmap")));
}
QPixmap PackageManagerPage::logoPixmap() const
@@ -851,16 +822,12 @@ IntroductionPage::IntroductionPage(PackageManagerCore *core)
, m_widget(0)
{
setObjectName(QLatin1String("IntroductionPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("IntroductionPage")));
- setTitle(titleForPage(QLatin1String("IntroductionPage"), tr("Setup - %1")).arg(productName()));
+ setTitle(tr("Setup - %1").arg(productName()));
m_msgLabel = new QLabel(this);
m_msgLabel->setWordWrap(true);
m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("IntroductionPage"));
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Welcome to the %1 "
- "Setup Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Welcome to the %1 Setup Wizard.").arg(productName()));
QVBoxLayout *layout = new QVBoxLayout(this);
setLayout(layout);
@@ -916,10 +883,9 @@ private:
LicenseAgreementPage::LicenseAgreementPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("LicenseAgreementPage"));
- setTitle(titleForPage(QLatin1String("LicenseAgreementPage"), tr("License Agreement")));
+ setTitle(tr("License Agreement"));
m_licenseListWidget = new QListWidget(this);
m_licenseListWidget->setObjectName(QLatin1String("LicenseListWidget"));
@@ -1046,11 +1012,10 @@ void LicenseAgreementPage::updateUi()
rejectButtonText = tr("I do not accept the licenses.");
}
- setSubTitle(subTitleForPage(QLatin1String("LicenseAgreementPage"), subTitleText));
+ setSubTitle(subTitleText);
- const QVariantHash hash = elementsForPage(QLatin1String("LicenseAgreementPage"));
- m_acceptLabel->setText(hash.value(QLatin1String("AcceptLicenseLabel"), acceptButtonText).toString());
- m_rejectLabel->setText(hash.value(QLatin1String("RejectLicenseLabel"), rejectButtonText).toString());
+ m_acceptLabel->setText(acceptButtonText);
+ m_rejectLabel->setText(rejectButtonText);
}
@@ -1072,8 +1037,10 @@ public:
{
m_treeView->setObjectName(QLatin1String("ComponentsTreeView"));
- connect(m_allModel, SIGNAL(defaultCheckStateChanged(bool)), q, SLOT(setModified(bool)));
- connect(m_updaterModel, SIGNAL(defaultCheckStateChanged(bool)), q, SLOT(setModified(bool)));
+ connect(m_allModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
+ SLOT(onCheckStateChanged(QInstaller::ComponentModel::ModelState)));
+ connect(m_updaterModel, SIGNAL(checkStateChanged(QInstaller::ComponentModel::ModelState)), this,
+ SLOT(onCheckStateChanged(QInstaller::ComponentModel::ModelState)));
QHBoxLayout *hlayout = new QHBoxLayout;
hlayout->addWidget(m_treeView, 3);
@@ -1099,18 +1066,15 @@ public:
m_checkDefault = new QPushButton;
connect(m_checkDefault, SIGNAL(clicked()), this, SLOT(selectDefault()));
- connect(m_allModel, SIGNAL(defaultCheckStateChanged(bool)), m_checkDefault, SLOT(setEnabled(bool)));
- const QVariantHash hash = q->elementsForPage(QLatin1String("ComponentSelectionPage"));
if (m_core->isInstaller()) {
m_checkDefault->setObjectName(QLatin1String("SelectDefaultComponentsButton"));
m_checkDefault->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+A", "select default components")));
- m_checkDefault->setText(hash.value(QLatin1String("SelectDefaultComponentsButton"), ComponentSelectionPage::tr("Def&ault"))
- .toString());
+ m_checkDefault->setText(ComponentSelectionPage::tr("Def&ault"));
} else {
m_checkDefault->setEnabled(false);
m_checkDefault->setObjectName(QLatin1String("ResetComponentsButton"));
m_checkDefault->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+R", "reset to already installed components")));
- m_checkDefault->setText(hash.value(QLatin1String("ResetComponentsButton"), ComponentSelectionPage::tr("&Reset")).toString());
+ m_checkDefault->setText(ComponentSelectionPage::tr("&Reset"));
}
hlayout = new QHBoxLayout;
hlayout->addWidget(m_checkDefault);
@@ -1120,15 +1084,14 @@ public:
connect(m_checkAll, SIGNAL(clicked()), this, SLOT(selectAll()));
m_checkAll->setObjectName(QLatin1String("SelectAllComponentsButton"));
m_checkAll->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+S", "select all components")));
- m_checkAll->setText(hash.value(QLatin1String("SelectAllComponentsButton"), ComponentSelectionPage::tr("&Select All")).toString());
+ m_checkAll->setText(ComponentSelectionPage::tr("&Select All"));
m_uncheckAll = new QPushButton;
hlayout->addWidget(m_uncheckAll);
connect(m_uncheckAll, SIGNAL(clicked()), this, SLOT(deselectAll()));
m_uncheckAll->setObjectName(QLatin1String("DeselectAllComponentsButton"));
m_uncheckAll->setShortcut(QKeySequence(ComponentSelectionPage::tr("Alt+D", "deselect all components")));
- m_uncheckAll->setText(hash.value(QLatin1String("DeselectAllComponentsButton"), ComponentSelectionPage::tr("&Deselect All"))
- .toString());
+ m_uncheckAll->setText(ComponentSelectionPage::tr("&Deselect All"));
hlayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding));
@@ -1139,10 +1102,10 @@ public:
{
m_checkDefault->setVisible(m_core->isInstaller() || m_core->isPackageManager());
if (m_treeView->selectionModel()) {
- disconnect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex)));
disconnect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentChanged(QModelIndex)));
+ SLOT(currentCheckedChanged(QModelIndex)));
+ disconnect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentSelectedChanged(QModelIndex)));
}
m_currentModel = m_core->isUpdater() ? m_updaterModel : m_allModel;
@@ -1165,62 +1128,69 @@ public:
hasChildren = m_currentModel->hasChildren(m_currentModel->index(row, 0));
m_treeView->setRootIsDecorated(hasChildren);
- connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex)));
connect(m_currentModel, SIGNAL(checkStateChanged(QModelIndex)), this,
- SLOT(currentChanged(QModelIndex)));
+ SLOT(currentCheckedChanged(QModelIndex)));
+ connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentSelectedChanged(QModelIndex)));
m_treeView->setCurrentIndex(m_currentModel->index(0, 0));
}
public slots:
- void currentChanged(const QModelIndex &current)
+ void currentCheckedChanged(const QModelIndex &current)
+ {
+ if (m_treeView->selectionModel()->currentIndex() == current)
+ currentSelectedChanged(current);
+ }
+
+ void currentSelectedChanged(const QModelIndex &current)
{
- // if there is not selection or the current selected node didn't change, return
- if (!current.isValid() || current != m_treeView->selectionModel()->currentIndex())
+ if (!current.isValid())
return;
+ m_sizeLabel->setText(QString());
m_descriptionLabel->setText(m_currentModel->data(m_currentModel->index(current.row(),
ComponentModelHelper::NameColumn, current.parent()), Qt::ToolTipRole).toString());
- m_sizeLabel->clear();
- if (!m_core->isUninstaller()) {
- Component *component = m_currentModel->componentFromIndex(current);
- if (component && component->updateUncompressedSize() > 0) {
- const QVariantHash hash = q->elementsForPage(QLatin1String("ComponentSelectionPage"));
- m_sizeLabel->setText(hash.value(QLatin1String("ComponentSizeLabel"),
- ComponentSelectionPage::tr("This component will occupy approximately %1 on your hard disk drive.")).toString()
- .arg(m_currentModel->data(m_currentModel->index(current.row(),
- ComponentModelHelper::UncompressedSizeColumn, current.parent())).toString()));
- }
+ Component *component = m_currentModel->componentFromIndex(current);
+ if ((m_core->isUninstaller()) || (!component))
+ return;
+
+ if ((component->checkState() != Qt::Unchecked) && (component->updateUncompressedSize() > 0)) {
+ m_sizeLabel->setText(ComponentSelectionPage::tr("This component "
+ "will occupy approximately %1 on your hard disk drive.")
+ .arg(humanReadableSize(component->value(scUncompressedSizeSum).toLongLong())));
}
}
- // TODO: all *select* function ignore the fact that components can be selected inside the tree view as
- // well, which will result in e.g. a disabled button state as long as "ALL" components not
- // unchecked again.
void selectAll()
{
- m_currentModel->selectAll();
-
- m_checkAll->setEnabled(false);
- m_uncheckAll->setEnabled(true);
+ m_currentModel->setCheckedState(ComponentModel::AllChecked);
}
void deselectAll()
{
- m_currentModel->deselectAll();
-
- m_checkAll->setEnabled(true);
- m_uncheckAll->setEnabled(false);
+ m_currentModel->setCheckedState(ComponentModel::AllUnchecked);
}
void selectDefault()
{
- m_currentModel->selectDefault();
+ m_currentModel->setCheckedState(ComponentModel::DefaultChecked);
+ }
+
+ void onCheckStateChanged(QInstaller::ComponentModel::ModelState state)
+ {
+ q->setModified(state != ComponentModel::DefaultChecked);
+
+ // If all components in the checked list are only checkable when run without forced installation, set
+ // ComponentModel::AllUnchecked as well, as we cannot uncheck anything. Helps to keep the UI correct.
+ if ((!m_core->noForceInstallation()) && (m_currentModel->checked() == m_currentModel->uncheckable()))
+ state |= ComponentModel::AllUnchecked;
- m_checkAll->setEnabled(true);
- m_uncheckAll->setEnabled(true);
+ // enable the button if the corresponding flag is not set
+ m_checkAll->setEnabled(state.testFlag(ComponentModel::AllChecked) == false);
+ m_uncheckAll->setEnabled(state.testFlag(ComponentModel::AllUnchecked) == false);
+ m_checkDefault->setEnabled(state.testFlag(ComponentModel::DefaultChecked) == false);
}
public:
@@ -1248,10 +1218,9 @@ ComponentSelectionPage::ComponentSelectionPage(PackageManagerCore *core)
: PackageManagerPage(core)
, d(new Private(this, core))
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("ComponentSelectionPage"));
- setTitle(titleForPage(QLatin1String("ComponentSelectionPage"), tr("Select Components")));
+ setTitle(tr("Select Components"));
}
ComponentSelectionPage::~ComponentSelectionPage()
@@ -1273,7 +1242,7 @@ void ComponentSelectionPage::entering()
if (core->isInstaller()) index = 1;
if (core->isUninstaller()) index = 2;
if (core->isPackageManager()) index = 3;
- setSubTitle(subTitleForPage(QLatin1String("ComponentSelectionPage"), tr(strings[index])));
+ setSubTitle(tr(strings[index]));
d->updateTreeView();
setModified(isComplete());
@@ -1331,8 +1300,8 @@ void ComponentSelectionPage::setModified(bool modified)
bool ComponentSelectionPage::isComplete() const
{
if (packageManagerCore()->isInstaller() || packageManagerCore()->isUpdater())
- return d->m_currentModel->hasCheckedComponents();
- return !d->m_currentModel->defaultCheckState();
+ return d->m_currentModel->checked().count();
+ return d->m_currentModel->checkedState() != ComponentModel::DefaultChecked;
}
@@ -1341,20 +1310,16 @@ bool ComponentSelectionPage::isComplete() const
TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("TargetDirectoryPage"));
- setSubTitle(subTitleForPage(QLatin1String("TargetDirectoryPage")));
- setTitle(titleForPage(QLatin1String("TargetDirectoryPage"), tr("Installation Folder")));
+ setTitle(tr("Installation Folder"));
QVBoxLayout *layout = new QVBoxLayout(this);
QLabel *msgLabel = new QLabel(this);
msgLabel->setWordWrap(true);
msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
- msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Please specify the folder "
- "where %1 will be installed.")).toString().arg(productName()));
+ msgLabel->setText(tr("Please specify the folder where %1 will be installed.").arg(productName()));
layout->addWidget(msgLabel);
QHBoxLayout *hlayout = new QHBoxLayout;
@@ -1368,8 +1333,7 @@ TargetDirectoryPage::TargetDirectoryPage(PackageManagerCore *core)
browseButton->setObjectName(QLatin1String("BrowseDirectoryButton"));
connect(browseButton, SIGNAL(clicked()), this, SLOT(dirRequested()));
browseButton->setShortcut(QKeySequence(tr("Alt+R", "browse file system to choose a file")));
- browseButton->setText(hash.value(QLatin1String("BrowseDirectoryButton"), tr("B&rowse..."))
- .toString());
+ browseButton->setText(tr("B&rowse..."));
hlayout->addWidget(browseButton);
layout->addLayout(hlayout);
@@ -1403,12 +1367,10 @@ void TargetDirectoryPage::initializePage()
bool TargetDirectoryPage::validatePage()
{
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
if (targetDir().isEmpty()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("EmptyTargetDirectoryMessage"), tr("Error"), hash
- .value(QLatin1String("EmptyTargetDirectoryMessage"), tr("The install directory cannot be "
- "empty, please specify a valid folder.")).toString(), QMessageBox::Ok);
+ QLatin1String("EmptyTargetDirectoryMessage"), tr("Error"), tr("The install directory cannot be "
+ "empty, please specify a valid folder."), QMessageBox::Ok);
return false;
}
@@ -1421,9 +1383,8 @@ bool TargetDirectoryPage::validatePage()
// it exists, but is not empty
if (dir == QDir::root()) {
MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("ForbiddenTargetDirectoryMessage"), tr("Error"), hash
- .value(QLatin1String("ForbiddenTargetDirectoryMessage"), tr("As the install directory is "
- "completely deleted, installing in %1 is forbidden.")).toString().arg(QDir::rootPath()),
+ QLatin1String("ForbiddenTargetDirectoryMessage"), tr("Error"), tr("As the install directory "
+ "is completely deleted on uninstall, installing in %1 is forbidden.").arg(QDir::rootPath()),
QMessageBox::Ok);
return false;
}
@@ -1432,11 +1393,10 @@ bool TargetDirectoryPage::validatePage()
return true;
return MessageBoxHandler::critical(MessageBoxHandler::currentBestSuitParent(),
- QLatin1String("OverwriteTargetDirectoryMessage"), tr("Warning"), hash
- .value(QLatin1String("OverwriteTargetDirectoryMessage"), tr("You have selected an existing, "
+ QLatin1String("OverwriteTargetDirectoryMessage"), tr("Warning"), tr("You have selected an existing, "
"non-empty folder for installation. Note that it will be completely wiped on uninstallation of "
"this application. It is not advisable to install into this folder as installation might fail. "
- "Do you want to continue?")).toString(), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
+ "Do you want to continue?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes;
}
return true;
}
@@ -1456,9 +1416,7 @@ void TargetDirectoryPage::targetDirSelected()
void TargetDirectoryPage::dirRequested()
{
- const QVariantHash hash = elementsForPage(QLatin1String("TargetDirectoryPage"));
- const QString newDirName = QFileDialog::getExistingDirectory(this, hash
- .value(QLatin1String("SelectInstallationFolderCaption"), tr("Select Installation Folder")).toString(),
+ const QString newDirName = QFileDialog::getExistingDirectory(this, tr("Select Installation Folder"),
targetDir());
if (newDirName.isEmpty() || newDirName == targetDir())
return;
@@ -1471,12 +1429,11 @@ void TargetDirectoryPage::dirRequested()
StartMenuDirectoryPage::StartMenuDirectoryPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("StartMenuDirectoryPage"));
- setTitle(titleForPage(QLatin1String("StartMenuDirectoryPage"), tr("Start Menu shortcuts")));
- setSubTitle(subTitleForPage(QLatin1String("StartMenuDirectoryPage"), tr("Select the Start Menu in which "
- "you would like to create the program's shortcuts. You can also enter a name to create a new folder.")));
+ setTitle(tr("Start Menu shortcuts"));
+ setSubTitle(tr("Select the Start Menu in which you would like to create the program's shortcuts. You can "
+ "also enter a name to create a new folder."));
m_lineEdit = new QLineEdit(this);
m_lineEdit->setObjectName(QLatin1String("LineEdit"));
@@ -1561,10 +1518,8 @@ ReadyForInstallationPage::ReadyForInstallationPage(PackageManagerCore *core)
: PackageManagerPage(core)
, m_msgLabel(new QLabel)
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("ReadyForInstallationPage"));
- setSubTitle(subTitleForPage(QLatin1String("ReadyForInstallationPage")));
QVBoxLayout *baseLayout = new QVBoxLayout();
baseLayout->setObjectName(QLatin1String("BaseLayout"));
@@ -1612,7 +1567,7 @@ void ReadyForInstallationPage::entering()
m_taskDetailsButton->setVisible(false);
m_taskDetailsBrowser->setVisible(false);
setButtonText(QWizard::CommitButton, tr("U&ninstall"));
- setTitle(titleForPage(objectName(), tr("Ready to Uninstall")));
+ setTitle(tr("Ready to Uninstall"));
m_msgLabel->setText(tr("Setup is now ready to begin removing %1 from your computer.<br>"
"<font color=\"red\">The program directory %2 will be deleted completely</font>, "
"including all content in that directory!")
@@ -1622,12 +1577,12 @@ void ReadyForInstallationPage::entering()
return;
} else if (packageManagerCore()->isPackageManager() || packageManagerCore()->isUpdater()) {
setButtonText(QWizard::CommitButton, tr("U&pdate"));
- setTitle(titleForPage(objectName(), tr("Ready to Update Packages")));
+ setTitle(tr("Ready to Update Packages"));
m_msgLabel->setText(tr("Setup is now ready to begin updating your installation."));
} else {
Q_ASSERT(packageManagerCore()->isInstaller());
setButtonText(QWizard::CommitButton, tr("&Install"));
- setTitle(titleForPage(objectName(), tr("Ready to Install")));
+ setTitle(tr("Ready to Install"));
m_msgLabel->setText(tr("Setup is now ready to begin installing %1 on your computer.")
.arg(productName()));
}
@@ -1791,10 +1746,8 @@ PerformInstallationPage::PerformInstallationPage(PackageManagerCore *core)
: PackageManagerPage(core)
, m_performInstallationForm(new PerformInstallationForm(this))
{
- setPixmap(QWizard::LogoPixmap, logoPixmap());
setPixmap(QWizard::WatermarkPixmap, QPixmap());
setObjectName(QLatin1String("PerformInstallationPage"));
- setSubTitle(subTitleForPage(QLatin1String("PerformInstallationPage")));
m_performInstallationForm->setupUi(this);
@@ -1836,17 +1789,17 @@ void PerformInstallationPage::entering()
if (packageManagerCore()->isUninstaller()) {
setButtonText(QWizard::CommitButton, tr("&Uninstall"));
- setTitle(titleForPage(objectName(), tr("Uninstalling %1")).arg(productName()));
+ setTitle(tr("Uninstalling %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runUninstaller()));
} else if (packageManagerCore()->isPackageManager() || packageManagerCore()->isUpdater()) {
setButtonText(QWizard::CommitButton, tr("&Update"));
- setTitle(titleForPage(objectName(), tr("Updating components of %1")).arg(productName()));
+ setTitle(tr("Updating components of %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runPackageUpdater()));
} else {
setButtonText(QWizard::CommitButton, tr("&Install"));
- setTitle(titleForPage(objectName(), tr("Installing %1")).arg(productName()));
+ setTitle(tr("Installing %1").arg(productName()));
QTimer::singleShot(30, packageManagerCore(), SLOT(runInstaller()));
}
@@ -1913,21 +1866,16 @@ FinishedPage::FinishedPage(PackageManagerCore *core)
, m_commitButton(0)
{
setObjectName(QLatin1String("FinishedPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("FinishedPage")));
- setTitle(titleForPage(QLatin1String("FinishedPage"), tr("Completing the %1 Wizard")).arg(productName()));
+ setTitle(tr("Completing the %1 Wizard").arg(productName()));
m_msgLabel = new QLabel(this);
m_msgLabel->setWordWrap(true);
m_msgLabel->setObjectName(QLatin1String("MessageLabel"));
- const QVariantHash hash = elementsForPage(QLatin1String("FinishedPage"));
#ifdef Q_OS_MAC
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Click Done to exit the %1 "
- "Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Click Done to exit the %1 Wizard.").arg(productName()));
#else
- m_msgLabel->setText(hash.value(QLatin1String("MessageLabel"), tr("Click Finish to exit the "
- "%1 Wizard.")).toString().arg(productName()));
+ m_msgLabel->setText(tr("Click Finish to exit the %1 Wizard.").arg(productName()));
#endif
m_runItCheckBox = new QCheckBox(this);
@@ -2012,11 +1960,13 @@ void FinishedPage::leaving()
void FinishedPage::handleFinishClicked()
{
const QString program = packageManagerCore()->replaceVariables(packageManagerCore()->value(scRunProgram));
+ const QStringList args = packageManagerCore()->replaceVariables(
+ packageManagerCore()->value(scRunProgramArguments)).split(QLatin1Char(' '));
if (!m_runItCheckBox->isChecked() || program.isEmpty())
return;
- qDebug() << "starting" << program;
- QProcess::startDetached(program);
+ qDebug() << "starting" << program << args;
+ QProcess::startDetached(program, args);
}
@@ -2026,10 +1976,7 @@ RestartPage::RestartPage(PackageManagerCore *core)
: PackageManagerPage(core)
{
setObjectName(QLatin1String("RestartPage"));
- setPixmap(QWizard::WatermarkPixmap, watermarkPixmap());
- setSubTitle(subTitleForPage(QLatin1String("RestartPage")));
- setTitle(titleForPage(QLatin1String("RestartPage"), tr("Completing the %1 Setup Wizard"))
- .arg(productName()));
+ setTitle(tr("Completing the %1 Setup Wizard").arg(productName()));
setFinalPage(false);
setCommitPage(false);
diff --git a/src/libs/installer/packagemanagergui.h b/src/libs/installer/packagemanagergui.h
index 5b7bd0615..93ade1552 100644
--- a/src/libs/installer/packagemanagergui.h
+++ b/src/libs/installer/packagemanagergui.h
@@ -155,6 +155,7 @@ public:
virtual QPixmap logoPixmap() const;
virtual QString productName() const;
virtual QPixmap watermarkPixmap() const;
+ virtual QPixmap bannerPixmap() const;
virtual bool isComplete() const;
void setComplete(bool complete);
@@ -168,10 +169,6 @@ public:
protected:
PackageManagerCore *packageManagerCore() const;
- QVariantHash elementsForPage(const QString &pageName) const;
-
- QString titleForPage(const QString &pageName, const QString &value = QString()) const;
- QString subTitleForPage(const QString &pageName, const QString &value = QString()) const;
// Inserts widget into the same layout like a sibling identified
// by its name. Default position is just behind the sibling.
@@ -187,9 +184,6 @@ protected:
bool isConstructing() const { return m_fresh; }
private:
- QString titleFromHash(const QVariantHash &hash, const QString &value = QString()) const;
-
-private:
bool m_fresh;
bool m_complete;
diff --git a/src/libs/installer/packagemanagerproxyfactory.h b/src/libs/installer/packagemanagerproxyfactory.h
index 2ddfe7a18..a50605232 100644
--- a/src/libs/installer/packagemanagerproxyfactory.h
+++ b/src/libs/installer/packagemanagerproxyfactory.h
@@ -51,7 +51,7 @@ class PackageManagerCore;
class PackageManagerProxyFactory : public KDUpdater::FileDownloaderProxyFactory
{
public:
- PackageManagerProxyFactory(const PackageManagerCore *const core);
+ explicit PackageManagerProxyFactory(const PackageManagerCore *const core);
PackageManagerProxyFactory *clone() const;
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery());
diff --git a/src/libs/installer/performinstallationform.h b/src/libs/installer/performinstallationform.h
index f3471ebe2..209afc42d 100644
--- a/src/libs/installer/performinstallationform.h
+++ b/src/libs/installer/performinstallationform.h
@@ -61,7 +61,7 @@ class PerformInstallationForm : public QObject
Q_OBJECT
public:
- PerformInstallationForm(QObject *parent);
+ explicit PerformInstallationForm(QObject *parent);
void setupUi(QWidget *widget);
void setDetailsWidgetVisible(bool visible);
diff --git a/src/libs/installer/productkeycheck.cpp b/src/libs/installer/productkeycheck.cpp
index f975db821..120014dad 100644
--- a/src/libs/installer/productkeycheck.cpp
+++ b/src/libs/installer/productkeycheck.cpp
@@ -47,10 +47,8 @@ ProductKeyCheck::~ProductKeyCheck()
ProductKeyCheck *ProductKeyCheck::instance()
{
- static ProductKeyCheck *instance = 0;
- if (instance == 0)
- instance = new ProductKeyCheck();
- return instance;
+ static ProductKeyCheck instance;
+ return &instance;
}
bool ProductKeyCheck::hasValidKey()
diff --git a/src/libs/installer/progresscoordinator.h b/src/libs/installer/progresscoordinator.h
index b1fa0ab67..263b25695 100644
--- a/src/libs/installer/progresscoordinator.h
+++ b/src/libs/installer/progresscoordinator.h
@@ -39,8 +39,8 @@
**
**************************************************************************/
-#ifndef PROGRESSCOORDNINATOR_H
-#define PROGRESSCOORDNINATOR_H
+#ifndef PROGRESSCOORDINATOR_H
+#define PROGRESSCOORDINATOR_H
#include <QtCore/QHash>
#include <QtCore/QObject>
@@ -102,4 +102,4 @@ private:
} //namespace QInstaller
-#endif //PROGRESSCOORDNINATOR_H
+#endif //PROGRESSCOORDINATOR_H
diff --git a/src/libs/installer/qinstallerglobal.h b/src/libs/installer/qinstallerglobal.h
index b7d5d3f3d..7f0fbbbc0 100644
--- a/src/libs/installer/qinstallerglobal.h
+++ b/src/libs/installer/qinstallerglobal.h
@@ -57,14 +57,6 @@ QT_END_NAMESPACE
namespace QInstaller {
-static QRegExp scCommaRegExp(QLatin1String("\\b(,|, )\\b"));
-
-enum INSTALLER_EXPORT RunMode
-{
- AllMode,
- UpdaterMode
-};
-
enum INSTALLER_EXPORT JobError
{
InvalidUrl = 0x24B04,
diff --git a/src/libs/installer/registerqtvqnxoperation.cpp b/src/libs/installer/registerqtincreatorqnxoperation.cpp
index b52558145..be99de4c7 100644
--- a/src/libs/installer/registerqtvqnxoperation.cpp
+++ b/src/libs/installer/registerqtincreatorqnxoperation.cpp
@@ -39,7 +39,7 @@
**
**************************************************************************/
-#include "registerqtvqnxoperation.h"
+#include "registerqtincreatorqnxoperation.h"
#include "packagemanagercore.h"
#include "qtcreator_constants.h"
diff --git a/src/libs/installer/registerqtvqnxoperation.h b/src/libs/installer/registerqtincreatorqnxoperation.h
index a5e49656a..5b6a3c9b1 100644
--- a/src/libs/installer/registerqtvqnxoperation.h
+++ b/src/libs/installer/registerqtincreatorqnxoperation.h
@@ -39,8 +39,8 @@
**
**************************************************************************/
-#ifndef REGISTERQTINCREATORVQNXOPERATION_H
-#define REGISTERQTINCREATORVQNXOPERATION_H
+#ifndef REGISTERQTINCREATORQNXOPERATION_H
+#define REGISTERQTINCREATORQNXOPERATION_H
#include "qinstallerglobal.h"
@@ -60,4 +60,4 @@ public:
} // namespace QInstaller
-#endif // REGISTERQTINCREATORVQNXOPERATION_H
+#endif // REGISTERQTINCREATORQNXOPERATION_H
diff --git a/src/libs/installer/settings.cpp b/src/libs/installer/settings.cpp
index acc664fb4..2635dc10c 100644
--- a/src/libs/installer/settings.cpp
+++ b/src/libs/installer/settings.cpp
@@ -52,10 +52,12 @@
using namespace QInstaller;
static const QLatin1String scIcon("Icon");
+static const QLatin1String scInstallerApplicationIcon("InstallerApplicationIcon");
+static const QLatin1String scInstallerWindowIcon("InstallerWindowIcon");
static const QLatin1String scLogo("Logo");
-static const QLatin1String scPages("Pages");
static const QLatin1String scPrefix("Prefix");
static const QLatin1String scWatermark("Watermark");
+static const QLatin1String scBanner("Banner");
static const QLatin1String scProductUrl("ProductUrl");
static const QLatin1String scBackground("Background");
static const QLatin1String scAdminTargetDir("AdminTargetDir");
@@ -134,40 +136,6 @@ static QSet<Repository> readRepositories(QXmlStreamReader &reader, bool isDefaul
return set;
}
-static QVariantHash readTitles(QXmlStreamReader &reader)
-{
- QVariantHash hash;
- while (reader.readNextStartElement())
- hash.insert(reader.name().toString(), reader.readElementText(QXmlStreamReader::SkipChildElements));
- return hash;
-}
-
-static QHash<QString, QVariantHash> readPages(QXmlStreamReader &reader, Settings::ParseMode parseMode)
-{
- QHash<QString, QVariantHash> hash;
- while (reader.readNextStartElement()) {
- if (reader.name() == QLatin1String("Page")) {
- QVariantHash pageElements;
- const QString pageName = reader.attributes().value(QLatin1String("name")).toString();
- if (pageName.isEmpty()) {
- raiseError(reader, QLatin1String("Expected non-empty attribute 'name' for element 'Page'."),
- parseMode);
- }
- while (reader.readNextStartElement()) {
- const QString name = reader.name().toString();
- if (name == QLatin1String("Title") || name == QLatin1String("SubTitle"))
- pageElements.insert(name, readTitles(reader));
- else
- pageElements.insert(name, reader.readElementText(QXmlStreamReader::SkipChildElements));
- }
- hash.insert(pageName, pageElements);
- } else {
- raiseError(reader, QString::fromLatin1("Unexpected element '%1'.").arg(reader.name().toString()),
- parseMode);
- }
- }
- return hash;
-}
// -- Settings::Private
@@ -235,16 +203,14 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix,
QStringList elementList;
elementList << scName << scVersion << scTitle << scPublisher << scProductUrl
<< scTargetDir << scAdminTargetDir
- << scIcon << scLogo << scWatermark << scBackground
+ << scIcon << scInstallerApplicationIcon << scInstallerWindowIcon
+ << scLogo << scWatermark << scBanner << scBackground
<< scStartMenuDir << scUninstallerName << scUninstallerIniFile << scRemoveTargetDir
- << scRunProgram << scRunProgramDescription
+ << scRunProgram << scRunProgramArguments << scRunProgramDescription
<< scDependsOnLocalInstallerBinary
<< scAllowSpaceInPath << scAllowNonAsciiCharacters
<< scRepositorySettingsPageVisible << scTargetConfigurationFile
- << scRemoteRepositories << scPages;
-
- QStringList blackList;
- blackList << scRemoteRepositories << scPages;
+ << scRemoteRepositories;
Settings s;
s.d->m_data.insert(scPrefix, prefix);
@@ -258,22 +224,15 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix,
parseMode);
}
- if (blackList.contains(name)) {
- if (name == scRemoteRepositories)
- s.addDefaultRepositories(readRepositories(reader, true, parseMode));
+ if (name == scIcon)
+ qWarning() << "Deprecated element 'Icon'.";
- if (name == scPages) {
- qWarning() << "Deprecated element 'Pages'.";
- QHash<QString, QVariantHash> pages = readPages(reader, parseMode);
- const QStringList &keys = pages.keys();
- foreach (const QString &key, keys)
- s.d->m_data.insert(key, pages.value(key));
- }
+ if (s.d->m_data.contains(name))
+ reader.raiseError(QString::fromLatin1("Element '%1' has been defined before.").arg(name));
+
+ if (name == scRemoteRepositories) {
+ s.addDefaultRepositories(readRepositories(reader, true, parseMode));
} else {
- if (s.d->m_data.contains(name)) {
- // instead of raising parse mode based error, raise a real error
- reader.raiseError(QString::fromLatin1("Element '%1' has been defined before.").arg(name));
- }
s.d->m_data.insert(name, reader.readElementText(QXmlStreamReader::SkipChildElements));
}
}
@@ -291,6 +250,10 @@ Settings Settings::fromFileAndPrefix(const QString &path, const QString &prefix,
// Add some possible missing values
if (!s.d->m_data.contains(scIcon))
s.d->m_data.insert(scIcon, QLatin1String(":/installer"));
+ if (!s.d->m_data.contains(scInstallerApplicationIcon))
+ s.d->m_data.insert(scInstallerApplicationIcon, s.d->m_data.value(scIcon));
+ if (!s.d->m_data.contains(scInstallerWindowIcon))
+ s.d->m_data.insert(scInstallerWindowIcon, s.d->m_data.value(scIcon).toString() + s.systemIconSuffix());
if (!s.d->m_data.contains(scRemoveTargetDir))
s.d->m_data.insert(scRemoveTargetDir, scTrue);
if (!s.d->m_data.contains(scUninstallerName))
@@ -342,6 +305,11 @@ QString Settings::watermark() const
return d->makeAbsolutePath(d->m_data.value(scWatermark).toString());
}
+QString Settings::banner() const
+{
+ return d->makeAbsolutePath(d->m_data.value(scBanner).toString());
+}
+
QString Settings::background() const
{
return d->makeAbsolutePath(d->m_data.value(scBackground).toString());
@@ -349,15 +317,30 @@ QString Settings::background() const
QString Settings::icon() const
{
- const QString icon = d->makeAbsolutePath(d->m_data.value(scIcon).toString());
+ return d->makeAbsolutePath(d->m_data.value(scIcon).toString() + systemIconSuffix());
+}
+
+QString Settings::installerApplicationIcon() const
+{
+ return d->makeAbsolutePath(d->m_data.value(scInstallerApplicationIcon).toString() + systemIconSuffix());
+}
+
+QString Settings::installerWindowIcon() const
+{
+ return d->makeAbsolutePath(d->m_data.value(scInstallerWindowIcon).toString());
+}
+
+QString Settings::systemIconSuffix() const
+{
#if defined(Q_OS_MAC)
- return icon + QLatin1String(".icns");
+ return QLatin1String(".icns");
#elif defined(Q_OS_WIN)
- return icon + QLatin1String(".ico");
+ return QLatin1String(".ico");
#endif
- return icon + QLatin1String(".png");
+ return QLatin1String(".png");
}
+
QString Settings::removeTargetDir() const
{
return d->m_data.value(scRemoveTargetDir).toString();
@@ -378,6 +361,11 @@ QString Settings::runProgram() const
return d->m_data.value(scRunProgram).toString();
}
+QString Settings::runProgramArguments() const
+{
+ return d->m_data.value(scRunProgramArguments).toString();
+}
+
QString Settings::runProgramDescription() const
{
return d->m_data.value(scRunProgramDescription).toString();
@@ -546,24 +534,6 @@ QVariantList Settings::values(const QString &key, const QVariantList &defaultVal
return list.isEmpty() ? defaultValue : list;
}
-QVariantHash Settings::titlesForPage(const QString &pageName) const
-{
- const QVariantHash hash = d->m_data.value(pageName).toHash();
- const QVariant variant = hash.value(QLatin1String("Title"), QVariant());
- if (!variant.canConvert<QVariantHash>())
- return QVariantHash();
- return variant.value<QVariantHash>();
-}
-
-QVariantHash Settings::subTitlesForPage(const QString &pageName) const
-{
- const QVariantHash hash = d->m_data.value(pageName).toHash();
- const QVariant variant = hash.value(QLatin1String("SubTitle"), QVariant());
- if (!variant.canConvert<QVariantHash>())
- return QVariantHash();
- return variant.value<QVariantHash>();
-}
-
bool Settings::repositorySettingsPageVisible() const
{
return d->m_data.value(scRepositorySettingsPageVisible, true).toBool();
diff --git a/src/libs/installer/settings.h b/src/libs/installer/settings.h
index fcea7cb55..277264f79 100644
--- a/src/libs/installer/settings.h
+++ b/src/libs/installer/settings.h
@@ -93,13 +93,18 @@ public:
QString publisher() const;
QString url() const;
QString watermark() const;
+ QString banner() const;
QString background() const;
QString icon() const;
+ QString installerApplicationIcon() const;
+ QString installerWindowIcon() const;
+ QString systemIconSuffix() const;
QString applicationName() const;
QString applicationVersion() const;
QString runProgram() const;
+ QString runProgramArguments() const;
QString runProgramDescription() const;
QString startMenuDir() const;
QString targetDir() const;
@@ -135,9 +140,6 @@ public:
QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
QVariantList values(const QString &key, const QVariantList &defaultValue = QVariantList()) const;
- QVariantHash titlesForPage(const QString &pageName) const;
- QVariantHash subTitlesForPage(const QString &pageName) const;
-
bool repositorySettingsPageVisible() const;
Settings::ProxyType proxyType() const;
diff --git a/src/libs/installer/utils.h b/src/libs/installer/utils.h
index 0d21adbee..e6aca456d 100644
--- a/src/libs/installer/utils.h
+++ b/src/libs/installer/utils.h
@@ -81,7 +81,7 @@ namespace QInstaller {
{
Q_OBJECT
public:
- VerboseWriter(QObject *parent = 0);
+ explicit VerboseWriter(QObject *parent = 0);
~VerboseWriter();
static VerboseWriter *instance();
diff --git a/src/libs/kdtools/kdsysinfo_win.cpp b/src/libs/kdtools/kdsysinfo_win.cpp
index 10666c8e0..0fa605ef9 100644
--- a/src/libs/kdtools/kdsysinfo_win.cpp
+++ b/src/libs/kdtools/kdsysinfo_win.cpp
@@ -247,7 +247,7 @@ bool killProcess(const ProcessInfo &process, int msecs)
// If we can't open the process with PROCESS_TERMINATE rights,
// then we give up immediately.
- HANDLE hProc = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, FALSE, process.id);
+ HANDLE hProc = OpenProcess(SYNCHRONIZE | PROCESS_TERMINATE, false, process.id);
if (hProc == 0)
return false;
diff --git a/src/libs/kdtools/kdtools.pri b/src/libs/kdtools/kdtools.pri
index cc9fd52fb..2b98089b9 100644
--- a/src/libs/kdtools/kdtools.pri
+++ b/src/libs/kdtools/kdtools.pri
@@ -36,7 +36,8 @@ HEADERS += $$PWD/kdupdater.h \
$$PWD/kdupdatertask.h \
$$PWD/kdupdaterupdatefinder.h \
$$PWD/kdupdaterupdatesinfo_p.h \
- $$PWD/environment.h
+ $$PWD/environment.h \
+ $$PWD/kdupdaterupdatesinfodata_p.h
SOURCES += $$PWD/kdupdaterapplication.cpp \
$$PWD/kdupdaterfiledownloader.cpp \
diff --git a/src/libs/kdtools/kdupdaterapplication.h b/src/libs/kdtools/kdupdaterapplication.h
index b2079fe7c..f1ca9d612 100644
--- a/src/libs/kdtools/kdupdaterapplication.h
+++ b/src/libs/kdtools/kdupdaterapplication.h
@@ -25,7 +25,6 @@
#include "kdupdater.h"
#include <QObject>
-#include <QRegExp>
QT_BEGIN_NAMESPACE
class QUrl;
@@ -36,7 +35,6 @@ namespace KDUpdater {
class PackagesInfo;
class UpdateSourcesInfo;
-static QRegExp scCommaRegExp(QLatin1String("\\b(,|, )\\b"));
class ConfigurationInterface
{
public:
diff --git a/src/libs/kdtools/kdupdaterpackagesinfo.cpp b/src/libs/kdtools/kdupdaterpackagesinfo.cpp
index 9ac2b8eac..142cf67b0 100644
--- a/src/libs/kdtools/kdupdaterpackagesinfo.cpp
+++ b/src/libs/kdtools/kdupdaterpackagesinfo.cpp
@@ -21,6 +21,7 @@
**********************************************************************/
#include "kdupdaterpackagesinfo.h"
#include "kdupdaterapplication.h"
+#include "globals.h"
#include <QFileInfo>
#include <QtXml/QDomDocument>
@@ -511,9 +512,10 @@ void PackagesInfo::PackagesInfoData::addPackageFrom(const QDomElement &packageE)
info.virtualComp = childNodeE.text().toLower() == QLatin1String("true") ? true : false;
else if (childNodeE.tagName() == QLatin1String("Size"))
info.uncompressedSize = childNodeE.text().toULongLong();
- else if (childNodeE.tagName() == QLatin1String("Dependencies"))
- info.dependencies = childNodeE.text().split(scCommaRegExp, QString::SkipEmptyParts);
- else if (childNodeE.tagName() == QLatin1String("ForcedInstallation"))
+ else if (childNodeE.tagName() == QLatin1String("Dependencies")) {
+ info.dependencies = childNodeE.text().split(QInstaller::commaRegExp(),
+ QString::SkipEmptyParts);
+ } else if (childNodeE.tagName() == QLatin1String("ForcedInstallation"))
info.forcedInstallation = childNodeE.text().toLower() == QLatin1String( "true" ) ? true : false;
else if (childNodeE.tagName() == QLatin1String("LastUpdateDate"))
info.lastUpdateDate = QDate::fromString(childNodeE.text(), Qt::ISODate);
diff --git a/src/libs/kdtools/kdupdaterupdatefinder.cpp b/src/libs/kdtools/kdupdaterupdatefinder.cpp
index caa66982e..0262dfc50 100644
--- a/src/libs/kdtools/kdupdaterupdatefinder.cpp
+++ b/src/libs/kdtools/kdupdaterupdatefinder.cpp
@@ -29,6 +29,8 @@
#include "kdupdaterfiledownloaderfactory.h"
#include "kdupdaterupdatesinfo_p.h"
+#include "globals.h"
+
#include <QCoreApplication>
#include <QDebug>
@@ -471,7 +473,7 @@ QList<UpdateInfo> UpdateFinder::Private::applicableUpdates(UpdatesInfo *updatesI
appName = appName.replace(QLatin1String( " ," ), QLatin1String( "," ));
// Catch hold of app names contained updatesInfo->applicationName()
- QStringList apps = appName.split(scCommaRegExp, QString::SkipEmptyParts);
+ QStringList apps = appName.split(QInstaller::commaRegExp(), QString::SkipEmptyParts);
appNameIndex = apps.indexOf(this->application->applicationName());
// If the application appName isn't one of the app names, then
diff --git a/src/libs/kdtools/kdupdaterupdateoperation.cpp b/src/libs/kdtools/kdupdaterupdateoperation.cpp
index 40d2e5ada..6f09bc825 100644
--- a/src/libs/kdtools/kdupdaterupdateoperation.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperation.cpp
@@ -38,7 +38,7 @@
update operations. Concrete implementations of this class must perform a single update
operation like copy, move, delete etc.
- \note Two seperate threads cannot be using a single instance of KDUpdater::UpdateOperation
+ \note Two separate threads cannot be using a single instance of KDUpdater::UpdateOperation
at the same time.
*/
diff --git a/src/libs/kdtools/kdupdaterupdateoperations.cpp b/src/libs/kdtools/kdupdaterupdateoperations.cpp
index 8270bba03..51fcaf7b1 100644
--- a/src/libs/kdtools/kdupdaterupdateoperations.cpp
+++ b/src/libs/kdtools/kdupdaterupdateoperations.cpp
@@ -886,7 +886,7 @@ bool ExecuteOperation::performOperation()
0, 0, 0, STARTF_USESHOWWINDOW, SW_HIDE, 0, 0, 0, 0, 0
};
success = CreateProcess(0, (wchar_t*)arguments.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ 0, 0, false, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
0,
&startupInfo, &pinfo);
diff --git a/src/libs/kdtools/kdupdaterupdatesinfo.cpp b/src/libs/kdtools/kdupdaterupdatesinfo.cpp
index b0cc8608b..fc4a7a2ce 100644
--- a/src/libs/kdtools/kdupdaterupdatesinfo.cpp
+++ b/src/libs/kdtools/kdupdaterupdatesinfo.cpp
@@ -22,47 +22,29 @@
#include "kdupdaterupdatesinfo_p.h"
-#include <QCoreApplication>
-#include <QtXml/QDomDocument>
-#include <QtXml/QDomElement>
#include <QFile>
-#include <QSharedData>
#include <QLocale>
+#include <QUrl>
using namespace KDUpdater;
-//
-// UpdatesInfo::UpdatesInfoData
-//
-struct UpdatesInfo::UpdatesInfoData : public QSharedData
+UpdatesInfoData::UpdatesInfoData()
+ : error(UpdatesInfo::NotYetReadError)
+ , compatLevel(-1)
{
- Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
-
-public:
- UpdatesInfoData() : error(UpdatesInfo::NotYetReadError), compatLevel(-1) { }
-
- QString errorMessage;
- UpdatesInfo::Error error;
- QString updateXmlFile;
- QString applicationName;
- QString applicationVersion;
- int compatLevel;
- QList<UpdateInfo> updateInfoList;
-
- void parseFile(const QString &updateXmlFile);
- bool parsePackageUpdateElement(const QDomElement &updateE);
- bool parseCompatUpdateElement(const QDomElement &updateE);
+}
- void setInvalidContentError(const QString &detail);
-};
+UpdatesInfoData::~UpdatesInfoData()
+{
+}
-void UpdatesInfo::UpdatesInfoData::setInvalidContentError(const QString &detail)
+void UpdatesInfoData::setInvalidContentError(const QString &detail)
{
error = UpdatesInfo::InvalidContentError;
errorMessage = tr("Updates.xml contains invalid content: %1").arg(detail);
}
-void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
+void UpdatesInfoData::parseFile(const QString &updateXmlFile)
{
QFile file(updateXmlFile);
if (!file.open(QFile::ReadOnly)) {
@@ -133,7 +115,7 @@ void UpdatesInfo::UpdatesInfoData::parseFile(const QString &updateXmlFile)
errorMessage.clear();
}
-bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
+bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
{
if (updateE.isNull())
return false;
@@ -210,7 +192,7 @@ bool UpdatesInfo::UpdatesInfoData::parsePackageUpdateElement(const QDomElement &
return true;
}
-bool UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement &updateE)
+bool UpdatesInfoData::parseCompatUpdateElement(const QDomElement &updateE)
{
if (updateE.isNull())
return false;
@@ -260,7 +242,7 @@ bool UpdatesInfo::UpdatesInfoData::parseCompatUpdateElement(const QDomElement &u
// UpdatesInfo
//
UpdatesInfo::UpdatesInfo()
- : d(new UpdatesInfo::UpdatesInfoData)
+ : d(new UpdatesInfoData)
{
}
diff --git a/src/libs/kdtools/kdupdaterupdatesinfo_p.h b/src/libs/kdtools/kdupdaterupdatesinfo_p.h
index 926133eb1..a1851ddf7 100644
--- a/src/libs/kdtools/kdupdaterupdatesinfo_p.h
+++ b/src/libs/kdtools/kdupdaterupdatesinfo_p.h
@@ -24,22 +24,19 @@
#define KD_UPDATER_UPDATE_INFO_H
#include "kdupdater.h"
+#include "kdupdaterupdatesinfodata_p.h"
-#include <QSharedDataPointer>
-#include <QString>
-#include <QDate>
-#include <QList>
-#include <QStringList>
-#include <QUrl>
#include <QHash>
+#include <QSharedData>
+#include <QString>
#include <QVariant>
-// Classes and structures in this header file are for internal use only.
// They are not a part of the public API
+// Classes and structures in this header file are for internal use only but still exported for auto tests.
namespace KDUpdater {
-struct UpdateFileInfo
+struct KDTOOLS_EXPORT UpdateFileInfo
{
UpdateFileInfo()
: compressedSize(0),
@@ -52,14 +49,14 @@ struct UpdateFileInfo
quint64 uncompressedSize;
};
-struct UpdateInfo
+struct KDTOOLS_EXPORT UpdateInfo
{
int type;
QHash<QString, QVariant> data;
QList<UpdateFileInfo> updateFiles;
};
-class UpdatesInfo
+class KDTOOLS_EXPORT UpdatesInfo
{
public:
enum Error
@@ -90,7 +87,6 @@ public:
QList<UpdateInfo> updatesInfo(int type = AllUpdate, int compatLevel = -1) const;
private:
- struct UpdatesInfoData;
QSharedDataPointer<UpdatesInfoData> d;
};
diff --git a/src/libs/kdtools/kdupdaterupdatesinfodata_p.h b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h
new file mode 100644
index 000000000..4b398ee91
--- /dev/null
+++ b/src/libs/kdtools/kdupdaterupdatesinfodata_p.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+** Copyright (C) 2001-2010 Klaralvdalens Datakonsult AB. All rights reserved.
+**
+** This file is part of the KD Tools library.
+**
+** Licensees holding valid commercial KD Tools licenses may use this file in
+** accordance with the KD Tools Commercial License Agreement provided with
+** the Software.
+**
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU Lesser General Public License version 2 and version 3 as published by the
+** Free Software Foundation and appearing in the file LICENSE.LGPL included.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** Contact info@kdab.com if any conditions of this licensing are not
+** clear to you.
+**
+**********************************************************************/
+
+#ifndef KD_UPDATER_UPDATE_INFO_DATA_H
+#define KD_UPDATER_UPDATE_INFO_DATA_H
+
+#include <QCoreApplication>
+#include <QDomElement>
+#include <QSharedData>
+
+namespace KDUpdater {
+
+struct UpdateInfo;
+
+struct UpdatesInfoData : public QSharedData
+{
+ Q_DECLARE_TR_FUNCTIONS(KDUpdater::UpdatesInfoData)
+
+public:
+ UpdatesInfoData();
+ ~UpdatesInfoData();
+
+ int error;
+ QString errorMessage;
+ QString updateXmlFile;
+ QString applicationName;
+ QString applicationVersion;
+ int compatLevel;
+ QList<UpdateInfo> updateInfoList;
+
+ void parseFile(const QString &updateXmlFile);
+ bool parsePackageUpdateElement(const QDomElement &updateE);
+ bool parseCompatUpdateElement(const QDomElement &updateE);
+
+ void setInvalidContentError(const QString &detail);
+};
+
+} // namespace KDUpdater
+
+#endif // KD_UPDATER_UPDATE_INFO_DATA_H