From e78615f172a2b9f549da6eef2b343a472d42f45f Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 2 Jun 2007 17:28:59 +0000 Subject: Provide a hover information when dragging items above other items. TODO: this code can be removed again when issue #160611 is solved in Qt 4.4. svn path=/trunk/KDE/kdebase/apps/; revision=670848 --- src/dolphiniconsview.cpp | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/dolphiniconsview.cpp') diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 3f2e978c3..a4d7fe454 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -31,11 +31,13 @@ #include #include +#include #include DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) : KListView(parent), - m_controller(controller) + m_controller(controller), + m_dragging(false) { Q_ASSERT(controller != 0); setViewMode(QListView::IconMode); @@ -129,6 +131,18 @@ void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event) if (event->mimeData()->hasUrls()) { event->acceptProposedAction(); } + m_dragging = true; +} + +void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event) +{ + KListView::dragMoveEvent(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); + setDirtyRegion(m_dropRect); } void DolphinIconsView::dropEvent(QDropEvent* event) @@ -141,6 +155,24 @@ void DolphinIconsView::dropEvent(QDropEvent* event) event->acceptProposedAction(); } KListView::dropEvent(event); + m_dragging = false; +} + +void DolphinIconsView::paintEvent(QPaintEvent* event) +{ + KListView::paintEvent(event); + + 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(); + } } void DolphinIconsView::slotShowPreviewChanged(bool showPreview) -- cgit v1.3