5pragma ComponentBehavior: Bound
8import QtQuick.Controls as QQC2
11import org.kde.kirigami as Kirigami
64 property alias model: listView.model
69 property alias delegate: listView.delegate
74 property alias currentItem: listView.currentItem
79 property alias section: listView.section
84 property alias text: searchField.text
89 property alias searchFieldLeftActions: searchField.leftActions
94 property alias searchFieldRightActions: searchField.rightActions
99 property alias searchFieldPlaceholderText: searchField.placeholderText
104 property alias count: listView.count
110 property alias emptyText: placeholder.text
116 property alias emptyIcon: placeholder.icon
126 property alias emptyHelpfulAction: placeholder.helpfulAction
128 width: Math.min(Kirigami.Units.gridUnit * 35, parent.width)
129 height: Math.min(Kirigami.Units.gridUnit * 20, parent.height)
133 anchors.centerIn: parent
138 searchField.forceActiveFocus();
139 searchField.text =
"";
140 listView.currentIndex = 0;
143 contentItem: ColumnLayout {
146 Kirigami.SearchField {
149 Layout.fillWidth:
true
153 Layout.margins: Kirigami.Units.smallSpacing
155 Keys.onDownPressed: {
156 const listViewHadFocus = listView.activeFocus;
157 listView.forceActiveFocus();
158 if (listView.currentIndex < listView.count - 1) {
160 if (listViewHadFocus) {
161 listView.currentIndex++;
164 listView.currentIndex = 0;
168 listView.forceActiveFocus();
169 if (listView.currentIndex === 0) {
170 listView.currentIndex = listView.count - 1;
172 listView.currentIndex--;
175 Keys.onPressed: (event) => {
177 case Qt.Key_PageDown:
178 listView.forceActiveFocus();
179 listView.currentIndex = Math.min(listView.count - 1, listView.currentIndex + Math.floor(listView.height / listView.currentItem.height));
180 event.accepted =
true;
183 listView.forceActiveFocus();
184 listView.currentIndex = Math.max(0, listView.currentIndex - Math.floor(listView.height / listView.currentItem.height));
185 event.accepted =
true;
193 onAccepted: root.accepted()
197 Layout.fillWidth:
true
201 Layout.fillWidth:
true
202 Layout.fillHeight:
true
203 Keys.forwardTo: searchField
210 highlightMoveDuration: 200
211 Keys.forwardTo: searchField
212 keyNavigationEnabled:
true
214 Kirigami.PlaceholderMessage {
216 anchors.centerIn: parent
217 width: parent.width - Kirigami.Units.gridUnit * 4
218 icon.name:
'system-search-symbolic'
219 visible: listView.count === 0 && text.length > 0