┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinview.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2008-11-14 17:49:30 +0000
committerPeter Penz <[email protected]>2008-11-14 17:49:30 +0000
commit718df1363dc1ecac2d3376d3e288947549aeb42f (patch)
treec0371a560eb802884f5eb4aa2f6a2d2fc0c8b9d4 /src/dolphinview.cpp
parent3cd004e748b02a3f7c17ece6b1679990fc425300 (diff)
when renaming a variable number of items, it is important that the selection order does not define the new sort order -> the sort order with the renamed files should stay similar with the old sort order
svn path=/trunk/KDE/kdebase/apps/; revision=884344
Diffstat (limited to 'src/dolphinview.cpp')
-rw-r--r--src/dolphinview.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp
index 31b9de785..9eadcecb2 100644
--- a/src/dolphinview.cpp
+++ b/src/dolphinview.cpp
@@ -33,6 +33,7 @@
#include <kdirlister.h>
#include <kfilepreviewgenerator.h>
#include <kiconeffect.h>
+#include <kfileitem.h>
#include <klocale.h>
#include <kio/deletejob.h>
#include <kio/netaccess.h>
@@ -44,6 +45,7 @@
#include <konq_fileitemcapabilities.h>
#include <konq_operations.h>
#include <konqmimedata.h>
+#include <kstringhandler.h>
#include <ktoggleaction.h>
#include <kurl.h>
@@ -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,
@@ -594,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;
@@ -615,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++);