Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qnmeapositioninfosource_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4#ifndef QNMEAPOSITIONINFOSOURCE_P_H
5#define QNMEAPOSITIONINFOSOURCE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
20
21#include <QObject>
22#include <QQueue>
23#include <QPointer>
24#include <QtCore/qtimer.h>
25#include <QtCore/private/qglobal_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class QBasicTimer;
30class QTimerEvent;
31class QTimer;
32
33class QNmeaReader;
35{
36 QGeoPositionInfo info;
37 bool hasFix;
38};
39
40
42{
44public:
47
48 void startUpdates();
49 void stopUpdates();
50 void requestUpdate(int msec);
51
52 bool parsePosInfoFromNmeaData(QByteArrayView data,
53 QGeoPositionInfo *posInfo,
54 bool *hasFix);
55
56 void notifyNewUpdate(QGeoPositionInfo *update, bool fixStatus);
57
60 QGeoPositionInfo m_lastUpdate;
64
65public Q_SLOTS:
66 void readyRead();
67
68protected:
69 void timerEvent(QTimerEvent *event) override;
70
71private Q_SLOTS:
72 void emitPendingUpdate();
73 void sourceDataClosed();
74 void updateRequestTimeout();
75
76private:
77 bool openSourceDevice();
78 bool initialize();
79 void prepareSourceDevice();
80 void emitUpdated(const QGeoPositionInfo &update);
81
82 QNmeaPositionInfoSource *m_source;
83 QNmeaReader *m_nmeaReader;
84 QGeoPositionInfo m_pendingUpdate;
85 QDate m_currentDate;
86 QBasicTimer *m_updateTimer; // the timer used in startUpdates()
87 QTimer *m_requestTimer; // the timer used in requestUpdate()
88 qreal m_horizontalAccuracy;
89 qreal m_verticalAccuracy;
90 bool m_noUpdateLastInterval;
91 bool m_updateTimeoutSent;
92 bool m_connectedReadyRead;
93};
94
95
97{
98public:
100 : m_proxy(sourcePrivate) {}
101 virtual ~QNmeaReader();
102
103 virtual void readAvailableData() = 0;
104
105protected:
107};
108
109
111{
112public:
115
116 void readAvailableData() override;
117 void notifyNewUpdate();
118
119 // Data members
120 QGeoPositionInfo m_update;
122 bool m_updateParsed = false;
123 bool m_hasFix = false;
124 QTimer m_timer;
125 int m_pushDelay = -1;
126};
127
128
130{
132public:
135 void readAvailableData() override;
136
137protected:
138 void timerEvent(QTimerEvent *event) override;
139
140private Q_SLOTS:
142
143private:
144 bool setFirstDateTime();
145 void processNextSentence();
146
147 QQueue<QPendingGeoPositionInfo> m_pendingUpdates;
148 QByteArray m_nextLine;
149 int m_currTimerId;
150 bool m_hasValidDateTime;
151};
152
153QT_END_NAMESPACE
154
155#endif
void notifyNewUpdate(QGeoPositionInfo *update, bool fixStatus)
bool parsePosInfoFromNmeaData(QByteArrayView data, QGeoPositionInfo *posInfo, bool *hasFix)
QGeoPositionInfoSource::Error m_positionError
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
QNmeaReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
QNmeaPositionInfoSourcePrivate * m_proxy
virtual void readAvailableData()=0
virtual ~QNmeaReader()
~QNmeaRealTimeReader() override
QNmeaRealTimeReader(QNmeaPositionInfoSourcePrivate *sourcePrivate)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
#define USE_POSITION_NMEA_PIMPL
static bool propagateCoordinate(QGeoPositionInfo &dst, const QGeoPositionInfo &src, bool force=true)
static int processSentence(QGeoPositionInfo &info, QByteArray &m_nextLine, QNmeaPositionInfoSourcePrivate *m_proxy, QQueue< QPendingGeoPositionInfo > &m_pendingUpdates, bool &hasFix)
static bool propagateAttributes(QGeoPositionInfo &dst, const QGeoPositionInfo &src, bool force=true)
static qint64 msecsTo(const QDateTime &from, const QDateTime &to)
static bool propagateDate(QGeoPositionInfo &dst, const QGeoPositionInfo &src)
static bool mergePositions(QGeoPositionInfo &dst, const QGeoPositionInfo &src, QByteArray nmeaSentence)