*/
void scrollToItem(int index);
- /**
- * @return The number of items that can be shown in parallel for one offset.
- * Assuming the scrolldirection is vertical then a value of 4 means
- * that 4 columns for items are available. Assuming the scrolldirection
- * is horizontal then a value of 4 means that 4 lines for items are
- * available.
- */
- int itemsPerOffset() const;
-
void beginTransaction();
void endTransaction();
bool isTransactionActive() const;
QList<KItemListWidget*> visibleItemListWidgets() const;
- /** @reimp */
- virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
-
protected slots:
virtual void slotItemsInserted(const KItemRangeList& itemRanges);
virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
KItemListRubberBand* rubberBand() const;
- void doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
- void doGroupHeadersLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
+ void doLayout(LayoutAnimationHint hint, int changedIndex = 0, int changedCount = 0);
+
+ /**
+ * Helper method for doLayout: Returns a list of items that can be reused for the visible
+ * area. Invisible group headers get recycled. The reusable items are items that are
+ * invisible. If the animation hint is 'Animation' then items that are currently animated
+ * won't be reused. Reusing items is faster in comparison to deleting invisible
+ * items and creating a new instance for visible items.
+ */
+ QList<int> recycleInvisibleItems(int firstVisibleIndex,
+ int lastVisibleIndex,
+ LayoutAnimationHint hint);
+
+ /**
+ * Helper method for doLayout: Starts a moving-animation for the widget to the given
+ * new position. The moving-animation is only started if the new position is within
+ * 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);
+
void emitOffsetChanges();
KItemListWidget* createWidget(int index);
void recycleWidget(KItemListWidget* widget);
void setWidgetIndex(KItemListWidget* widget, int index);
- /**
- * Helper method for setGeometry() and setItemSize(): Calling both methods might result
- * in a changed number of visible items. To assure that currently invisible items can
- * get animated from the old position to the new position prepareLayoutForIncreasedItemCount()
- * takes care to create all item widgets that are visible with the old or the new size.
- * @param size Size of the layouter or the item dependent on \p sizeType.
- * @param sizeType LayouterSize: KItemListLayouter::setSize() is used.
- * ItemSize: KItemListLayouter::setItemSize() is used.
- */
- void prepareLayoutForIncreasedItemCount(const QSizeF& size, SizeType sizeType);
-
/**
* Helper method for prepareLayoutForIncreasedItemCount().
*/
* if no header is shown.
*/
QRectF headerBoundaries() const;
+
+ /**
+ * @return True if the number of columns or rows will be changed when applying
+ * the new grid- and item-size. Used to determine whether an animation
+ * should be done when applying the new layout.
+ */
+ bool changesItemGridLayout(const QSizeF& newGridSize, const QSizeF& newItemSize) const;
+
+ /**
+ * @param changedItemCount Number of inserted or removed items.
+ * @return True if the inserting or removing of items should be animated.
+ * No animation should be done if the number of items is too large
+ * to provide a pleasant animation.
+ */
+ bool animateChangedItemCount(int changedItemCount) const;
/**
* Helper function for triggerAutoScrolling().
bool m_useHeaderWidths;
friend class KItemListController;
+ friend class KItemListControllerTest;
};
/**
};
template <class T>
-class LIBDOLPHINPRIVATE_EXPORT KItemListWidgetCreator : public KItemListWidgetCreatorBase
+class KItemListWidgetCreator : public KItemListWidgetCreatorBase
{
public:
virtual ~KItemListWidgetCreator();
};
template <class T>
-class LIBDOLPHINPRIVATE_EXPORT KItemListGroupHeaderCreator : public KItemListGroupHeaderCreatorBase
+class KItemListGroupHeaderCreator : public KItemListGroupHeaderCreatorBase
{
public:
virtual ~KItemListGroupHeaderCreator();