KOSMIndoorMap

gatemodel.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_GATEMODEL_H
8 #define KOSMINDOORMAP_GATEMODEL_H
9 
10 #include "kosmindoormap_export.h"
11 
12 #include <KOSMIndoorMap/MapData>
13 
14 #include <KOSM/Element>
15 
16 #include <QAbstractListModel>
17 
18 namespace KOSMIndoorMap {
19 
20 /** An airport gate. */
21 struct Gate {
22  OSM::Node node;
23  OSM::Element sourceElement;
24  QString name;
25  int level = 0;
26 };
27 
28 
29 /** Lists all airport gates found in the current map.
30  * This also contains the concept of (optional) arrival/departure gates,
31  * for matching gate names from other sources and highlighting those in the output.
32  */
33 class KOSMINDOORMAP_EXPORT GateModel : public QAbstractListModel
34 {
35  Q_OBJECT
36  Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData WRITE setMapData NOTIFY mapDataChanged)
37  Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY mapDataChanged)
38 
39  /** Row indexes of the matched arrival/departure gates, if found and/or set, otherwise @c -1. */
40  Q_PROPERTY(int arrivalGateRow READ arrivalGateRow NOTIFY gateIndexChanged)
41  Q_PROPERTY(int departureGateRow READ departureGateRow NOTIFY gateIndexChanged)
42 public:
43  explicit GateModel(QObject *parent = nullptr);
44  ~GateModel();
45 
46  MapData mapData() const;
47  void setMapData(const MapData &data);
48 
49  bool isEmpty() const;
50 
51  enum Role {
52  CoordinateRole = Qt::UserRole,
53  ElementRole,
54  LevelRole,
55  ArrivalGateRole,
56  DepartureGateRole,
57  HiddenElementRole,
58  };
59  Q_ENUM(Role)
60 
61  int rowCount(const QModelIndex &parent = {}) const override;
62  QVariant data(const QModelIndex & index, int role) const override;
63  QHash<int, QByteArray> roleNames() const override;
64 
65  /** Match arrival/departure gates against what we found in the map data. */
66  Q_INVOKABLE void setArrivalGate(const QString &name);
67  Q_INVOKABLE void setDepartureGate(const QString &name);
68 
69  int arrivalGateRow() const;
70  int departureGateRow() const;
71 
72 Q_SIGNALS:
73  void mapDataChanged();
74  void gateIndexChanged();
75 
76 private:
77  void populateModel();
78  void matchGates();
79  int matchGate(const QString &name) const;
80  void setGateTag(int idx, OSM::TagKey key, bool enabled);
81 
82  std::vector<Gate> m_gates;
83  MapData m_data;
84 
85  struct {
86  OSM::TagKey mxArrival;
87  OSM::TagKey mxDeparture;
88  } m_tagKeys;
89 
90  QString m_arrivalGate;
91  QString m_departureGate;
92  int m_arrivalGateRow = -1;
93  int m_departureGateRow = -1;
94 };
95 
96 }
97 
98 #endif // KOSMINDOORMAP_GATEMODEL_H
OSM-based multi-floor indoor maps for buildings.
Lists all airport gates found in the current map.
Definition: gatemodel.h:33
An airport gate.
Definition: gatemodel.h:21
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:03:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.