]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
Update property when needed.
[dolphin.git] / src / dolphiniconsview.cpp
index d21ffba32752ebfd42b8257a7a5aab67125dcd78..237a319c835e181609db9fb341aa27cf4324879f 100644 (file)
 
 #include "dolphin_iconsmodesettings.h"
 
+#include <kdialog.h>
+
 #include <QAbstractProxyModel>
 #include <QApplication>
 #include <QPainter>
 #include <QPoint>
 
 DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
-    KListView(parent),
+    KCategorizedView(parent),
     m_controller(controller),
     m_dragging(false)
 {
     Q_ASSERT(controller != 0);
     setViewMode(QListView::IconMode);
     setResizeMode(QListView::Adjust);
-
+    setSpacing(KDialog::spacingHint());
     setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
 
@@ -49,8 +51,6 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
         connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
                 controller, SLOT(triggerItem(const QModelIndex&)));
     }
-    connect(this, SIGNAL(activated(const QModelIndex&)),
-            controller, SLOT(triggerItem(const QModelIndex&)));
     connect(this, SIGNAL(entered(const QModelIndex&)),
             controller, SLOT(emitItemEntered(const QModelIndex&)));
     connect(this, SIGNAL(viewportEntered()),
@@ -68,7 +68,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
     Q_ASSERT(settings != 0);
 
-    m_viewOptions = KListView::viewOptions();
+    m_viewOptions = KCategorizedView::viewOptions();
     m_viewOptions.showDecorationSelected = true;
 
     QFont font(settings->fontFamily(), settings->fontSize());
@@ -100,7 +100,7 @@ QStyleOptionViewItem DolphinIconsView::viewOptions() const
 
 void DolphinIconsView::contextMenuEvent(QContextMenuEvent* event)
 {
-    KListView::contextMenuEvent(event);
+    KCategorizedView::contextMenuEvent(event);
     m_controller->triggerContextMenuRequest(event->pos());
 }
 
@@ -114,7 +114,7 @@ void DolphinIconsView::mousePressEvent(QMouseEvent* event)
         }
     }
 
-    KListView::mousePressEvent(event);
+    KCategorizedView::mousePressEvent(event);
 }
 
 void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
@@ -127,7 +127,7 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
 
 void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
 {
-    KListView::dragLeaveEvent(event);
+    KCategorizedView::dragLeaveEvent(event);
 
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     m_dragging = false;
@@ -136,7 +136,7 @@ void DolphinIconsView::dragLeaveEvent(QDragLeaveEvent* event)
 
 void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
 {
-    KListView::dragMoveEvent(event);
+    KCategorizedView::dragMoveEvent(event);
 
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     const QModelIndex index = indexAt(event->pos());
@@ -147,31 +147,27 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
 
 void DolphinIconsView::dropEvent(QDropEvent* event)
 {
-    const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
-    if (!urls.isEmpty()) {
-        m_controller->indicateDroppedUrls(urls,
-                                          indexAt(event->pos()),
-                                          event->source());
-        event->acceptProposedAction();
+    if (!selectionModel()->isSelected(indexAt(event->pos()))) {
+        const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
+        if (!urls.isEmpty()) {
+            m_controller->indicateDroppedUrls(urls,
+                                              indexAt(event->pos()),
+                                              event->source());
+            event->acceptProposedAction();
+        }
     }
-    KListView::dropEvent(event);
+    KCategorizedView::dropEvent(event);
     m_dragging = false;
 }
 
 void DolphinIconsView::paintEvent(QPaintEvent* event)
 {
-    KListView::paintEvent(event);
+    KCategorizedView::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);
     }
 }