┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kitemlistwidget.h
diff options
context:
space:
mode:
authorAkseli Lahtinen <[email protected]>2025-06-20 00:15:31 +0300
committerAkseli Lahtinen <[email protected]>2025-06-20 00:15:31 +0300
commitc1e71289082ec7416ac19c822393ea70f63d1b75 (patch)
tree58e43ee607af7c6586235417d1056d7df5e8838b /src/kitemviews/kitemlistwidget.h
parentb1d46a3cbd6dd70a6ec7e31d2d11056a5f5c6d91 (diff)
New selection effects
This adds a new selection effect that is similar to what we have in QtQuick file item views. There are also changes to some usability: Instead of only the icon and text being the clickable area in icon and details mode, the whole selection is now the clickable area. Otherwise the usability should stay the same, it's mostly a visual change. See also: https://invent.kde.org/teams/vdg/issues/-/issues/94
Diffstat (limited to 'src/kitemviews/kitemlistwidget.h')
-rw-r--r--src/kitemviews/kitemlistwidget.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/kitemviews/kitemlistwidget.h b/src/kitemviews/kitemlistwidget.h
index 0e07d7ab5..b87a3b34e 100644
--- a/src/kitemviews/kitemlistwidget.h
+++ b/src/kitemviews/kitemlistwidget.h
@@ -98,6 +98,10 @@ public:
void setHovered(bool hovered);
bool isHovered() const;
+ /** Sets a purely visual pressed highlight effect. */
+ void setPressed(bool enabled);
+ bool isPressed() const;
+
void setExpansionAreaHovered(bool hover);
bool expansionAreaHovered() const;
@@ -137,19 +141,14 @@ public:
int iconSize() const;
/**
- * @return True if \a point is inside KItemListWidget::hoverRect(),
- * KItemListWidget::textRect(), KItemListWidget::selectionToggleRect()
+ * @return True if \a point is inside KItemListWidget::selectionRectFull(),
+ * KItemListWidget::selectionToggleRect()
* or KItemListWidget::expansionToggleRect().
* @reimp
*/
bool contains(const QPointF &point) const override;
/**
- * @return Rectangle for the area that shows the icon.
- */
- virtual QRectF iconRect() const = 0;
-
- /**
* @return Rectangle for the area that contains the text-properties.
*/
virtual QRectF textRect() const = 0;
@@ -164,9 +163,17 @@ public:
virtual QRectF textFocusRect() const;
/**
- * @return Rectangle around which a selection box should be drawn if the item is selected.
+ * Used for drawing the visuals, and situations where we want the behavior of the
+ * selection to match the visuals.
+ *
+ * @return The rectangle around selection.
+ */
+ virtual QRectF selectionRectFull() const = 0;
+
+ /**
+ * @return The core area of the item. All of it reacts exactly the same way to mouse clicks.
*/
- virtual QRectF selectionRect() const = 0;
+ virtual QRectF selectionRectCore() const = 0;
/**
* @return Rectangle for the selection-toggle that is used to select or deselect an item.
@@ -258,6 +265,7 @@ private:
bool m_expansionAreaHovered;
bool m_alternateBackground;
bool m_enabledSelectionToggle;
+ bool m_clickHighlighted;
QHash<QByteArray, QVariant> m_data;
QList<QByteArray> m_visibleRoles;
QHash<QByteArray, qreal> m_columnWidths;