X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/10f131fff826036c8299f7547cb4f4323dac5c36..862ceee323ad3b474ce9de11eefbddd99c528fac:/src/dolphiniconsview.cpp diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 3f2e978c3..d21ffba32 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -25,17 +25,15 @@ #include "dolphin_iconsmodesettings.h" -#include -#include -#include - #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); @@ -108,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)) { @@ -118,17 +117,32 @@ 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()) { event->acceptProposedAction(); } + 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); + + // 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)