QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgssensormodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgssensormodel.h
3 ---------------
4 begin : March 2023
5 copyright : (C) 2023 by Mathieu pellerin
6 email : mathieu at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSSENSORMODEL_H
17#define QGSSENSORMODEL_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QAbstractItemModel>
23
25
32class CORE_EXPORT QgsSensorModel: public QAbstractItemModel
33{
34 Q_OBJECT
35
36 public:
37
39 enum class Column : int
40 {
41 Name = 0,
42 LastValue = 1,
43 };
44
45 // *INDENT-OFF*
46
54 {
55 SensorType = Qt::UserRole + 1,
56 SensorId,
57 SensorName,
58 SensorStatus,
59 SensorLastValue,
60 SensorLastTimestamp,
61 Sensor,
62 };
63 Q_ENUM( CustomRole )
64 // *INDENT-ON*
65
66
69 explicit QgsSensorModel( QgsSensorManager *manager, QObject *parent SIP_TRANSFERTHIS = nullptr );
70
71 QVariant data( const QModelIndex &index, int role ) const override;
72 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
73 Qt::ItemFlags flags( const QModelIndex &index ) const override;
74 QVariant headerData( int section, Qt::Orientation orientation,
75 int role = Qt::DisplayRole ) const override;
76 QModelIndex index( int row, int column,
77 const QModelIndex &parent = QModelIndex() ) const override;
78 QModelIndex parent( const QModelIndex &index ) const override;
79 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
80 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
81
82 private slots:
83
84 void sensorAdded( const QString &id );
85 void sensorRemoved( const QString &id );
86 void sensorNameChanged( const QString &id );
87 void sensorStatusChanged( const QString &id );
88 void sensorDataCaptured( const QString &id );
89
90 private:
91
92 QgsSensorManager *mSensorManager = nullptr;
93 QStringList mSensorIds;
94};
95
96#endif //QGSSENSORMODEL_H
Manages sensors.
A QAbstractItemModel subclass for showing sensors within a QgsSensorManager.
Column
Model columns.
CustomRole
Custom model roles.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition: qgis_sip.h:271