KOSMIndoorMap

IndoorMapInfoSheet.qml
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Layouts
9import QtQuick.Controls as QQC2
10import org.kde.kirigami as Kirigami
11import org.kde.kosmindoormap
12import org.kde.osm.editorcontroller
13
14Kirigami.OverlaySheet {
15 id: elementDetailsSheet
16 property var model
17 property var mapData
18
19 header: Column {
20 Kirigami.Heading {
21 text: elementDetailsSheet.model.name
22 }
23 Kirigami.Heading {
24 text: elementDetailsSheet.model.category
25 level: 4
26 visible: text != ""
27 }
28 }
29
30 ListView {
31 id: contentView
32 model: elementDetailsSheet.model
33 clip: true
34 Layout.preferredWidth: Kirigami.Units.gridUnit * 25
35
36 Component {
37 id: infoStringDelegate
38 RowLayout {
39 x: Kirigami.Units.largeSpacing
40 width: parent.ListView.view.width - 2 * x
41 QQC2.Label {
42 visible: row && row.keyLabel != ""
43 text: row ? row.keyLabel + ":" : ""
44 color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
45 Layout.alignment: Qt.AlignTop
46 }
47 QQC2.Label {
48 text: row ? row.value : ""
49 color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
50 wrapMode: Text.WordWrap
51 Layout.fillWidth: true
52 }
53 }
54 }
55
56 Component {
57 id: infoLinkDelegate
58 RowLayout {
59 x: Kirigami.Units.largeSpacing
60 width: parent.ListView.view.width - 2 * x
61 QQC2.Label {
62 visible: row && row.keyLabel != ""
63 text: row ? row.keyLabel + ":" : ""
64 color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
65 Layout.alignment: Qt.AlignTop
66 }
67 QQC2.Label {
68 text: row ? "<a href=\"" + row.url + "\">" + row.value + "</a>" : ""
69 color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
70 onLinkActivated: Qt.openUrlExternally(link)
71 wrapMode: Text.WordWrap
72 Layout.fillWidth: true
73 }
74 }
75 }
76
77 Component {
78 id: infoAddressDelegate
79 QQC2.Label {
80 x: Kirigami.Units.largeSpacing
81 width: parent.ListView.view.width - 2 * x
82 text: (row.value.street + " " + row.value.houseNumber + "\n" + row.value.postalCode + " " + row.value.city + "\n" + row.value.country).trim()
83 }
84 }
85
86 Component {
87 id: infoOpeningHoursDelegate
88 IndoorMapInfoSheetOpeningHoursDelegate {
89 x: Kirigami.Units.largeSpacing
90 width: parent.ListView.view.width - 2 * x
91 mapData: elementDetailsSheet.mapData
92 model: row
93 }
94 }
95
96 section.property: "categoryLabel"
97 section.delegate: Kirigami.Heading {
98 x: Kirigami.Units.largeSpacing
99 level: 4
100 text: section
101 color: section == "Debug" ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
102 height: implicitHeight + Kirigami.Units.largeSpacing
103 verticalAlignment: Qt.AlignBottom
104 }
105 section.criteria: ViewSection.FullString
106 section.labelPositioning: ViewSection.InlineLabels
107
108 delegate: Loader {
109 property var row: model
110 sourceComponent: {
111 switch (row.type) {
112 case OSMElementInformationModel.Link:
113 return infoLinkDelegate;
114 case OSMElementInformationModel.PostalAddress:
115 return infoAddressDelegate;
116 case OSMElementInformationModel.OpeningHoursType:
117 return infoOpeningHoursDelegate;
118 case OSMElementInformationModel.String:
119 default:
120 return infoStringDelegate;
121 }
122 }
123 }
124 }
125
126 footer: RowLayout {
127 Item { Layout.fillWidth: true }
128 QQC2.Button {
129 icon.name: "document-edit"
130 text: "Edit with iD"
131 onClicked: EditorController.editElement(elementDetailsSheet.model.element.element, Editor.ID)
132 }
133 QQC2.Button {
134 icon.name: "org.openstreetmap.josm"
135 text: "Edit with JOSM"
136 visible: EditorController.hasEditor(Editor.JOSM)
137 onClicked: EditorController.editElement(elementDetailsSheet.model.element.element, Editor.JOSM)
138 }
139 QQC2.Button {
140 icon.name: "document-edit"
141 text: "Edit with Vespucci"
142 visible: EditorController.hasEditor(Editor.Vespucci)
143 onClicked: EditorController.editElement(elementDetailsSheet.model.element.element, Editor.Vespucci)
144 }
145 }
146
147 onClosed: elementDetailsSheet.model.clear()
148}
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
@ Text
maximum width before wrapping
QStringView level(QStringView ifopt)
KI18NLOCALEDATA_EXPORT KCountry country(const char *ianaId)
AlignBottom
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.