┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-10-05 18:11:46 +0000
committerPeter Penz <[email protected]>2008-10-05 18:11:46 +0000
commit224f471a9f04605f15f807fdb5d35f46d104de7f (patch)
tree67bc75888d3cc52a81e7cdd5dffd194adbd40770 /src/dolphinview.cpp
parent3b8df5665049f877863b963137c51350ae88ebb7 (diff)
update the statusbar and provide a progress information within the Dolphin KPart, so that Konqueror shows the same information as Dolphin (thanks to Simon St James for the patch!)
CCMAIL: [email protected] svn path=/trunk/KDE/kdebase/apps/; revision=868210
Diffstat (limited to 'src/dolphinview.cpp')
-rw-r--r--src/dolphinview.cpp56
1 files changed, 54 insertions, 2 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index b3be62252..4e8b565bf 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -481,9 +481,9 @@ void DolphinView::setNameFilter(const QString& nameFilter)
}
}
-void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
+void DolphinView::calculateItemCount(int& fileCount, int& folderCount) const
{
- foreach (const KFileItem &item, m_dirLister->items()) {
+ foreach (const KFileItem& item, m_dirLister->items()) {
if (item.isDir()) {
++folderCount;
} else {
@@ -492,6 +492,58 @@ void DolphinView::calculateItemCount(int& fileCount, int& folderCount)
}
}
+QString DolphinView::statusBarText() const
+{
+ 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();
+ }
+
+ 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) {
+ const KFileItem& item = *it;
+ if (item.isDir()) {
+ ++folderCount;
+ } else {
+ ++fileCount;
+ byteSize += item.size();
+ }
+ ++it;
+ }
+
+ if (folderCount > 0) {
+ text = i18ncp("@info:status", "1 Folder selected", "%1 Folders selected", folderCount);
+ if (fileCount > 0) {
+ text += ", ";
+ }
+ }
+
+ if (fileCount > 0) {
+ const QString sizeText(KIO::convertSize(byteSize));
+ text += i18ncp("@info:status", "1 File selected (%2)", "%1 Files selected (%2)", fileCount, sizeText);
+ }
+ 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);
+ }
+}
+
void DolphinView::setUrl(const KUrl& url)
{
// remember current item candidate (see restoreCurrentItem())