QGIS/plugins/gps_importer/qgsgpsdevice.cpp
larsl 1a4f4d138d Forgot to add the QgsGPSDevice files
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@2811 c8812cc2-4d05-0410-92ff-de0c093fc19c
2005-02-15 15:39:43 +00:00

85 lines
2.2 KiB
C++

#include <qregexp.h>
#include "qgsgpsdevice.h"
QgsGPSDevice::QgsGPSDevice(const QString& wptDlCmd, const QString& wptUlCmd,
const QString& rteDlCmd, const QString& rteUlCmd,
const QString& trkDlCmd, const QString& trkUlCmd) {
if (!wptDlCmd.isEmpty())
mWptDlCmd = QStringList::split(QRegExp("\\s"), wptDlCmd);
if (!wptUlCmd.isEmpty())
mWptUlCmd = QStringList::split(QRegExp("\\s"), wptUlCmd);
if (!rteDlCmd.isEmpty())
mRteDlCmd = QStringList::split(QRegExp("\\s"), rteDlCmd);
if (!rteUlCmd.isEmpty())
mRteUlCmd = QStringList::split(QRegExp("\\s"), rteUlCmd);
if (!trkDlCmd.isEmpty())
mTrkDlCmd = QStringList::split(QRegExp("\\s"), trkDlCmd);
if (!trkUlCmd.isEmpty())
mTrkUlCmd = QStringList::split(QRegExp("\\s"), trkUlCmd);
}
QStringList QgsGPSDevice::importCommand(const QString& babel,
const QString& type,
const QString& in,
const QString& out) const {
const QStringList* original;
if (type == "-w")
original = &mWptDlCmd;
else if (type == "-r")
original = &mRteDlCmd;
else if (type == "-t")
original = &mTrkDlCmd;
else throw "Bad error!";
QStringList copy;
QStringList::const_iterator iter;
for (iter = original->begin(); iter != original->end(); ++iter) {
if (*iter == "%babel")
copy.append(babel);
else if (*iter == "%type")
copy.append(type);
else if (*iter == "%in")
copy.append(in);
else if (*iter == "%out")
copy.append(out);
else
copy.append(*iter);
}
return copy;
}
QStringList QgsGPSDevice::exportCommand(const QString& babel,
const QString& type,
const QString& in,
const QString& out) const {
const QStringList* original;
if (type == "-w")
original = &mWptUlCmd;
else if (type == "-r")
original = &mRteUlCmd;
else if (type == "-t")
original = &mTrkUlCmd;
else throw "Bad error!";
QStringList copy;
QStringList::const_iterator iter;
for (iter = original->begin(); iter != original->end(); ++iter) {
if (*iter == "%babel")
copy.append(babel);
else if (*iter == "%type")
copy.append(type);
else if (*iter == "%in")
copy.append(in);
else if (*iter == "%out")
copy.append(out);
else
copy.append(*iter);
}
return copy;
}