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
118 width: Math.min(Kirigami.Units.gridUnit * 35, parent.width)
119 height: Math.min(Kirigami.Units.gridUnit * 20, parent.height)
123 anchors.centerIn: parent
128 searchField.forceActiveFocus();
129 searchField.text =
"";
130 listView.currentIndex = 0;
133 contentItem: ColumnLayout {
136 Kirigami.SearchField {
139 Layout.fillWidth:
true
143 Layout.margins: Kirigami.Units.smallSpacing
145 Keys.onDownPressed: {
146 const listViewHadFocus = listView.activeFocus;
147 listView.forceActiveFocus();
148 if (listView.currentIndex < listView.count - 1) {
150 if (listViewHadFocus) {
151 listView.currentIndex++;
154 listView.currentIndex = 0;
158 listView.forceActiveFocus();
159 if (listView.currentIndex === 0) {
160 listView.currentIndex = listView.count - 1;
162 listView.currentIndex--;
165 Keys.onPressed: (event) => {
167 case Qt.Key_PageDown:
168 listView.forceActiveFocus();
169 listView.currentIndex = Math.min(listView.count - 1, listView.currentIndex + Math.floor(listView.height / listView.currentItem.height));
170 event.accepted =
true;
173 listView.forceActiveFocus();
174 listView.currentIndex = Math.max(0, listView.currentIndex - Math.floor(listView.height / listView.currentItem.height));
175 event.accepted =
true;
183 onAccepted: root.accepted()
187 Layout.fillWidth:
true
191 Layout.fillWidth:
true
192 Layout.fillHeight:
true
193 Keys.forwardTo: searchField
200 highlightMoveDuration: 200
201 Keys.forwardTo: searchField
202 keyNavigationEnabled:
true
204 Kirigami.PlaceholderMessage {
206 anchors.centerIn: parent
207 width: parent.width - Kirigami.Units.gridUnit * 4
208 icon.name:
'system-search-symbolic'
209 visible: listView.count === 0 && text.length > 0