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 };
44
45 enum Group {
46 UndefinedGroup,
47 FoodGroup,
48 ShopGroup,
49 ToiletGroup,
50 AmenityGroup,
51 HealthcareGroup,
52 AccommodationGroup,
53 };
54 Q_ENUM(Group)
55
56 [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
57 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
58 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
59
61 void mapDataChanged();
62
63private:
64 struct Entry {
65 OSM::Element element;
66 int level;
67 Group group = UndefinedGroup;
68 QByteArray typeKey;
69 QString icon;
70 };
71
72 void populateModel();
73 static QString iconSource(const Entry &entry);
74
75 MapData m_data;
76 MapCSSStyle m_style;
77 std::vector<Entry> m_entries;
78 OSM::Languages m_langs;
79};
80
81}
82
83#endif // KOSMINDOORMAP_AMENITYMODEL_H
List all amenities in a given data set.
@ CuisineRole
details on entries in the FoodGroup
@ FallbackNameRole
Brand/operator/network name, better than nothing but not the first choice to display.
@ OpeningHoursRole
opening hours expression
Raw OSM map data, separated by levels.
Definition mapdata.h:60
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
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 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.