Skip to content
Permalink
Browse files

also show descriptions for GPS ports

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12747 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jan 12, 2010
1 parent bebb5a4 commit b8def0bc008f1f9ce109aee2683a6f35102a01e8
@@ -191,9 +191,11 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi

QgsGPSInformationWidget::~QgsGPSInformationWidget()
{
if ( mpMapMarker ) delete mpMapMarker;
if ( mpMapMarker )
delete mpMapMarker;

QSettings mySettings;
mySettings.setValue( "/gps/lastPort", mCboDevices->currentText() );
mySettings.setValue( "/gps/lastPort", mCboDevices->itemData( mCboDevices->currentIndex() ).toString() );
mySettings.setValue( "/gps/trackWidth", mSpinTrackWidth->value() );
mySettings.setValue( "/gps/markerSize", mSliderMarkerSize->value() );
mySettings.setValue( "/gps/autoAddVertices", mCbxAutoAddVertices->isChecked() );
@@ -220,6 +222,7 @@ QgsGPSInformationWidget::~QgsGPSInformationWidget()
{
mySettings.setValue( "/gps/panMode", "none" );
}

if ( mpRubberBand )
{
delete mpRubberBand;
@@ -305,14 +308,14 @@ void QgsGPSInformationWidget::connectGps()
{
if ( mRadUserPath->isChecked() )
{
if ( !mCboDevices->currentText().isEmpty() )
if ( !mCboDevices->itemData( mCboDevices->currentIndex() ).toString().isEmpty() )
{
mNmea = new QgsNMEAConnection( mCboDevices->currentText(), 500 );
mNmea = new QgsNMEAConnection( mCboDevices->itemData( mCboDevices->currentIndex() ).toString(), 500 );
QObject::connect( mNmea, SIGNAL( stateChanged( const QgsGPSInformation& ) ),
this, SLOT( displayGPSInformation( const QgsGPSInformation& ) ) );
mThread = new QgsGPSTrackerThread( mNmea );
mThread->start();
mGPSTextEdit->append( tr( "Connecting on %1" ).arg( mCboDevices->currentText() ) );
mGPSTextEdit->append( tr( "Connecting on %1" ).arg( mCboDevices->itemData( mCboDevices->currentIndex() ).toString() ) );
}
else
{
@@ -418,7 +421,8 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
}
mpCurve->setData( myXData, mySignalData );
mpPlot->replot();
if ( mpMapMarker ) delete mpMapMarker;
if ( mpMapMarker )
delete mpMapMarker;
QgsPoint myNewCenter = QgsPoint( info.longitude, info.latitude );
if ( mGroupShowMarker->isChecked() )
{
@@ -854,31 +858,30 @@ void QgsGPSInformationWidget::on_mBtnRefreshDevices_clicked( )
/* Copied from gps plugin */
void QgsGPSInformationWidget::populateDevices()
{
QList< QPair<QString, QString> > ports = QgsGPSConnection::availablePorts();

mCboDevices->clear();
mCboDevices->addItems( QgsGPSConnection::availablePorts() );
for ( int i = 0; i < ports.size(); i++ )
{
mCboDevices->addItem( ports[i].second, ports[i].first );
}

// remember the last ports used
QSettings settings;
QString lastPort = settings.value( "/gps/lastPort", "" ).toString();
for ( int i = 0; i < mCboDevices->count(); ++i )
{
if ( mCboDevices->itemText( i ) == lastPort )
{
mCboDevices->setCurrentIndex( i );
break;
}
}

int idx = mCboDevices->findData( lastPort );
mCboDevices->setCurrentIndex( idx < 0 ? 0 : idx );
}

void QgsGPSInformationWidget::createRubberBand( )
{
if ( mpRubberBand == 0 )
if ( mpRubberBand )
{
delete mpRubberBand;
}
QSettings settings;
bool isPolygon = false;
mpRubberBand = new QgsRubberBand( mpCanvas, isPolygon );
mpRubberBand = new QgsRubberBand( mpCanvas, false );
setTrackColour();
mpRubberBand->setWidth( settings.value( "/gps/trackWidth", 2 ).toInt() );
mpRubberBand->show();
@@ -152,9 +152,11 @@ QgsGPSConnection* QgsGPSConnection::detectGPSConnection()
QList<BaudRateType>::const_iterator baudIt = baudRatesToTry.constBegin();
for ( ; baudIt != baudRatesToTry.constEnd(); ++baudIt )
{
foreach( QString portname, availablePorts() )
QList< QPair<QString, QString> > ports = availablePorts();

for ( int i = 0; i < ports.size(); i++ )
{
port = new QextSerialPort( portname );
port = new QextSerialPort( ports[i].first );
port->setBaudRate( *baudIt );
port->setFlowControl( FLOW_OFF );
port->setParity( PAR_NONE );
@@ -192,9 +194,9 @@ QgsGPSConnection* QgsGPSConnection::detectGPSConnection()
return 0;
}

QStringList QgsGPSConnection::availablePorts()
QList< QPair<QString, QString> > QgsGPSConnection::availablePorts()
{
QStringList devs;
QList< QPair<QString, QString> > devs;

#ifdef linux
// look for linux serial devices
@@ -204,7 +206,7 @@ QStringList QgsGPSConnection::availablePorts()
{
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
{
devs << linuxDev.arg( i );
devs << QPair<QString, QString>( linuxDev.arg( i ), linuxDev.arg( i ) );
}
}
}
@@ -218,7 +220,7 @@ QStringList QgsGPSConnection::availablePorts()
{
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
{
devs << freebsdDev.arg( i );
devs << QPair<QString, QString>( freebsdDev.arg( i ), freebsdDev.arg( i ) );
}
}
}
@@ -231,7 +233,7 @@ QStringList QgsGPSConnection::availablePorts()
{
if ( QFileInfo( solarisDev.arg( i ) ).exists() )
{
devs << solarisDev.arg( i );
devs << QPair<QString, QString>( solarisDev.arg( i ), solarisDev.arg( i ) );
}
}
#endif
@@ -240,7 +242,7 @@ QStringList QgsGPSConnection::availablePorts()
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
foreach( QextPortInfo port, ports )
{
devs << port.portName;
devs << QPair<QString, QString>( port.portName, port.friendName );
}
#endif

@@ -113,7 +113,8 @@ void QgsGPSPluginGui::on_buttonBox_accepted()
fileName += ".gpx";
}

emit downloadFromGPS( cmbDLDevice->currentText(), cmbDLPort->currentText(),
emit downloadFromGPS( cmbDLDevice->currentText(),
cmbDLPort->itemData( cmbDLPort->currentIndex() ).toString(),
featureType == 0, featureType == 1, featureType == 2,
fileName, leDLBasename->text() );
break;
@@ -122,7 +123,8 @@ void QgsGPSPluginGui::on_buttonBox_accepted()
case 3:
{
emit uploadToGPS( mGPXLayers[cmbULLayer->currentIndex()],
cmbULDevice->currentText(), cmbULPort->currentText() );
cmbULDevice->currentText(),
cmbULPort->itemData( cmbULPort->currentIndex() ).toString() );
break;
}
// or convert between waypoints/tracks=
@@ -304,32 +306,25 @@ void QgsGPSPluginGui::on_pbnRefresh_clicked()

void QgsGPSPluginGui::populatePortComboBoxes()
{
QStringList devs = QgsGPSConnection::availablePorts() << "usb:";
QList< QPair<QString, QString> > devs = QgsGPSConnection::availablePorts() << QPair<QString, QString>( "usb:", "usb:" );

cmbDLPort->clear();
cmbDLPort->addItems( devs );
cmbULPort->clear();
cmbULPort->addItems( devs );
for ( int i = 0; i < devs.size(); i++ )
{
cmbDLPort->addItem( devs[i].second, devs[i].first );
cmbULPort->addItem( devs[i].second, devs[i].first );
}

// remember the last ports used
QSettings settings;
QString lastDLPort = settings.value( "/Plugin-GPS/lastdlport", "" ).toString();
QString lastULPort = settings.value( "/Plugin-GPS/lastulport", "" ).toString();
for ( int i = 0; i < cmbDLPort->count(); ++i )
{
if ( cmbDLPort->itemText( i ) == lastDLPort )
{
cmbDLPort->setCurrentIndex( i );
break;
}
}
for ( int i = 0; i < cmbULPort->count(); ++i )
{
if ( cmbULPort->itemText( i ) == lastULPort )
{
cmbULPort->setCurrentIndex( i );
break;
}
}

int idx = cmbDLPort->findData( lastDLPort );
cmbDLPort->setCurrentIndex( idx < 0 ? 0 : idx );
idx = cmbULPort->findData( lastULPort );
cmbULPort->setCurrentIndex( idx < 0 ? 0 : idx );
}


@@ -318,9 +318,6 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="mPathLabel">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Path to serial device</string>
</property>

0 comments on commit b8def0b

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