]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistview.h
Fix alternate backgrounds when enabling grouping
[dolphin.git] / src / kitemviews / kitemlistview.h
index 293f4b1ecd2d2c8c4bbf7fb0f8f14f32a5f89b05..17b7b8880bd77e448710ab05e5c4dd53957a18d8 100644 (file)
@@ -176,7 +176,7 @@ public:
      *         has to take care itself how to visually represent the expanded items provided
      *         by the model.
      */
-    virtual bool supportsItemExpanding() const;
+    bool supportsItemExpanding() const;
 
     /**
      * @return The rectangle of the item relative to the top/left of
@@ -298,6 +298,13 @@ protected:
 
     QList<KItemListWidget*> visibleItemListWidgets() const;
 
+    /**
+     * Must be called by the derived class if it supports the expanding
+     * of items.
+     * @see supportsItemExpanding()
+     */
+    void setSupportsItemExpanding(bool supportsExpanding);
+
 protected slots:
     virtual void slotItemsInserted(const KItemRangeList& itemRanges);
     virtual void slotItemsRemoved(const KItemRangeList& itemRanges);
@@ -389,14 +396,15 @@ private:
     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().
+     * Changes the index of the widget to \a index and assures a consistent
+     * update for m_visibleItems and m_visibleCells. The cell-information
+     * for the new index will not be updated and be initialized as empty cell.
      */
     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.
+     * setWidgetIndex() the cell-information for the widget gets updated.
      * This update gives doLayout() the chance to animate the moving
      * of the item visually (see moveWidget()).
      */
@@ -414,7 +422,7 @@ private:
     void updateWidgetProperties(KItemListWidget* widget, int index);
 
     /**
-     * Helper method for createWidget() and setWidgetIndex() to create or update
+     * Helper method for updateWidgetPropertes() to create or update
      * the itemlist group-header.
      */
     void updateGroupHeaderForWidget(KItemListWidget* widget);
@@ -438,6 +446,26 @@ private:
      */
     void updateVisibleGroupHeaders();
 
+    /**
+     * @return Index for the item in the list returned by KItemModelBase::groups()
+     *         that represents the group where the item with the index \a index
+     *         belongs to. -1 is returned if no groups are available.
+     */
+    int groupIndexForItem(int index) const;
+
+    /**
+     * Updates the alternateBackground-property of the widget dependent
+     * on the state of useAlternateBackgrounds() and the grouping state.
+     */
+    void updateAlternateBackgroundForWidget(KItemListWidget* widget);
+
+    /**
+     * @return True if alternate backgrounds should be used for the items.
+     *         This is the case if an empty item-size is given and if there
+     *         is more than one visible role.
+     */
+    bool useAlternateBackgrounds() const;
+
     /**
      * @return The widths of each visible role that is shown in the KItemListHeader.
      */
@@ -547,6 +575,7 @@ private:
 private:
     bool m_enabledSelectionToggles;
     bool m_grouped;
+    bool m_supportsItemExpanding;
     int m_activeTransactions; // Counter for beginTransaction()/endTransaction()
     LayoutAnimationHint m_endTransactionAnimationHint;