diff options
author | kh1 <qt-info@nokia.com> | 2011-04-01 12:07:50 +0200 |
---|---|---|
committer | kh1 <qt-info@nokia.com> | 2011-04-01 12:07:50 +0200 |
commit | c02b582caca6f18a4c0dd870fc407479a46342eb (patch) | |
tree | 1c80a40ff28547d9e633ca9920b547877782b04f /installerbuilder/libinstaller/qinstallercomponent.cpp | |
parent | a6c661f18055a53f9248d777704f2d5de315ea8b (diff) |
Add a method to return the uncompressed size as string.
Diffstat (limited to 'installerbuilder/libinstaller/qinstallercomponent.cpp')
-rw-r--r-- | installerbuilder/libinstaller/qinstallercomponent.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/installerbuilder/libinstaller/qinstallercomponent.cpp b/installerbuilder/libinstaller/qinstallercomponent.cpp index 70c758437..d1eac3694 100644 --- a/installerbuilder/libinstaller/qinstallercomponent.cpp +++ b/installerbuilder/libinstaller/qinstallercomponent.cpp @@ -195,6 +195,21 @@ void Component::loadDataFromUpdate(KDUpdater::Update* update) loadLicenses(QString::fromLatin1("%1/%2/").arg(localTempPath(), name()), licenseHash); } +QString Component::uncompressedSize() const +{ + double size = value(skUncompressedSize).toDouble(); + if (size < 10000.0) + return tr("%L1 Bytes").arg(size); + size /= 1024.0; + if (size < 10000.0) + return tr("%L1 kBytes").arg(size, 0, 'f', 1); + size /= 1024.0; + if (size < 10000.0) + return tr("%L1 MBytes").arg(size, 0, 'f', 1); + size /= 1024.0; + return tr("%L1 GBytes").arg(size, 0, 'f', 1); +} + void Component::updateState(const bool selected) { setValue(QLatin1String("PreviousState"), |