KOSMIndoorMap

floorlevelmodel.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_FLOORLEVELMODEL_H
8#define KOSMINDOORMAP_FLOORLEVELMODEL_H
9
10#include <kosmindoormap_export.h>
11
12#include <QAbstractListModel>
13
14#include <vector>
15
16namespace KOSMIndoorMap {
17
18class MapData;
19class MapLevel;
20
21/** Floor level model. */
22class KOSMINDOORMAP_EXPORT FloorLevelModel : public QAbstractListModel
23{
24 Q_OBJECT
25 Q_PROPERTY(bool hasFloorLevels READ hasFloorLevels NOTIFY contentChanged)
26
27public:
28 explicit FloorLevelModel(QObject *parent = nullptr);
30
31 enum Roles {
32 MapLevelRole = Qt::UserRole
33 };
34
35 void setMapData(MapData *data);
36
37 int rowCount(const QModelIndex &parent = {}) const override;
38 QVariant data(const QModelIndex &index, int role) const override;
39
40 /** Maps a floor level to a model row index. */
41 Q_INVOKABLE int rowForLevel(int level) const;
42 /** Maps a row index to a floor level. */
43 Q_INVOKABLE int levelForRow(int row) const;
44
45 /** Returns @c true when we can still go further down. */
46 Q_INVOKABLE bool hasFloorLevelBelow(int level) const;
47 /** Returns the floor level below @p level. */
48 Q_INVOKABLE int floorLevelBelow(int level) const;
49 /** Returns @c true when we can still go further up. */
50 Q_INVOKABLE bool hasFloorLevelAbove(int level) const;
51 /** Returns the floor level above @p level. */
52 Q_INVOKABLE int floorLevelAbove(int level) const;
53
54 /** Returns whether the given floor level has an explicit name
55 * obtained from the OSM data.
56 */
57 Q_INVOKABLE bool hasName(int level) const;
58 /** Returns the name for the floor @p level.
59 * This is either an explicitly determined name from the OSM data
60 * or a numeric representation of the floor.
61 */
62 Q_INVOKABLE QString name(int level) const;
63
64 /** We have more than the base/outdoor floor levels. */
65 bool hasFloorLevels() const;
66
67Q_SIGNALS:
68 void contentChanged();
69
70private:
71 std::vector<MapLevel> m_level;
72};
73
74}
75
76#endif // KOSMINDOORMAP_FLOORLEVELMODEL_H
Raw OSM map data, separated by levels.
Definition mapdata.h:60
OSM-based multi-floor indoor maps for buildings.
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.