diff options
| author | Rafael Fernández López <[email protected]> | 2007-06-28 23:29:47 +0000 |
|---|---|---|
| committer | Rafael Fernández López <[email protected]> | 2007-06-28 23:29:47 +0000 |
| commit | 71680def7f7c9b3e59d4bc93816b87e6131d35da (patch) | |
| tree | 60f386ba8c936890370cb4cf60800874a67b2fb9 | |
| parent | 123e5008ae1feba49a4a2d2ca5cf3bf97fda30ac (diff) | |
++optimization
svn path=/trunk/KDE/kdebase/apps/; revision=681449
| -rw-r--r-- | src/klistview.cpp | 26 | ||||
| -rw-r--r-- | src/klistview_p.h | 11 |
2 files changed, 35 insertions, 2 deletions
diff --git a/src/klistview.cpp b/src/klistview.cpp index fa78de638..403e984a2 100644 --- a/src/klistview.cpp +++ b/src/klistview.cpp @@ -409,6 +409,30 @@ void KListView::Private::drawDraggedItems(QPainter *painter) } } +void KListView::Private::drawDraggedItems() +{ + int dx; + int dy; + QRect rectToUpdate; + QRect currentRect; + foreach (const QModelIndex &index, listView->selectionModel()->selectedIndexes()) + { + dx = mousePosition.x() - initialPressPosition.x() + listView->horizontalOffset(); + dy = mousePosition.y() - initialPressPosition.y() + listView->verticalOffset(); + + currentRect = visualRect(index); + currentRect.adjust(dx, dy, dx, dy); + + rectToUpdate = rectToUpdate.united(currentRect); + } + + listView->viewport()->update(lastDraggedItemsRect); + + lastDraggedItemsRect = rectToUpdate; + + listView->viewport()->update(rectToUpdate); +} + //============================================================================== @@ -890,6 +914,8 @@ void KListView::dragMoveEvent(QDragMoveEvent *event) } d->dragLeftViewport = false; + + d->drawDraggedItems(); } void KListView::dragLeaveEvent(QDragLeaveEvent *event) diff --git a/src/klistview_p.h b/src/klistview_p.h index 2980e98d6..11c0c3a6e 100644 --- a/src/klistview_p.h +++ b/src/klistview_p.h @@ -99,10 +99,16 @@ public: void updateScrollbars(); /** - * This method will draw dragged items + * This method will draw dragged items in the painting operation */ void drawDraggedItems(QPainter *painter); + /** + * This method will determine which rect needs to be updated because of a + * dragging operation + */ + void drawDraggedItems(); + // Attributes @@ -121,6 +127,7 @@ public: bool isDragging; bool dragLeftViewport; QModelIndex hovered; + QString hoveredCategory; QPoint initialPressPosition; QPoint mousePosition; QItemSelection lastSelection; @@ -135,7 +142,7 @@ public: QHash<QString, QRect> categoriesPosition; QStringList categories; QModelIndexList intersectedIndexes; - QString hoveredCategory; + QRect lastDraggedItemsRect; // Attributes for speed reasons KSortFilterProxyModel *proxyModel; |
