File indexing completed on 2024-05-12 04:42:08

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KOSMINDOORMAP_REALTIMEEQUIPMENTMODEL_H
0008 #define KOSMINDOORMAP_REALTIMEEQUIPMENTMODEL_H
0009 
0010 #include <KOSMIndoorMap/EquipmentModel>
0011 
0012 #include <qqmlregistration.h>
0013 
0014 namespace KPublicTransport {
0015 class Equipment;
0016 }
0017 
0018 class QAbstractItemModel;
0019 
0020 namespace KOSMIndoorMap {
0021 
0022 /** Elevator/escalator overlay source augmented with realtime status data where available. */
0023 class RealtimeEquipmentModel : public EquipmentModel
0024 {
0025     Q_OBJECT
0026     Q_PROPERTY(QObject* realtimeModel READ realtimeModel WRITE setRealtimeModel NOTIFY realtimeModelChanged)
0027     QML_ELEMENT
0028 
0029 public:
0030     explicit RealtimeEquipmentModel(QObject *parent = nullptr);
0031     ~RealtimeEquipmentModel();
0032 
0033     QObject *realtimeModel() const;
0034     void setRealtimeModel(QObject *model);
0035 
0036 Q_SIGNALS:
0037     void realtimeModelChanged();
0038 
0039 private:
0040     void updateRealtimeState();
0041     void updateEquipment(Equipment &eq, const KPublicTransport::Equipment &rtEq) const;
0042     void resolveEquipmentPair(int eqRow1, int eqRow2, int rtRow1, int rtRow2);
0043 
0044     QPointer<QAbstractItemModel> m_realtimeModel;
0045     bool m_pendingRealtimeUpdate = false;
0046 };
0047 
0048 }
0049 
0050 #endif // KOSMINDOORMAP_REALTIMEEQUIPMENTMODEL_H