1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMLCOMPASS_P_H
5#define QMLCOMPASS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include "qmlsensor_p.h"
19
20QT_BEGIN_NAMESPACE
21
22class QCompass;
23
24class Q_SENSORSQUICK_PRIVATE_EXPORT QmlCompass : public QmlSensor
25{
26 Q_OBJECT
27 QML_NAMED_ELEMENT(Compass)
28 QML_ADDED_IN_VERSION(5,0)
29public:
30 explicit QmlCompass(QObject *parent = 0);
31 ~QmlCompass();
32
33 QSensor *sensor() const override;
34
35private:
36 QCompass *m_sensor;
37 QmlSensorReading *createReading() const override;
38};
39
40class Q_SENSORSQUICK_PRIVATE_EXPORT QmlCompassReading : public QmlSensorReading
41{
42 Q_OBJECT
43 Q_PROPERTY(qreal azimuth READ azimuth NOTIFY azimuthChanged BINDABLE bindableAzimuth)
44 Q_PROPERTY(qreal calibrationLevel READ calibrationLevel
45 NOTIFY calibrationLevelChanged BINDABLE bindableCalibrationLevel)
46 QML_NAMED_ELEMENT(CompassReading)
47 QML_UNCREATABLE("Cannot create CompassReading")
48 QML_ADDED_IN_VERSION(5,0)
49public:
50 explicit QmlCompassReading(QCompass *sensor);
51 ~QmlCompassReading();
52
53 qreal azimuth() const;
54 QBindable<qreal> bindableAzimuth() const;
55 qreal calibrationLevel() const;
56 QBindable<qreal> bindableCalibrationLevel() const;
57
58Q_SIGNALS:
59 void azimuthChanged();
60 void calibrationLevelChanged();
61
62private:
63 QSensorReading *reading() const override;
64 void readingUpdate() override;
65 QCompass *m_sensor;
66 Q_OBJECT_BINDABLE_PROPERTY(QmlCompassReading, qreal,
67 m_azimuth, &QmlCompassReading::azimuthChanged)
68 Q_OBJECT_BINDABLE_PROPERTY(QmlCompassReading, qreal,
69 m_calibrationLevel, &QmlCompassReading::calibrationLevelChanged)
70};
71
72QT_END_NAMESPACE
73#endif
74

source code of qtsensors/src/sensorsquick/qmlcompass_p.h