From 51bd6cfdfad4d1be706f6dc125762889c19fcc5a Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Fri, 17 Feb 2012 16:00:52 +0100 Subject: Remember the row- and column-information for visible items Up to now KItemListView has not been aware to which column or row an item belongs to. This has been handled internally in KItemListViewLayouter. But for deciding whether a move-animation might result in overlapping items it is mandatory to be aware about the column/row. The current approach to guess a column/row change by comparing the source- and target-rectangle works very well but breaks on some corner-cases when e.g. zooming. Now the layouter allows to access the information. This assures that in the vertical alignment no move-animation is done between rows and the in the horizontal alignment no move-animation is done between the columns. --- src/kitemviews/kitemlistview.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/kitemviews/kitemlistview.h') diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 118ed2f03..293f4b1ec 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -381,14 +381,27 @@ private: * the same row or column, otherwise the create-animation is used instead. * @return True if the moving-animation has been applied. */ - bool moveWidget(KItemListWidget* widget, const QRectF& itemBounds); + bool moveWidget(KItemListWidget* widget, const QPointF& newPos); void emitOffsetChanges(); KItemListWidget* createWidget(int index); void recycleWidget(KItemListWidget* widget); + + /** + * Changes the index of the widget to \a index. The cell-information + * for the widget gets reset and will be updated in the next doLayout(). + */ void setWidgetIndex(KItemListWidget* widget, int index); + /** + * Changes the index of the widget to \a index. In opposite to + * setWidgetIndex() the cell-information of the widget gets updated. + * This update gives doLayout() the chance to animate the moving + * of the item visually (see moveWidget()). + */ + void moveWidgetToIndex(KItemListWidget* widget, int index); + /** * Helper method for prepareLayoutForIncreasedItemCount(). */ @@ -550,6 +563,15 @@ private: QHash m_visibleItems; QHash m_visibleGroups; + struct Cell + { + Cell() : column(-1), row(-1) {} + Cell(int c, int r) : column(c), row(r) {} + int column; + int row; + }; + QHash m_visibleCells; + int m_scrollBarExtent; KItemListSizeHintResolver* m_sizeHintResolver; KItemListViewLayouter* m_layouter; -- cgit v1.3.1