KOSMIndoorMap

locationqueryoverlayproxymodel.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_LOCATIONQUERYOVERLAYPROXYMODEL_H
8 #define KOSMINDOORMAP_LOCATIONQUERYOVERLAYPROXYMODEL_H
9 
10 #include <QAbstractItemModel>
11 
12 #include <KOSMIndoorMap/MapData>
13 
14 namespace OSM {
15 class Element;
16 class Node;
17 }
18 
19 namespace KOSMIndoorMap {
20 
21 /** Adapts a KPublicTransport::LocationQueryModel to be compatible with a KOSMIndoorMap::OverlaySource.
22  */
24 {
25  Q_OBJECT
26  Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData WRITE setMapData NOTIFY mapDataChanged)
27  Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged)
28 
29 public:
30  explicit LocationQueryOverlayProxyModel(QObject *parent = nullptr);
32 
33  MapData mapData() const;
34  void setMapData(const MapData &data);
35 
36  QObject *sourceModel() const;
37  void setSourceModel(QObject *sourceModel);
38 
39  enum Role {
40  ElementRole = Qt::UserRole,
41  LevelRole,
42  HiddenElementRole,
43  };
44  Q_ENUM(Role)
45 
46  int rowCount(const QModelIndex &parent = {}) const override;
47  QVariant data(const QModelIndex & index, int role) const override;
48  QHash<int, QByteArray> roleNames() const override;
49 
50 Q_SIGNALS:
51  void mapDataChanged();
52  void sourceModelChanged();
53 
54 private:
55  struct Info {
56  OSM::Node overlayNode;
57  OSM::Element sourceElement;
58  };
59 
60  void initialize();
61  Info nodeForRow(int row) const;
62 
63  struct {
64  OSM::TagKey name;
65  OSM::TagKey amenity;
66  OSM::TagKey capacity;
67  OSM::TagKey realtimeAvailable;
68  OSM::TagKey network;
69  OSM::TagKey mxoid;
70  OSM::TagKey remainingRange;
71  OSM::TagKey vehicle;
72  } m_tagKeys;
73  OSM::TagKey m_realtimeAvailableTagKeys[5];
74 
75  std::vector<Info> m_nodes;
76  MapData m_data;
77  QAbstractItemModel *m_sourceModel = nullptr;
78 };
79 
80 }
81 
82 #endif // KOSMINDOORMAP_LOCATIONQUERYOVERLAYPROXYMODEL_H
OSM-based multi-floor indoor maps for buildings.
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition: element.h:22
A key of an OSM tag.
Definition: datatypes.h:179
An OSM node.
Definition: datatypes.h:194
UserRole
Raw OSM map data, separated by levels.
Definition: mapdata.h:59
Adapts a KPublicTransport::LocationQueryModel to be compatible with a KOSMIndoorMap::OverlaySource.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.