KOSMIndoorMap

AmenitySearchDialog.qml
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6import QtQuick
7import org.kde.kirigami as Kirigami
8import org.kde.kosmindoormap
9
10/** Amenity search dialog.
11 * For use in combination with AmenityModel.
12 */
13Kirigami.SearchDialog {
14 id: root
15
16 property AmenityModel amenityModel: null
17
18 searchFieldPlaceholderText: i18nd("kosmindoormap", "Search amenity…")
19
20 model: AmenitySortFilterProxyModel {
21 id: amenitySortModel
22 sourceModel: root.visible ? root.amenityModel : null
23 filterCaseSensitivity: Qt.CaseInsensitive
24 }
25
26 /** Emitted when an entry of this dialog as been selected. */
27 signal amenitySelected(amenity: var)
28
29 delegate: AmenityListDelegate {
30 id: item
31 required property QtObject model
32 onClicked: {
33 root.amenitySelected({ element: item.model.element, level: item.model.level });
34 root.accept();
35 }
36
37 Keys.onPressed: (event) => {
38 if (event.key === Qt.Key_Enter || event.key == Qt.Key_Return) {
39 event.accepted = true;
40 root.amenitySelected({ element: item.model.element, level: item.model.level });
41 root.accept();
42 }
43 }
44 }
45
46 section {
47 property: "groupName"
48 delegate: Kirigami.ListSectionHeader {
49 text: section
50 width: ListView.view.width
51 }
52 }
53
54 onTextChanged: amenitySortModel.filterString = root.text
55}
Delegate for use on an AmenityModel.
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
QStringView level(QStringView ifopt)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.