KOSMIndoorMap

floorlevelchangemodel.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
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 
20 namespace KOSMIndoorMap {
21 
22 class MapLevel;
23 
24 /** Floor level changes on steps or elevators. */
26 {
27  Q_OBJECT
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  */
41  Q_PROPERTY(bool hasMultipleLevelChanges READ hasMultipleLevelChanges NOTIFY contentChanged)
42 
43 public:
44  explicit FloorLevelChangeModel(QObject *parent = nullptr);
46 
47  enum Roles {
48  FloorLevelRole = Qt::UserRole,
49  CurrentFloorRole,
50  };
51 
52  int rowCount(const QModelIndex &parent = {}) const override;
53  QVariant data(const QModelIndex &index, int role) const override;
54  QHash<int, QByteArray> roleNames() const override;
55 
56  int currentFloorLevel() const;
57  void setCurrentFloorLevel(int level);
58  FloorLevelModel* floorLevelModel() const;
59  void setFloorLevelModel(FloorLevelModel *floorLevelModel);
60  OSMElement element() const;
61  void setElement(const OSMElement &element);
62 
63  bool hasSingleLevelChange() const;
64  int destinationLevel() const;
65  QString destinationLevelName() const;
66  bool hasMultipleLevelChanges() const;
67 
68 Q_SIGNALS:
69  void contentChanged();
70 
71 private:
72  bool isLevelChangeElement(OSM::Element element) const;
73  void appendFloorLevel(int level);
74  void appendFullFloorLevel(int level);
75 
76  int m_currentFloorLevel = 0;
77  FloorLevelModel *m_floorLevelModel = nullptr;
78  OSM::Element m_element;
79  std::vector<MapLevel> m_levels;
80 };
81 
82 }
83 
84 #endif // KOSMINDOORMAP_FLOORLEVELCHANGEMODEL_H
OSM-based multi-floor indoor maps for buildings.
QML wrapper around an OSM element.
Definition: osmelement.h:18
Q_SIGNALSQ_SIGNALS
Floor level changes on steps or elevators.
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition: element.h:22
Q_OBJECTQ_OBJECT
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
UserRole
int destinationLevel
The destination level for a single level change.
bool hasMultipleLevelChanges
The current element changes to multiple levels based on users choice, ie.
Q_PROPERTY(...)
bool hasSingleLevelChange
The current element changes to a single other floor, ie.
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 27 2021 23:05:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.