Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGeoAreaMonitorPolling Class Reference

#include <qgeoareamonitor_polling.h>

+ Inheritance diagram for QGeoAreaMonitorPolling:
+ Collaboration diagram for QGeoAreaMonitorPolling:

Public Member Functions

 QGeoAreaMonitorPolling (QObject *parent=0)
 
 ~QGeoAreaMonitorPolling ()
 
void setPositionInfoSource (QGeoPositionInfoSource *source) override
 Sets the new \l QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object.
 
QGeoPositionInfoSourcepositionInfoSource () const override
 Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource object.
 
Error error () const override
 Returns the type of error that last occurred.
 
bool startMonitoring (const QGeoAreaMonitorInfo &monitor) override
 Returns true if the monitoring of monitor could be successfully started; otherwise returns false.
 
bool requestUpdate (const QGeoAreaMonitorInfo &monitor, const char *signal) override
 Enables single shot area monitoring.
 
bool stopMonitoring (const QGeoAreaMonitorInfo &monitor) override
 Returns true if monitor was successfully removed from the list of \l activeMonitors(); otherwise returns false.
 
QList< QGeoAreaMonitorInfoactiveMonitors () const override
 Returns the list of all active monitors known to the QGeoAreaMonitorSource object.
 
QList< QGeoAreaMonitorInfoactiveMonitors (const QGeoShape &region) const override
 Returns the list of all active monitors known to the QGeoAreaMonitorSource object whose center lies within lookupArea.
 
QGeoAreaMonitorSource::AreaMonitorFeatures supportedAreaMonitorFeatures () const override
 Returns the area monitoring features available to this source.
 
bool isValid ()
 
- Public Member Functions inherited from QGeoAreaMonitorSource
 QGeoAreaMonitorSource (QObject *parent)
 Creates a monitor source with the given parent.
 
virtual ~QGeoAreaMonitorSource ()
 Destroys the monitor source.
 
QString sourceName () const
 Returns the unique name of the area monitor source implementation in use.
 
virtual bool setBackendProperty (const QString &name, const QVariant &value)
 
virtual QVariant backendProperty (const QString &name) const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Private Member Functions

void connectNotify (const QMetaMethod &signal) override
 
void disconnectNotify (const QMetaMethod &signal) override
 

Friends

class QGeoAreaMonitorPollingPrivate
 

Additional Inherited Members

- Public Types inherited from QGeoAreaMonitorSource
enum  Error { AccessError = 0 , InsufficientPositionInfo = 1 , UnknownSourceError = 2 , NoError = 3 }
 Defines the types of positioning methods. More...
 
enum  AreaMonitorFeature { PersistentAreaMonitorFeature = 0x00000001 , AnyAreaMonitorFeature = 0xffffffff }
 Defines the types of area monitoring capabilities. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Signals inherited from QGeoAreaMonitorSource
