KOSMIndoorMap

floorlevelchangemodel.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KOSMINDOORMAP_FLOORLEVELCHANGEMODEL_H
8#define KOSMINDOORMAP_FLOORLEVELCHANGEMODEL_H
9
10#include "osmelement.h"
11
12#include <KOSMIndoorMap/FloorLevelModel>
13
14#include <osm/element.h>
15
16#include <QAbstractListModel>
17
18#include <vector>
19
20namespace KOSMIndoorMap {
21
22class MapLevel;
23
24/** Floor level changes on steps or elevators. */
26{
28 Q_PROPERTY(int currentFloorLevel READ currentFloorLevel WRITE setCurrentFloorLevel NOTIFY contentChanged)
29 Q_PROPERTY(KOSMIndoorMap::FloorLevelModel* floorLevelModel READ floorLevelModel WRITE setFloorLevelModel NOTIFY contentChanged)
30 Q_PROPERTY(KOSMIndoorMap::OSMElement element READ element WRITE setElement NOTIFY contentChanged)
31
32 /** The current element changes to a single other floor, ie. typically stairs or a ramp. */
33 Q_PROPERTY(bool hasSingleLevelChange READ hasSingleLevelChange NOTIFY contentChanged)
34 /** The destination level for a single level change. */
35 Q_PROPERTY(int destinationLevel READ destinationLevel NOTIFY contentChanged)
36 Q_PROPERTY(QString destinationLevelName READ destinationLevelName NOTIFY contentChanged)
37
38 /** The current element changes to multiple levels based on users choice, ie. typically an elevator.
39 * The model in this case provides the levels that are reachable.
40 */
42
43 /** Human-readable title of the thing enabling a floor level change here.
44 * E.g. "Elevator" or "Staircase"
45 */
46 Q_PROPERTY(QString title READ title NOTIFY contentChanged)
47
48public:
49 explicit FloorLevelChangeModel(QObject *parent = nullptr);
51
52 enum Roles {
53 FloorLevelRole = Qt::UserRole,
54 CurrentFloorRole,
55 };
56
57 int rowCount(const QModelIndex &parent = {}) const override;
58 QVariant data(const QModelIndex &index, int role) const override;
59 QHash<int, QByteArray> roleNames() const override;
60
61 int currentFloorLevel() const;
62 void setCurrentFloorLevel(int level);
63 FloorLevelModel* floorLevelModel() const;
64 void setFloorLevelModel(FloorLevelModel *floorLevelModel);
65 OSMElement element() const;
66 void setElement(const OSMElement &element);
67
68 bool hasSingleLevelChange() const;
69 int destinationLevel() const;
70 QString destinationLevelName() const;
71 bool hasMultipleLevelChanges() const;
72
73 QString title() const;
74
76 void contentChanged();
77
78private:
79 bool isLevelChangeElement(OSM::Element element) const;
80 void appendFloorLevel(int level);
81 void appendFullFloorLevel(int level);
82
83 int m_currentFloorLevel = 0;
84 FloorLevelModel *m_floorLevelModel = nullptr;
85 OSM::Element m_element;
86 std::vector<MapLevel> m_levels;
87};
88
89}
90
91#endif // KOSMINDOORMAP_FLOORLEVELCHANGEMODEL_H
Floor level changes on steps or elevators.
int destinationLevel
The destination level for a single level change.
QString title
Human-readable title of the thing enabling a floor level change here.
bool hasSingleLevelChange
The current element changes to a single other floor, ie.
bool hasMultipleLevelChanges
The current element changes to multiple levels based on users choice, ie.
QML wrapper around an OSM element.
Definition osmelement.h:19
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
Definition element.h:24
OSM-based multi-floor indoor maps for buildings.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
UserRole
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.