25 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
29 #include <QStringList>
33 #if defined( HAVE_QT5SERIALPORT )
34 #include <QSerialPortInfo>
35 #include <QSerialPort>
40 QList< QPair<QString, QString> > devs;
43 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
44 devs << QPair<QString, QString>( QStringLiteral(
"internalGPS" ), tr(
"internal GPS" ) );
48 devs << QPair<QString, QString>( QStringLiteral(
"localhost:2947:" ), tr(
"local gpsd" ) );
51 #if defined( HAVE_QT5SERIALPORT )
52 for (
auto p : QSerialPortInfo::availablePorts() )
54 devs << QPair<QString, QString>( p.portName(), tr(
"%1: %2" ).arg( p.portName(), p.description() ) );
63 #if defined( HAVE_QT5SERIALPORT )
64 mBaudList << QSerialPort::Baud4800 << QSerialPort::Baud9600 << QSerialPort::Baud38400 << QSerialPort::Baud57600 << QSerialPort::Baud115200;
67 if ( portName.isEmpty() )
73 mPortList << QPair<QString, QString>( portName, portName );
88 if ( mBaudIndex == mBaudList.size() )
94 if ( mPortIndex == mPortList.size() )
101 if ( mPortList.at( mPortIndex ).first.contains(
':' ) )
103 mBaudIndex = mBaudList.size() - 1;
105 QStringList gpsParams = mPortList.at( mPortIndex ).first.split(
':' );
107 Q_ASSERT( gpsParams.size() >= 3 );
109 mConn = qgis::make_unique< QgsGpsdConnection >( gpsParams[0], gpsParams[1].toShort(), gpsParams[2] );
111 else if ( mPortList.at( mPortIndex ).first.contains( QLatin1String(
"internalGPS" ) ) )
113 #if defined(HAVE_QT_MOBILITY_LOCATION ) || defined(QT_POSITIONING_LIB)
114 mConn = qgis::make_unique< QgsQtLocationConnection >();
116 qWarning(
"QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
121 #if defined( HAVE_QT5SERIALPORT )
122 std::unique_ptr< QSerialPort > serial = qgis::make_unique< QSerialPort >( mPortList.at( mPortIndex ).first );
124 serial->setBaudRate( mBaudList[ mBaudIndex ] );
126 serial->setFlowControl( settings.
enumValue( QStringLiteral(
"gps/flow_control" ), QSerialPort::NoFlowControl,
QgsSettings::Core ) );
131 if ( serial->open( QIODevice::ReadOnly ) )
133 mConn = qgis::make_unique< QgsNmeaConnection >( serial.release() );
136 qWarning(
"QT5SERIALPORT not found and mPortList matches serial port, this should never happen" );
171 if ( obj == mConn.get() )