KOSMIndoorMap

IndoorMapAmenityDelegate.qml
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6import QtQuick
7import QtQuick.Layouts
8import QtQuick.Controls as QQC2
9import org.kde.kirigami as Kirigami
10import org.kde.kopeninghours
11import org.kde.kosmindoormap
12
13QQC2.ItemDelegate {
14 id: root
15 required property string name
16 required property string typeName
17 required property string iconSource
18 required property string cuisine
19 required property string fallbackName
20 required property string openingHours
21
22 required property var mapData
23
24 required property int index // for Kirigami
25
26 highlighted: false
27 width: ListView.view.width
28
29 property var oh: {
30 let v = OpeningHoursParser.parse(root.openingHours);
31 v.region = root.mapData.regionCode;
32 v.timeZone = root.mapData.timeZone;
33 v.setLocation(root.mapData.center.y, root.mapData.center.x);
34 if (v.error != OpeningHours.Null && v.error != OpeningHours.NoError) {
35 console.log("Opening hours parsing error:", v.error, root.mapData.region, root.mapData.timeZone)
36 }
37 return v;
38 }
39
40 contentItem: RowLayout {
41 spacing: Kirigami.Units.largeSpacing
42
43 Kirigami.Icon {
44 Layout.minimumHeight: Kirigami.Units.iconSizes.medium
45 Layout.maximumHeight: Kirigami.Units.iconSizes.medium
46 Layout.minimumWidth: Kirigami.Units.iconSizes.medium
47 Layout.maximumWidth: Kirigami.Units.iconSizes.medium
48 source: root.iconSource
49 isMask: true
50 }
51
52 ColumnLayout {
53 Layout.alignment: Qt.AlignVCenter
54 Layout.fillWidth: true
55 spacing: 0
56
57 QQC2.Label {
58 Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
59 Layout.fillWidth: true
60 text: root.name !== "" ? root.name : root.typeName
61 elide: Text.ElideRight
62 }
63
64 QQC2.Label {
65 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
66 Layout.fillWidth: true
67 text: {
68 if (root.cuisine && root.name === "")
69 return root.cuisine;
70 if (root.cuisine)
71 return root.typeName + " (" + root.cuisine + ")";
72 return root.name === "" && root.fallbackName !== "" ? root.fallbackName : root.typeName;
73 }
74 elide: Text.ElideRight
75 font: Kirigami.Theme.smallFont
76 opacity: 0.7
77 }
78
79 QQC2.Label {
80 Layout.fillWidth: true
81 text: Display.currentState(root.oh)
82 color: {
83 if (root.highlighted || root.checked || root.down)
84 return Kirigami.Theme.highlightedTextColor
85 const currentInterval = root.oh.interval(new Date());
86 switch (currentInterval.state) {
87 case Interval.Open: return Kirigami.Theme.positiveTextColor;
88 case Interval.Closed: return Kirigami.Theme.negativeTextColor;
89 default: return Kirigami.Theme.textColor;
90 }
91 }
92 elide: Text.ElideRight
93 font: Kirigami.Theme.smallFont
94 visible: text !== ""
95 }
96 }
97 }
98}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:50:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.