118
// Slot called when the buffer menu item is activated
113
// Slot called when the menu item is activated
119
114
void QgsGPSPlugin::run()
121
116
// find all GPX layers
122
117
std::vector<QgsVectorLayer*> gpxLayers;
123
std::map<QString, QgsMapLayer*>::const_iterator iter;
124
for (iter = mQGisInterface->getLayerRegistry()->mapLayers().begin();
125
iter != mQGisInterface->getLayerRegistry()->mapLayers().end(); ++iter) {
126
if (iter->second->type() == QgsMapLayer::VECTOR) {
127
QgsVectorLayer* vLayer = dynamic_cast<QgsVectorLayer*>(iter->second);
128
if (vLayer->providerType() == "gpx")
129
gpxLayers.push_back(vLayer);
118
QMap<QString, QgsMapLayer*>::const_iterator iter;
119
QgsMapLayerRegistry* registry = QgsMapLayerRegistry::instance();
120
for ( iter = registry->mapLayers().begin();
121
iter != registry->mapLayers().end(); ++iter )
123
if ( iter.value()->type() == QgsMapLayer::VectorLayer )
125
QgsVectorLayer* vLayer = qobject_cast<QgsVectorLayer *>( iter.value() );
126
if ( vLayer->providerType() == "gpx" )
127
gpxLayers.push_back( vLayer );
133
QgsGPSPluginGui *myPluginGui =
134
new QgsGPSPluginGui(mImporters, mDevices, gpxLayers, mMainWindowPointer,
135
QgisGui::ModalDialogFlags);
131
QgsGPSPluginGui *myPluginGui =
132
new QgsGPSPluginGui( mImporters, mDevices, gpxLayers, mQGisInterface->mainWindow(),
133
QgisGui::ModalDialogFlags );
134
myPluginGui->setAttribute( Qt::WA_DeleteOnClose );
136
135
//listen for when the layer has been made so we can draw it
137
connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)),
138
this, SLOT(drawVectorLayer(QString,QString,QString)));
139
connect(myPluginGui, SIGNAL(loadGPXFile(QString, bool, bool, bool)),
140
this, SLOT(loadGPXFile(QString, bool, bool, bool)));
141
connect(myPluginGui, SIGNAL(importGPSFile(QString, QgsBabelFormat*, bool,
142
bool, bool, QString, QString)),
143
this, SLOT(importGPSFile(QString, QgsBabelFormat*, bool, bool,
144
bool, QString, QString)));
145
connect(myPluginGui, SIGNAL(downloadFromGPS(QString, QString, bool, bool,
146
bool, QString, QString)),
147
this, SLOT(downloadFromGPS(QString, QString, bool, bool, bool,
149
connect(myPluginGui, SIGNAL(uploadToGPS(QgsVectorLayer*, QString, QString)),
150
this, SLOT(uploadToGPS(QgsVectorLayer*, QString, QString)));
151
connect(this, SIGNAL(closeGui()), myPluginGui, SLOT(close()));
136
connect( myPluginGui, SIGNAL( drawVectorLayer( QString, QString, QString ) ),
137
this, SLOT( drawVectorLayer( QString, QString, QString ) ) );
138
connect( myPluginGui, SIGNAL( loadGPXFile( QString, bool, bool, bool ) ),
139
this, SLOT( loadGPXFile( QString, bool, bool, bool ) ) );
140
connect( myPluginGui, SIGNAL( importGPSFile( QString, QgsBabelFormat*, bool,
141
bool, bool, QString, QString ) ),
142
this, SLOT( importGPSFile( QString, QgsBabelFormat*, bool, bool,
143
bool, QString, QString ) ) );
144
connect( myPluginGui, SIGNAL( convertGPSFile( QString, int,
145
QString, QString ) ),
146
this, SLOT( convertGPSFile( QString, int,
147
QString, QString ) ) );
148
connect( myPluginGui, SIGNAL( downloadFromGPS( QString, QString, bool, bool,
149
bool, QString, QString ) ),
150
this, SLOT( downloadFromGPS( QString, QString, bool, bool, bool,
151
QString, QString ) ) );
152
connect( myPluginGui, SIGNAL( uploadToGPS( QgsVectorLayer*, QString, QString ) ),
153
this, SLOT( uploadToGPS( QgsVectorLayer*, QString, QString ) ) );
154
connect( this, SIGNAL( closeGui() ), myPluginGui, SLOT( close() ) );
153
156
myPluginGui->show();
157
void QgsGPSPlugin::createGPX() {
159
QFileDialog::getSaveFileName(mMainWindowPointer,
160
tr("Save new GPX file as..."), "." , tr("GPS eXchange file (*.gpx)"));
161
if (!fileName.isEmpty()) {
162
QFileInfo fileInfo(fileName);
163
std::ofstream ofs((const char*)fileName);
165
QMessageBox::warning(NULL, tr("Could not create file"),
166
tr("Unable to create a GPX file with the given name. ")+
167
tr("Try again with another name or in another ")+
160
void QgsGPSPlugin::createGPX()
163
QFileDialog::getSaveFileName( mQGisInterface->mainWindow(),
164
tr( "Save new GPX file as..." ),
166
tr( "GPS eXchange file (*.gpx)" ) );
167
if ( !fileName.isEmpty() )
169
QFileInfo fileInfo( fileName );
170
std::ofstream ofs( fileName.toUtf8() );
173
QMessageBox::warning( NULL, tr( "Could not create file" ),
174
tr( "Unable to create a GPX file with the given name. " ) +
175
tr( "Try again with another name or in another " ) +
176
tr( "directory." ) );
171
ofs<<"<gpx></gpx>"<<std::endl;
173
emit drawVectorLayer(fileName + "?type=track",
174
fileInfo.baseName() + ", tracks", "gpx");
175
emit drawVectorLayer(fileName + "?type=route",
176
fileInfo.baseName() + ", routes", "gpx");
177
emit drawVectorLayer(fileName + "?type=waypoint",
178
fileInfo.baseName() + ", waypoints", "gpx");
179
ofs << "<gpx></gpx>" << std::endl;
181
emit drawVectorLayer( fileName + "?type=track",
182
fileInfo.baseName() + ", tracks", "gpx" );
183
emit drawVectorLayer( fileName + "?type=route",
184
fileInfo.baseName() + ", routes", "gpx" );
185
emit drawVectorLayer( fileName + "?type=waypoint",
186
fileInfo.baseName() + ", waypoints", "gpx" );
183
void QgsGPSPlugin::drawVectorLayer(QString thePathNameQString,
184
QString theBaseNameQString,
185
QString theProviderQString)
191
void QgsGPSPlugin::drawVectorLayer( QString thePathNameQString,
192
QString theBaseNameQString,
193
QString theProviderQString )
187
mQGisInterface->addVectorLayer(thePathNameQString, theBaseNameQString,
195
mQGisInterface->addVectorLayer( thePathNameQString, theBaseNameQString,
196
theProviderQString );
191
199
// Unload the plugin by cleaning up the GUI
192
200
void QgsGPSPlugin::unload()
194
202
// remove the GUI
195
mQGisInterface->removePluginMenu(tr("&Gps"),mQActionPointer);
196
mQGisInterface->removePluginMenu(tr("&Gps"),mCreateGPXAction);
197
mQGisInterface->removeToolBarIcon(mQActionPointer);
203
mQGisInterface->removePluginMenu( tr( "&Gps" ), mQActionPointer );
204
mQGisInterface->removePluginMenu( tr( "&Gps" ), mCreateGPXAction );
205
mQGisInterface->removeToolBarIcon( mQActionPointer );
198
206
delete mQActionPointer;
201
void QgsGPSPlugin::loadGPXFile(QString filename, bool loadWaypoints, bool loadRoutes,
209
void QgsGPSPlugin::loadGPXFile( QString fileName, bool loadWaypoints, bool loadRoutes,
204
213
//check if input file is readable
205
QFileInfo fileInfo(filename);
206
if (!fileInfo.isReadable()) {
207
QMessageBox::warning(NULL, tr("GPX Loader"),
208
tr("Unable to read the selected file.\n")+
209
tr("Please reselect a valid file.") );
214
QFileInfo fileInfo( fileName );
215
if ( !fileInfo.isReadable() )
217
QMessageBox::warning( NULL, tr( "GPX Loader" ),
218
tr( "Unable to read the selected file.\n"
219
"Please reselect a valid file." ) );
213
223
// remember the directory
214
224
QSettings settings;
215
settings.writeEntry("/Plugin-GPS/gpxdirectory", fileInfo.dirPath());
225
settings.setValue( "/Plugin-GPS/gpxdirectory", fileInfo.path() );
217
227
// add the requested layers
219
emit drawVectorLayer(filename + "?type=track",
220
fileInfo.baseName() + ", tracks", "gpx");
222
emit drawVectorLayer(filename + "?type=route",
223
fileInfo.baseName() + ", routes", "gpx");
225
emit drawVectorLayer(filename + "?type=waypoint",
226
fileInfo.baseName() + ", waypoints", "gpx");
229
emit drawVectorLayer( fileName + "?type=track",
230
fileInfo.baseName() + ", tracks", "gpx" );
232
emit drawVectorLayer( fileName + "?type=route",
233
fileInfo.baseName() + ", routes", "gpx" );
235
emit drawVectorLayer( fileName + "?type=waypoint",
236
fileInfo.baseName() + ", waypoints", "gpx" );
232
void QgsGPSPlugin::importGPSFile(QString inputFilename, QgsBabelFormat* importer,
233
bool importWaypoints, bool importRoutes,
234
bool importTracks, QString outputFilename,
242
void QgsGPSPlugin::importGPSFile( QString inputFileName, QgsBabelFormat* importer,
243
bool importWaypoints, bool importRoutes,
244
bool importTracks, QString outputFileName,
237
248
// what features does the user want to import?
250
if ( importWaypoints )
241
else if (importRoutes)
252
else if ( importRoutes )
243
else if (importTracks)
254
else if ( importTracks )
246
// try to start the gpsbabel process
247
QStringList babelArgs =
248
importer->importCommand(mBabelPath, typeArg,
249
inputFilename, outputFilename);
250
Q3Process babelProcess(babelArgs);
251
if (!babelProcess.start()) {
252
QMessageBox::warning(NULL, tr("Could not start process"),
253
tr("Could not start GPSBabel!"));
257
// wait for gpsbabel to finish (or the user to cancel)
258
Q3ProgressDialog progressDialog(tr("Importing data..."), tr("Cancel"), 0,
260
progressDialog.show();
261
for (int i = 0; babelProcess.isRunning(); ++i) {
262
QCoreApplication::processEvents();
264
progressDialog.setProgress(i/64);
265
if (progressDialog.wasCanceled())
269
// did we get any data?
270
if (babelProcess.exitStatus() != 0) {
271
QString babelError(babelProcess.readStderr());
272
QString errorMsg(tr("Could not import data from %1!\n\n")
273
.arg(inputFilename));
274
errorMsg += babelError;
275
QMessageBox::warning(NULL, tr("Error importing data"), errorMsg);
281
emit drawVectorLayer(outputFilename + "?type=track",
284
emit drawVectorLayer(outputFilename + "?type=route",
287
emit drawVectorLayer(outputFilename + "?type=waypoint",
294
void QgsGPSPlugin::downloadFromGPS(QString device, QString port,
295
bool downloadWaypoints, bool downloadRoutes,
296
bool downloadTracks, QString outputFilename,
257
// try to start the gpsbabel process
258
QStringList babelArgs =
259
importer->importCommand( mBabelPath, typeArg,
260
inputFileName, outputFileName );
262
QgsDebugMsg( QString( "Import command: " ) + babelArgs.join( "|" ) );
264
QProcess babelProcess;
265
babelProcess.start( babelArgs.join( " " ) );
266
if ( !babelProcess.waitForStarted() )
268
QMessageBox::warning( NULL, tr( "Could not start process" ),
269
tr( "Could not start GPSBabel!" ) );
273
// wait for gpsbabel to finish (or the user to cancel)
274
QProgressDialog progressDialog( tr( "Importing data..." ), tr( "Cancel" ), 0, 0 );
275
progressDialog.setWindowModality( Qt::WindowModal );
276
for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
278
progressDialog.setValue( i / 64 );
279
if ( progressDialog.wasCanceled() )
283
// did we get any data?
284
if ( babelProcess.exitStatus() != 0 )
286
QString babelError( babelProcess.readAllStandardError() );
287
QString errorMsg( tr( "Could not import data from %1!\n\n" )
288
.arg( inputFileName ) );
289
errorMsg += babelError;
290
QMessageBox::warning( NULL, tr( "Error importing data" ), errorMsg );
296
emit drawVectorLayer( outputFileName + "?type=track",
299
emit drawVectorLayer( outputFileName + "?type=route",
301
if ( importWaypoints )
302
emit drawVectorLayer( outputFileName + "?type=waypoint",
309
void QgsGPSPlugin::convertGPSFile( QString inputFileName,
311
QString outputFileName,
315
// what features does the user want to import?
317
QStringList convertStrings;
319
switch ( convertType )
322
convertStrings << "-x" << "transform,wpt=rte,del"; break;
324
convertStrings << "-x" << "transform,rte=wpt,del"; break;
326
QgsDebugMsg( "Illegal conversion index!" );
330
// try to start the gpsbabel process
331
QStringList babelArgs;
332
babelArgs << mBabelPath << "-i" << "gpx" << "-f" << QString( "\"%1\"" ).arg( inputFileName )
333
<< convertStrings << "-o" << "gpx" << "-F" << QString( "\"%1\"" ).arg( outputFileName );
334
QgsDebugMsg( QString( "Conversion command: " ) + babelArgs.join( "|" ) );
336
QProcess babelProcess;
337
babelProcess.start( babelArgs.join( " " ) );
338
if ( !babelProcess.waitForStarted() )
340
QMessageBox::warning( NULL, tr( "Could not start process" ),
341
tr( "Could not start GPSBabel!" ) );
345
// wait for gpsbabel to finish (or the user to cancel)
346
QProgressDialog progressDialog( tr( "Importing data..." ), tr( "Cancel" ), 0, 0 );
347
progressDialog.setWindowModality( Qt::WindowModal );
348
for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
350
progressDialog.setValue( i / 64 );
351
if ( progressDialog.wasCanceled() )
355
// did we get any data?
356
if ( babelProcess.exitStatus() != 0 )
358
QString babelError( babelProcess.readAllStandardError() );
359
QString errorMsg( tr( "Could not convert data from %1!\n\n" )
360
.arg( inputFileName ) );
361
errorMsg += babelError;
362
QMessageBox::warning( NULL, tr( "Error converting data" ), errorMsg );
367
switch ( convertType )
370
emit drawVectorLayer( outputFileName + "?type=waypoint",
374
emit drawVectorLayer( outputFileName + "?type=route",
378
QgsDebugMsg( "Illegal conversion index!" );
385
void QgsGPSPlugin::downloadFromGPS( QString device, QString port,
386
bool downloadWaypoints, bool downloadRoutes,
387
bool downloadTracks, QString outputFileName,
299
391
// what does the user want to download?
300
392
QString typeArg, features;
301
if (downloadWaypoints) {
393
if ( downloadWaypoints )
303
396
features = "waypoints";
305
else if (downloadRoutes) {
398
else if ( downloadRoutes )
307
401
features = "routes";
309
else if (downloadTracks) {
403
else if ( downloadTracks )
311
406
features = "tracks";
314
409
// try to start the gpsbabel process
315
QStringList babelArgs =
316
mDevices[device]->importCommand(mBabelPath, typeArg,
317
port, outputFilename);
318
if (babelArgs.isEmpty()) {
319
QMessageBox::warning(NULL, tr("Not supported"),
320
QString(tr("This device does not support downloading ") +
321
tr("of ")) + features + ".");
324
Q3Process babelProcess(babelArgs);
325
if (!babelProcess.start()) {
326
QMessageBox::warning(NULL, tr("Could not start process"),
327
tr("Could not start GPSBabel!"));
410
QStringList babelArgs =
411
mDevices[device]->importCommand( mBabelPath, typeArg,
412
port, outputFileName );
413
if ( babelArgs.isEmpty() )
415
QMessageBox::warning( NULL, tr( "Not supported" ),
416
tr( "This device does not support downloading of %1." )
422
QgsDebugMsg( QString( "Download command: " ) + babelArgs.join( "|" ) );
424
QProcess babelProcess;
425
babelProcess.start( babelArgs.join( " " ) );
426
if ( !babelProcess.waitForStarted() )
428
QMessageBox::warning( NULL, tr( "Could not start process" ),
429
tr( "Could not start GPSBabel!" ) );
331
433
// wait for gpsbabel to finish (or the user to cancel)
332
Q3ProgressDialog progressDialog(tr("Downloading data..."), tr("Cancel"), 0,
334
progressDialog.show();
335
for (int i = 0; babelProcess.isRunning(); ++i) {
336
QCoreApplication::processEvents();
338
progressDialog.setProgress(i/64);
339
if (progressDialog.wasCanceled())
434
QProgressDialog progressDialog( tr( "Downloading data..." ), tr( "Cancel" ), 0, 0 );
435
progressDialog.setWindowModality( Qt::WindowModal );
436
for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
438
progressDialog.setValue( i / 64 );
439
if ( progressDialog.wasCanceled() )
343
443
// did we get any data?
344
if (babelProcess.exitStatus() != 0) {
345
QString babelError(babelProcess.readStderr());
346
QString errorMsg(tr("Could not download data from GPS!\n\n"));
444
if ( babelProcess.exitStatus() != 0 )
446
QString babelError( babelProcess.readAllStandardError() );
447
QString errorMsg( tr( "Could not download data from GPS!\n\n" ) );
347
448
errorMsg += babelError;
348
QMessageBox::warning(NULL, tr("Error downloading data"), errorMsg);
449
QMessageBox::warning( NULL, tr( "Error downloading data" ), errorMsg );
353
if (downloadWaypoints)
354
emit drawVectorLayer(outputFilename + "?type=waypoint",
357
emit drawVectorLayer(outputFilename + "?type=route",
360
emit drawVectorLayer(outputFilename + "?type=track",
454
if ( downloadWaypoints )
455
emit drawVectorLayer( outputFileName + "?type=waypoint",
457
if ( downloadRoutes )
458
emit drawVectorLayer( outputFileName + "?type=route",
460
if ( downloadTracks )
461
emit drawVectorLayer( outputFileName + "?type=track",
363
464
// everything was OK, remember the device and port for next time
364
465
QSettings settings;
365
settings.writeEntry("/Plugin-GPS/lastdldevice", device);
366
settings.writeEntry("/Plugin-GPS/lastdlport", port);
466
settings.setValue( "/Plugin-GPS/lastdldevice", device );
467
settings.setValue( "/Plugin-GPS/lastdlport", port );
372
void QgsGPSPlugin::uploadToGPS(QgsVectorLayer* gpxLayer, QString device,
375
const QString& source(gpxLayer->getDataProvider()->getDataSourceUri());
473
void QgsGPSPlugin::uploadToGPS( QgsVectorLayer* gpxLayer, QString device,
477
const QString& source( gpxLayer->dataProvider()->dataSourceUri() );
377
479
// what kind of data does the user want to upload?
378
480
QString typeArg, features;
379
if (source.right(8) == "waypoint") {
481
if ( source.right( 8 ) == "waypoint" )
381
484
features = "waypoints";
383
else if (source.right(5) == "route") {
486
else if ( source.right( 5 ) == "route" )
385
489
features = "routes";
387
else if (source.right(5) == "track") {
491
else if ( source.right( 5 ) == "track" )
389
494
features = "tracks";
392
std::cerr << source.right(8).toLocal8Bit().data() << std::endl;
498
QgsDebugMsg( source.right( 8 ) );
396
502
// try to start the gpsbabel process
397
QStringList babelArgs =
398
mDevices[device]->exportCommand(mBabelPath, typeArg,
399
source.left(source.findRev('?')), port);
400
if (babelArgs.isEmpty()) {
401
QMessageBox::warning(NULL, tr("Not supported"),
402
QString(tr("This device does not support uploading of "))+
406
Q3Process babelProcess(babelArgs);
407
if (!babelProcess.start()) {
408
QMessageBox::warning(NULL, tr("Could not start process"),
409
tr("Could not start GPSBabel!"));
503
QStringList babelArgs =
504
mDevices[device]->exportCommand( mBabelPath, typeArg,
505
source.left( source.lastIndexOf( '?' ) ), port );
506
if ( babelArgs.isEmpty() )
508
QMessageBox::warning( NULL, tr( "Not supported" ),
509
tr( "This device does not support uploading of %1." )
514
QgsDebugMsg( QString( "Upload command: " ) + babelArgs.join( "|" ) );
516
QProcess babelProcess;
517
babelProcess.start( babelArgs.join( " " ) );
518
if ( !babelProcess.waitForStarted() )
520
QMessageBox::warning( NULL, tr( "Could not start process" ),
521
tr( "Could not start GPSBabel!" ) );
413
525
// wait for gpsbabel to finish (or the user to cancel)
414
Q3ProgressDialog progressDialog(tr("Uploading data..."), tr("Cancel"), 0,
416
progressDialog.show();
417
for (int i = 0; babelProcess.isRunning(); ++i) {
418
QCoreApplication::processEvents();
420
progressDialog.setProgress(i/64);
421
if (progressDialog.wasCanceled())
526
QProgressDialog progressDialog( tr( "Uploading data..." ), tr( "Cancel" ), 0, 0 );
527
progressDialog.setWindowModality( Qt::WindowModal );
528
for ( int i = 0; babelProcess.state() == QProcess::Running; ++i )
530
progressDialog.setValue( i / 64 );
531
if ( progressDialog.wasCanceled() )
425
535
// did we get an error?
426
if (babelProcess.exitStatus() != 0) {
427
QString babelError(babelProcess.readStderr());
428
QString errorMsg(tr("Error while uploading data to GPS!\n\n"));
536
if ( babelProcess.exitStatus() != 0 )
538
QString babelError( babelProcess.readAllStandardError() );
539
QString errorMsg( tr( "Error while uploading data to GPS!\n\n" ) );
429
540
errorMsg += babelError;
430
QMessageBox::warning(NULL, tr("Error uploading data"), errorMsg);
541
QMessageBox::warning( NULL, tr( "Error uploading data" ), errorMsg );
434
545
// everything was OK, remember this device for next time
435
546
QSettings settings;
436
settings.writeEntry("/Plugin-GPS/lastuldevice", device);
437
settings.writeEntry("/Plugin-GPS/lastulport", port);
547
settings.setValue( "/Plugin-GPS/lastuldevice", device );
548
settings.setValue( "/Plugin-GPS/lastulport", port );
443
void QgsGPSPlugin::setupBabel() {
554
void QgsGPSPlugin::setupBabel()
445
557
// where is gpsbabel?
446
558
QSettings settings;
447
mBabelPath = settings.value("/Plugin-GPS/gpsbabelpath", "").toString();
448
if (mBabelPath.isEmpty())
559
mBabelPath = settings.value( "/Plugin-GPS/gpsbabelpath", "" ).toString();
560
if ( mBabelPath.isEmpty() )
449
561
mBabelPath = "gpsbabel";
450
562
// the importable formats
563
mImporters["Shapefile"] =
564
new QgsSimpleBabelFormat( "shape", true, true, true );
451
565
mImporters["Geocaching.com .loc"] =
452
new QgsSimpleBabelFormat("geo", true, false, false);
453
mImporters["Magellan Mapsend"] =
454
new QgsSimpleBabelFormat("mapsend", true, true, true);
455
mImporters["Garmin PCX5"] =
456
new QgsSimpleBabelFormat("pcx", true, false, true);
457
mImporters["Garmin Mapsource"] =
458
new QgsSimpleBabelFormat("mapsource", true, true, true);
459
mImporters["GPSUtil"] =
460
new QgsSimpleBabelFormat("gpsutil", true, false, false);
461
mImporters["PocketStreets 2002/2003 Pushpin"] =
462
new QgsSimpleBabelFormat("psp", true, false, false);
463
mImporters["CoPilot Flight Planner"] =
464
new QgsSimpleBabelFormat("copilot", true, false, false);
465
mImporters["Magellan Navigator Companion"] =
466
new QgsSimpleBabelFormat("magnav", true, false, false);
467
mImporters["Holux"] =
468
new QgsSimpleBabelFormat("holux", true, false, false);
469
mImporters["Topo by National Geographic"] =
470
new QgsSimpleBabelFormat("tpg", true, false, false);
471
mImporters["TopoMapPro"] =
472
new QgsSimpleBabelFormat("tmpro", true, false, false);
473
mImporters["GeocachingDB"] =
474
new QgsSimpleBabelFormat("gcdb", true, false, false);
475
mImporters["Tiger"] =
476
new QgsSimpleBabelFormat("tiger", true, false, false);
477
mImporters["EasyGPS Binary Format"] =
478
new QgsSimpleBabelFormat("easygps", true, false, false);
479
mImporters["Delorme Routes"] =
480
new QgsSimpleBabelFormat("saroute", false, false, true);
481
mImporters["Navicache"] =
482
new QgsSimpleBabelFormat("navicache", true, false, false);
483
mImporters["PSITrex"] =
484
new QgsSimpleBabelFormat("psitrex", true, true, true);
485
mImporters["Delorme GPS Log"] =
486
new QgsSimpleBabelFormat("gpl", false, false, true);
487
mImporters["OziExplorer"] =
488
new QgsSimpleBabelFormat("ozi", true, false, false);
489
mImporters["NMEA Sentences"] =
490
new QgsSimpleBabelFormat("nmea", true, false, true);
491
mImporters["Delorme Street Atlas 2004 Plus"] =
492
new QgsSimpleBabelFormat("saplus", true, false, false);
493
mImporters["Microsoft Streets and Trips"] =
494
new QgsSimpleBabelFormat("s_and_t", true, false, false);
495
mImporters["NIMA/GNIS Geographic Names"] =
496
new QgsSimpleBabelFormat("nima", true, false, false);
497
mImporters["Maptech"] =
498
new QgsSimpleBabelFormat("mxf", true, false, false);
499
mImporters["Mapopolis.com Mapconverter Application"] =
500
new QgsSimpleBabelFormat("mapconverter", true, false, false);
501
mImporters["GPSman"] =
502
new QgsSimpleBabelFormat("gpsman", true, false, false);
503
mImporters["GPSDrive"] =
504
new QgsSimpleBabelFormat("gpsdrive", true, false, false);
505
mImporters["Fugawi"] =
506
new QgsSimpleBabelFormat("fugawi", true, false, false);
508
new QgsSimpleBabelFormat("dna", true, false, false);
566
new QgsSimpleBabelFormat( "geo", true, false, false );
567
mImporters["Magellan Mapsend"] =
568
new QgsSimpleBabelFormat( "mapsend", true, true, true );
569
mImporters["Garmin PCX5"] =
570
new QgsSimpleBabelFormat( "pcx", true, false, true );
571
mImporters["Garmin Mapsource"] =
572
new QgsSimpleBabelFormat( "mapsource", true, true, true );
573
mImporters["GPSUtil"] =
574
new QgsSimpleBabelFormat( "gpsutil", true, false, false );
575
mImporters["PocketStreets 2002/2003 Pushpin"] =
576
new QgsSimpleBabelFormat( "psp", true, false, false );
577
mImporters["CoPilot Flight Planner"] =
578
new QgsSimpleBabelFormat( "copilot", true, false, false );
579
mImporters["Magellan Navigator Companion"] =
580
new QgsSimpleBabelFormat( "magnav", true, false, false );
581
mImporters["Holux"] =
582
new QgsSimpleBabelFormat( "holux", true, false, false );
583
mImporters["Topo by National Geographic"] =
584
new QgsSimpleBabelFormat( "tpg", true, false, false );
585
mImporters["TopoMapPro"] =
586
new QgsSimpleBabelFormat( "tmpro", true, false, false );
587
mImporters["GeocachingDB"] =
588
new QgsSimpleBabelFormat( "gcdb", true, false, false );
589
mImporters["Tiger"] =
590
new QgsSimpleBabelFormat( "tiger", true, false, false );
591
mImporters["EasyGPS Binary Format"] =
592
new QgsSimpleBabelFormat( "easygps", true, false, false );
593
mImporters["Delorme Routes"] =
594
new QgsSimpleBabelFormat( "saroute", false, false, true );
595
mImporters["Navicache"] =
596
new QgsSimpleBabelFormat( "navicache", true, false, false );
597
mImporters["PSITrex"] =
598
new QgsSimpleBabelFormat( "psitrex", true, true, true );
599
mImporters["Delorme GPS Log"] =
600
new QgsSimpleBabelFormat( "gpl", false, false, true );
601
mImporters["OziExplorer"] =
602
new QgsSimpleBabelFormat( "ozi", true, false, false );
603
mImporters["NMEA Sentences"] =
604
new QgsSimpleBabelFormat( "nmea", true, false, true );
605
mImporters["Delorme Street Atlas 2004 Plus"] =
606
new QgsSimpleBabelFormat( "saplus", true, false, false );
607
mImporters["Microsoft Streets and Trips"] =
608
new QgsSimpleBabelFormat( "s_and_t", true, false, false );
609
mImporters["NIMA/GNIS Geographic Names"] =
610
new QgsSimpleBabelFormat( "nima", true, false, false );
611
mImporters["Maptech"] =
612
new QgsSimpleBabelFormat( "mxf", true, false, false );
613
mImporters["Mapopolis.com Mapconverter Application"] =
614
new QgsSimpleBabelFormat( "mapconverter", true, false, false );
615
mImporters["GPSman"] =
616
new QgsSimpleBabelFormat( "gpsman", true, false, false );
617
mImporters["GPSDrive"] =
618
new QgsSimpleBabelFormat( "gpsdrive", true, false, false );
619
mImporters["Fugawi"] =
620
new QgsSimpleBabelFormat( "fugawi", true, false, false );
622
new QgsSimpleBabelFormat( "dna", true, false, false );
510
624
// and the GPS devices
511
mDevices["Garmin serial"] =
512
new QgsGPSDevice("%babel -w -i garmin -o gpx %in %out",
513
"%babel -w -i gpx -o garmin %in %out",
514
"%babel -r -i garmin -o gpx %in %out",
515
"%babel -r -i gpx -o garmin %in %out",
516
"%babel -t -i garmin -o gpx %in %out",
517
"%babel -t -i gpx -o garmin %in %out");
518
QStringList deviceNames = settings.value("/Plugin-GPS/devicelist").
625
mDevices["Garmin serial"] =
626
new QgsGPSDevice( "%babel -w -i garmin -o gpx %in %out",
627
"%babel -w -i gpx -o garmin %in %out",
628
"%babel -r -i garmin -o gpx %in %out",
629
"%babel -r -i gpx -o garmin %in %out",
630
"%babel -t -i garmin -o gpx %in %out",
631
"%babel -t -i gpx -o garmin %in %out" );
632
QStringList deviceNames = settings.value( "/Plugin-GPS/devicelist" ).
521
635
QStringList::const_iterator iter;
523
for (iter = deviceNames.begin(); iter != deviceNames.end(); ++iter) {
637
for ( iter = deviceNames.begin(); iter != deviceNames.end(); ++iter )
524
639
QString wptDownload = settings.
525
value(QString("/Plugin-GPS/devices/%1/wptdownload").
526
arg(*iter), "").toString();
640
value( QString( "/Plugin-GPS/devices/%1/wptdownload" ).
641
arg( *iter ), "" ).toString();
527
642
QString wptUpload = settings.
528
value(QString("/Plugin-GPS/devices/%1/wptupload").arg(*iter), "").
643
value( QString( "/Plugin-GPS/devices/%1/wptupload" ).arg( *iter ), "" ).
530
645
QString rteDownload = settings.
531
value(QString("/Plugin-GPS/devices/%1/rtedownload").arg(*iter), "").
646
value( QString( "/Plugin-GPS/devices/%1/rtedownload" ).arg( *iter ), "" ).
533
648
QString rteUpload = settings.
534
value(QString("/Plugin-GPS/devices/%1/rteupload").arg(*iter), "").
649
value( QString( "/Plugin-GPS/devices/%1/rteupload" ).arg( *iter ), "" ).
536
651
QString trkDownload = settings.
537
value(QString("/Plugin-GPS/devices/%1/trkdownload").arg(*iter), "").
652
value( QString( "/Plugin-GPS/devices/%1/trkdownload" ).arg( *iter ), "" ).
539
654
QString trkUpload = settings.
540
value(QString("/Plugin-GPS/devices/%1/trkupload").arg(*iter), "").
542
mDevices[*iter] = new QgsGPSDevice(wptDownload, wptUpload,
543
rteDownload, rteUpload,
544
trkDownload, trkUpload);
552
* Required extern functions needed for every plugin
655
value( QString( "/Plugin-GPS/devices/%1/trkupload" ).arg( *iter ), "" ).
657
mDevices[*iter] = new QgsGPSDevice( wptDownload, wptUpload,
658
rteDownload, rteUpload,
659
trkDownload, trkUpload );
663
//! Set icons to the current theme
664
void QgsGPSPlugin::setCurrentTheme( QString theThemeName )
666
QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/gps_importer.png";
667
QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/gps_importer.png";
668
QString myQrcPath = ":/gps_importer.png";
669
if ( QFile::exists( myCurThemePath ) )
671
mQActionPointer->setIcon( QIcon( myCurThemePath ) );
672
mCreateGPXAction->setIcon( QIcon( myCurThemePath ) );
674
else if ( QFile::exists( myDefThemePath ) )
676
mQActionPointer->setIcon( QIcon( myDefThemePath ) );
677
mCreateGPXAction->setIcon( QIcon( myDefThemePath ) );
679
else if ( QFile::exists( myQrcPath ) )
681
mQActionPointer->setIcon( QIcon( myQrcPath ) );
682
mCreateGPXAction->setIcon( QIcon( myQrcPath ) );
686
mQActionPointer->setIcon( QIcon() );
687
mCreateGPXAction->setIcon( QIcon() );
692
* Required extern functions needed for every plugin
553
693
* These functions can be called prior to creating an instance
554
694
* of the plugin class
556
696
// Class factory to return a new instance of the plugin class
557
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer,
558
QgisIface * theQgisInterfacePointer)
697
QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
560
return new QgsGPSPlugin(theQGisAppPointer, theQgisInterfacePointer);
699
return new QgsGPSPlugin( theQgisInterfacePointer );
563
702
// Return the name of the plugin - note that we do not user class members as