sensoritem.h Example File
sensor_explorer/import/sensoritem.h
#ifndef QSENSORITEM_H
#define QSENSORITEM_H
#include <QtQml/QtQml>
#include <QtCore/QString>
#include "propertyinfo.h"
class QSensor;
class QSensorItem : public QObject
{
Q_OBJECT
Q_PROPERTY(bool start READ start WRITE setStart NOTIFY startChanged)
Q_PROPERTY(QString id READ id CONSTANT)
Q_PROPERTY(QQmlListProperty<QPropertyInfo> properties READ properties NOTIFY propertiesChanged)
public:
QSensorItem(QObject* parent = 0);
QSensorItem(QSensor* sensor, QObject* parent = 0);
virtual ~QSensorItem();
public slots:
void select();
void unSelect();
void changePropertyValue(QPropertyInfo* property, const QString& val);
private slots:
void sensorReadingChanged();
private:
QString id();
bool start();
void setStart(bool run);
QQmlListProperty<QPropertyInfo> properties();
QString convertValue(const QString& type, const QVariant& val);
bool isWriteable(const QString& propertyname);
bool ignoreProperty(const QString& propertyname);
void updateSensorPropertyValues();
Q_SIGNALS:
void propertiesChanged();
void startChanged();
private:
QSensor* _qsensor;
QList<QPropertyInfo*> _properties;
QList<QPropertyInfo*> _readerProperties;
QList<QPropertyInfo*> _sensorProperties;
};
QML_DECLARE_TYPE(QSensorItem)
#endif // QSENSORITEM_H