QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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
46 enum Role
47 {
48 SensorType = Qt::UserRole + 1,
55 };
56
60 explicit QgsSensorModel( QgsSensorManager *manager, QObject *parent SIP_TRANSFERTHIS = nullptr );
61
62 QVariant data( const QModelIndex &index, int role ) const override;
63 bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) override;
64 Qt::ItemFlags flags( const QModelIndex &index ) const override;
65 QVariant headerData( int section, Qt::Orientation orientation,
66 int role = Qt::DisplayRole ) const override;
67 QModelIndex index( int row, int column,
68 const QModelIndex &parent = QModelIndex() ) const override;
69 QModelIndex parent( const QModelIndex &index ) const override;
70 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
71 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
72
73 private slots:
74
75 void sensorAdded( const QString &id );
76 void sensorRemoved( const QString &id );
77 void sensorNameChanged( const QString &id );
78 void sensorStatusChanged( const QString &id );
79 void sensorDataCaptured( const QString &id );
80
81 private:
82
83 QgsSensorManager *mSensorManager = nullptr;
84 QStringList mSensorIds;
85};
86
87#endif //QGSSENSORMODEL_H
Manages sensors.
A QAbstractItemModel subclass for showing sensors within a QgsSensorManager.
Column
Model columns.
Role
Custom model roles.
@ SensorStatus
Sensor status (disconnected, connected, etc.)
@ SensorId
Sensor id.
@ SensorLastValue
Sensor last captured value.
@ SensorName
Sensor name.
@ Sensor
Sensor object pointer.
@ SensorLastTimestamp
Sensor timestamp of last captured value.
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53