diff --git a/src/package.h b/src/package.h --- a/src/package.h +++ b/src/package.h @@ -309,6 +309,27 @@ */ qint64 availableInstalledSize() const; +/** + * Returns the amount of hard drive space that this package takes up + * when installed. + * If the package is installed, then it is the size of the currently + * installed version. Otherwise, it is the size of the candidate + * version. + * This is human-unreadable, so KDE applications may wish to run this + * through the KFormat().formatByteSize() function to get a + * localized, human-readable number. + * + * Returns -1 on error. + * + * @return The installed size of the package + * + * @see currentInstalledSize() + * @see availableInstalledSize() + * + * @since 3.1 + */ + qint64 installedSize() const; + /** * Returns the download size of the package archive in bytes. * This is human-unreadable, so KDE applications may wish to run this diff --git a/src/package.cpp b/src/package.cpp --- a/src/package.cpp +++ b/src/package.cpp @@ -710,6 +710,17 @@ return qint64(State.CandidateVerIter(*d->backend->cache()->depCache())->InstalledSize); } +qint64 Package::installedSize() const +{ + const pkgCache::VerIterator &ver = d->packageIter.CurrentVer(); + + if (!ver.end()) { + return qint64(ver->InstalledSize); + } + + return availableInstalledSize(); +} + qint64 Package::downloadSize() const { pkgDepCache::StateCache &State = (*d->backend->cache()->depCache())[d->packageIter];