]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincolumnwidget.cpp
there's no need having 2-liners inside their own method when this method is only...
[dolphin.git] / src / dolphincolumnwidget.cpp
index c212e6ad82ec2778733739bc62ca7dfa1a264f4f..1a7f712f38e2a3681f81fd941eab1239c4409973 100644 (file)
@@ -26,8 +26,8 @@
 #include "dolphinmodel.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphinsettings.h"
-
 #include "dolphin_columnmodesettings.h"
+#include "draganddrophelper.h"
 
 #include <kcolorutils.h>
 #include <kcolorscheme.h>
@@ -197,6 +197,11 @@ void DolphinColumnWidget::setNameFilter(const QString& nameFilter)
     m_proxyModel->setFilterRegExp(nameFilter);
 }
 
+void DolphinColumnWidget::startDrag(Qt::DropActions supportedActions)
+{
+    DragAndDropHelper::startDrag(this, supportedActions);
+}
+
 void DolphinColumnWidget::dragEnterEvent(QDragEnterEvent* event)
 {
     if (event->mimeData()->hasUrls()) {
@@ -222,7 +227,11 @@ void DolphinColumnWidget::dragMoveEvent(QDragMoveEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
     setDirtyRegion(m_dropRect);
-    m_dropRect = visualRect(index);
+    if (itemForIndex(index).isDir()) {
+        m_dropRect = visualRect(index);
+    } else {
+        m_dropRect.setSize(QSize()); // set as invalid
+    }
     setDirtyRegion(m_dropRect);
 }
 
@@ -231,14 +240,11 @@ void DolphinColumnWidget::dropEvent(QDropEvent* event)
     const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
     if (!urls.isEmpty()) {
         const QModelIndex index = indexAt(event->pos());
-        if (index.isValid()) {
-            const KFileItem item = itemForIndex(index);
-            m_view->m_controller->indicateDroppedUrls(urls,
-                                                      url(),
-                                                      item,
-                                                      event->source());
-            event->acceptProposedAction();
-        }
+        const KFileItem item = itemForIndex(index);
+        m_view->m_controller->indicateDroppedUrls(urls,
+                                                  url(),
+                                                  item);
+        event->acceptProposedAction();
     }
     QListView::dropEvent(event);
     m_dragging = false;
@@ -270,7 +276,7 @@ void DolphinColumnWidget::paintEvent(QPaintEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     if (m_dragging) {
         const QBrush& brush = m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight);
-        DolphinController::drawHoverIndication(viewport(), m_dropRect, brush);
+        DragAndDropHelper::drawHoverIndication(viewport(), m_dropRect, brush);
     }
 }
 
@@ -325,6 +331,7 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
     selModel->select(selected, QItemSelectionModel::Select);
     selModel->select(deselected, QItemSelectionModel::Deselect);
 }
+
 void DolphinColumnWidget::triggerItem(const QModelIndex& index)
 {
     const KFileItem item = itemForIndex(index);