void areaEntered (const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
 Emitted when the current position has moved from a position outside of the active monitor to a position within the monitored area.
 
void areaExited (const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
 Emitted when the current position has moved from a position within the active monitor to a position outside the monitored area.
 
void monitorExpired (const QGeoAreaMonitorInfo &monitor)
 Emitted when monitor has expired.
 
void errorOccurred (QGeoAreaMonitorSource::Error error)
 This signal is emitted after an error occurred.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 
- Static Public Member Functions inherited from QGeoAreaMonitorSource
static QGeoAreaMonitorSourcecreateDefaultSource (QObject *parent)
 Creates and returns a monitor source with the given parent that monitors areas using resources on the underlying system.
 
static QGeoAreaMonitorSourcecreateSource (const QString &sourceName, QObject *parent)
 Creates and returns a monitor source with the given parent, by loading the plugin named sourceName.
 
static QStringList availableSources ()
 Returns a list of available monitor plugins, including the default system backend if one is available.
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

Definition at line 17 of file qgeoareamonitor_polling.h.

Constructor & Destructor Documentation

◆ QGeoAreaMonitorPolling()

QGeoAreaMonitorPolling::QGeoAreaMonitorPolling ( QObject * parent = 0)
explicit

Definition at line 287 of file qgeoareamonitor_polling.cpp.

References QGeoPositionInfoSource::createDefaultSource(), and d.

+ Here is the call graph for this function:

◆ ~QGeoAreaMonitorPolling()

QGeoAreaMonitorPolling::~QGeoAreaMonitorPolling ( )

Definition at line 296 of file qgeoareamonitor_polling.cpp.

References QGeoAreaMonitorPollingPrivate::deregisterClient().

+ Here is the call graph for this function:

Member Function Documentation

◆ activeMonitors() [1/2]

QList< QGeoAreaMonitorInfo > QGeoAreaMonitorPolling::activeMonitors ( ) const
overridevirtual

Returns the list of all active monitors known to the QGeoAreaMonitorSource object.

An active monitor was started via startMonitoring(). For every active monitor the source object will emit the required signals, such as areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances within the same application share the same active monitor objects.

Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo will be stopped once the current application terminates.

Implements QGeoAreaMonitorSource.

Definition at line 393 of file qgeoareamonitor_polling.cpp.

References QGeoAreaMonitorPollingPrivate::activeMonitors(), and QHash< Key, T >::values().

+ Here is the call graph for this function:

◆ activeMonitors() [2/2]

QList< QGeoAreaMonitorInfo > QGeoAreaMonitorPolling::activeMonitors ( const QGeoShape & lookupArea) const
overridevirtual

Returns the list of all active monitors known to the QGeoAreaMonitorSource object whose center lies within lookupArea.

If lookupArea is empty the returned list will be empty.

An active monitor was started via startMonitoring(). For every active monitor the source object will emit the required signals, such as areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances within the same application share the same active monitor objects.

Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo will be stopped once the current application terminates.

See also
QGeoShape

Implements QGeoAreaMonitorSource.

Definition at line 398 of file qgeoareamonitor_polling.cpp.

References QGeoAreaMonitorPollingPrivate::activeMonitors(), QList< T >::append(), QGeoShape::contains(), QGeoShape::isEmpty, list, and results.

+ Here is the call graph for this function:

◆ connectNotify()

void QGeoAreaMonitorPolling::connectNotify ( const QMetaMethod & signal)
overrideprivatevirtual
Since
5.0

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, you can use QMetaMethod::fromSignal() as follows:

if (signal == QMetaMethod::fromSignal(&MyObject::valueChanged)) {
// signal is valueChanged
}
Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.
This function is called from the thread which performs the connection, which may be a different thread from the thread in which this object lives. This function may also be called with a QObject internal mutex locked. It is therefore not allowed to re-enter any QObject functions, including isSignalConnected(), from your reimplementation. If you lock a mutex in your reimplementation, make sure that you don't call QObject functions with that mutex held in other places or it will result in a deadlock.
See also
connect(), disconnectNotify()

Reimplemented from QObject.

Definition at line 418 of file qgeoareamonitor_polling.cpp.

References areaEnteredSignal(), areaExitedSignal(), QGeoAreaMonitorPollingPrivate::checkStartStop(), and signal.

+ Here is the call graph for this function:

◆ disconnectNotify()

void QGeoAreaMonitorPolling::disconnectNotify ( const QMetaMethod & signal)
overrideprivatevirtual
Since
5.0

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

If all signals were disconnected from this object (e.g., the signal argument to disconnect() was \nullptr), disconnectNotify() is only called once, and the signal will be an invalid QMetaMethod (QMetaMethod::isValid() returns false).

Warning
This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.
This function is called from the thread which performs the disconnection, which may be a different thread from the thread in which this object lives. This function may also be called with a QObject internal mutex locked. It is therefore not allowed to re-enter any QObject functions, including isSignalConnected(), from your reimplementation. If you lock a mutex in your reimplementation, make sure that you don't call QObject functions with that mutex held in other places or it will result in a deadlock.
See also
disconnect(), connectNotify()

Reimplemented from QObject.

Definition at line 429 of file qgeoareamonitor_polling.cpp.

References areaEnteredSignal(), areaExitedSignal(), QGeoAreaMonitorPollingPrivate::checkStartStop(), and signal.

+ Here is the call graph for this function:

◆ error()

QGeoAreaMonitorSource::Error QGeoAreaMonitorPolling::error ( ) const
overridevirtual

Returns the type of error that last occurred.

Note
Since Qt6 the last error is always reset when calling startMonitoring() or requestUpdate().

Implements QGeoAreaMonitorSource.

Definition at line 311 of file qgeoareamonitor_polling.cpp.

◆ isValid()

bool QGeoAreaMonitorPolling::isValid ( )
inline

Definition at line 39 of file qgeoareamonitor_polling.h.

References positionInfoSource().

+ Here is the call graph for this function:

◆ positionInfoSource()

QGeoPositionInfoSource * QGeoAreaMonitorPolling::positionInfoSource ( ) const
overridevirtual

Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource object.

The function will return \l QGeoPositionInfoSource::createDefaultSource() if no other object has been set.

The function returns nullptr if not even a default QGeoPositionInfoSource exists.

Any usage of the returned \l QGeoPositionInfoSource instance should account for the fact that it may reside in a different thread.

See also
QGeoPositionInfoSource, setPositionInfoSource()

Reimplemented from QGeoAreaMonitorSource.

Definition at line 301 of file qgeoareamonitor_polling.cpp.

References QGeoAreaMonitorPollingPrivate::positionSource().

Referenced by isValid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ requestUpdate()

bool QGeoAreaMonitorPolling::requestUpdate ( const QGeoAreaMonitorInfo & monitor,
const char * signal )
overridevirtual

Enables single shot area monitoring.

Area monitoring for monitor will be performed until this QGeoAreaMonitorSource instance emits signal for the first time. Once the signal was emitted, monitor is automatically removed from the list of \l activeMonitors(). If monitor is invalid or has an expiry date that has been passed, this function returns false.

QGeoAreaMonitor singleShotMonitor;
//...
bool ret = source->requestUpdate(singleShotMonitor,
SIGNAL(areaExited(QGeoAreaMonitor,QGeoPositionInfo)));
\inmodule QtPositioning
static QGeoAreaMonitorSource * createDefaultSource(QObject *parent)
Creates and returns a monitor source with the given parent that monitors areas using resources on the...
void areaExited(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
Emitted when the current position has moved from a position within the active monitor to a position o...
\inmodule QtPositioning
return ret
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLsizei GLsizei GLchar * source

The above singleShotMonitor object will cease to send updates once the \l areaExited() signal was emitted for the first time. Until this point in time any other signal may be emitted zero or more times depending on the area context.

It is not possible to simultanously request updates for more than one signal of the same monitor object. The last call to this function determines the signal upon which the updates cease to continue. At this stage only the \l areaEntered() and \l areaExited() signals can be used to terminate the monitoring process.

Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.

If monitor was already registered via \l startMonitoring() it is converted to a single shot behavior.

Note
Since Qt6 this method always resets the last error to \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
See also
startMonitoring(), stopMonitoring()

Implements QGeoAreaMonitorSource.

Definition at line 352 of file qgeoareamonitor_polling.cpp.

References areaEnteredSignal(), areaExitedSignal(), QDateTime::currentDateTime(), QGeoAreaMonitorInfo::expiration(), QGeoAreaMonitorInfo::isPersistent(), QDateTime::isValid(), QGeoAreaMonitorInfo::isValid(), QGeoAreaMonitorSource::NoError, QGeoAreaMonitorPollingPrivate::requestUpdate(), and signal.

+ Here is the call graph for this function:

◆ setPositionInfoSource()

void QGeoAreaMonitorPolling::setPositionInfoSource ( QGeoPositionInfoSource * newSource)
overridevirtual

Sets the new \l QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object.

The area monitoring backend becomes the new QObject parent for newSource. The previous \l QGeoPositionInfoSource object will be deleted. All QGeoAreaMonitorSource instances based on the same \l sourceName() share the same QGeoPositionInfoSource instance.

This may be useful when it is desirable to manipulate the positioning system used by the area monitoring engine.

Note that ownership must be taken care of by subclasses of QGeoAreaMonitorSource. Due to the singleton pattern behind this class newSource may be moved to a new thread.

See also
positionInfoSource()

Reimplemented from QGeoAreaMonitorSource.

Definition at line 306 of file qgeoareamonitor_polling.cpp.

References QGeoAreaMonitorPollingPrivate::setPositionSource().

+ Here is the call graph for this function:

◆ startMonitoring()

bool QGeoAreaMonitorPolling::startMonitoring ( const QGeoAreaMonitorInfo & monitor)
overridevirtual

Returns true if the monitoring of monitor could be successfully started; otherwise returns false.

A reason for not being able to start monitoring could be the unavailability of an appropriate default position info source while no alternative QGeoPositionInfoSource has been set via \l setPositionInfoSource().

If monitor is already active, the existing monitor object will be replaced by the new monitor reference. The identification of QGeoAreaMonitorInfo instances happens via \l QGeoAreaMonitorInfo::identifier(). Therefore this function can also be used to update active monitors.

If monitor has an expiry date that has been passed this function returns false. Calling this function for an already via \l requestUpdate() registered single shot monitor switches the monitor to a permanent monitoring mode.

Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.

Note
Since Qt6 this method always resets the last error to \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
See also
stopMonitoring()

Implements QGeoAreaMonitorSource.

Definition at line 316 of file qgeoareamonitor_polling.cpp.

References QDateTime::currentDateTime(), QGeoAreaMonitorInfo::expiration(), QGeoAreaMonitorInfo::isPersistent(), QDateTime::isValid(), QGeoAreaMonitorInfo::isValid(), QGeoAreaMonitorSource::NoError, and QGeoAreaMonitorPollingPrivate::startMonitoring().

+ Here is the call graph for this function:

◆ stopMonitoring()

bool QGeoAreaMonitorPolling::stopMonitoring ( const QGeoAreaMonitorInfo & monitor)
overridevirtual

Returns true if monitor was successfully removed from the list of \l activeMonitors(); otherwise returns false.

This behavior is independent on whether monitor was registered via \l startMonitoring() or \l requestUpdate().

Implements QGeoAreaMonitorSource.

Definition at line 386 of file qgeoareamonitor_polling.cpp.

References info, and QGeoAreaMonitorPollingPrivate::stopMonitoring().

+ Here is the call graph for this function:

◆ supportedAreaMonitorFeatures()

QGeoAreaMonitorSource::AreaMonitorFeatures QGeoAreaMonitorPolling::supportedAreaMonitorFeatures ( ) const
overridevirtual

Returns the area monitoring features available to this source.

Implements QGeoAreaMonitorSource.

Definition at line 413 of file qgeoareamonitor_polling.cpp.

Friends And Related Symbol Documentation

◆ QGeoAreaMonitorPollingPrivate

friend class QGeoAreaMonitorPollingPrivate
friend

Definition at line 49 of file qgeoareamonitor_polling.h.


The documentation for this class was generated from the following files: