From: Jeff Mitchell Date: Tue, 14 Aug 2007 16:46:06 +0000 (+0000) Subject: When renaming, use the actual name of the item (from the KFileItem) in the dialog. X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/f8fa4e8df155250fa546288caf9bb89b0044f91b When renaming, use the actual name of the item (from the KFileItem) in the dialog. svn path=/trunk/KDE/kdebase/apps/; revision=700054 --- diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 32d5a407f..59c2e5e3c 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -190,10 +190,11 @@ void DolphinViewContainer::renameSelectedItems() { DolphinViewContainer* view = m_mainWindow->activeViewContainer(); const KUrl::List urls = m_view->selectedUrls(); + const QList 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; } diff --git a/src/renamedialog.cpp b/src/renamedialog.cpp index d65330cdd..6f08f175e 100644 --- a/src/renamedialog.cpp +++ b/src/renamedialog.cpp @@ -19,20 +19,21 @@ #include "renamedialog.h" +#include #include #include #include #include -RenameDialog::RenameDialog(const KUrl::List& items) : +RenameDialog::RenameDialog(const KUrl::List& urls, const QList& 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 %1 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; diff --git a/src/renamedialog.h b/src/renamedialog.h index d6adb6f95..3aa2ff72d 100644 --- a/src/renamedialog.h +++ b/src/renamedialog.h @@ -25,6 +25,7 @@ #include +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& items); virtual ~RenameDialog(); /** diff --git a/src/treeviewcontextmenu.cpp b/src/treeviewcontextmenu.cpp index f4469776b..1e6583e55 100644 --- a/src/treeviewcontextmenu.cpp +++ b/src/treeviewcontextmenu.cpp @@ -20,6 +20,7 @@ #include "treeviewcontextmenu.h" +#include #include #include #include @@ -140,7 +141,9 @@ void TreeViewContextMenu::paste() void TreeViewContextMenu::rename() { const KUrl& oldUrl = m_fileInfo.url(); - RenameDialog dialog(oldUrl); + QList items; + items.append( m_fileInfo ); + RenameDialog dialog(oldUrl, items); if (dialog.exec() == QDialog::Accepted) { const QString& newName = dialog.newName(); if (!newName.isEmpty()) {