+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
+ const KFileItemList list = selectedItems();
+ if (list.isEmpty()) {
+ // when an item is triggered, it is temporary selected but selectedItems()
+ // will return an empty list
+ return text;
+ }
+
+ KFileItemList::const_iterator it = list.begin();
+ const KFileItemList::const_iterator end = list.end();
+ while (it != end) {
+ const KFileItem& item = *it;
+ if (item.isDir()) {
+ ++folderCount;
+ } else {
+ ++fileCount;
+ totalFileSize += item.size();
+ }
+ ++it;
+ }
+
+ if (folderCount + fileCount == 1) {
+ // if only one item is selected, show the filename
+ const QString name = list.first().name();
+ text = (folderCount == 1) ? i18nc("@info:status", "<filename>%1</filename> selected", name) :
+ i18nc("@info:status", "<filename>%1</filename> selected (%2)",
+ name, KIO::convertSize(totalFileSize));
+ } else {
+ // at least 2 items are selected
+ const QString foldersText = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
+ const QString filesText = i18ncp("@info:status", "1 File selected", "%1 Files selected", fileCount);
+ if ((folderCount > 0) && (fileCount > 0)) {
+ text = i18nc("@info:status folders, files (size)", "%1, %2 (%3)",
+ foldersText, filesText, KIO::convertSize(totalFileSize));
+ } else if (fileCount > 0) {
+ text = i18nc("@info:status files (size)", "%1 (%2)", filesText, KIO::convertSize(totalFileSize));
+ } else {
+ Q_ASSERT(folderCount > 0);
+ text = foldersText;
+ }
+ }
+ } else {
+ calculateItemCount(fileCount, folderCount, totalFileSize);
+ text = KIO::itemsSummaryString(fileCount + folderCount,
+ fileCount, folderCount,
+ totalFileSize, true);
+ }
+
+ return text;
+}
+