┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistview.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2012-02-22 18:28:11 +0100
committerPeter Penz <[email protected]>2012-02-22 18:31:03 +0100
commitdbc5fd7a491f95ca4084a113d0f902ea975478fd (patch)
treef9c43d6008e48189f39bd58cd7f0982a5f177065 /src/kitemviews/kitemlistview.h
parentbdd0fdf2460232fe17b0e54e42fcda4cc18b811a (diff)
Fix alternate backgrounds when enabling grouping
Up to now the alternating backgrounds just have been calculated by checking whether the item index is odd. This does not work well when grouping is enabled: In this case the alternate background color of the first item of a group should stay consistent.
Diffstat (limited to 'src/kitemviews/kitemlistview.h')
-rw-r--r--src/kitemviews/kitemlistview.h29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h
index d524dbdf4..17b7b8880 100644
--- a/src/kitemviews/kitemlistview.h
+++ b/src/kitemviews/kitemlistview.h
@@ -396,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()).
*/
@@ -421,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);
@@ -446,6 +447,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.
*/
QHash<QByteArray, qreal> headerRolesWidths() const;