KOSMIndoorMap

FloorLevelSelector.qml
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6import QtQuick
7import QtQuick.Controls as QQC2
8import org.kde.kirigami as Kirigami
9import org.kde.kosmindoormap
10
11/** Floor level selection popup, e.g. for elevators. */
12Kirigami.Dialog {
13 id: root
14
15 /** Instance of a FloorLevelChangeModel. */
16 property FloorLevelChangeModel model
17
18 /** Emitted when a floor level has been selected. */
19 signal floorLevelSelected(level: int)
20
21 title: root.model.title
22
23 width: Math.min(applicationWindow().width, Kirigami.Units.gridUnit * 10)
24 height: Math.min(applicationWindow().height, listView.contentHeight + root.header.implicitHeight + Kirigami.Units.largeSpacing)
25
26 contentItem: ListView {
27 id: listView
28 clip: true
29 model: root.model
30 keyNavigationEnabled: true
31
32 delegate: QQC2.ItemDelegate {
33 id: delegateRoot
34 required property string name
35 required property int floorLevel
36 required property bool isCurrentFloor
37
38 width: ListView.view.width
39 contentItem: Kirigami.TitleSubtitle {
40 title: delegateRoot.name
41 font.bold: delegateRoot.isCurrentFloor
42 }
43 onClicked: {
44 root.close();
45 root.floorLevelSelected(delegateRoot.floorLevel);
46 }
47 Keys.onPressed: (event) => {
48 if (event.key === Qt.Key_Enter || event.key == Qt.Key_Return) {
49 event.accepted = true;
50 root.close();
51 root.floorLevelSelected(delegateRoot.floorLevel);
52 }
53 }
54 }
55 }
56
57 onOpened: {
58 listView.forceActiveFocus();
59 listView.currentIndex = root.model.currentFloorLevelRow;
60 }
61}
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:15 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.