blob: ed5a74828258007d0714a40018032a3656dd87ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef TEST_SENSOR_H
#define TEST_SENSOR_H
#include <qsensor.h>
class TestSensorReadingPrivate;
class TestSensorReading : public QSensorReading
{
Q_OBJECT
Q_PROPERTY(int test READ test)
DECLARE_READING(TestSensorReading)
public:
int test() const;
void setTest(int test);
};
class TestSensorFilter : public QSensorFilter
{
public:
virtual bool filter(TestSensorReading *reading) = 0;
private:
bool filter(QSensorReading *reading) override { return filter(static_cast<TestSensorReading*>(reading)); }
};
class TestSensor : public QSensor
{
Q_OBJECT
public:
explicit TestSensor(QObject *parent = 0)
: QSensor(TestSensor::sensorType, parent)
, sensorsChangedEmitted(0)
{
connect(this, SIGNAL(availableSensorsChanged()), this, SLOT(s_availableSensorsChanged()));
}
virtual ~TestSensor() {}
TestSensorReading *reading() const { return static_cast<TestSensorReading*>(QSensor::reading()); }
static const char *sensorType;
// used by the testSensorsChangedSignal test function
int sensorsChangedEmitted;
private slots:
void s_availableSensorsChanged()
{
sensorsChangedEmitted++;
}
};
#endif
|