1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtPositioning module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QGEOPOSITIONINFOSOURCE_H
41#define QGEOPOSITIONINFOSOURCE_H
42
43#include <QtPositioning/QGeoPositionInfo>
44
45#include <QtCore/QObject>
46
47QT_BEGIN_NAMESPACE
48
49class QGeoPositionInfoSourcePrivate;
50class Q_POSITIONING_EXPORT QGeoPositionInfoSource : public QObject
51{
52 Q_OBJECT
53 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval)
54 Q_PROPERTY(int minimumUpdateInterval READ minimumUpdateInterval)
55 Q_PROPERTY(QString sourceName READ sourceName)
56
57public:
58 enum Error {
59 AccessError = 0,
60 ClosedError = 1,
61 UnknownSourceError = 2,
62 NoError = 3
63 };
64 Q_ENUMS(Error)
65
66 enum PositioningMethod {
67 NoPositioningMethods = 0x00000000,
68 SatellitePositioningMethods = 0x000000ff,
69 NonSatellitePositioningMethods = 0xffffff00,
70 AllPositioningMethods = 0xffffffff
71 };
72 Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod)
73
74 explicit QGeoPositionInfoSource(QObject *parent);
75 virtual ~QGeoPositionInfoSource();
76
77 virtual void setUpdateInterval(int msec);
78 int updateInterval() const;
79
80 virtual void setPreferredPositioningMethods(PositioningMethods methods);
81 PositioningMethods preferredPositioningMethods() const;
82
83 virtual QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const = 0;
84
85 virtual PositioningMethods supportedPositioningMethods() const = 0;
86 virtual int minimumUpdateInterval() const = 0;
87
88 QString sourceName() const;
89
90 bool setBackendProperty(const QString &name, const QVariant &value);
91 QVariant backendProperty(const QString &name) const;
92
93 static QGeoPositionInfoSource *createDefaultSource(QObject *parent);
94 static QGeoPositionInfoSource *createDefaultSource(const QVariantMap &parameters, QObject *parent);
95 static QGeoPositionInfoSource *createSource(const QString &sourceName, QObject *parent);
96 static QGeoPositionInfoSource *createSource(const QString &sourceName, const QVariantMap &parameters, QObject *parent);
97 static QStringList availableSources();
98 virtual Error error() const = 0;
99
100public Q_SLOTS:
101 virtual void startUpdates() = 0;
102 virtual void stopUpdates() = 0;
103
104 virtual void requestUpdate(int timeout = 0) = 0;
105
106Q_SIGNALS:
107 void positionUpdated(const QGeoPositionInfo &update);
108 void updateTimeout();
109 void error(QGeoPositionInfoSource::Error);
110 void supportedPositioningMethodsChanged();
111
112protected:
113 explicit QGeoPositionInfoSource(QGeoPositionInfoSourcePrivate &dd, QObject *parent);
114
115private:
116 Q_DISABLE_COPY(QGeoPositionInfoSource)
117 QGeoPositionInfoSourcePrivate *d;
118
119 friend class QGeoPositionInfoSourcePrivate;
120};
121
122Q_DECLARE_OPERATORS_FOR_FLAGS(QGeoPositionInfoSource::PositioningMethods)
123
124QT_END_NAMESPACE
125
126#endif
127

source code of qtlocation/src/positioning/qgeopositioninfosource.h