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 /** The current floor level. */
29 Q_PROPERTY(int currentFloorLevel READ currentFloorLevel WRITE setCurrentFloorLevel NOTIFY contentChanged)
30 /** The model row representing the current floor level. */
32
33 Q_PROPERTY(KOSMIndoorMap::FloorLevelModel* floorLevelModel READ floorLevelModel WRITE setFloorLevelModel NOTIFY contentChanged)
34 Q_PROPERTY(KOSMIndoorMap::OSMElement element READ element WRITE setElement NOTIFY contentChanged)
35
36 /** The current element changes to a single other floor, ie. typically stairs or a ramp. */
37 Q_PROPERTY(bool hasSingleLevelChange READ hasSingleLevelChange NOTIFY contentChanged)
38 /** The destination level for a single level change. */
39 Q_PROPERTY(int destinationLevel READ destinationLevel NOTIFY contentChanged)
40 Q_PROPERTY(QString destinationLevelName READ destinationLevelName NOTIFY contentChanged)
41
42 /** The current element changes to multiple levels based on users choice, ie. typically an elevator.
43 * The model in this case provides the levels that are reachable.
44 */
46
47 /** Human-readable title of the thing enabling a floor level change here.
48 * E.g. "Elevator" or "Staircase"
49 */
50 Q_PROPERTY(QString title READ title NOTIFY contentChanged)
51
52public:
53 explicit FloorLevelChangeModel(QObject *parent = nullptr);
55
56 enum Roles {
57 FloorLevelRole = Qt::UserRole,
58 CurrentFloorRole,
59 };
60
61 [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
62 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
63 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
64
65 [[nodiscard]] int currentFloorLevel() const;
66 [[nodiscard]] int currentFloorLevelRow() const;
67 void setCurrentFloorLevel(int level);
68 [[nodiscard]] FloorLevelModel* floorLevelModel() const;
69 void setFloorLevelModel(FloorLevelModel *floorLevelModel);
70 [[nodiscard]] OSMElement element() const;
71 void setElement(const OSMElement &element);
72
73 [[nodiscard]] bool hasSingleLevelChange() const;
74 [[nodiscard]] int destinationLevel() const;
75 [[nodiscard]] QString destinationLevelName() const;
76 [[nodiscard]] bool hasMultipleLevelChanges() const;
77
78 [[nodiscard]] QString title() const;
79
81 void contentChanged();
82
83private:
84 [[nodiscard]] bool isLevelChangeElement(OSM::Element element) const;
85 void appendFloorLevel(int level);
86 void appendFullFloorLevel(int level);
87
88 int m_currentFloorLevel = 0;
89 FloorLevelModel *m_floorLevelModel = nullptr;
90 OSM::Element m_element;
91 std::vector<MapLevel> m_levels;
92};
93
94}
95
96#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.
int currentFloorLevelRow
The model row representing the current floor level.
bool hasSingleLevelChange
The current element changes to a single other floor, ie.
int currentFloorLevel
The current floor level.
bool hasMultipleLevelChanges
The current element changes to multiple levels based on users choice, ie.
QML wrapper around an OSM element.
Definition osmelement.h:21
A reference to any of OSM::Node/OSMWay/OSMRelation.
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 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.