qtmobility/examples/sensors/grueplugin/gruesensorimpl.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
child 5 453da2cfceef
--- a/qtmobility/examples/sensors/grueplugin/gruesensorimpl.cpp	Fri Apr 16 15:51:22 2010 +0300
+++ b/qtmobility/examples/sensors/grueplugin/gruesensorimpl.cpp	Mon May 03 13:18:40 2010 +0300
@@ -48,15 +48,18 @@
     : QSensorBackend(sensor)
 {
     lightSensor = new QAmbientLightSensor(this);
-    lightSensor->setUpdatePolicy(QSensor::OccasionalUpdates);
     lightSensor->addFilter(this);
+    lightSensor->connectToBackend();
 
-    setSupportedUpdatePolicies(QSensor::OnChangeUpdates | QSensor::OccasionalUpdates);
     setReading<GrueSensorReading>(&m_reading);
+    setDataRates(lightSensor);
+    addOutputRange(0, 1, 0.1);
+    setDescription(QLatin1String("Grue Sensor"));
 }
 
 void gruesensorimpl::start()
 {
+    lightSensor->setDataRate(sensor()->dataRate());
     lightSensor->start();
 }
 
@@ -65,11 +68,6 @@
     lightSensor->stop();
 }
 
-void gruesensorimpl::poll()
-{
-    lightSensor->poll();
-}
-
 bool gruesensorimpl::filter(QAmbientLightReading *reading)
 {
     qreal chance;
@@ -89,8 +87,7 @@
         break;
     }
 
-    if (QSensorBackend::m_sensor->updatePolicy() == QSensor::OccasionalUpdates ||
-            chance != m_reading.chanceOfBeingEaten()) {
+    if (chance != m_reading.chanceOfBeingEaten()) {
         m_reading.setTimestamp(reading->timestamp());
         m_reading.setChanceOfBeingEaten(chance);