KOSMIndoorMap

roommodel.h
1/*
2 SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KOSMINDOORMAP_ROOMMODEL_H
7#define KOSMINDOORMAP_ROOMMODEL_H
8
9#include <KOSMIndoorMap/MapData>
10#include <KOSMIndoorMap/MapCSSStyle>
11
12#include <KOSM/Element>
13
14#include <QAbstractListModel>
15#include <QPolygonF>
16
17namespace KOSMIndoorMap {
18
19/** List all rooms of buildings in a given data set. */
21{
23 Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData WRITE setMapData NOTIFY mapDataChanged)
24 /** Number of buildings found in the model data. */
25 Q_PROPERTY(int buildingCount READ buildingCount NOTIFY populated)
26public:
27 explicit RoomModel(QObject *parent = nullptr);
28 ~RoomModel();
29
30 [[nodiscard]] MapData mapData() const;
31 void setMapData(const MapData &data);
32
33 enum Role {
34 NameRole = Qt::DisplayRole, ///< room name, if set
35 CoordinateRole = Qt::UserRole,
36 NumberRole, ///< room number, if set
37 LevelRole, ///< numeric level for positioning rather than for display
38 ElementRole, ///< OSM element for this room
39 TypeNameRole, ///< Type of the room as translated human readable text, if set
40 BuildingNameRole, ///< Name of the building the room is in
41 LevelLongNameRole, ///< Name of the floor the room is on (long form, if available)
42 LevelShortNameRole, ///< Name of the floor the room is on (short form, if available)
43 };
45
46 [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
47 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
48 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
49
50 [[nodiscard]] int buildingCount() const;
51
53 void mapDataChanged();
54 void populated();
55
56private:
57 struct Level {
58 OSM::Element element;
59 int level;
60 };
61
62 struct Building {
63 OSM::Element element;
64 QPolygonF outerPath;
65 std::vector<Level> levels;
66 int roomCount = 0;
67 };
68
69 struct Room {
70 OSM::Element element;
71 OSM::Element buildingElement;
72 OSM::Element levelElement;
73 int level;
74 };
75
76 void populateModel();
77
78 MapData m_data;
79 MapCSSStyle m_style;
80
81 std::vector<Building> m_buildings;
82 std::vector<Room> m_rooms;
83
84 OSM::Languages m_langs;
85};
86
87}
88
89#endif // KOSMINDOORMAP_ROOMMODEL_H
Raw OSM map data, separated by levels.
Definition mapdata.h:60
List all rooms of buildings in a given data set.
Definition roommodel.h:21
int buildingCount
Number of buildings found in the model data.
Definition roommodel.h:25
@ TypeNameRole
Type of the room as translated human readable text, if set.
Definition roommodel.h:39
@ NumberRole
room number, if set
Definition roommodel.h:36
@ LevelRole
numeric level for positioning rather than for display
Definition roommodel.h:37
@ ElementRole
OSM element for this room.
Definition roommodel.h:38
@ LevelShortNameRole
Name of the floor the room is on (short form, if available)
Definition roommodel.h:42
@ NameRole
room name, if set
Definition roommodel.h:34
@ LevelLongNameRole
Name of the floor the room is on (long form, if available)
Definition roommodel.h:41
@ BuildingNameRole
Name of the building the room is in.
Definition roommodel.h:40
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 Fri May 17 2024 11:53:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.