Skip to content
Permalink
Browse files
use QgsGPSConnection::availablePorts() also in gps plugin
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12739 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Jan 11, 2010
1 parent 15e7940 commit 94800acdd086d54f2f87a7f4232e13e983eb6736
Showing with 6 additions and 93 deletions.
  1. +0 −2 src/core/gps/qgsgpsconnection.cpp
  2. +1 −1 src/plugins/gps_importer/CMakeLists.txt
  3. +5 −90 src/plugins/gps_importer/qgsgpsplugingui.cpp
@@ -208,8 +208,6 @@ QStringList QgsGPSConnection::availablePorts()
}
}
}

devs << "usb:";
#endif

#ifdef __FreeBSD__ // freebsd
@@ -38,7 +38,7 @@ ADD_LIBRARY (gpsimporterplugin MODULE ${GPS_SRCS} ${GPS_MOC_SRCS} ${GPS_RCC_SRCS
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../core ../../core/gps
../../gui
..
${EXPAT_INCLUDE_DIR}
@@ -15,6 +15,7 @@
#include "qgsdataprovider.h"
#include "qgscontexthelp.h"
#include "qgslogger.h"
#include "qgsgpsconnection.h"

//qt includes
#include <QFileDialog>
@@ -303,97 +304,11 @@ void QgsGPSPluginGui::on_pbnRefresh_clicked()

void QgsGPSPluginGui::populatePortComboBoxes()
{

QStringList devs = QgsGPSConnection::availablePorts() << "usb:";
cmbDLPort->clear();
#ifdef linux
// look for linux serial devices
QString linuxDev( "/dev/ttyS%1" );
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
{
cmbDLPort->addItem( linuxDev.arg( i ) );
cmbULPort->addItem( linuxDev.arg( i ) );
}
else
break;
}

// and the ttyUSB* devices (serial USB adaptor)
linuxDev = "/dev/ttyUSB%1";
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( linuxDev.arg( i ) ).exists() )
{
cmbDLPort->addItem( linuxDev.arg( i ) );
cmbULPort->addItem( linuxDev.arg( i ) );
}
else
break;
}

cmbDLPort->addItem( "usb:" );
cmbULPort->addItem( "usb:" );
#endif

#ifdef __FreeBSD__ // freebsd
// and freebsd devices (untested)
QString freebsdDev( "/dev/cuaa%1" );
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
{
cmbDLPort->addItem( freebsdDev.arg( i ) );
cmbULPort->addItem( freebsdDev.arg( i ) );
}
else
break;
}

// and the ucom devices (serial USB adaptors)
freebsdDev = "/dev/ucom%1";
for ( int i = 0; i < 10; ++i )
{
if ( QFileInfo( freebsdDev.arg( i ) ).exists() )
{
cmbDLPort->addItem( freebsdDev.arg( i ) );
cmbULPort->addItem( freebsdDev.arg( i ) );
}
else
break;
}

#endif

#ifdef sparc
// and solaris devices (also untested)
QString solarisDev( "/dev/cua/%1" );
for ( int i = 'a'; i < 'k'; ++i )
{
if ( QFileInfo( solarisDev.arg( char( i ) ) ).exists() )
{
cmbDLPort->addItem( solarisDev.arg( char( i ) ) );
cmbULPort->addItem( solarisDev.arg( char( i ) ) );
}
else
break;
}
#endif

#ifdef WIN32
cmbULPort->addItem( "com1" );
cmbULPort->addItem( "com2" );
cmbULPort->addItem( "com3" );
cmbULPort->addItem( "com4" );
cmbULPort->addItem( "usb:" );
cmbDLPort->addItem( "com1" );
cmbDLPort->addItem( "com2" );
cmbDLPort->addItem( "com3" );
cmbDLPort->addItem( "com4" );
cmbDLPort->addItem( "usb:" );
#endif

// OSX, OpenBSD, NetBSD etc? Anyone?
cmbDLPort->addItems( devs );
cmbULPort->clear();
cmbULPort->addItems( devs );

// remember the last ports used
QSettings settings;

0 comments on commit 94800ac

Please sign in to comment.