summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/sensors/qsensor.cpp19
-rw-r--r--src/sensors/qsensor.h2
-rw-r--r--src/sensors/qsensor_p.h6
3 files changed, 23 insertions, 4 deletions
diff --git a/src/sensors/qsensor.cpp b/src/sensors/qsensor.cpp
index e3298ae62f..405347bebe 100644
--- a/src/sensors/qsensor.cpp
+++ b/src/sensors/qsensor.cpp
@@ -196,16 +196,29 @@ static int qoutputrangelist_id = qRegisterMetaType<QtMobility::qoutputrangelist>
\since 1.0
*/
+void QSensorPrivate::init(const QByteArray &sensorType)
+{
+ type = sensorType;
+ q->registerInstance(); // so the availableSensorsChanged() signal works
+}
/*!
Construct the \a type sensor as a child of \a parent.
\since 1.0
*/
QSensor::QSensor(const QByteArray &type, QObject *parent)
: QObject(parent)
- , d(new QSensorPrivate)
+ , d(new QSensorPrivate(this))
+{
+ d->init(type);
+}
+
+/*!
+ \internal
+ */
+QSensor::QSensor(const QByteArray &type, QSensorPrivate *dd, QObject *parent)
+ : QObject(parent), d(dd)
{
- d->type = type;
- registerInstance(); // so the availableSensorsChanged() signal works
+ d->init(type);
}
/*!
diff --git a/src/sensors/qsensor.h b/src/sensors/qsensor.h
index a75a9c6611..dc003bddf6 100644
--- a/src/sensors/qsensor.h
+++ b/src/sensors/qsensor.h
@@ -171,12 +171,14 @@ Q_SIGNALS:
void dataRateChanged();
protected:
+ QSensor(const QByteArray &type, QSensorPrivate *dd, QObject* parent = 0);
// called by the back end
QSensorPrivate *d_func() const { return d.data(); }
private:
void registerInstance();
+ friend class QSensorPrivate;
QScopedPointer<QSensorPrivate> d;
Q_DISABLE_COPY(QSensor)
};
diff --git a/src/sensors/qsensor_p.h b/src/sensors/qsensor_p.h
index 1aa3fdef16..02f31c7c59 100644
--- a/src/sensors/qsensor_p.h
+++ b/src/sensors/qsensor_p.h
@@ -62,7 +62,7 @@ typedef QList<QSensorFilter*> QFilterList;
class QSensorPrivate
{
public:
- QSensorPrivate()
+ QSensorPrivate(QSensor *sensor)
: identifier()
, type()
, outputRange(-1)
@@ -76,9 +76,12 @@ public:
, error(0)
, alwaysOn(false)
, skipDuplicates(false)
+ , q(sensor)
{
}
+ void init(const QByteArray &sensorType);
+
// meta-data
QByteArray identifier;
QByteArray type;
@@ -104,6 +107,7 @@ public:
bool alwaysOn;
bool skipDuplicates;
+ QSensor *q;
};
class QSensorReadingPrivate