KOSMIndoorMap

amenitymodel.h
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KOSMINDOORMAP_AMENITYMODEL_H
7#define KOSMINDOORMAP_AMENITYMODEL_H
8
9#include <KOSMIndoorMap/MapData>
10#include <KOSMIndoorMap/MapCSSStyle>
11
12#include <KOSM/Element>
13
14#include <QAbstractListModel>
15
16namespace KOSMIndoorMap {
17
18/** List all amenities in a given data set. */
20{
22 Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData WRITE setMapData NOTIFY mapDataChanged)
23public:
24 explicit AmenityModel(QObject *parent = nullptr);
26
27 [[nodiscard]] MapData mapData() const;
28 void setMapData(const MapData &data);
29
30 enum Role {
31 NameRole = Qt::DisplayRole,
32 CoordinateRole = Qt::UserRole,
33 LevelRole,
34 ElementRole,
35 TypeNameRole,
36 GroupRole,
37 GroupNameRole,
38 IconSourceRole,
39 CuisineRole, ///< details on entries in the FoodGroup
40 FallbackNameRole, ///< Brand/operator/network name, better than nothing but not the first choice to display
41 OpeningHoursRole, ///< opening hours expression
42 TimeZoneRole, ///< IANA timezone id this amenity is in (relevant for opening hours interpretation)
43 RegionCodeRole, ///< ISO 3166-1/2 code of the region this amenity is in (relevant for opening hours interpretation)
44 ToiletDetailsRole, ///< details information for the ToiletGroup
45 DetailsLabelRole, ///< section-dependent details label (e.g. CuisineRole or ToiletDetailsRole)
46 };
48
49 enum Group {
50 UndefinedGroup,
51 FoodGroup,
52 ShopGroup,
53 ToiletGroup,
54 AmenityGroup,
55 HealthcareGroup,
56 AccommodationGroup,
57 };
58 Q_ENUM(Group)
59
60 [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
61 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
62 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
63
65 void mapDataChanged();
66
67private:
68 struct Entry {
69 OSM::Element element;
70 int level;
71 Group group = UndefinedGroup;
72 QByteArray typeKey;
73 QString icon;
74 };
75
76 void populateModel();
77 static QString iconSource(const Entry &entry);
78
79 MapData m_data;
80 MapCSSStyle m_style;
81 std::vector<Entry> m_entries;
82 OSM::Languages m_langs;
83};
84
85}
86
87#endif // KOSMINDOORMAP_AMENITYMODEL_H
List all amenities in a given data set.
@ DetailsLabelRole
section-dependent details label (e.g. CuisineRole or ToiletDetailsRole)
@ CuisineRole
details on entries in the FoodGroup
@ RegionCodeRole
ISO 3166-1/2 code of the region this amenity is in (relevant for opening hours interpretation)
@ FallbackNameRole
Brand/operator/network name, better than nothing but not the first choice to display.
@ TimeZoneRole
IANA timezone id this amenity is in (relevant for opening hours interpretation)
@ OpeningHoursRole
opening hours expression
@ ToiletDetailsRole
details information for the ToiletGroup
Raw OSM map data, separated by levels.
Definition mapdata.h:60
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition element.h:24
Languages in preference order to consider when looking up translated tag values.
Definition languages.h:25
OSM-based multi-floor indoor maps for buildings.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:57:46 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.