diff options
| author | Peter Penz <[email protected]> | 2008-11-03 08:20:41 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-11-03 08:20:41 +0000 |
| commit | 98139616ac65bb0b96352da03d2c106bd9c8f8bb (patch) | |
| tree | d91974a27087cf63818c2439aa79613a10b71841 /src/dolphinview.cpp | |
| parent | b08ed55218cce6609ac4296b0507864833140f05 (diff) | |
* Show the total size of files in the statusbar (thanks to Bram Schoenmakers for the patch).
* Changed the format of the string to be consistent with the format used when doing a selection. Maybe it would be useful adjusting KIO::itemsSummaryString() instead using a custom output format. Currently KIO::itemsSummaryString() shows "20 Items (5 Files, 15 Folders) - (200 KiB Total)", which is quite confusing IMO, as the total size is only counted for the files. Dolphin currently shows: "15 Folders, 5 Files (200 KiB)"
BUG: 161462
svn path=/trunk/KDE/kdebase/apps/; revision=879405
Diffstat (limited to 'src/dolphinview.cpp')
| -rw-r--r-- | src/dolphinview.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 404000cf4..f381bf073 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -487,32 +487,36 @@ void DolphinView::setNameFilter(const QString& nameFilter) } } -void DolphinView::calculateItemCount(int& fileCount, int& folderCount) const +void DolphinView::calculateItemCount(int& fileCount, + int& folderCount, + KIO::filesize_t& totalFileSize) const { foreach (const KFileItem& item, m_dirLister->items()) { if (item.isDir()) { ++folderCount; } else { ++fileCount; + totalFileSize += item.size(); } } } QString DolphinView::statusBarText() const -{ +{ + QString text; + int folderCount = 0; + int fileCount = 0; + KIO::filesize_t totalFileSize = 0; + if (hasSelection()) { // give a summary of the status of the selected files - QString text; const KFileItemList list = selectedItems(); if (list.isEmpty()) { // when an item is triggered, it is temporary selected but selectedItems() // will return an empty list - return QString(); + return text; } - int fileCount = 0; - int folderCount = 0; - KIO::filesize_t byteSize = 0; KFileItemList::const_iterator it = list.begin(); const KFileItemList::const_iterator end = list.end(); while (it != end) { @@ -521,33 +525,31 @@ QString DolphinView::statusBarText() const ++folderCount; } else { ++fileCount; - byteSize += item.size(); + totalFileSize += item.size(); } ++it; } - - if (folderCount > 0) { - text = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount); - if (fileCount > 0) { - text += ", "; - } - } - + } else { + calculateItemCount(fileCount, folderCount, totalFileSize); + } + + if (folderCount > 0) { + text = hasSelection() ? + i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount) : + i18ncp("@info:status", "1 Folder", "%1 Folders", folderCount); if (fileCount > 0) { - const QString sizeText(KIO::convertSize(byteSize)); - text += i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected (%2)", fileCount, sizeText); + text += i18nc("@info:status separator between 2 status infos", ", "); } - return text; - } else { - // Give a summary of the status of the current folder. - int folderCount = 0; - int fileCount = 0; - calculateItemCount(fileCount, folderCount); - return KIO::itemsSummaryString(fileCount + folderCount, - fileCount, - folderCount, - 0, false); } + + if (fileCount > 0) { + const QString sizeText = KIO::convertSize(totalFileSize); + text += hasSelection() ? + i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected (%2)", fileCount, sizeText) : + i18ncp("@info:status", "1 File (%2)", "%1 Files (%2)", fileCount, sizeText); + } + + return text; } void DolphinView::setUrl(const KUrl& url) |
