]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
provide an option to rename files inline
[dolphin.git] / src / dolphinview.cpp
index 0cf740cd56978a97f7a69b8ea51ba38f8dd95ab3..3f8933bd31b1b6f28470957bb3a1a34651312069 100644 (file)
@@ -39,6 +39,7 @@
 #include <kio/previewjob.h>
 #include <kjob.h>
 #include <kmenu.h>
+#include <kmessagebox.h>
 #include <kmimetyperesolver.h>
 #include <konq_operations.h>
 #include <konqmimedata.h>
@@ -865,18 +866,12 @@ void DolphinView::emitContentsMoved()
 
 void DolphinView::showHoverInformation(const KFileItem& item)
 {
-    if (hasSelection() || !m_active) {
-        return;
-    }
-
     emit requestItemInfo(item);
 }
 
 void DolphinView::clearHoverInformation()
 {
-    if (m_active) {
-        emit requestItemInfo(KFileItem());
-    }
+    emit requestItemInfo(KFileItem());
 }
 
 void DolphinView::createView()
@@ -1022,14 +1017,19 @@ void DolphinView::renameSelectedItems()
                 }
             }
         }
+    } else if (DolphinSettings::instance().generalSettings()->renameInline()) {
+        Q_ASSERT(items.count() == 1);
+
+        if (isColumnViewActive()) {
+            m_columnView->editItem(items.first());
+        } else {
+            const QModelIndex dirIndex = m_dolphinModel->indexForItem(items.first());
+            const QModelIndex proxyIndex = m_proxyModel->mapFromSource(dirIndex);
+            itemView()->edit(proxyIndex);
+        }
     } else {
-        // Only one item has been selected for renaming. Use the custom
-        // renaming mechanism from the views.
         Q_ASSERT(items.count() == 1);
 
-        // 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(this, items);
         if (dialog.exec() == QDialog::Rejected) {
             return;
@@ -1103,8 +1103,8 @@ void DolphinView::paste()
 
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
 
-    // per default the pasting is done into the current Url of the view
-    KUrl destUrl(url());
+    // per default the pasting is done into the current URL of the view
+    KUrl destUrl = url();
 
     // check whether the pasting should be done into a selected directory
     const KUrl::List selectedUrls = this->selectedUrls();
@@ -1117,6 +1117,17 @@ void DolphinView::paste()
             // only one item is selected which is a directory, hence paste
             // into this directory
             destUrl = selectedUrls.first();
+            if (sourceUrls.contains(destUrl)) {
+                const QString text = i18nc("@info", "The folder <filename>%1</filename> is pasted into itself. Is this intended?", fileItem.name());
+                int result = KMessageBox::questionYesNo(window(),
+                                                        text,
+                                                        i18nc("@title:window", "Paste into Folder"),
+                                                        KGuiItem(i18nc("@action:button", "Paste"), "dialog-ok"),
+                                                        KGuiItem(i18nc("@action:button", "Cancel"), "dialog-cancel"));
+                if (result == KMessageBox::No) {
+                    return;
+                }
+            }
         }
     }
 
@@ -1139,7 +1150,14 @@ QPair<bool, QString> DolphinView::pasteInfo() const
     KUrl::List urls = KUrl::List::fromMimeData(mimeData);
     if (!urls.isEmpty()) {
         ret.first = true;
-        ret.second = i18ncp("@action:inmenu", "Paste One File", "Paste %1 Files", urls.count());
+        if (urls.count() == 1) {
+            const KFileItem item(KFileItem::Unknown, KFileItem::Unknown, urls.first(), true);
+            ret.second = item.isDir() ? i18nc("@action:inmenu", "Paste One Folder") :
+                                        i18nc("@action:inmenu", "Paste One File");
+
+        } else {
+            ret.second = i18ncp("@action:inmenu", "Paste One Item", "Paste %1 Items", urls.count());
+        }
     } else {
         ret.first = false;
         ret.second = i18nc("@action:inmenu", "Paste");