diff options
| author | Peter Penz <[email protected]> | 2007-06-02 17:28:59 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2007-06-02 17:28:59 +0000 |
| commit | e78615f172a2b9f549da6eef2b343a472d42f45f (patch) | |
| tree | 5fe9ce5bec06055b849f0452f6db6265ef91d3f1 /src/dolphiniconsview.cpp | |
| parent | f7a5c62746b91a1e96387c697605544e7df2ffb2 (diff) | |
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
Diffstat (limited to 'src/dolphiniconsview.cpp')
| -rw-r--r-- | src/dolphiniconsview.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
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 <QAbstractProxyModel> #include <QApplication> +#include <QPainter> #include <QPoint> 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) |
