]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
The paste operation should ignore the current selection to behave similar as Konquero...
[dolphin.git] / src / dolphinview.cpp
index 4800b9e9ab620e18eabbc3a029df52aa3768a5c2..d905e5cabf0dd207f0b0584a200521fc7254e273 100644 (file)
@@ -31,6 +31,7 @@
 #include <kactioncollection.h>
 #include <kcolorscheme.h>
 #include <kdirlister.h>
+#include <kfileitemdelegate.h>
 #include <kiconeffect.h>
 #include <klocale.h>
 #include <kio/deletejob.h>
@@ -49,7 +50,6 @@
 #include "dolphinmodel.h"
 #include "dolphincolumnview.h"
 #include "dolphincontroller.h"
-#include "dolphinfileitemdelegate.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphindetailsview.h"
 #include "dolphiniconsview.h"
@@ -866,16 +866,12 @@ void DolphinView::emitContentsMoved()
 
 void DolphinView::showHoverInformation(const KFileItem& item)
 {
-    if (!hasSelection()) {
-        emit requestItemInfo(item);
-    }
+    emit requestItemInfo(item);
 }
 
 void DolphinView::clearHoverInformation()
 {
-    if (m_active) {
-        emit requestItemInfo(KFileItem());
-    }
+    emit requestItemInfo(KFileItem());
 }
 
 void DolphinView::createView()
@@ -909,7 +905,7 @@ void DolphinView::createView()
 
     m_controller->setItemView(view);
 
-    m_fileItemDelegate = new DolphinFileItemDelegate(view);
+    m_fileItemDelegate = new KFileItemDelegate(view);
     view->setItemDelegate(m_fileItemDelegate);
 
     view->setModel(m_proxyModel);
@@ -1021,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;
@@ -1101,41 +1102,12 @@ void DolphinView::paste()
     const QMimeData* mimeData = clipboard->mimeData();
 
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
-
-    // 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();
-    if (selectedUrls.count() == 1) {
-        const KFileItem fileItem(S_IFDIR,
-                                 KFileItem::Unknown,
-                                 selectedUrls.first(),
-                                 true);
-        if (fileItem.isDir()) {
-            // 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;
-                }
-            }
-        }
-    }
-
     if (KonqMimeData::decodeIsCutSelection(mimeData)) {
-        KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, destUrl);
+        KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url());
         emit doingOperation(KonqFileUndoManager::MOVE);
         clipboard->clear();
     } else {
-        KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, destUrl);
+        KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url());
         emit doingOperation(KonqFileUndoManager::COPY);
     }
 }
@@ -1162,19 +1134,6 @@ QPair<bool, QString> DolphinView::pasteInfo() const
         ret.second = i18nc("@action:inmenu", "Paste");
     }
 
-    if (ret.first) {
-        const KFileItemList items = selectedItems();
-        const uint count = items.count();
-        if (count > 1) {
-            // pasting should not be allowed when more than one file
-            // is selected
-            ret.first = false;
-        } else if (count == 1) {
-            // Only one file is selected. Pasting is only allowed if this
-            // file is a directory.
-            ret.first = items.first().isDir();
-        }
-    }
     return ret;
 }