void setItemSize(const QSizeF& size);
QSizeF itemSize() const;
+ /**
+ * Margin between the rows and columns of items.
+ */
+ void setItemMargin(const QSizeF& margin);
+ QSizeF itemMargin() const;
+
/**
* Sets the height of the header that is always aligned
* at the top. A height of <= 0.0 means that no header is
void setGroupHeaderHeight(qreal height);
qreal groupHeaderHeight() const;
- // TODO: add note that offset can be < 0 or > maximumOffset!
+ /**
+ * Sets the margin between the last items of the group n and
+ * the group header for the group n + 1.
+ */
+ void setGroupHeaderMargin(qreal margin);
+ qreal groupHeaderMargin() const;
+
void setScrollOffset(qreal scrollOffset);
qreal scrollOffset() const;
QRectF itemRect(int index) const;
QRectF groupHeaderRect(int index) const;
+
+ /**
+ * @return Column of the item with the index \a index.
+ * -1 is returned if an invalid index is given.
+ */
+ int itemColumn(int index) const;
+
+ /**
+ * @return Row of the item with the index \a index.
+ * -1 is returned if an invalid index is given.
+ */
+ int itemRow(int index) const;
/**
* @return Maximum number of (at least partly) visible items for
void markAsDirty();
+#ifndef QT_NO_DEBUG
+ /**
+ * @return True if the layouter has been marked as dirty and hence has
+ * not called yet doLayout(). Is enabled only in the debugging
+ * mode, as it is not useful to check the dirty state otherwise.
+ */
+ bool isDirty();
+#endif
+
private:
void doLayout();
void updateVisibleIndexes();
QSizeF m_size;
QSizeF m_itemSize;
- qreal m_headerHeight;
+ QSizeF m_itemMargin;
+ qreal m_headerHeight;
const KItemModelBase* m_model;
const KItemListSizeHintResolver* m_sizeHintResolver;
// Assures fast access for KItemListViewLayouter::isFirstGroupItem().
QSet<int> m_groupItemIndexes;
qreal m_groupHeaderHeight;
+ qreal m_groupHeaderMargin;
+
+ struct ItemInfo {
+ QRectF rect;
+ int column;
+ int row;
+ };
+ QList<ItemInfo> m_itemInfos;
- QList<QRectF> m_itemRects;
+ friend class KItemListControllerTest;
};
#endif