summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins.qnx@kdab.com>2013-02-27 05:22:01 +0000
committerSérgio Martins <sergio.martins.qnx@kdab.com>2013-03-07 13:29:39 +0100
commit4d18883db196e771057e67b7deed4c2a09511a62 (patch)
tree5269642147c58ca55fffcfce7b2b73e582464cf4 /src
parent27e62ecfafa5e3e269eb470e591d51496c58cc1d (diff)
Backport QAmbientTemperatureSensor from QSensors to qt-mobility.
Change-Id: Ibaf0f89cfb8e3f570980b43ff3179afe83e7cb48 Reviewed-by: Thomas McGuire <thomas.mcguire@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/sensors/qambienttemperaturesensor.cpp144
-rw-r--r--src/sensors/qambienttemperaturesensor.h84
-rw-r--r--src/sensors/qambienttemperaturesensor_p.h70
-rw-r--r--src/sensors/sensors.pro1
4 files changed, 299 insertions, 0 deletions
diff --git a/src/sensors/qambienttemperaturesensor.cpp b/src/sensors/qambienttemperaturesensor.cpp
new file mode 100644
index 0000000000..cc43742226
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qambienttemperaturesensor.h>
+#include "qambienttemperaturesensor_p.h"
+
+QTM_BEGIN_NAMESPACE
+
+IMPLEMENT_READING(QAmbientTemperatureReading)
+
+/*!
+ \class QAmbientTemperatureReading
+ \ingroup sensors_reading
+ \inmodule QtSensors
+ \since 1.3
+
+ \brief The QAmbientTemperatureReading class holds readings of the ambient temperature.
+
+ The ambient (room) temperature is the temperature in degree Celsius.
+*/
+
+/*!
+ \property QAmbientTemperatureReading::temperature
+ \brief The ambient temperature
+
+ Measured in degree Celsius.
+*/
+
+qreal QAmbientTemperatureReading::temperature() const
+{
+ return d->temperature;
+}
+
+/*!
+ Sets ambient temperature to \a temperature.
+*/
+void QAmbientTemperatureReading::setTemperature(qreal temperature)
+{
+ d->temperature = temperature;
+}
+
+// =====================================================================
+
+/*!
+ \class QAmbientTemperatureFilter
+ \ingroup sensors_filter
+ \inmodule QtSensors
+ \since 1.3
+
+ \brief The QAmbientTemperatureFilter class is a convenience wrapper around QSensorFilter.
+
+ The only difference is that the filter() method features a pointer to QAmbientTemperatureReading
+ instead of QSensorReading.
+*/
+
+/*!
+ \fn QAmbientTemperatureFilter::filter(QAmbientTemperatureReading *reading)
+
+ Called when \a reading changes. Returns false to prevent the reading from propagating.
+
+ \sa QSensorFilter::filter()
+*/
+
+char const * const QAmbientTemperatureSensor::type("QAmbientTemperatureSensor");
+
+/*!
+ \class QAmbientTemperatureSensor
+ \ingroup sensors_type
+ \inmodule QtSensors
+ \since 1.3
+
+ \brief The QAmbientTemperatureSensor class is a convenience wrapper around QSensor.
+
+ The only behavioural difference is that this class sets the type properly.
+
+ This class also features a reading() function that returns a QAmbientTemperatureReading instead of a QSensorReading.
+
+ For details about how the sensor works, see \l QAmbientTemperatureReading.
+
+ \sa QAmbientTemperatureReading
+*/
+
+/*!
+ Construct the sensor as a child of \a parent.
+*/
+QAmbientTemperatureSensor::QAmbientTemperatureSensor(QObject *parent)
+ : QSensor(QAmbientTemperatureSensor::type, parent)
+{
+}
+
+/*!
+ Destroy the sensor. Stops the sensor if it has not already been stopped.
+*/
+QAmbientTemperatureSensor::~QAmbientTemperatureSensor()
+{
+}
+
+/*!
+ \fn QAmbientTemperatureSensor::reading() const
+
+ Returns the reading class for this sensor.
+
+ \sa QSensor::reading()
+*/
+
+#include "moc_qambienttemperaturesensor.cpp"
+QTM_END_NAMESPACE
diff --git a/src/sensors/qambienttemperaturesensor.h b/src/sensors/qambienttemperaturesensor.h
new file mode 100644
index 0000000000..0d5fc8566b
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_H
+#define QAMBIENTTEMPERATURESENSOR_H
+
+#include <QtSensors/qsensor.h>
+
+QTM_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate;
+
+class Q_SENSORS_EXPORT QAmbientTemperatureReading : public QSensorReading
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal temperature READ temperature)
+ DECLARE_READING(QAmbientTemperatureReading)
+public:
+ qreal temperature() const;
+ void setTemperature(qreal temperature);
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureFilter : public QSensorFilter
+{
+public:
+ virtual bool filter(QAmbientTemperatureReading *reading) = 0;
+private:
+ bool filter(QSensorReading *reading)
+ { return filter(static_cast<QAmbientTemperatureReading*>(reading)); }
+};
+
+class Q_SENSORS_EXPORT QAmbientTemperatureSensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit QAmbientTemperatureSensor(QObject *parent = 0);
+ ~QAmbientTemperatureSensor();
+ QAmbientTemperatureReading *reading() const { return static_cast<QAmbientTemperatureReading*>(QSensor::reading()); }
+ static char const * const type;
+
+private:
+ Q_DISABLE_COPY(QAmbientTemperatureSensor)
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/qambienttemperaturesensor_p.h b/src/sensors/qambienttemperaturesensor_p.h
new file mode 100644
index 0000000000..e5bfa47b88
--- /dev/null
+++ b/src/sensors/qambienttemperaturesensor_p.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Research In Motion
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Mobility Components.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QAMBIENTTEMPERATURESENSOR_P_H
+#define QAMBIENTTEMPERATURESENSOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+QTM_BEGIN_NAMESPACE
+
+class QAmbientTemperatureReadingPrivate
+{
+public:
+ QAmbientTemperatureReadingPrivate()
+ : temperature(0)
+ {
+ }
+
+ qreal temperature;
+};
+
+QTM_END_NAMESPACE
+
+#endif
diff --git a/src/sensors/sensors.pro b/src/sensors/sensors.pro
index 8909969ad6..7f0259a61f 100644
--- a/src/sensors/sensors.pro
+++ b/src/sensors/sensors.pro
@@ -58,6 +58,7 @@ SENSORS=\
qaccelerometer\
qaltimeter\
qambientlightsensor\
+ qambienttemperaturesensor\
qcompass\
qholstersensor\
qlightsensor\