Skip to content
Permalink
Browse files
** Added menu item for creating an empty GPX file
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 61684d0f78ccbd1b5d6280d67eab7029bf13393f
Showing with 35 additions and 1 deletion.
  1. +3 −0 ChangeLog
  2. +1 −1 configure.in
  3. +29 −0 plugins/gps_importer/qgsgpsplugin.cpp
  4. +2 −0 plugins/gps_importer/qgsgpsplugin.h
@@ -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)

@@ -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
@@ -44,6 +44,7 @@

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

//the gui subclass
@@ -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);

@@ -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)
@@ -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

0 comments on commit 61684d0

Please sign in to comment.