]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
New and powerful KListView. Still pending class renaming. There are two
[dolphin.git] / src / dolphiniconsview.cpp
index a4d7fe454584341905b6553cd84005ffdec675e1..cf5be61ef5d9042c3348a3fd2c3085554e8c7102 100644 (file)
 
 #include "dolphin_iconsmodesettings.h"
 
-#include <kdirmodel.h>
-#include <kfileitem.h>
-#include <kfileitemdelegate.h>
-
 #include <QAbstractProxyModel>
 #include <QApplication>
 #include <QPainter>
@@ -42,7 +38,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     Q_ASSERT(controller != 0);
     setViewMode(QListView::IconMode);
     setResizeMode(QListView::Adjust);
-
+    setSpacing(10);
     setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
 
@@ -110,6 +106,7 @@ void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 
 void DolphinIconsView::mousePressEvent(QMouseEvent* event)
 {
+    m_controller->triggerActivation();
     if (!indexAt(event->pos()).isValid()) {
         const Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers();
         if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
@@ -120,12 +117,6 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event)
     KListView::mousePressEvent(event);
 }
 
-void DolphinIconsView::mouseReleaseEvent(QMouseEvent* event)
-{
-    KListView::mouseReleaseEvent(event);
-    m_controller->triggerActivation();
-}
-
 void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
 {
     if (event->mimeData()->hasUrls()) {
@@ -134,6 +125,15 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
     m_dragging = true;
 }
 
+void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
+{
+    KListView::dragLeaveEvent(event);
+
+    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
+    m_dragging = false;
+    setDirtyRegion(m_dropRect);
+}
+
 void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
 {
     KListView::dragMoveEvent(event);
@@ -162,16 +162,10 @@ void DolphinIconsView::paintEvent(QPaintEvent* event)
 {
     KListView::paintEvent(event);
 
+    // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     if (m_dragging) {
-        // TODO: remove this code when the issue #160611 is solved in Qt 4.4
-        QPainter painter(viewport());
-        painter.save();
-        QBrush brush(m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight));
-        QColor color = brush.color();
-        color.setAlpha(64);
-        brush.setColor(color);
-        painter.fillRect(m_dropRect, brush);
-        painter.restore();
+        const QBrush& brush = m_viewOptions.palette.brush(QPalette::Normal, QPalette::Highlight);
+        DolphinController::drawHoverIndication(viewport(), m_dropRect, brush);
     }
 }