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 NameRole = Qt::DisplayRole,
58 FloorLevelRole = Qt::UserRole,
59 CurrentFloorRole,
60 };
61
62 [[nodiscard]] int rowCount(const QModelIndex &parent = {}) const override;
63 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
64 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
65
66 [[nodiscard]] int currentFloorLevel() const;
67 [[nodiscard]] int currentFloorLevelRow() const;
68 void setCurrentFloorLevel(int level);
69 [[nodiscard]] FloorLevelModel* floorLevelModel() const;
70 void setFloorLevelModel(FloorLevelModel *floorLevelModel);
71 [[nodiscard]] OSMElement element() const;
72 void setElement(const OSMElement &element);
73
74 [[nodiscard]] bool hasSingleLevelChange() const;
75 [[nodiscard]] int destinationLevel() const;
76 [[nodiscard]] QString destinationLevelName() const;
77 [[nodiscard]] bool hasMultipleLevelChanges() const;
78
79 [[nodiscard]] QString title() const;
80
82 void contentChanged();
83
84private:
85 [[nodiscard]] bool isLevelChangeElement(OSM::Element element) const;
86 void appendFloorLevel(int level);
87 void appendFullFloorLevel(int level);
88
89 int m_currentFloorLevel = 0;
90 FloorLevelModel *m_floorLevelModel = nullptr;
91 OSM::Element m_element;
92 std::vector<MapLevel> m_levels;
93};
94
95}
96
97#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/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
DisplayRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:55:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.