diff options
author | Alex Blasche <alexander.blasche@digia.com> | 2013-08-26 09:35:01 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-17 11:38:14 +0200 |
commit | 0ed9f7496656fa0ea52d703c7fddff26c2192857 (patch) | |
tree | ec0d4d7dc638e8018a8896a0b62cc91840c9c23d /src/positioning/doc | |
parent | 87ce030b7b7336e561779dc9516d5ae2242a5d5f (diff) | |
download | qtlocation-0ed9f7496656fa0ea52d703c7fddff26c2192857.tar.gz |
Improve area monitoring API.
1.) QGeoAreaMonitor renamed to QGeoAreaMonitorSource
2.) Add new QGeoAreaMonitorInfo data type encpsulating individual areas to be monitored
3.) Port positionpoll plug-in to new features
4.) Make positionpoll monitor thread safe
4.) Extend and fix the QGeoAreaMonitor unit test
5.) Fix documentation.
Task-number: QTBUG-31711
Change-Id: Icfc982de4753d2f43cb4d15c234eb7b7c039a0c4
Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/positioning/doc')
-rw-r--r-- | src/positioning/doc/snippets/cpp/cppqml.cpp | 40 | ||||
-rw-r--r-- | src/positioning/doc/src/cpp-position.qdoc | 4 | ||||
-rw-r--r-- | src/positioning/doc/src/qtpositioning-plugins.qdoc | 2 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/positioning/doc/snippets/cpp/cppqml.cpp b/src/positioning/doc/snippets/cpp/cppqml.cpp index 5ab23513..95d34b7c 100644 --- a/src/positioning/doc/snippets/cpp/cppqml.cpp +++ b/src/positioning/doc/snippets/cpp/cppqml.cpp @@ -39,9 +39,12 @@ ****************************************************************************/ #include <QtCore/QObject> +#include <QtCore/QDebug> #include <QtCore/QVariant> #include <QtPositioning/QGeoAddress> #include <QtPositioning/QGeoLocation> +#include <QtPositioning/QGeoCircle> +#include <QtPositioning/QGeoAreaMonitorSource> void cppQmlInterface(QObject *qmlObject) { @@ -62,3 +65,40 @@ void cppQmlInterface(QObject *qmlObject) //! [Location set] } +class MyClass : public QObject +{ + Q_OBJECT +//! [BigBen] +public: + MyClass() : QObject() + { + QGeoAreaMonitorSource *monitor = QGeoAreaMonitorSource::createDefaultMonitorSource(this); + if (monitor) { + connect(monitor, SIGNAL(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)), + this, SLOT(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)); + connect(monitor, SIGNAL(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)), + this, SLOT(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo))); + + QGeoAreaMonitorInfo bigBen("Big Ben"); + QGeoCoordinate position(51.50104, -0.124632); + bigBen.setMonitoredArea(QGeoCircle(position, 100)); + + monitor->startMonitoring(bigBen); + + } else { + qDebug() << "Could not create default area monitor"; + } + } + +public Q_SLOTS: + void areaEntered(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update) + { + qDebug() << "Now within 100 meters, current position is" << update.coordinate(); + } + + void areaExited(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update) + { + qDebug() << "No longer within 100 meters, current position is" << update.coordinate(); + } +//! [BigBen] +}; diff --git a/src/positioning/doc/src/cpp-position.qdoc b/src/positioning/doc/src/cpp-position.qdoc index 75c2e30e..16fceea5 100644 --- a/src/positioning/doc/src/cpp-position.qdoc +++ b/src/positioning/doc/src/cpp-position.qdoc @@ -84,10 +84,10 @@ the platform. If a problem occurs with access to the information source then an \l {QGeoPositionInfoSource::error()}{error()} signal is emitted. -The QGeoAreaMonitor class enables client applications to be notified when +The QGeoAreaMonitorSource class enables client applications to be notified when the receiving device has moved in or out of a particular area, as specified by a coordinate and radius. If the platform provides built-in support for -area monitoring, QGeoAreaMonitor::createDefaultMonitor() returns an instance of +area monitoring, QGeoAreaMonitorSource::createDefaultMonitor() returns an instance of the default area monitor. Satellite information can also be distributed through the diff --git a/src/positioning/doc/src/qtpositioning-plugins.qdoc b/src/positioning/doc/src/qtpositioning-plugins.qdoc index 1ed1be1a..5873aadd 100644 --- a/src/positioning/doc/src/qtpositioning-plugins.qdoc +++ b/src/positioning/doc/src/qtpositioning-plugins.qdoc @@ -61,7 +61,7 @@ The entries have the following meaning: \li Set to \c true if the plugin implements a \l QGeoSatelliteInfoSource. \row \li Monitor - \li Set to \c true if the plugin implements a \l QGeoAreaMonitor. + \li Set to \c true if the plugin implements a \l QGeoAreaMonitorSource. \row \li Priority \li The plugin priority. If multiple plugins have the same provider name, the plugin |