KOSMIndoorMap

IndoorMapInfoSheet.qml
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 import QtQuick 2.12
8 import QtQuick.Layouts 1.1
9 import QtQuick.Controls 2.1 as QQC2
10 import org.kde.kirigami 2.7 as Kirigami
11 import org.kde.kosmindoormap 1.0
12 
13 Kirigami.OverlaySheet {
14  id: elementDetailsSheet
15  property var model
16  property var mapData
17 
18  header: Column {
19  Kirigami.Heading {
20  text: elementDetailsSheet.model.name
21  }
22  Kirigami.Heading {
23  text: elementDetailsSheet.model.category
24  level: 4
25  visible: text != ""
26  }
27  }
28 
29  ListView {
30  id: contentView
31  model: elementDetailsSheet.model
32 
33  Component {
34  id: infoStringDelegate
35  RowLayout {
36  QQC2.Label {
37  visible: row && row.keyLabel != ""
38  text: row ? row.keyLabel + ":" : ""
39  color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
40  Layout.alignment: Qt.AlignTop
41  }
42  QQC2.Label {
43  text: row ? row.value : ""
44  color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
45  wrapMode: Text.WordWrap
46  Layout.fillWidth: true
47  }
48  }
49  }
50 
51  Component {
52  id: infoLinkDelegate
53  RowLayout {
54  QQC2.Label {
55  visible: row && row.keyLabel != ""
56  text: row ? row.keyLabel + ":" : ""
57  color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
58  Layout.alignment: Qt.AlignTop
59  }
60  QQC2.Label {
61  text: row ? "<a href=\"" + row.url + "\">" + row.value + "</a>" : ""
62  color: (row && row.category == OSMElementInformationModel.DebugCategory) ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
63  onLinkActivated: Qt.openUrlExternally(link)
64  wrapMode: Text.WordWrap
65  Layout.fillWidth: true
66  }
67  }
68  }
69 
70  Component {
71  id: infoAddressDelegate
72  QQC2.Label {
73  text: (row.value.street + " " + row.value.houseNumber + "\n" + row.value.postalCode + " " + row.value.city + "\n" + row.value.country).trim()
74  }
75  }
76 
77  Component {
78  id: infoOpeningHoursDelegate
79  IndoorMapInfoSheetOpeningHoursDelegate {
80  mapData: elementDetailsSheet.mapData
81  model: row
82  }
83  }
84 
85  section.property: "categoryLabel"
86  section.delegate: Kirigami.Heading {
88  level: 4
89  text: section
90  color: section == "Debug" ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
91  height: implicitHeight + Kirigami.Units.largeSpacing
92  verticalAlignment: Qt.AlignBottom
93  }
94  section.criteria: ViewSection.FullString
95  section.labelPositioning: ViewSection.InlineLabels
96 
97  delegate: Loader {
98  property var row: model
100  width: ListView.view.width - 2 * x
101  sourceComponent: {
102  switch (row.type) {
103  case OSMElementInformationModel.Link:
104  return infoLinkDelegate;
105  case OSMElementInformationModel.PostalAddress:
106  return infoAddressDelegate;
107  case OSMElementInformationModel.OpeningHoursType:
108  return infoOpeningHoursDelegate;
109  case OSMElementInformationModel.String:
110  default:
111  return infoStringDelegate;
112  }
113  }
114  }
115  }
116 
117  onSheetOpenChanged: {
118  if (sheetOpen == false) {
119  elementDetailsSheet.model.clear()
120  }
121  }
122 }
QStringView level(QStringView ifopt)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.