diff options
author | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-10-24 11:02:20 +0200 |
---|---|---|
committer | Maurice Kalinowski <maurice.kalinowski@qt.io> | 2016-11-04 06:21:20 +0000 |
commit | e0c93fc1530f1a325f2ac514fb61e6b9f78872d0 (patch) | |
tree | 2bbe8418153d575cd94ff257f692c84654e5365e /src | |
parent | 91568e6301653a6e5e41a45b60eca53a2a9001b1 (diff) | |
download | qtlocation-e0c93fc1530f1a325f2ac514fb61e6b9f78872d0.tar.gz |
winrt: Use backend provided timestamps
IGeoCoordinate does provide a timestamp in system time. This value
should be used to provide a timestamp to be forwarded to the user. In
case the information provided is invalid, an invalid QDateTime is used
for the position update.
Task-number: QTBUG-56623
Change-Id: If476b41e5fd183edf33742d8e4401236a32c6037
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp index 5dbbacb5..4564c76a 100644 --- a/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp +++ b/src/plugins/position/winrt/qgeopositioninfosource_winrt.cpp @@ -331,7 +331,7 @@ void QGeoPositionInfoSourceWinRT::virtualPositionUpdate() // We can only do this if we received a valid position before if (d->lastPosition.isValid()) { QGeoPositionInfo sent = d->lastPosition; - sent.setTimestamp(QDateTime::currentDateTime()); + sent.setTimestamp(sent.timestamp().addMSecs(updateInterval())); d->lastPosition = sent; emit positionUpdated(sent); } @@ -474,7 +474,24 @@ HRESULT QGeoPositionInfoSourceWinRT::onPositionChanged(IGeolocator *locator, IPo currentInfo.setAttribute(QGeoPositionInfo::GroundSpeed, value); } - currentInfo.setTimestamp(QDateTime::currentDateTime()); + DateTime dateTime; + hr = coord->get_Timestamp(&dateTime); + + if (dateTime.UniversalTime > 0) { + ULARGE_INTEGER uLarge; + uLarge.QuadPart = dateTime.UniversalTime; + FILETIME fileTime; + fileTime.dwHighDateTime = uLarge.HighPart; + fileTime.dwLowDateTime = uLarge.LowPart; + SYSTEMTIME systemTime; + if (FileTimeToSystemTime(&fileTime, &systemTime)) { + currentInfo.setTimestamp(QDateTime(QDate(systemTime.wYear, systemTime.wMonth, + systemTime.wDay), + QTime(systemTime.wHour, systemTime.wMinute, + systemTime.wSecond, systemTime.wMilliseconds), + Qt::UTC)); + } + } emit nativePositionUpdate(currentInfo); |