]> cloud.milkyroute.net Git - dolphin.git/commitdiff
When renaming, use the actual name of the item (from the KFileItem) in the dialog.
authorJeff Mitchell <mitchell@kde.org>
Tue, 14 Aug 2007 16:46:06 +0000 (16:46 +0000)
committerJeff Mitchell <mitchell@kde.org>
Tue, 14 Aug 2007 16:46:06 +0000 (16:46 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=700054

src/dolphinviewcontainer.cpp
src/renamedialog.cpp
src/renamedialog.h
src/treeviewcontextmenu.cpp

index 32d5a407faeb3d2dcea7b08a645a3a1a610f619c..59c2e5e3cd87c6477ddacc1044ff07f58c6ec395 100644 (file)
@@ -190,10 +190,11 @@ void DolphinViewContainer::renameSelectedItems()
 {
     DolphinViewContainer* view = m_mainWindow->activeViewContainer();
     const KUrl::List urls = m_view->selectedUrls();
+    const QList<KFileItem> items = m_view->selectedItems();
     if (urls.count() > 1) {
         // More than one item has been selected for renaming. Open
         // a rename dialog and rename all items afterwards.
-        RenameDialog dialog(urls);
+        RenameDialog dialog(urls, items);
         if (dialog.exec() == QDialog::Rejected) {
             return;
         }
@@ -238,7 +239,7 @@ void DolphinViewContainer::renameSelectedItems()
         // TODO: Think about using KFileItemDelegate as soon as it supports editing.
         // Currently the RenameDialog is used, but I'm not sure whether inline renaming
         // is a benefit for the user at all -> let's wait for some input first...
-        RenameDialog dialog(urls);
+        RenameDialog dialog(urls, items);
         if (dialog.exec() == QDialog::Rejected) {
             return;
         }
index d65330cddad1231db499a2e723f4a375cbabcf7c..6f08f175ec55e3b70903884a88bf35f075f67831 100644 (file)
 
 #include "renamedialog.h"
 
+#include <kfileitem.h>
 #include <klineedit.h>
 #include <klocale.h>
 
 #include <QtGui/QLabel>
 #include <QtGui/QBoxLayout>
 
-RenameDialog::RenameDialog(const KUrl::List& items) :
+RenameDialog::RenameDialog(const KUrl::List& urls, const QList<KFileItem>& items) :
     KDialog(),
     m_renameOneItem(false)
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
 
-    const int itemCount = items.count();
+    const int itemCount = urls.count();
     Q_ASSERT(itemCount >= 1);
     m_renameOneItem = (itemCount == 1);
 
@@ -52,8 +53,7 @@ RenameDialog::RenameDialog(const KUrl::List& items) :
 
     QLabel* editLabel = 0;
     if (m_renameOneItem) {
-        const KUrl& url = items.first();
-        m_newName = url.fileName();
+        m_newName = items.first().name();
         editLabel = new QLabel(i18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
                                page);
     } else {
@@ -65,13 +65,13 @@ RenameDialog::RenameDialog(const KUrl::List& items) :
     }
 
     m_lineEdit = new KLineEdit(page);
-    QString extension = extensionString(items[0].prettyUrl());
+    QString extension = extensionString(urls[0].prettyUrl());
     if (extension.length() > 0) {
         // The first item seems to have a extension (e. g. '.jpg' or '.txt'). Now
-        // check whether all other items have the same extension. If this is the
+        // check whether all other URLs have the same extension. If this is the
         // case, add this extension to the name suggestion.
         for (int i = 1; i < itemCount; ++i) {
-            if (!items[i].prettyUrl().contains(extension)) {
+            if (!urls[i].prettyUrl().contains(extension)) {
                 // at least one item does not have the same extension
                 extension.truncate(0);
                 break;
index d6adb6f95ae15161d7066f1c6a505691aea34946..3aa2ff72ddd85a2ad57673a487d35eb576c6879b 100644 (file)
@@ -25,6 +25,7 @@
 #include <kurl.h>
 
 
+class KFileItem;
 class KLineEdit;
 
 /**
@@ -51,7 +52,7 @@ class LIBDOLPHINPRIVATE_EXPORT RenameDialog : public KDialog
     Q_OBJECT
 
 public:
-    explicit RenameDialog(const KUrl::List& items);
+    explicit RenameDialog(const KUrl::List& urls, const QList<KFileItem>& items);
     virtual ~RenameDialog();
 
     /**
index f4469776bb0ef30ffd2689e616689edcd78e0b06..1e6583e55bea53620939ebfe57c0e59fa73e4fbb 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "treeviewcontextmenu.h"
 
+#include <kfileitem.h>
 #include <kiconloader.h>
 #include <kio/deletejob.h>
 #include <kmenu.h>
@@ -140,7 +141,9 @@ void TreeViewContextMenu::paste()
 void TreeViewContextMenu::rename()
 {
     const KUrl& oldUrl = m_fileInfo.url();
-    RenameDialog dialog(oldUrl);
+    QList<KFileItem> items;
+    items.append( m_fileInfo );
+    RenameDialog dialog(oldUrl, items);
     if (dialog.exec() == QDialog::Accepted) {
         const QString& newName = dialog.newName();
         if (!newName.isEmpty()) {