Warning, /libraries/kosmindoormap/src/app/IndoorMapAmenityDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
0003     SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005 
0006 import QtQuick
0007 import QtQuick.Layouts
0008 import QtQuick.Controls as QQC2
0009 import org.kde.kirigami as Kirigami
0010 import org.kde.kopeninghours
0011 import org.kde.kosmindoormap
0012 
0013 QQC2.ItemDelegate {
0014     id: root
0015     required property string name
0016     required property string typeName
0017     required property string iconSource
0018     required property string cuisine
0019     required property string fallbackName
0020     required property string openingHours
0021 
0022     required property var mapData
0023 
0024     required property int index // for Kirigami
0025 
0026     highlighted: false
0027     width: ListView.view.width
0028 
0029     property var oh: {
0030         let v = OpeningHoursParser.parse(root.openingHours);
0031         v.region = root.mapData.regionCode;
0032         v.timeZone = root.mapData.timeZone;
0033         v.setLocation(root.mapData.center.y, root.mapData.center.x);
0034         if (v.error != OpeningHours.Null && v.error != OpeningHours.NoError) {
0035             console.log("Opening hours parsing error:", v.error, root.mapData.region, root.mapData.timeZone)
0036         }
0037         return v;
0038     }
0039 
0040     contentItem: RowLayout {
0041         spacing: Kirigami.Units.largeSpacing
0042 
0043         Kirigami.Icon {
0044             Layout.minimumHeight: Kirigami.Units.iconSizes.medium
0045             Layout.maximumHeight: Kirigami.Units.iconSizes.medium
0046             Layout.minimumWidth: Kirigami.Units.iconSizes.medium
0047             Layout.maximumWidth: Kirigami.Units.iconSizes.medium
0048             source: root.iconSource
0049             isMask: true
0050         }
0051 
0052         ColumnLayout {
0053             Layout.alignment: Qt.AlignVCenter
0054             Layout.fillWidth: true
0055             spacing: 0
0056 
0057             QQC2.Label {
0058                 Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
0059                 Layout.fillWidth: true
0060                 text: root.name !== "" ? root.name : root.typeName
0061                 elide: Text.ElideRight
0062             }
0063 
0064             QQC2.Label {
0065                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0066                 Layout.fillWidth: true
0067                 text: {
0068                     if (root.cuisine && root.name === "")
0069                         return root.cuisine;
0070                     if (root.cuisine)
0071                         return root.typeName + " (" + root.cuisine + ")";
0072                     return root.name === "" && root.fallbackName !== "" ? root.fallbackName : root.typeName;
0073                 }
0074                 elide: Text.ElideRight
0075                 font: Kirigami.Theme.smallFont
0076                 opacity: 0.7
0077             }
0078 
0079             QQC2.Label {
0080                 Layout.fillWidth: true
0081                 text: Display.currentState(root.oh)
0082                 color: {
0083                     if (root.highlighted || root.checked || root.down)
0084                         return Kirigami.Theme.highlightedTextColor
0085                     const currentInterval = root.oh.interval(new Date());
0086                     switch (currentInterval.state) {
0087                         case Interval.Open: return Kirigami.Theme.positiveTextColor;
0088                         case Interval.Closed: return Kirigami.Theme.negativeTextColor;
0089                         default: return Kirigami.Theme.textColor;
0090                     }
0091                 }
0092                 elide: Text.ElideRight
0093                 font: Kirigami.Theme.smallFont
0094                 visible: text !== ""
0095             }
0096         }
0097     }
0098 }