diff options
author | Alexander Lenhardt <alexander.lenhardt@nokia.com> | 2012-01-05 15:18:16 +0100 |
---|---|---|
committer | Alexander Lenhardt <alexander.lenhardt@nokia.com> | 2012-01-05 17:25:25 +0100 |
commit | 3fee266f5ce102f26a5a20de9946bc2e0c947497 (patch) | |
tree | df62b824c1af7e5558fb1f507399b0e9e907e490 /installerbuilder | |
parent | a9797dbc73d0cd61c550f9ccabde8ed1a34ed956 (diff) |
fixed QTIFW-75
Change-Id: I012819b8e95aa47d08576765eaeffaef01eeaabf
Reviewed-by: Tim Jenssen <tim.jenssen@nokia.com>
Diffstat (limited to 'installerbuilder')
-rw-r--r-- | installerbuilder/libinstaller/component.cpp | 19 | ||||
-rw-r--r-- | installerbuilder/libinstaller/component.h | 1 | ||||
-rw-r--r-- | installerbuilder/libinstaller/componentmodel.cpp | 7 | ||||
-rw-r--r-- | installerbuilder/libinstaller/constants.h | 1 | ||||
-rw-r--r-- | installerbuilder/libinstaller/packagemanagercore.cpp | 4 |
5 files changed, 28 insertions, 4 deletions
diff --git a/installerbuilder/libinstaller/component.cpp b/installerbuilder/libinstaller/component.cpp index 03e1ed335..e64bf24b8 100644 --- a/installerbuilder/libinstaller/component.cpp +++ b/installerbuilder/libinstaller/component.cpp @@ -184,9 +184,25 @@ void Component::loadDataFromPackage(const Package &package) loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash); } +quint64 Component::updateUncompressedSize() +{ + quint64 size = 0; + + if (isSelected()) + size = (quint64)value(scUncompressedSize).toDouble(); + + foreach (Component* comp, d->m_allChildComponents) + size += comp->updateUncompressedSize(); + + setValue(scUncompressedSizeSum, QString::number(size)); + setData(uncompressedSize(), UncompressedSize); + + return size; +} + QString Component::uncompressedSize() const { - double size = value(scUncompressedSize).toDouble(); + double size = value(scUncompressedSizeSum).toDouble(); if (size < 1000.0) return tr("%L1 Bytes").arg(size); size /= 1024.0; @@ -196,6 +212,7 @@ QString Component::uncompressedSize() const if (size < 1000.0) return tr("%L1 MBytes").arg(size, 0, 'f', 2); size /= 1024.0; + return tr("%L1 GBytes").arg(size, 0, 'f', 2); } diff --git a/installerbuilder/libinstaller/component.h b/installerbuilder/libinstaller/component.h index 2e0d7f281..66609ad50 100644 --- a/installerbuilder/libinstaller/component.h +++ b/installerbuilder/libinstaller/component.h @@ -146,6 +146,7 @@ public: QString name() const; QString displayName() const; QString uncompressedSize() const; + quint64 updateUncompressedSize(); QUrl repositoryUrl() const; void setRepositoryUrl(const QUrl &url); diff --git a/installerbuilder/libinstaller/componentmodel.cpp b/installerbuilder/libinstaller/componentmodel.cpp index 7532d3637..89133abab 100644 --- a/installerbuilder/libinstaller/componentmodel.cpp +++ b/installerbuilder/libinstaller/componentmodel.cpp @@ -171,8 +171,12 @@ bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, in component->setData(value, role); emit dataChanged(index, index); - if (role == Qt::CheckStateRole) + if (role == Qt::CheckStateRole) { emit checkStateChanged(index); + foreach (Component* comp, m_rootComponentList) { + comp->updateUncompressedSize(); + } + } return true; } @@ -380,6 +384,7 @@ void ComponentModel::slotModelReset() foreach (const QString &name, m_currentCheckedSet) setData(indexFromComponentName(name), Qt::Checked, Qt::CheckStateRole); + } static Qt::CheckState verifyPartiallyChecked(Component *component) diff --git a/installerbuilder/libinstaller/constants.h b/installerbuilder/libinstaller/constants.h index b5843c03b..99f6d77b5 100644 --- a/installerbuilder/libinstaller/constants.h +++ b/installerbuilder/libinstaller/constants.h @@ -53,6 +53,7 @@ static const QLatin1String scRepositories("Repositories"); static const QLatin1String scCompressedSize("CompressedSize"); static const QLatin1String scInstalledVersion("InstalledVersion"); static const QLatin1String scUncompressedSize("UncompressedSize"); +static const QLatin1String scUncompressedSizeSum("UncompressedSizeSum"); static const QLatin1String scRequiresAdminRights("RequiresAdminRights"); // constants used throughout the components class diff --git a/installerbuilder/libinstaller/packagemanagercore.cpp b/installerbuilder/libinstaller/packagemanagercore.cpp index dd16e199a..5e03e6fc8 100644 --- a/installerbuilder/libinstaller/packagemanagercore.cpp +++ b/installerbuilder/libinstaller/packagemanagercore.cpp @@ -323,8 +323,8 @@ quint64 PackageManagerCore::requiredDiskSpace() const { quint64 result = 0; - foreach (QInstaller::Component *component, orderedComponentsToInstall()) - result += size(component, scUncompressedSize); + foreach (QInstaller::Component *component, rootComponents()) + result += component->updateUncompressedSize(); return result; } |