Skip to content

Commit

Permalink
Allow Qt5::Positioning as alternative to QtMobility/QtLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed May 4, 2015
1 parent 72cfe46 commit 72eb1aa
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ IF (ENABLE_QT5)
FIND_PACKAGE(Qt5Svg REQUIRED) FIND_PACKAGE(Qt5Svg REQUIRED)
FIND_PACKAGE(Qt5Concurrent REQUIRED) FIND_PACKAGE(Qt5Concurrent REQUIRED)
FIND_PACKAGE(Qt5PrintSupport REQUIRED) FIND_PACKAGE(Qt5PrintSupport REQUIRED)
FIND_PACKAGE(Qt5Positioning)
FIND_PACKAGE(Qt5WebKit REQUIRED) FIND_PACKAGE(Qt5WebKit REQUIRED)
FIND_PACKAGE(Qt5WebKitWidgets REQUIRED) FIND_PACKAGE(Qt5WebKitWidgets REQUIRED)
FIND_PACKAGE(Qt5Test REQUIRED) FIND_PACKAGE(Qt5Test REQUIRED)
Expand Down
21 changes: 14 additions & 7 deletions src/core/CMakeLists.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ ELSE (WITH_INTERNAL_QEXTSERIALPORT)
INCLUDE_DIRECTORIES(${QEXTSERIALPORT_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${QEXTSERIALPORT_INCLUDE_DIR})
ENDIF (WITH_INTERNAL_QEXTSERIALPORT) ENDIF (WITH_INTERNAL_QEXTSERIALPORT)


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


ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll) ADD_FLEX_FILES(QGIS_CORE_SRCS qgsexpressionlexer.ll)


Expand Down Expand Up @@ -450,11 +450,11 @@ IF (WITH_INTERNAL_QEXTSERIALPORT)
) )
ENDIF (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} SET(QGIS_CORE_MOC_HDRS ${QGIS_CORE_MOC_HDRS}
gps/qgsqtlocationconnection.h 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}) QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})


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


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


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


IF (QT_MOBILITY_LOCATION_FOUND) 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) ENDIF (QT_MOBILITY_LOCATION_FOUND)


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


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

# install # install


INSTALL(TARGETS qgis_core INSTALL(TARGETS qgis_core
Expand Down
6 changes: 3 additions & 3 deletions src/core/gps/qgsgpsdetector.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "qgsnmeaconnection.h" #include "qgsnmeaconnection.h"
#include "qgsgpsdconnection.h" #include "qgsgpsdconnection.h"


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


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


// try local QtLocation first // 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" ) ); devs << QPair<QString, QString>( "internalGPS", tr( "internal GPS" ) );
#endif #endif
// try local gpsd first // try local gpsd first
Expand Down Expand Up @@ -155,7 +155,7 @@ void QgsGPSDetector::advance()
} }
else if ( mPortList[ mPortIndex ].first.contains( "internalGPS" ) ) 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(); mConn = new QgsQtLocationConnection();
#else #else
qWarning( "QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" ); qWarning( "QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
Expand Down
16 changes: 14 additions & 2 deletions src/core/gps/qgsqtlocationconnection.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ QgsQtLocationConnection::QgsQtLocationConnection(): QgsGPSConnection( new QLocal
//needed to fix https://sourceforge.net/p/necessitas/tickets/146/ //needed to fix https://sourceforge.net/p/necessitas/tickets/146/
qRegisterMetaType< QList<QGeoSatelliteInfo> >( "QList<QGeoSatelliteInfo>" ); qRegisterMetaType< QList<QGeoSatelliteInfo> >( "QList<QGeoSatelliteInfo>" );


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


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


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

if ( !satelliteInfoSource ) if ( !satelliteInfoSource )
{ {
satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource( this ); satelliteInfoSource = QGeoSatelliteInfoSource::createDefaultSource( this );
Expand Down
16 changes: 12 additions & 4 deletions src/core/gps/qgsqtlocationconnection.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@
#define QGSQTLOCATIONCONNECTION_H #define QGSQTLOCATIONCONNECTION_H


#include "qgsgpsconnection.h" #include "qgsgpsconnection.h"

#include <QtCore/QPointer> #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 class CORE_EXPORT QgsQtLocationConnection: public QgsGPSConnection
{ {
Expand Down

0 comments on commit 72eb1aa

Please sign in to comment.