X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/040bdcea237e2576aad744bc4e7b5cadedcc98dc..971d65338f90f8baa020bb161da4e1fa0e5b0883:/src/dolphinview.cpp diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index aec798d31..9eadcecb2 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include @@ -64,6 +66,15 @@ #include "viewproperties.h" #include "zoomlevelinfo.h" +/** + * Helper function for sorting items with qSort() in + * DolphinView::renameSelectedItems(). + */ +bool lessThan(const KFileItem& item1, const KFileItem& item2) +{ + return KStringHandler::naturalCompare(item1.name(), item2.name()) < 0; +} + DolphinView::DolphinView(QWidget* parent, const KUrl& url, KDirLister* dirLister, @@ -534,16 +545,25 @@ QString DolphinView::statusBarText() const ++it; } - 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)); + 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", "%1 selected", name) : + i18nc("@info:status", "%1 selected (%2)", + name, KIO::convertSize(totalFileSize)); } else { - Q_ASSERT(folderCount > 0); - text = foldersText; + // 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); @@ -585,7 +605,7 @@ void DolphinView::changeSelection(const KFileItemList& selection) void DolphinView::renameSelectedItems() { - const KFileItemList items = selectedItems(); + KFileItemList items = selectedItems(); const int itemCount = items.count(); if (itemCount < 1) { return; @@ -606,10 +626,14 @@ void DolphinView::renameSelectedItems() // TODO: check how this can be integrated into KIO::FileUndoManager/KonqOperations // as one operation instead of n rename operations like it is done now... Q_ASSERT(newName.contains('#')); + + // currently the items are sorted by the selection order, resort + // them by the file name + qSort(items.begin(), items.end(), lessThan); // iterate through all selected items and rename them... int index = 1; - foreach (const KFileItem &item, items) { + foreach (const KFileItem& item, items) { const KUrl& oldUrl = item.url(); QString number; number.setNum(index++);