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#ifndef QNMEAPOSITIONINFOSOURCE_P_H
4#define QNMEAPOSITIONINFOSOURCE_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
19
20#include <QObject>
21#include <QQueue>
22#include <QPointer>
23#include <QtCore/qtimer.h>
24#include <QtCore/private/qglobal_p.h>
25
26QT_BEGIN_NAMESPACE
27
28class QBasicTimer;
29class QTimerEvent;
30class QTimer;
31
32class QNmeaReader;
34{
35 QGeoPositionInfo info;
36 bool hasFix;
37};
38
39
41{
43public:
46
47 void startUpdates();
48 void stopUpdates();
49 void requestUpdate(int msec);
50
51 bool parsePosInfoFromNmeaData(QByteArrayView data,
52 QGeoPositionInfo *posInfo,
53 bool *hasFix);
54
55 void notifyNewUpdate(QGeoPositionInfo *update, bool fixStatus);
56
59 QGeoPositionInfo m_lastUpdate;
63
64public Q_SLOTS:
65 void readyRead();
66
67protected:
68 void timerEvent(QTimerEvent *event) override;
69
70private Q_SLOTS:
71 void emitPendingUpdate();
72 void sourceDataClosed();
73 void updateRequestTimeout();
74
75private:
76 bool openSourceDevice();
77 bool initialize();
78 void prepareSourceDevice();
79 void emitUpdated(const QGeoPositionInfo &update);
80
81 QNmeaPositionInfoSource *m_source;
82 QNmeaReader *m_nmeaReader;
83 QGeoPositionInfo m_pendingUpdate;
84 QDate m_currentDate;
85 QBasicTimer *m_updateTimer; // the timer used in startUpdates()
86 QTimer *m_requestTimer; // the timer used in requestUpdate()
87 qreal m_horizontalAccuracy;
88 qreal m_verticalAccuracy;
89 bool m_noUpdateLastInterval;
90 bool m_updateTimeoutSent;
91 bool m_connectedReadyRead;
92};
93
94
96{
97public:
99 : m_proxy(sourcePrivate) {}
100 virtual ~QNmeaReader();
101
102 virtual void readAvailableData() = 0;
103
104protected:
106};
107
108
110{
111public:
114
115 void readAvailableData() override;
116 void notifyNewUpdate();
117
118 // Data members
119 QGeoPositionInfo m_update;
121 bool m_updateParsed = false;
122 bool m_hasFix = false;
123 QTimer m_timer;
124 int m_pushDelay = -1;
125};
126
127
129{
131public:
134 void readAvailableData() override;
135
136protected:
137 void timerEvent(QTimerEvent *event) override;
138
139private Q_SLOTS:
141
142private:
143 bool setFirstDateTime();
144 void processNextSentence();
145
146 QQueue<QPendingGeoPositionInfo> m_pendingUpdates;
147 QByteArray m_nextLine;
148 int m_currTimerId;
149 bool m_hasValidDateTime;
150};
151
152QT_END_NAMESPACE
153
154#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 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)