]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/panels/folders/folderspanel.cpp
Merge remote-tracking branch 'origin/KDE/4.9'
[dolphin.git] / src / panels / folders / folderspanel.cpp
index 5e8286cdcdea25d242781895cdb3c3fa7a5a9c1a..6e3a7678f6490b8382b7414b8e0bf29dffcb3ba1 100644 (file)
@@ -22,7 +22,9 @@
 #include "dolphin_folderspanelsettings.h"
 #include "dolphin_generalsettings.h"
 #include "treeviewcontextmenu.h"
+#include "foldersitemlistwidget.h"
 
+#include <views/renamedialog.h>
 #include <kitemviews/kitemlistselectionmanager.h>
 #include <kitemviews/kfileitemlistview.h>
 #include <kitemviews/kfileitemlistwidget.h>
@@ -89,8 +91,16 @@ bool FoldersPanel::autoScrolling() const
 
 void FoldersPanel::rename(const KFileItem& item)
 {
-    const int index = m_model->index(item);
-    m_controller->view()->editRole(index, "text");
+    if (GeneralSettings::renameInline()) {
+        const int index = m_model->index(item);
+        m_controller->view()->editRole(index, "text");
+    } else {
+        RenameDialog* dialog = new RenameDialog(this, KFileItemList() << item);
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        dialog->show();
+        dialog->raise();
+        dialog->activateWindow();
+    }
 }
 
 bool FoldersPanel::urlChanged()
@@ -120,6 +130,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
         // This assures that no performance and memory overhead is given when the folders panel is not
         // used at all and stays invisible.
         KFileItemListView* view  = new KFileItemListView();
+        view->setWidgetCreator(new KItemListWidgetCreator<FoldersItemListWidget>());
         view->setSupportsItemExpanding(true);
         // Set the opacity to 0 initially. The opacity will be increased after the loading of the initial tree
         // has been finished in slotLoadingCompleted(). This prevents an unnecessary animation-mess when
@@ -138,6 +149,8 @@ void FoldersPanel::showEvent(QShowEvent* event)
 
         m_controller = new KItemListController(m_model, view, this);
         m_controller->setSelectionBehavior(KItemListController::SingleSelection);
+        m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly);
+        m_controller->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem);
         m_controller->setAutoActivationDelay(750);
         m_controller->setSingleClickActivation(true);
 
@@ -173,7 +186,7 @@ void FoldersPanel::slotItemActivated(int index)
 {
     const KFileItem item = m_model->fileItem(index);
     if (!item.isNull()) {
-        emit changeUrl(item.url(), Qt::LeftButton);
+        emit folderActivated(item.url());
     }
 }
 
@@ -181,7 +194,7 @@ void FoldersPanel::slotItemMiddleClicked(int index)
 {
     const KFileItem item = m_model->fileItem(index);
     if (!item.isNull()) {
-        emit changeUrl(item.url(), Qt::MiddleButton);
+        emit folderMiddleClicked(item.url());
     }
 }
 
@@ -223,7 +236,10 @@ void FoldersPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* eve
                              event->buttons(),
                              event->modifiers());
 
-        DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
+        const QString error = DragAndDropHelper::dropUrls(destItem, destItem.url(), &dropEvent);
+        if (!error.isEmpty()) {
+            emit errorMessage(error);
+        }
     }
 }