Skip to content

Commit

Permalink
** Added menu item for creating an empty GPX file
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@2194 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
larsl committed Nov 2, 2004
1 parent 1c58002 commit 61684d0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog
Expand Up @@ -3,6 +3,9 @@ ChangeLog,v 1.200 2004/10/21 17:27:35 mcoletti Exp
------------------------------------------------------------------------------
Version 0.6 'Simon' .... development version

2004-11-02 [larsl] 0.5.0devel19
** Added menu item for creating an empty GPX file

2004-10-31 [timlinux] 0.5.0devel18
** Fix bug #1047002 (label buffer enabled / disabled checkbox not working)

Expand Down
2 changes: 1 addition & 1 deletion configure.in
Expand Up @@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
MAJOR_VERSION=0
MINOR_VERSION=5
MICRO_VERSION=0
EXTRA_VERSION=18
EXTRA_VERSION=19
if test $EXTRA_VERSION -eq 0; then
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
else
Expand Down
29 changes: 29 additions & 0 deletions plugins/gps_importer/qgsgpsplugin.cpp
Expand Up @@ -44,6 +44,7 @@

//non qt includes
#include <cassert>
#include <fstream>
#include <iostream>

//the gui subclass
Expand Down Expand Up @@ -101,6 +102,7 @@ void QgsGPSPlugin::initGui()
// add a menu with 2 items
QPopupMenu *pluginMenu = new QPopupMenu(mMainWindowPointer);
pluginMenu->insertItem(QIconSet(icon),"&Gps Tools", this, SLOT(run()));
pluginMenu->insertItem("&Create new GPX layer", this, SLOT(createGPX()));
mMenuBarPointer = ((QMainWindow *) mMainWindowPointer)->menuBar();
mMenuId = mQGisInterface->addMenu("&Gps", pluginMenu);

Expand Down Expand Up @@ -162,6 +164,33 @@ void QgsGPSPlugin::run()
}


void QgsGPSPlugin::createGPX() {
QString fileName =
QFileDialog::getSaveFileName("." , "GPS eXchange file (*.gpx)",
mMainWindowPointer, "OpenFileDialog",
"Save new GPX file as...");
if (!fileName.isEmpty()) {
QFileInfo fileInfo(fileName);
std::ofstream ofs((const char*)fileName);
if (!ofs) {
QMessageBox::warning(NULL, "Could not create file",
"Unable to create a GPX file with the given name. "
"Try again with another name or in another "
"directory.");
return;
}
ofs<<"<gpx></gpx>"<<std::endl;

emit drawVectorLayer(fileName + "?type=track",
fileInfo.baseName() + ", tracks", "gpx");
emit drawVectorLayer(fileName + "?type=route",
fileInfo.baseName() + ", routes", "gpx");
emit drawVectorLayer(fileName + "?type=waypoint",
fileInfo.baseName() + ", waypoints", "gpx");
}
}


void QgsGPSPlugin::drawVectorLayer(QString thePathNameQString,
QString theBaseNameQString,
QString theProviderQString)
Expand Down
2 changes: 2 additions & 0 deletions plugins/gps_importer/qgsgpsplugin.h
Expand Up @@ -47,6 +47,8 @@ class QgsGPSPlugin:public QObject, public QgisPlugin
public slots:
//! Show the dialog box
void run();
//! Create a new GPX layer
void createGPX();
//! Add a vector layer given vectorLayerPath, baseName, providerKey
void drawVectorLayer(QString,QString,QString);
//! unload the plugin
Expand Down

0 comments on commit 61684d0

Please sign in to comment.