@@ -37,6 +37,7 @@ QgsGPSPluginGui::QgsGPSPluginGui(const BabelMap& importers,
37
37
populatePortComboBoxes ();
38
38
populateULLayerComboBox ();
39
39
populateIMPBabelFormats ();
40
+ populateCONVDialog ();
40
41
41
42
connect (pbULEditDevices, SIGNAL (clicked ()), this , SLOT (openDeviceEditor ()));
42
43
connect (pbDLEditDevices, SIGNAL (clicked ()), this , SLOT (openDeviceEditor ()));
@@ -53,6 +54,12 @@ QgsGPSPluginGui::QgsGPSPluginGui(const BabelMap& importers,
53
54
this , SLOT (enableRelevantControls ()));
54
55
connect (leIMPLayer, SIGNAL (textChanged (const QString&)),
55
56
this , SLOT (enableRelevantControls ()));
57
+ connect (leCONVInput, SIGNAL (textChanged (const QString&)),
58
+ this , SLOT (enableRelevantControls ()));
59
+ connect (leCONVOutput, SIGNAL (textChanged (const QString&)),
60
+ this , SLOT (enableRelevantControls ()));
61
+ connect (leCONVLayer, SIGNAL (textChanged (const QString&)),
62
+ this , SLOT (enableRelevantControls ()));
56
63
connect (leDLOutput, SIGNAL (textChanged (const QString&)),
57
64
this , SLOT (enableRelevantControls ()));
58
65
connect (leDLBasename, SIGNAL (textChanged (const QString&)),
@@ -74,38 +81,14 @@ void QgsGPSPluginGui::on_buttonBox_accepted()
74
81
{
75
82
76
83
// what should we do?
77
- switch (tabWidget->currentPageIndex ()) {
84
+ switch (tabWidget->currentPageIndex ())
85
+ {
78
86
// add a GPX layer?
79
87
case 0 :
80
88
emit loadGPXFile (leGPXFile->text (), cbGPXWaypoints->isChecked (),
81
89
cbGPXRoutes->isChecked (), cbGPXTracks->isChecked ());
82
90
break ;
83
91
84
- // or import a download file?
85
- /*
86
- case 666:
87
- //check input file exists
88
- //
89
- if (!QFile::exists ( leInputFile->text() ))
90
- {
91
- QMessageBox::warning( this, "GPS Importer",
92
- "Unable to find the input file.\n"
93
- "Please reselect a valid file." );
94
- return;
95
- }
96
- WayPointToShape * myWayPointToShape = new WayPointToShape(leOutputShapeFile->text(),leInputFile->text());
97
- //
98
- // If you have a produced a raster layer using your plugin, you can ask qgis to
99
- // add it to the view using:
100
- // emit drawRasterLayer(QString("layername"));
101
- // or for a vector layer
102
- // emit drawVectorLayer(QString("pathname"),QString("layername"),QString("provider name (either ogr or postgres"));
103
- //
104
- delete myWayPointToShape;
105
- emit drawVectorLayer(leOutputShapeFile->text(),QString("Waypoints"),QString("ogr"));
106
- break;
107
- */
108
-
109
92
// or import other file?
110
93
case 1 : {
111
94
const QString& typeString (cmbDLFeatureType->currentText ());
@@ -116,7 +99,6 @@ void QgsGPSPluginGui::on_buttonBox_accepted()
116
99
leIMPLayer->text ());
117
100
break ;
118
101
}
119
-
120
102
// or download GPS data from a device?
121
103
case 2 : {
122
104
int featureType = cmbDLFeatureType->currentItem ();
@@ -125,13 +107,22 @@ void QgsGPSPluginGui::on_buttonBox_accepted()
125
107
leDLOutput->text (), leDLBasename->text ());
126
108
break ;
127
109
}
128
-
129
110
// or upload GPS data to a device?
130
- case 3 :
111
+ case 3 : {
131
112
emit uploadToGPS (mGPXLayers [cmbULLayer->currentItem ()],
132
113
cmbULDevice->currentText (), cmbULPort->currentText ());
133
114
break ;
134
115
}
116
+ // or convert between waypoints/tracks=
117
+ case 4 : {
118
+ int convertType = cmbCONVType->currentItem ();
119
+ emit convertGPSFile (leCONVInput->text (),
120
+ convertType,
121
+ leCONVOutput->text (),
122
+ leCONVLayer->text ());
123
+ break ;
124
+ }
125
+ }
135
126
accept ();
136
127
}
137
128
@@ -200,6 +191,16 @@ void QgsGPSPluginGui::enableRelevantControls()
200
191
else
201
192
pbnOK->setEnabled (true );
202
193
}
194
+
195
+ // convert between waypoint/routes
196
+ else if (tabWidget->currentPageIndex () == 4 ) {
197
+
198
+ if ((leCONVInput->text () == " " ) || (leCONVOutput->text () == " " ) ||
199
+ (leCONVLayer->text () == " " ))
200
+ pbnOK->setEnabled (false );
201
+ else
202
+ pbnOK->setEnabled (true );
203
+ }
203
204
}
204
205
205
206
@@ -400,6 +401,52 @@ void QgsGPSPluginGui::populateIMPBabelFormats() {
400
401
cmbDLDevice->setCurrentItem (d);
401
402
}
402
403
404
+ void QgsGPSPluginGui::populateCONVDialog () {
405
+ cmbCONVType->insertItem (tr (" Route -> Waypoint" ));
406
+ cmbCONVType->insertItem (tr (" Waypoint -> Route" ));
407
+ QString format = QString (" <html><head><meta name=\" qrichtext\" content=\" 1\" /><style type=\" text/css\" > p, li { white-space: pre-wrap; } </style></head><body style=\" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;\" ><p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:12pt;\" ><span style=\" font-size:10pt;\" >" \
408
+ " %1" \
409
+ " </span><a href=\" http://gpsbabel.sf.net\" ><span style=\" font-size:10pt; text-decoration: underline; color:#0000ff;\" >http://gpsbabel.sf.net</span></a><span style=\" font-size:10pt;\" >" \
410
+ " %2" \
411
+ " </span></p><p style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Arial'; font-size:10pt;\" >" \
412
+ " %3" \
413
+ " </p></body></html>" );
414
+ QString text = format
415
+ .arg (tr (" QGIS can perform conversions of GPX files, by using GPSBabel (" ))
416
+ .arg (tr (" ) to perform the conversions. This requires that you have GPSBabel installed where QGIS can find it." ))
417
+ .arg (tr (" Select a GPX input file name, the type of conversion you want to perform, a GPX filename that you want to save the converted file as, and a name for the new layer created from the result." ));
418
+
419
+ teCONVDescription->setHtml (text);
420
+ QgsDebugMsg (text);
421
+ }
422
+
423
+ void QgsGPSPluginGui::on_pbnCONVInput_clicked ()
424
+ {
425
+ QString myFileTypeQString;
426
+ QString myFilterString=tr (" GPS eXchange format (*.gpx)" );
427
+ QSettings settings;
428
+ QString dir = settings.readEntry (" /Plugin-GPS/gpxdirectory" );
429
+ if (dir.isEmpty ())
430
+ dir = " ." ;
431
+ QString myFileNameQString = QFileDialog::getOpenFileName (
432
+ this , // parent dialog
433
+ tr (" Select GPX file" ), // caption
434
+ dir, // initial dir
435
+ myFilterString, // filters to select
436
+ &myFileTypeQString); // the pointer to store selected filter
437
+ if (!myFileNameQString.isEmpty ())
438
+ leCONVInput->setText (myFileNameQString);
439
+ }
440
+
441
+ void QgsGPSPluginGui::on_pbnCONVOutput_clicked () {
442
+ QString myFileNameQString =
443
+ QFileDialog::getSaveFileName (this , // parent dialog
444
+ tr (" Choose a filename to save under" ),
445
+ " ." , // initial dir
446
+ tr (" GPS eXchange format (*.gpx)" ));
447
+ if (!myFileNameQString.isEmpty ())
448
+ leCONVOutput->setText (myFileNameQString);
449
+ }
403
450
404
451
void QgsGPSPluginGui::openDeviceEditor () {
405
452
QgsGPSDeviceDialog* dlg = new QgsGPSDeviceDialog (mDevices );
0 commit comments