Kirigami-addons

ListRowDelegate.qml
1/*
2 * Copyright 2023 Evgeny Chesnokov <echesnokov@astralinux.ru>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6import QtQuick
7import QtQuick.Controls as QQC2
8import QtQuick.Layouts
9
10import org.kde.kirigami as Kirigami
11
12QQC2.ItemDelegate {
13 id: delegate
14
15 Accessible.role: Accessible.Row
16
17 padding: 0
18 horizontalPadding: 0
19
20 required property var model
21 required property int index
22
23 property bool alternatingRows
24
25 background: Rectangle {
26 color: {
27 if (delegate.enabled) {
28 if (delegate.down || delegate.highlighted) {
29 return Kirigami.Theme.highlightColor
30 }
31
32 if (delegate.hovered && !Kirigami.Settings.isMobile) {
33 return Qt.alpha(Kirigami.Theme.hoverColor, 0.3)
34 }
35 }
36
37 if (delegate.alternatingRows && index % 2) {
38 return Kirigami.Theme.alternateBackgroundColor;
39 }
40
41 return "Transparent"
42 }
43 }
44
45 contentItem: Row {
46 spacing: 0
47
48 Repeater {
49 model: root.__columnModel
50
51 delegate: ListCellDelegate {
52 implicitWidth: root.__columnModel.get(index)?.headerComponent.width ?? 0
53 implicitHeight: root.__rowHeight
54 entry: delegate.model
55 rowIndex: delegate.index
56 }
57 }
58 }
59
60 onClicked: delegate.forceActiveFocus()
61}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:51:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.