Skip to content

Commit 0081c37

Browse files
author
mhugent
committedFeb 3, 2010
Added utc date and time to gps information and insert connection into the registry
git-svn-id: http://svn.osgeo.org/qgis/trunk@12862 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent dfbe471 commit 0081c37

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed
 

‎src/app/gps/qgsgpsinformationwidget.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "qgsgpsinformationwidget.h"
1919
#include "qgsvectorlayer.h"
2020
#include "qgsnmeaconnection.h"
21+
#include "qgsgpsconnectionregistry.h"
2122
#include "qgsgpsdetector.h"
2223
#include "qgscoordinatetransform.h"
2324
#include <qgspoint.h>
@@ -338,12 +339,14 @@ void QgsGPSInformationWidget::connected( QgsGPSConnection *conn )
338339
this, SLOT( displayGPSInformation( const QgsGPSInformation& ) ) );
339340
mGPSTextEdit->append( tr( "Connected!" ) );
340341
mConnectButton->setText( tr( "Disconnect" ) );
342+
//insert connection into registry such that it can also be used by other dialogs or plugins
343+
QgsGPSConnectionRegistry::instance()->registerConnection( mNmea );
341344
}
342345

343346
void QgsGPSInformationWidget::disconnectGps()
344347
{
348+
QgsGPSConnectionRegistry::instance()->unregisterConnection( mNmea );
345349
delete mNmea;
346-
347350
mGPSTextEdit->append( tr( "Disconnected..." ) );
348351
mConnectButton->setChecked( false );
349352
mConnectButton->setText( tr( "Connect" ) );

‎src/core/gps/qgsgpsconnection.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,6 @@ void QgsGPSConnection::clearLastGPSInformation()
9494
mLastGPSInformation.satellitesInView.clear();
9595
mLastGPSInformation.speed = 0;
9696
mLastGPSInformation.vdop = 0;
97+
mLastGPSInformation.utcDateTime.setDate( QDate() );
98+
mLastGPSInformation.utcDateTime.setTime( QTime() );
9799
}

‎src/core/gps/qgsgpsconnection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef QGSGPSCONNECTION_H
1919
#define QGSGPSCONNECTION_H
2020

21+
#include <QDateTime>
2122
#include <QObject>
2223

2324
class QIODevice;
@@ -42,6 +43,7 @@ struct CORE_EXPORT QgsGPSInformation
4243
double pdop;
4344
double hdop;
4445
double vdop;
46+
QDateTime utcDateTime;
4547
};
4648

4749
/**Abstract base class for connection to a GPS device*/

‎src/core/gps/qgsnmeaconnection.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ void QgsNMEAConnection::processRMCSentence( const char* data, int len )
178178
mLastGPSInformation.latitude = nmea_ndeg2degree( latitude );
179179
mLastGPSInformation.speed = KNOTS_TO_KMH * result.speed;
180180
mLastGPSInformation.direction = result.direction;
181+
182+
//date and time
183+
QDate date( result.utc.year, result.utc.day, result.utc.sec );
184+
QTime time( result.utc.hour, result.utc.min, result.utc.sec );
185+
mLastGPSInformation.utcDateTime.setTimeSpec( Qt::UTC );
186+
mLastGPSInformation.utcDateTime.setDate( date );
187+
mLastGPSInformation.utcDateTime.setTime( time );
181188
}
182189
}
183190

0 commit comments

Comments
 (0)