2013-04-05 22:46:56 +02:00
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pfdqmlgadgetconfiguration.h"
|
|
|
|
#include "utils/pathutils.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads a saved configuration or defaults if non exist.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
PfdQmlGadgetConfiguration::PfdQmlGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
|
|
|
|
IUAVGadgetConfiguration(classId, parent),
|
|
|
|
m_qmlFile("Unknown"),
|
|
|
|
m_earthFile("Unknown"),
|
|
|
|
m_openGLEnabled(true),
|
|
|
|
m_terrainEnabled(false),
|
|
|
|
m_actualPositionUsed(false),
|
|
|
|
m_latitude(0),
|
|
|
|
m_longitude(0),
|
|
|
|
m_altitude(0),
|
2013-06-18 00:52:27 +02:00
|
|
|
m_cacheOnly(false),
|
|
|
|
m_speedFactor(1.0),
|
|
|
|
m_altitudeFactor(1.0)
|
2013-04-05 22:46:56 +02:00
|
|
|
{
|
2013-06-22 13:24:47 +02:00
|
|
|
m_speedMap[1.0] = "m/s";
|
|
|
|
m_speedMap[3.6] = "km/h";
|
|
|
|
m_speedMap[2.2369] = "mph";
|
|
|
|
m_speedMap[1.9438] = "knots";
|
2013-06-18 00:52:27 +02:00
|
|
|
|
2013-06-22 13:24:47 +02:00
|
|
|
m_altitudeMap[1.0] = "m";
|
2013-06-18 00:52:27 +02:00
|
|
|
m_altitudeMap[3.2808] = "ft";
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
// if a saved configuration exists load it
|
|
|
|
if (qSettings != 0) {
|
|
|
|
m_qmlFile = qSettings->value("qmlFile").toString();
|
|
|
|
m_qmlFile = Utils::PathUtils().InsertDataPath(m_qmlFile);
|
2013-04-05 22:46:56 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
m_earthFile = qSettings->value("earthFile").toString();
|
|
|
|
m_earthFile = Utils::PathUtils().InsertDataPath(m_earthFile);
|
2013-04-05 22:46:56 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
m_openGLEnabled = qSettings->value("openGLEnabled", true).toBool();
|
|
|
|
m_terrainEnabled = qSettings->value("terrainEnabled").toBool();
|
2013-04-05 22:46:56 +02:00
|
|
|
m_actualPositionUsed = qSettings->value("actualPositionUsed").toBool();
|
2013-05-19 16:37:30 +02:00
|
|
|
m_latitude = qSettings->value("latitude").toDouble();
|
|
|
|
m_longitude = qSettings->value("longitude").toDouble();
|
|
|
|
m_altitude = qSettings->value("altitude").toDouble();
|
|
|
|
m_cacheOnly = qSettings->value("cacheOnly").toBool();
|
2013-06-18 00:52:27 +02:00
|
|
|
m_speedFactor = qSettings->value("speedFactor").toDouble();
|
|
|
|
m_altitudeFactor = qSettings->value("altitudeFactor").toDouble();
|
2013-04-05 22:46:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Clones a configuration.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
IUAVGadgetConfiguration *PfdQmlGadgetConfiguration::clone()
|
|
|
|
{
|
|
|
|
PfdQmlGadgetConfiguration *m = new PfdQmlGadgetConfiguration(this->classId());
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
m->m_qmlFile = m_qmlFile;
|
|
|
|
m->m_openGLEnabled = m_openGLEnabled;
|
|
|
|
m->m_earthFile = m_earthFile;
|
|
|
|
m->m_terrainEnabled = m_terrainEnabled;
|
2013-04-05 22:46:56 +02:00
|
|
|
m->m_actualPositionUsed = m_actualPositionUsed;
|
2013-05-19 16:37:30 +02:00
|
|
|
m->m_latitude = m_latitude;
|
|
|
|
m->m_longitude = m_longitude;
|
|
|
|
m->m_altitude = m_altitude;
|
|
|
|
m->m_cacheOnly = m_cacheOnly;
|
2013-06-18 00:52:27 +02:00
|
|
|
m->m_speedFactor = m_speedFactor;
|
|
|
|
m->m_altitudeFactor = m_altitudeFactor;
|
2013-04-05 22:46:56 +02:00
|
|
|
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves a configuration.
|
|
|
|
*
|
|
|
|
*/
|
2013-05-19 16:37:30 +02:00
|
|
|
void PfdQmlGadgetConfiguration::saveConfig(QSettings *qSettings) const
|
|
|
|
{
|
|
|
|
QString qmlFile = Utils::PathUtils().RemoveDataPath(m_qmlFile);
|
|
|
|
|
2013-04-05 22:46:56 +02:00
|
|
|
qSettings->setValue("qmlFile", qmlFile);
|
|
|
|
QString earthFile = Utils::PathUtils().RemoveDataPath(m_earthFile);
|
|
|
|
qSettings->setValue("earthFile", earthFile);
|
|
|
|
|
|
|
|
qSettings->setValue("openGLEnabled", m_openGLEnabled);
|
|
|
|
qSettings->setValue("terrainEnabled", m_terrainEnabled);
|
|
|
|
qSettings->setValue("actualPositionUsed", m_actualPositionUsed);
|
|
|
|
qSettings->setValue("latitude", m_latitude);
|
|
|
|
qSettings->setValue("longitude", m_longitude);
|
|
|
|
qSettings->setValue("altitude", m_altitude);
|
|
|
|
qSettings->setValue("cacheOnly", m_cacheOnly);
|
2013-06-18 00:52:27 +02:00
|
|
|
qSettings->setValue("speedFactor", m_speedFactor);
|
|
|
|
qSettings->setValue("altitudeFactor", m_altitudeFactor);
|
2013-04-05 22:46:56 +02:00
|
|
|
}
|