* 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
-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;
{
foreach (const KFileItem& item, m_dirLister->items()) {
if (item.isDir()) {
++folderCount;
} else {
++fileCount;
+ totalFileSize += item.size();
}
}
}
QString DolphinView::statusBarText() const
}
}
}
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
if (hasSelection()) {
// give a summary of the status of the selected files
const KFileItemList list = selectedItems();
if (list.isEmpty()) {
// when an item is triggered, it is temporary selected but selectedItems()
// will return an empty list
const KFileItemList list = selectedItems();
if (list.isEmpty()) {
// when an item is triggered, it is temporary selected but selectedItems()
// will return an empty list
- 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) {
KFileItemList::const_iterator it = list.begin();
const KFileItemList::const_iterator end = list.end();
while (it != end) {
++folderCount;
} else {
++fileCount;
++folderCount;
} else {
++fileCount;
- byteSize += item.size();
+ totalFileSize += item.size();
-
- 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);
- 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)
}
void DolphinView::setUrl(const KUrl& url)
/**
* Calculates the number of currently shown files into
* \a fileCount and the number of folders into \a folderCount.
/**
* Calculates the number of currently shown files into
* \a fileCount and the number of folders into \a folderCount.
+ * The size of all files is written into \a totalFileSize.
* It is recommend using this method instead of asking the
* directory lister or the model directly, as it takes
* filtering and hierarchical previews into account.
*/
* It is recommend using this method instead of asking the
* directory lister or the model directly, as it takes
* filtering and hierarchical previews into account.
*/
- void calculateItemCount(int& fileCount, int& folderCount) const;
+ void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
/**
* Returns a textual representation of the state of the current
/**
* Returns a textual representation of the state of the current