Skip to content
Permalink
Browse files

Allow Qt5::Positioning as alternative to QtMobility/QtLocation

  • Loading branch information
m-kuhn committed May 4, 2015
1 parent 72cfe46 commit 72eb1aae976dce2e2060490388773d88f17bd3fe
@@ -242,6 +242,7 @@ IF (ENABLE_QT5)
FIND_PACKAGE(Qt5Svg REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
FIND_PACKAGE(Qt5Test REQUIRED)
@@ -337,11 +337,11 @@ ELSE (WITH_INTERNAL_QEXTSERIALPORT)
INCLUDE_DIRECTORIES(${QEXTSERIALPORT_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_QEXTSERIALPORT)

IF (QT_MOBILITY_LOCATION_FOUND)
IF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
gps/qgsqtlocationconnection.cpp
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
ENDIF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)

ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll)

@@ -450,11 +450,11 @@ IF (WITH_INTERNAL_QEXTSERIALPORT)
)
ENDIF (WITH_INTERNAL_QEXTSERIALPORT)

IF (QT_MOBILITY_LOCATION_FOUND)
IF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
gps/qgsqtlocationconnection.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
ENDIF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)

QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})

@@ -666,11 +666,12 @@ SET(QGIS_CORE_HDRS
layertree/qgslayertreeutils.h
)

IF (QT_MOBILITY_LOCATION_FOUND)
IF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)
SET(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
gps/qgsgpsconnectionregistry.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)
ENDIF (QT_MOBILITY_LOCATION_FOUND OR Qt5Positioning_FOUND)

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
@@ -762,7 +763,7 @@ IF (NOT WITH_INTERNAL_QEXTSERIALPORT)
ENDIF (NOT WITH_INTERNAL_QEXTSERIALPORT)

IF (QT_MOBILITY_LOCATION_FOUND)
TARGET_LINK_LIBRARIES(qgis_core ${QT_MOBILITY_LOCATION_LIBRARY})
TARGET_LINK_LIBRARIES(qgis_core ${QT_MOBILITY_LOCATION_LIBRARY})
ENDIF (QT_MOBILITY_LOCATION_FOUND)

TARGET_LINK_LIBRARIES(qgis_core
@@ -783,6 +784,12 @@ TARGET_LINK_LIBRARIES(qgis_core
${SPATIALITE_LIBRARY}
)

IF (Qt5Positioning_FOUND)
TARGET_LINK_LIBRARIES(qgis_core
Qt5::Positioning
)
ENDIF (Qt5Positioning_FOUND)

# install

INSTALL(TARGETS qgis_core
@@ -22,7 +22,7 @@
#include "qgsnmeaconnection.h"
#include "qgsgpsdconnection.h"

#ifdef HAVE_QT_MOBILITY_LOCATION
#if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
#include "qgsqtlocationconnection.h"
#endif

@@ -35,7 +35,7 @@ QList< QPair<QString, QString> > QgsGPSDetector::availablePorts()
QList< QPair<QString, QString> > devs;

// try local QtLocation first
#ifdef HAVE_QT_MOBILITY_LOCATION
#if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
devs << QPair<QString, QString>( "internalGPS", tr( "internal GPS" ) );
#endif
// try local gpsd first
@@ -155,7 +155,7 @@ void QgsGPSDetector::advance()
}
else if ( mPortList[ mPortIndex ].first.contains( "internalGPS" ) )
{
#ifdef HAVE_QT_MOBILITY_LOCATION
#if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
mConn = new QgsQtLocationConnection();
#else
qWarning( "QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
@@ -27,8 +27,8 @@ QgsQtLocationConnection::QgsQtLocationConnection(): QgsGPSConnection( new QLocal
//needed to fix https://sourceforge.net/p/necessitas/tickets/146/
qRegisterMetaType< QList<QGeoSatelliteInfo> >( "QList<QGeoSatelliteInfo>" );

startGPS();
startSatelliteMonitor();
startGPS();

//HACK to signal the gpsinformationwidget that we have a QtLocationConnection
QTimer::singleShot( 500, this, SLOT( broadcastConnectionAvailable() ) );
@@ -65,7 +65,6 @@ void QgsQtLocationConnection::parseData()
{
mStatus = GPSDataReceived;
//const QGeoPositionInfo &info = locationDataSource->lastKnownPosition();
qDebug() << mInfo;
if ( mInfo.isValid() )
{
// mInfo.HorizontalAccuracy;
@@ -110,7 +109,11 @@ void QgsQtLocationConnection::satellitesInViewUpdated(
QgsSatelliteInfo satelliteInfo;
satelliteInfo.azimuth = currentSatellite.attribute( QGeoSatelliteInfo::Azimuth );
satelliteInfo.elevation = currentSatellite.attribute( QGeoSatelliteInfo::Elevation );
#if defined(HAVE_QT_MOBILITY_LOCATION )
satelliteInfo.id = currentSatellite.prnNumber();
#else // QtPositioning
satelliteInfo.id = currentSatellite.satelliteIdentifier();
#endif
satelliteInfo.signal = currentSatellite.signalStrength();
mLastGPSInformation.satellitesInView.append( satelliteInfo );
}
@@ -130,13 +133,21 @@ void QgsQtLocationConnection::satellitesInUseUpdated(
{
QGeoSatelliteInfo currentSatellite = satellites.at( i );
//add pnr to mLastGPSInformation.satPrn
#if defined(HAVE_QT_MOBILITY_LOCATION )
mLastGPSInformation.satPrn.append( currentSatellite.prnNumber() );
#else // QtPositioning
mLastGPSInformation.satPrn.append( currentSatellite.satelliteIdentifier() );
#endif

//set QgsSatelliteInfo.inuse to true for the satellites in use
for ( int i = 0; i < mLastGPSInformation.satellitesInView.size(); ++i )
{
QgsSatelliteInfo satInView = mLastGPSInformation.satellitesInView.at( i );
#if defined(HAVE_QT_MOBILITY_LOCATION )
if ( satInView.id == currentSatellite.prnNumber() )
#else // QtPositioning
if ( satInView.id == currentSatellite.satelliteIdentifier() )
#endif
{
satInView.inUse = true;
break;
@@ -184,6 +195,7 @@ void QgsQtLocationConnection::startGPS()
void QgsQtLocationConnection::startSatelliteMonitor()
{
QgsDebugMsg( "Starting GPS QtLocation satellite monitor" );

if ( !satelliteInfoSource )
{
satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource( this );
@@ -19,12 +19,20 @@
#define QGSQTLOCATIONCONNECTION_H

#include "qgsgpsconnection.h"

#include <QtCore/QPointer>
#include <QtLocation/QGeoPositionInfoSource>
#include <QtLocation/QGeoSatelliteInfo>
#include <QtLocation/QGeoSatelliteInfoSource>

QTM_USE_NAMESPACE
#if defined(HAVE_QT_MOBILITY_LOCATION )
#include <QtLocation/QGeoPositionInfoSource>
#include <QtLocation/QGeoSatelliteInfo>
#include <QtLocation/QGeoSatelliteInfoSource>

QTM_USE_NAMESPACE
#else // Using QtPositioning
#include <QtPositioning/QGeoPositionInfoSource>
#include <QtPositioning/QGeoSatelliteInfo>
#include <QtPositioning/QGeoSatelliteInfoSource>
#endif

class CORE_EXPORT QgsQtLocationConnection: public QgsGPSConnection
{

0 comments on commit 72eb1aa

Please sign in to comment.
You can’t perform that action at this time.