]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistviewlayouter_p.h
Fix alternate backgrounds when enabling grouping
[dolphin.git] / src / kitemviews / kitemlistviewlayouter_p.h
index dec99d0542a1a4ea82c926dd09dc845aab169070..0d7c0d0408c711ece0b78674310cbb0cda86872d 100644 (file)
@@ -47,6 +47,12 @@ public:
     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
@@ -62,7 +68,13 @@ public:
     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;
 
@@ -100,6 +112,18 @@ public:
     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
@@ -115,6 +139,15 @@ public:
 
     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();
@@ -138,7 +171,8 @@ private:
     QSizeF m_size;
 
     QSizeF m_itemSize;
-    qreal m_headerHeight;
+    QSizeF m_itemMargin;
+    qreal m_headerHeight;    
     const KItemModelBase* m_model;
     const KItemListSizeHintResolver* m_sizeHintResolver;
 
@@ -159,8 +193,16 @@ private:
     // 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