mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Use QSettings key/properties instead of byte arrays for plugin configurations.
I've left in the reading of the byte arrays for now, so people can load their old config files, on the next save they'll be converted. This should be removed at some point in the not too far future though, since it's a lot of duplicate code in each plugin. I've converted all the plugins, it's certainly possible I made a typo somewhere, I tried to test as much as I could, sorry if I broke something though :) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1599 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ddf6ee46ee
commit
f826ee0a20
@ -34,15 +34,18 @@ ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, const QByt
|
||||
|
||||
}
|
||||
|
||||
ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetConfiguration::clone()
|
||||
{
|
||||
ConfigGadgetConfiguration *m = new ConfigGadgetConfiguration(this->classId());
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray ConfigGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
return bytes;
|
||||
void ConfigGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
|
||||
}
|
||||
|
@ -36,8 +36,9 @@ class ConfigGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
QByteArray saveState() const;
|
||||
explicit ConfigGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit ConfigGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
};
|
||||
|
@ -51,6 +51,11 @@ IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(const QByteArr
|
||||
return new ConfigGadgetConfiguration(QString("ConfigGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new ConfigGadgetConfiguration(QString("ConfigGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ConfigGadgetOptionsPage(qobject_cast<ConfigGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Core {
|
||||
|
||||
@ -46,7 +47,8 @@ public:
|
||||
bool locked() const { return m_locked; }
|
||||
void setLocked(bool locked) { m_locked = locked; }
|
||||
|
||||
virtual QByteArray saveState() const = 0;
|
||||
virtual void saveConfig(QSettings* settings) const = 0;
|
||||
|
||||
virtual IUAVGadgetConfiguration *clone() = 0;
|
||||
|
||||
signals:
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QSettings>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QStringList;
|
||||
@ -54,6 +55,7 @@ public:
|
||||
|
||||
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
|
||||
virtual IUAVGadgetConfiguration *createConfiguration(const QByteArray &/*state*/) { return 0; }
|
||||
virtual IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings) { return 0; }
|
||||
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; }
|
||||
QString classId() const { return m_classId; }
|
||||
QString name() const { return m_name; }
|
||||
|
@ -96,7 +96,14 @@ void UAVGadgetInstanceManager::readConfigs_1_0_0(QSettings *qs)
|
||||
{
|
||||
IUAVGadgetFactory *f = factory(classId);
|
||||
qs->beginGroup(classId);
|
||||
QStringList configs = qs->childKeys();
|
||||
|
||||
// New style: each config is a group, old style: each config is a value
|
||||
QStringList groups = qs->childGroups();
|
||||
bool oldStyle = groups.size() == 0;
|
||||
QStringList configs = QStringList();
|
||||
if(oldStyle) {
|
||||
// Old style configuration
|
||||
configs = qs->childKeys();
|
||||
|
||||
foreach (QString configName, configs) {
|
||||
QByteArray ba = QByteArray::fromBase64(qs->value(configName).toByteArray());
|
||||
@ -121,6 +128,33 @@ void UAVGadgetInstanceManager::readConfigs_1_0_0(QSettings *qs)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// New style configuration
|
||||
configs = qs->childGroups();
|
||||
|
||||
foreach (QString configName, configs) {
|
||||
qDebug() << "Loading config: " << classId << "," << configName;
|
||||
qs->beginGroup(configName);
|
||||
bool locked = qs->value("config.locked").toBool();
|
||||
IUAVGadgetConfiguration *config = f->createConfiguration(qs);
|
||||
if (config){
|
||||
config->setName(configName);
|
||||
config->setProvisionalName(configName);
|
||||
config->setLocked(locked);
|
||||
int idx = indexForConfig(m_configurations, classId, configName);
|
||||
if ( idx >= 0 ){
|
||||
// We should replace the config, but it might be used, so just
|
||||
// throw it out of the list. The GCS should be reinitialised soon.
|
||||
m_configurations[idx] = config;
|
||||
}
|
||||
else{
|
||||
m_configurations.append(config);
|
||||
}
|
||||
}
|
||||
|
||||
qs->endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
if (configs.count() == 0) {
|
||||
IUAVGadgetConfiguration *config = f->createConfiguration(0);
|
||||
@ -145,11 +179,11 @@ void UAVGadgetInstanceManager::writeConfigurations(QSettings *qs)
|
||||
foreach (IUAVGadgetConfiguration *config, m_configurations)
|
||||
{
|
||||
qs->beginGroup(config->classId());
|
||||
QByteArray ba;
|
||||
QDataStream stream(&ba, QIODevice::WriteOnly);
|
||||
stream << config->locked();
|
||||
stream << config->saveState();
|
||||
qs->setValue(config->name(), ba.toBase64());
|
||||
qs->beginGroup(config->name());
|
||||
// TODO: Someone could accidentially use the same name?
|
||||
qs->setValue("config.locked", config->locked());
|
||||
config->saveConfig(qs);
|
||||
qs->endGroup();
|
||||
qs->endGroup();
|
||||
}
|
||||
qs->endGroup();
|
||||
|
@ -88,6 +88,65 @@ DialGadgetConfiguration::DialGadgetConfiguration(QString classId, const QByteArr
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
DialGadgetConfiguration::DialGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultDial("Unknown"),
|
||||
dialBackgroundID("background"),
|
||||
dialForegroundID("foreground"),
|
||||
dialNeedleID1("needle"),
|
||||
dialNeedleID2("needle2"),
|
||||
dialNeedleID3("needle3"),
|
||||
needle1MinValue(0),
|
||||
needle1MaxValue(100),
|
||||
needle2MinValue(0),
|
||||
needle2MaxValue(100),
|
||||
needle3MinValue(0),
|
||||
needle3MaxValue(100),
|
||||
needle1Factor(1),
|
||||
needle2Factor(1),
|
||||
needle3Factor(1),
|
||||
needle1Move("Rotate"),
|
||||
needle2Move("Rotate"),
|
||||
needle3Move("Rotate")
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString dialFile = qSettings->value("dialFile").toString();
|
||||
|
||||
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile);
|
||||
dialBackgroundID = qSettings->value("dialBackgroundID").toString();
|
||||
dialForegroundID = qSettings->value("dialForegroundID").toString();
|
||||
dialNeedleID1 = qSettings->value("dialNeedleID1").toString();
|
||||
dialNeedleID2 = qSettings->value("dialNeedleID2").toString();
|
||||
dialNeedleID3 = qSettings->value("dialNeedleID3").toString();
|
||||
needle1MinValue = qSettings->value("needle1MinValue").toDouble();
|
||||
needle1MaxValue = qSettings->value("needle1MaxValue").toDouble();
|
||||
needle2MinValue = qSettings->value("needle2MinValue").toDouble();
|
||||
needle2MaxValue = qSettings->value("needle2MaxValue").toDouble();
|
||||
needle3MinValue = qSettings->value("needle3MinValue").toDouble();
|
||||
needle3MaxValue = qSettings->value("needle3MaxValue").toDouble();
|
||||
needle1DataObject = qSettings->value("needle1DataObject").toString();
|
||||
needle1ObjectField = qSettings->value("needle1ObjectField").toString();
|
||||
needle2DataObject = qSettings->value("needle2DataObject").toString();
|
||||
needle2ObjectField = qSettings->value("needle2ObjectField").toString();
|
||||
needle3DataObject = qSettings->value("needle3DataObject").toString();
|
||||
needle3ObjectField = qSettings->value("needle3ObjectField").toString();
|
||||
needle1Factor = qSettings->value("needle1Factor").toDouble();
|
||||
needle2Factor = qSettings->value("needle2Factor").toDouble();
|
||||
needle3Factor = qSettings->value("needle3Factor").toDouble();
|
||||
needle1Move = qSettings->value("needle1Move").toString();
|
||||
needle2Move = qSettings->value("needle2Move").toString();
|
||||
needle3Move = qSettings->value("needle3Move").toString();
|
||||
font = qSettings->value("font").toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -123,40 +182,43 @@ IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray DialGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
void DialGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
|
||||
stream << dialFile;
|
||||
stream << dialBackgroundID;
|
||||
stream << dialForegroundID;
|
||||
stream << dialNeedleID1;
|
||||
stream << dialNeedleID2;
|
||||
stream << dialNeedleID3;
|
||||
stream << needle1MinValue;
|
||||
stream << needle1MaxValue;
|
||||
stream << needle2MinValue;
|
||||
stream << needle2MaxValue;
|
||||
stream << needle3MinValue;
|
||||
stream << needle3MaxValue;
|
||||
stream << needle1DataObject;
|
||||
stream << needle1ObjectField;
|
||||
stream << needle2DataObject;
|
||||
stream << needle2ObjectField;
|
||||
stream << needle3DataObject;
|
||||
stream << needle3ObjectField;
|
||||
stream << needle1Factor;
|
||||
stream << needle2Factor;
|
||||
stream << needle3Factor;
|
||||
stream << needle1Move;
|
||||
stream << needle2Move;
|
||||
stream << needle3Move;
|
||||
stream << font;
|
||||
settings->setValue("dialFile", dialFile);
|
||||
|
||||
return bytes;
|
||||
settings->setValue("dialBackgroundID", dialBackgroundID);
|
||||
settings->setValue("dialForegroundID", dialForegroundID);
|
||||
|
||||
settings->setValue("dialNeedleID1", dialNeedleID1);
|
||||
settings->setValue("dialNeedleID2", dialNeedleID2);
|
||||
settings->setValue("dialNeedleID3", dialNeedleID3);
|
||||
|
||||
settings->setValue("needle1MinValue", needle1MinValue);
|
||||
settings->setValue("needle1MaxValue", needle1MaxValue);
|
||||
settings->setValue("needle2MinValue", needle2MinValue);
|
||||
settings->setValue("needle2MaxValue", needle2MaxValue);
|
||||
settings->setValue("needle3MinValue", needle3MinValue);
|
||||
settings->setValue("needle3MaxValue", needle3MaxValue);
|
||||
|
||||
settings->setValue("needle1DataObject", needle1DataObject);
|
||||
settings->setValue("needle1ObjectField", needle1ObjectField);
|
||||
settings->setValue("needle2DataObject", needle2DataObject);
|
||||
settings->setValue("needle2ObjectField", needle2ObjectField);
|
||||
settings->setValue("needle3DataObject", needle3DataObject);
|
||||
settings->setValue("needle3ObjectField", needle3ObjectField);
|
||||
|
||||
settings->setValue("needle1Factor", needle1Factor);
|
||||
settings->setValue("needle2Factor", needle2Factor);
|
||||
settings->setValue("needle3Factor", needle3Factor);
|
||||
|
||||
settings->setValue("needle1Move", needle1Move);
|
||||
settings->setValue("needle2Move", needle2Move);
|
||||
settings->setValue("needle3Move", needle3Move);
|
||||
|
||||
settings->setValue("font", font);
|
||||
}
|
||||
|
@ -40,7 +40,9 @@ class DialGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit DialGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit DialGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
|
||||
//set dial configuration functions
|
||||
void setDialFile(QString dialFile){m_defaultDial=dialFile;}
|
||||
@ -97,7 +99,7 @@ public:
|
||||
QString getN3Move() { return needle3Move; }
|
||||
QString getFont() { return font;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -54,6 +54,11 @@ IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(const QByteArray
|
||||
return new DialGadgetConfiguration(QString("DialGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new DialGadgetConfiguration(QString("DialGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *DialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new DialGadgetOptionsPage(qobject_cast<DialGadgetConfiguration*>(config));
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -84,6 +84,53 @@ GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, co
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
GpsDisplayGadgetConfiguration::GpsDisplayGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_connectionMode("Serial"),
|
||||
m_defaultPort("Unknown"),
|
||||
m_defaultSpeed(BAUD4800),
|
||||
m_defaultDataBits(DATA_8),
|
||||
m_defaultFlow(FLOW_OFF),
|
||||
m_defaultParity(PAR_NONE),
|
||||
m_defaultStopBits(STOP_1),
|
||||
m_defaultTimeOut(5000)
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
BaudRateType speed;
|
||||
DataBitsType databits;
|
||||
FlowType flow;
|
||||
ParityType parity;
|
||||
StopBitsType stopbits;
|
||||
|
||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||
int iflow = qSettings->value("defaultFlow").toInt();
|
||||
int iparity = qSettings->value("defaultParity").toInt();
|
||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
||||
QString port = qSettings->value("defaultPort").toString();
|
||||
QString conMode = qSettings->value("connectionMode").toString();
|
||||
|
||||
databits = (DataBitsType) idatabits;
|
||||
flow = (FlowType)iflow;
|
||||
parity = (ParityType)iparity;
|
||||
stopbits = (StopBitsType)istopbits;
|
||||
speed = (BaudRateType)ispeed;
|
||||
m_defaultPort = port;
|
||||
m_defaultSpeed = speed;
|
||||
m_defaultDataBits = databits;
|
||||
m_defaultFlow = flow;
|
||||
m_defaultParity = parity;
|
||||
m_defaultStopBits = stopbits;
|
||||
m_connectionMode = conMode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -106,16 +153,13 @@ IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone()
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray GpsDisplayGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << (int)m_defaultSpeed;
|
||||
stream << (int)m_defaultDataBits;
|
||||
stream << (int)m_defaultFlow;
|
||||
stream << (int)m_defaultParity;
|
||||
stream << (int)m_defaultStopBits;
|
||||
stream << m_defaultPort;
|
||||
stream << m_connectionMode;
|
||||
return bytes;
|
||||
void GpsDisplayGadgetConfiguration::saveConfig(QSettings* settings) const {
|
||||
settings->setValue("defaultSpeed", m_defaultSpeed);
|
||||
settings->setValue("defaultDataBits", m_defaultDataBits);
|
||||
settings->setValue("defaultFlow", m_defaultFlow);
|
||||
settings->setValue("defaultParity", m_defaultParity);
|
||||
settings->setValue("defaultStopBits", m_defaultStopBits);
|
||||
settings->setValue("defaultPort", m_defaultPort);
|
||||
settings->setValue("connectionMode", m_connectionMode);
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,8 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GpsDisplayGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit GpsDisplayGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit GpsDisplayGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
void setConnectionMode(QString mode) { m_connectionMode = mode; }
|
||||
QString connectionMode() { return m_connectionMode; }
|
||||
@ -60,7 +61,7 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
ParityType parity() {return m_defaultParity;}
|
||||
long timeOut(){return m_defaultTimeOut;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +53,11 @@ IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(const QByt
|
||||
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *GpsDisplayGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new GpsDisplayGadgetOptionsPage(qobject_cast<GpsDisplayGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -56,6 +56,33 @@ HITLConfiguration::HITLConfiguration(QString classId, const QByteArray &state, Q
|
||||
}
|
||||
}
|
||||
|
||||
HITLConfiguration::HITLConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent)
|
||||
{
|
||||
settings.simulatorId = "";
|
||||
settings.binPath = "";
|
||||
settings.dataPath = "";
|
||||
settings.manual = false;
|
||||
settings.hostAddress = "127.0.0.1";
|
||||
settings.outPort = 0;
|
||||
settings.inPort = 0;
|
||||
settings.latitude = "";
|
||||
settings.longitude = "";
|
||||
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
settings.simulatorId = qSettings->value("simulatorId").toString();
|
||||
settings.binPath = qSettings->value("binPath").toString();
|
||||
settings.dataPath = qSettings->value("dataPath").toString();
|
||||
settings.manual = qSettings->value("manual").toBool();
|
||||
settings.hostAddress = qSettings->value("hostAddress").toString();
|
||||
settings.outPort = qSettings->value("outPort").toInt();
|
||||
settings.inPort = qSettings->value("inPort").toInt();
|
||||
settings.latitude = qSettings->value("latitude").toString();
|
||||
settings.longitude = qSettings->value("longitude").toString();
|
||||
}
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *HITLConfiguration::clone()
|
||||
{
|
||||
HITLConfiguration *m = new HITLConfiguration(this->classId());
|
||||
@ -64,20 +91,19 @@ IUAVGadgetConfiguration *HITLConfiguration::clone()
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray HITLConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
|
||||
stream << settings.simulatorId;
|
||||
stream << settings.binPath;
|
||||
stream << settings.dataPath;
|
||||
stream << settings.manual;
|
||||
stream << settings.hostAddress;
|
||||
stream << settings.outPort;
|
||||
stream << settings.inPort;
|
||||
stream << settings.latitude;
|
||||
stream << settings.longitude;
|
||||
return bytes;
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void HITLConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("simulatorId", settings.simulatorId);
|
||||
qSettings->setValue("binPath", settings.binPath);
|
||||
qSettings->setValue("dataPath", settings.dataPath);
|
||||
qSettings->setValue("manual", settings.manual);
|
||||
qSettings->setValue("hostAddress", settings.hostAddress);
|
||||
qSettings->setValue("outPort", settings.outPort);
|
||||
qSettings->setValue("inPort", settings.inPort);
|
||||
qSettings->setValue("latitude", settings.latitude);
|
||||
qSettings->setValue("longitude", settings.longitude);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,10 @@ class HITLConfiguration : public IUAVGadgetConfiguration
|
||||
Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings)
|
||||
|
||||
public:
|
||||
explicit HITLConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
QByteArray saveState() const;
|
||||
explicit HITLConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit HITLConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
SimulatorSettings Settings() const { return settings; }
|
||||
|
@ -54,6 +54,11 @@ IUAVGadgetConfiguration *HITLFactory::createConfiguration(const QByteArray &stat
|
||||
return new HITLConfiguration(QString("HITL"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *HITLFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new HITLConfiguration(QString("HITL"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new HITLOptionsPage(qobject_cast<HITLConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -44,6 +44,21 @@ ImportExportGadgetConfiguration::ImportExportGadgetConfiguration(QString classId
|
||||
stream >> dialFile;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
ImportExportGadgetConfiguration::ImportExportGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
dialFile("gcs.ini")
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
dialFile = qSettings->value("dialFile").toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -54,16 +69,13 @@ IUAVGadgetConfiguration *ImportExportGadgetConfiguration::clone()
|
||||
m->dialFile = dialFile;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray ImportExportGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << dialFile;
|
||||
return bytes;
|
||||
void ImportExportGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("dialFile", dialFile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,8 @@ class IMPORTEXPORT_EXPORT ImportExportGadgetConfiguration : public IUAVGadgetCon
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImportExportGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit ImportExportGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit ImportExportGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set dial configuration functions
|
||||
void setDialFile(QString filename) {
|
||||
@ -51,7 +52,7 @@ public:
|
||||
return dialFile;
|
||||
}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -56,6 +56,12 @@ IUAVGadgetConfiguration *ImportExportGadgetFactory::createConfiguration(const QB
|
||||
return lastConfig;
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ImportExportGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
lastConfig = new ImportExportGadgetConfiguration(QString("ImportExportGadget"), qSettings);
|
||||
return lastConfig;
|
||||
}
|
||||
|
||||
IOptionsPage *ImportExportGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ImportExportGadgetOptionsPage(qobject_cast<ImportExportGadgetConfiguration*>(config));
|
||||
|
@ -48,6 +48,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
|
||||
private:
|
||||
|
@ -37,9 +37,20 @@ IPconnectionConfiguration::IPconnectionConfiguration(QString classId, const QByt
|
||||
{
|
||||
settings = Core::ICore::instance()->settings();
|
||||
}
|
||||
|
||||
IPconnectionConfiguration::IPconnectionConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_HostName("127.0.0.1"),
|
||||
m_Port(1000),
|
||||
m_UseTCP(1)
|
||||
{
|
||||
settings = Core::ICore::instance()->settings();
|
||||
}
|
||||
|
||||
IPconnectionConfiguration::~IPconnectionConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
|
||||
{
|
||||
IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId());
|
||||
@ -49,18 +60,16 @@ IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray IPconnectionConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << m_Port;
|
||||
stream << m_HostName;
|
||||
stream << m_UseTCP;
|
||||
return bytes;
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void IPconnectionConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("port", m_Port);
|
||||
qSettings->setValue("hostName", m_HostName);
|
||||
qSettings->setValue("useTCP", m_UseTCP);
|
||||
}
|
||||
|
||||
|
||||
void IPconnectionConfiguration::savesettings() const
|
||||
{
|
||||
settings->beginGroup(QLatin1String("IPconnection"));
|
||||
|
@ -42,9 +42,11 @@ Q_PROPERTY(int Port READ Port WRITE setPort)
|
||||
Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP)
|
||||
|
||||
public:
|
||||
explicit IPconnectionConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit IPconnectionConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit IPconnectionConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
virtual ~IPconnectionConfiguration();
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
//void savesettings(QSettings* settings) const;
|
||||
//void restoresettings(QSettings* settings);
|
||||
void savesettings() const;
|
||||
|
@ -70,6 +70,47 @@ LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, co
|
||||
stream >> factor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
dialFile("Unknown"),
|
||||
sourceDataObject("Unknown"),
|
||||
sourceObjectField("Unknown"),
|
||||
minValue(0),
|
||||
maxValue(100),
|
||||
redMin(0),
|
||||
redMax(33),
|
||||
yellowMin(33),
|
||||
yellowMax(66),
|
||||
greenMin(66),
|
||||
greenMax(100),
|
||||
factor(1.00),
|
||||
decimalPlaces(0)
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString dFile = qSettings->value("dFile").toString();
|
||||
dialFile = Utils::PathUtils().InsertDataPath(dFile);
|
||||
sourceDataObject = qSettings->value("sourceDataObject").toString();
|
||||
sourceObjectField = qSettings->value("sourceObjectField").toString();
|
||||
minValue = qSettings->value("minValue").toDouble();
|
||||
maxValue = qSettings->value("maxValue").toDouble();
|
||||
redMin = qSettings->value("redMin").toDouble();
|
||||
redMax = qSettings->value("redMax").toDouble();
|
||||
yellowMin = qSettings->value("yellowMin").toDouble();
|
||||
yellowMax = qSettings->value("yellowMax").toDouble();
|
||||
greenMin = qSettings->value("greenMin").toDouble();
|
||||
greenMax = qSettings->value("greenMax").toDouble();
|
||||
font = qSettings->value("font").toString();
|
||||
decimalPlaces = qSettings->value("decimalPlaces").toInt();
|
||||
factor = qSettings->value("factor").toDouble();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -94,29 +135,25 @@ IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray LineardialGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
void LineardialGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
QString dFile = Utils::PathUtils().RemoveDataPath(dialFile);
|
||||
stream << dFile;
|
||||
stream << sourceDataObject;
|
||||
stream << sourceObjectField;
|
||||
stream << minValue;
|
||||
stream << maxValue;
|
||||
stream << redMin;
|
||||
stream << redMax;
|
||||
stream << yellowMin;
|
||||
stream << yellowMax;
|
||||
stream << greenMin;
|
||||
stream << greenMax;
|
||||
stream << font;
|
||||
stream << decimalPlaces;
|
||||
stream << factor;
|
||||
|
||||
return bytes;
|
||||
qSettings->setValue("dFile", dFile);
|
||||
qSettings->setValue("sourceDataObject", sourceDataObject);
|
||||
qSettings->setValue("sourceObjectField", sourceObjectField);
|
||||
qSettings->setValue("minValue", minValue);
|
||||
qSettings->setValue("maxValue", maxValue);
|
||||
qSettings->setValue("redMin", redMin);
|
||||
qSettings->setValue("redMax", redMax);
|
||||
qSettings->setValue("yellowMin", yellowMin);
|
||||
qSettings->setValue("yellowMax", yellowMax);
|
||||
qSettings->setValue("greenMin", greenMin);
|
||||
qSettings->setValue("greenMax", greenMax);
|
||||
qSettings->setValue("font", font);
|
||||
qSettings->setValue("decimalPlaces", decimalPlaces);
|
||||
qSettings->setValue("factor", factor);
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ class LineardialGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LineardialGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit LineardialGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit LineardialGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set dial configuration functions
|
||||
void setDialFile(QString filename){dialFile=filename;}
|
||||
@ -72,7 +73,7 @@ public:
|
||||
int getDecimalPlaces() { return decimalPlaces; }
|
||||
double getFactor() { return factor; }
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +53,11 @@ IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(const QByt
|
||||
return new LineardialGadgetConfiguration(QString("LineardialGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new LineardialGadgetConfiguration(QString("LineardialGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *LineardialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new LineardialGadgetOptionsPage(qobject_cast<LineardialGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -47,6 +47,22 @@ ModelViewGadgetConfiguration::ModelViewGadgetConfiguration(QString classId, cons
|
||||
}
|
||||
}
|
||||
|
||||
ModelViewGadgetConfiguration::ModelViewGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_acFilename("../share/models/Easystar/EasyStar.3ds"),
|
||||
m_bgFilename(""),
|
||||
m_enableVbo(false)
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString modelFile = qSettings->value("acFilename").toString();
|
||||
QString bgFile = qSettings->value("bgFilename").toString();
|
||||
m_enableVbo = qSettings->value("enableVbo").toBool();
|
||||
m_acFilename = Utils::PathUtils().InsertDataPath(modelFile);
|
||||
m_bgFilename = Utils::PathUtils().InsertDataPath(bgFile);
|
||||
}
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
|
||||
{
|
||||
ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId());
|
||||
@ -56,14 +72,12 @@ IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
|
||||
return mv;
|
||||
}
|
||||
|
||||
QByteArray ModelViewGadgetConfiguration::saveState() const
|
||||
{
|
||||
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << Utils::PathUtils().RemoveDataPath(m_acFilename);
|
||||
stream << Utils::PathUtils().RemoveDataPath(m_bgFilename);
|
||||
stream << m_enableVbo;
|
||||
return bytes;
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void ModelViewGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("acFilename", Utils::PathUtils().RemoveDataPath(m_acFilename));
|
||||
qSettings->setValue("bgFilename", Utils::PathUtils().RemoveDataPath(m_bgFilename));
|
||||
qSettings->setValue("enableVbo", m_enableVbo);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,10 @@ class ModelViewGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ModelViewGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
QByteArray saveState() const;
|
||||
explicit ModelViewGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit ModelViewGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
QString acFilename() {return m_acFilename;}
|
||||
void setAcFilename(QString acFile) { m_acFilename = acFile; }
|
||||
|
@ -52,6 +52,11 @@ IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(const QByte
|
||||
return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *ModelViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ModelViewGadgetOptionsPage(qobject_cast<ModelViewGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -78,6 +78,44 @@ OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, const QByteA
|
||||
}
|
||||
}
|
||||
|
||||
OPMapGadgetConfiguration::OPMapGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_mapProvider("GoogleHybrid"),
|
||||
m_defaultZoom(2),
|
||||
m_defaultLatitude(0),
|
||||
m_defaultLongitude(0),
|
||||
m_useOpenGL(false),
|
||||
m_showTileGridLines(false),
|
||||
m_accessMode("ServerAndCache"),
|
||||
m_useMemoryCache(true),
|
||||
m_cacheLocation(QDir::currentPath() + QDir::separator() + "mapscache" + QDir::separator())
|
||||
{
|
||||
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString mapProvider = qSettings->value("mapProvider").toString();
|
||||
int zoom = qSettings->value("defaultZoom").toInt();
|
||||
double latitude= qSettings->value("defaultLatitude").toDouble();
|
||||
double longitude= qSettings->value("defaultLongitude").toDouble();
|
||||
bool useOpenGL= qSettings->value("useOpenGL").toBool();
|
||||
bool showTileGridLines= qSettings->value("showTileGridLines").toBool();
|
||||
QString accessMode= qSettings->value("accessMode").toString();
|
||||
bool useMemoryCache= qSettings->value("useMemoryCache").toBool();
|
||||
QString cacheLocation= qSettings->value("cacheLocation").toString();
|
||||
|
||||
if (!mapProvider.isEmpty()) m_mapProvider = mapProvider;
|
||||
m_defaultZoom = zoom;
|
||||
m_defaultLatitude = latitude;
|
||||
m_defaultLongitude = longitude;
|
||||
m_useOpenGL = useOpenGL;
|
||||
m_showTileGridLines = showTileGridLines;
|
||||
|
||||
if (!accessMode.isEmpty()) m_accessMode = accessMode;
|
||||
m_useMemoryCache = useMemoryCache;
|
||||
if (!cacheLocation.isEmpty()) m_cacheLocation = cacheLocation;
|
||||
}
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
||||
{
|
||||
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
|
||||
@ -95,20 +133,14 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray OPMapGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
|
||||
stream << m_mapProvider;
|
||||
stream << m_defaultZoom;
|
||||
stream << m_defaultLatitude;
|
||||
stream << m_defaultLongitude;
|
||||
stream << m_useOpenGL;
|
||||
stream << m_showTileGridLines;
|
||||
stream << m_accessMode;
|
||||
stream << m_useMemoryCache;
|
||||
stream << m_cacheLocation;
|
||||
|
||||
return bytes;
|
||||
void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("mapProvider", m_mapProvider);
|
||||
qSettings->setValue("defaultZoom", m_defaultZoom);
|
||||
qSettings->setValue("defaultLatitude", m_defaultLatitude);
|
||||
qSettings->setValue("defaultLongitude", m_defaultLongitude);
|
||||
qSettings->setValue("useOpenGL", m_useOpenGL);
|
||||
qSettings->setValue("showTileGridLines", m_showTileGridLines);
|
||||
qSettings->setValue("accessMode", m_accessMode);
|
||||
qSettings->setValue("useMemoryCache", m_useMemoryCache);
|
||||
qSettings->setValue("cacheLocation", m_cacheLocation);
|
||||
}
|
||||
|
@ -48,8 +48,10 @@ Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
|
||||
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
|
||||
|
||||
public:
|
||||
explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
QByteArray saveState() const;
|
||||
explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
QString mapProvider() const { return m_mapProvider; }
|
||||
|
@ -51,6 +51,11 @@ IUAVGadgetConfiguration * OPMapGadgetFactory::createConfiguration(const QByteArr
|
||||
return new OPMapGadgetConfiguration(QString("OPMapGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new OPMapGadgetConfiguration(QString("OPMapGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new OPMapGadgetOptionsPage(qobject_cast<OPMapGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -47,6 +47,24 @@ PFDGadgetConfiguration::PFDGadgetConfiguration(QString classId, const QByteArray
|
||||
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
PFDGadgetConfiguration::PFDGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultDial("Unknown")
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString dialFile = qSettings->value("dialFile").toString();
|
||||
useOpenGLFlag = qSettings->value("useOpenGLFlag").toBool();
|
||||
hqFonts = qSettings->value("hqFonts").toBool();
|
||||
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -59,18 +77,14 @@ IUAVGadgetConfiguration *PFDGadgetConfiguration::clone()
|
||||
m->hqFonts = hqFonts;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray PFDGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
void PFDGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
|
||||
stream << dialFile;
|
||||
stream << useOpenGLFlag;
|
||||
stream << hqFonts;
|
||||
|
||||
return bytes;
|
||||
qSettings->setValue("dialFile", dialFile);
|
||||
qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
|
||||
qSettings->setValue("hqFonts", hqFonts);
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ class PFDGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PFDGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit PFDGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit PFDGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set dial configuration functions
|
||||
void setDialFile(QString dialFile){m_defaultDial=dialFile;}
|
||||
@ -47,7 +48,7 @@ public:
|
||||
bool useOpenGL() { return useOpenGLFlag; }
|
||||
bool getHqFonts() { return hqFonts; }
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +53,11 @@ IUAVGadgetConfiguration *PFDGadgetFactory::createConfiguration(const QByteArray
|
||||
return new PFDGadgetConfiguration(QString("PFDGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *PFDGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new PFDGadgetConfiguration(QString("PFDGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *PFDGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new PFDGadgetOptionsPage(qobject_cast<PFDGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -78,6 +78,58 @@ ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, const QByteA
|
||||
}
|
||||
|
||||
|
||||
ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_plotType((int)ChronoPlot),
|
||||
m_dataSize(60),
|
||||
m_refreshInterval(1000)
|
||||
{
|
||||
uint currentStreamVersion = 0;
|
||||
int plotCurveCount = 0;
|
||||
|
||||
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
currentStreamVersion = qSettings->value("configurationStreamVersion").toUInt();
|
||||
|
||||
if(currentStreamVersion != m_configurationStreamVersion)
|
||||
return;
|
||||
|
||||
m_plotType = qSettings->value("plotType").toInt();
|
||||
m_dataSize = qSettings->value("dataSize").toInt();
|
||||
m_refreshInterval = qSettings->value("refreshInterval").toInt();
|
||||
plotCurveCount = qSettings->value("plotCurveCount").toInt();
|
||||
|
||||
for(int plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
|
||||
{
|
||||
QString uavObject;
|
||||
QString uavField;
|
||||
QRgb color;
|
||||
|
||||
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
||||
|
||||
PlotCurveConfiguration* plotCurveConf = new PlotCurveConfiguration();
|
||||
uavObject = qSettings->value("uavObject").toString();
|
||||
plotCurveConf->uavObject = uavObject;
|
||||
uavField = qSettings->value("uavField").toString();
|
||||
plotCurveConf->uavField = uavField;
|
||||
color = qSettings->value("color").value<QRgb>();
|
||||
plotCurveConf->color = color;
|
||||
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
|
||||
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
|
||||
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
|
||||
|
||||
m_PlotCurveConfigs.append(plotCurveConf);
|
||||
|
||||
qSettings->endGroup();
|
||||
}
|
||||
|
||||
//The value is converted to milliseconds, so if it is < 100, it is still seconds
|
||||
if(m_refreshInterval < 100)
|
||||
m_refreshInterval *= 1000;
|
||||
}
|
||||
}
|
||||
|
||||
void ScopeGadgetConfiguration::clearPlotData()
|
||||
{
|
||||
PlotCurveConfiguration* poltCurveConfig;
|
||||
@ -129,31 +181,31 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray ScopeGadgetConfiguration::saveState() const
|
||||
{
|
||||
void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
|
||||
int plotCurveCount = m_PlotCurveConfigs.size();
|
||||
int plotDatasLoadIndex = 0;
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << m_configurationStreamVersion;
|
||||
stream << m_plotType;
|
||||
stream << m_dataSize;
|
||||
stream << m_refreshInterval;
|
||||
stream << plotCurveCount;
|
||||
|
||||
qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion);
|
||||
qSettings->setValue("plotType", m_plotType);
|
||||
qSettings->setValue("dataSize", m_dataSize);
|
||||
qSettings->setValue("refreshInterval", m_refreshInterval);
|
||||
qSettings->setValue("plotCurveCount", plotCurveCount);
|
||||
|
||||
for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
|
||||
{
|
||||
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
|
||||
|
||||
PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(plotDatasLoadIndex);
|
||||
qSettings->setValue("uavObject", plotCurveConf->uavObject);
|
||||
qSettings->setValue("uavField", plotCurveConf->uavField);
|
||||
qSettings->setValue("color", plotCurveConf->color);
|
||||
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
|
||||
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
|
||||
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
|
||||
|
||||
stream << plotCurveConf->uavObject;
|
||||
stream << plotCurveConf->uavField;
|
||||
stream << plotCurveConf->color;
|
||||
stream << plotCurveConf->yScalePower;
|
||||
stream << plotCurveConf->yMinimum;
|
||||
stream << plotCurveConf->yMaximum;
|
||||
qSettings->endGroup();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration*> newPlotCurveConfigs)
|
||||
|
@ -49,7 +49,9 @@ class ScopeGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ScopeGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit ScopeGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit ScopeGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
~ScopeGadgetConfiguration();
|
||||
|
||||
//configuration setter functions
|
||||
@ -66,7 +68,7 @@ public:
|
||||
int refreshInterval(){return m_refreshInterval;}
|
||||
QList<PlotCurveConfiguration*> plotCurveConfigs(){return m_PlotCurveConfigs;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +53,11 @@ IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(const QByteArra
|
||||
return new ScopeGadgetConfiguration(QString("ScopeGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new ScopeGadgetConfiguration(QString("ScopeGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new ScopeGadgetOptionsPage(qobject_cast<ScopeGadgetConfiguration*>(config));
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -45,6 +45,22 @@ SystemHealthGadgetConfiguration::SystemHealthGadgetConfiguration(QString classId
|
||||
systemFile = Utils::PathUtils().InsertDataPath(diagram);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
SystemHealthGadgetConfiguration::SystemHealthGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
systemFile("Unknown")
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QString diagram= qSettings->value("diagram").toString();
|
||||
systemFile = Utils::PathUtils().InsertDataPath(diagram);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -55,16 +71,12 @@ IUAVGadgetConfiguration *SystemHealthGadgetConfiguration::clone()
|
||||
m->systemFile=systemFile;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray SystemHealthGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
void SystemHealthGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
QString diagram = Utils::PathUtils().RemoveDataPath(systemFile);
|
||||
stream << diagram;
|
||||
|
||||
return bytes;
|
||||
qSettings->setValue("diagram", diagram);
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ class SystemHealthGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SystemHealthGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit SystemHealthGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit SystemHealthGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set system health configuration functions
|
||||
void setSystemFile(QString filename){systemFile=filename;}
|
||||
@ -47,7 +48,7 @@ public:
|
||||
//get dial configuration functions
|
||||
QString getSystemFile() {return systemFile;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -53,6 +53,11 @@ IUAVGadgetConfiguration *SystemHealthGadgetFactory::createConfiguration(const QB
|
||||
return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *SystemHealthGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *SystemHealthGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new SystemHealthGadgetOptionsPage(qobject_cast<SystemHealthGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -48,6 +48,24 @@ UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, co
|
||||
}
|
||||
}
|
||||
|
||||
UAVObjectBrowserConfiguration::UAVObjectBrowserConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_recentlyUpdatedColor(QColor(255, 230, 230)),
|
||||
m_manuallyChangedColor(QColor(230, 230, 255)),
|
||||
m_recentlyUpdatedTimeout(500)
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
QColor recent = qSettings->value("recentlyUpdatedColor").value<QColor>();
|
||||
QColor manual = qSettings->value("manuallyChangedColor").value<QColor>();
|
||||
int timeout = qSettings->value("recentlyUpdatedTimeout").toInt();
|
||||
|
||||
m_recentlyUpdatedColor = recent;
|
||||
m_manuallyChangedColor = manual;
|
||||
m_recentlyUpdatedTimeout = timeout;
|
||||
}
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
|
||||
{
|
||||
UAVObjectBrowserConfiguration *m = new UAVObjectBrowserConfiguration(this->classId());
|
||||
@ -57,13 +75,12 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
|
||||
return m;
|
||||
}
|
||||
|
||||
QByteArray UAVObjectBrowserConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << m_recentlyUpdatedColor;
|
||||
stream << m_manuallyChangedColor;
|
||||
stream << m_recentlyUpdatedTimeout;
|
||||
return bytes;
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
void UAVObjectBrowserConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("recentlyUpdatedColor", m_recentlyUpdatedColor);
|
||||
qSettings->setValue("manuallyChangedColor", m_manuallyChangedColor);
|
||||
qSettings->setValue("recentlyUpdatedTimeout", m_recentlyUpdatedTimeout);
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,10 @@ Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRece
|
||||
Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor)
|
||||
Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout)
|
||||
public:
|
||||
explicit UAVObjectBrowserConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
QByteArray saveState() const;
|
||||
explicit UAVObjectBrowserConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit UAVObjectBrowserConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
QColor recentlyUpdatedColor() const { return m_recentlyUpdatedColor; }
|
||||
|
@ -51,6 +51,12 @@ IUAVGadgetConfiguration *UAVObjectBrowserFactory::createConfiguration(const QByt
|
||||
return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *UAVObjectBrowserFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), qSettings);
|
||||
}
|
||||
|
||||
|
||||
IOptionsPage *UAVObjectBrowserFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new UAVObjectBrowserOptionsPage(qobject_cast<UAVObjectBrowserConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
@ -80,6 +80,54 @@ UploaderGadgetConfiguration::UploaderGadgetConfiguration(QString classId, const
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
*
|
||||
*/
|
||||
UploaderGadgetConfiguration::UploaderGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_defaultPort("Unknown"),
|
||||
m_defaultSpeed(BAUD19200),
|
||||
m_defaultDataBits(DATA_8),
|
||||
m_defaultFlow(FLOW_OFF),
|
||||
m_defaultParity(PAR_NONE),
|
||||
m_defaultStopBits(STOP_1),
|
||||
m_defaultTimeOut(5000)
|
||||
|
||||
{
|
||||
//if a saved configuration exists load it
|
||||
if(qSettings != 0) {
|
||||
BaudRateType speed;
|
||||
DataBitsType databits;
|
||||
FlowType flow;
|
||||
ParityType parity;
|
||||
StopBitsType stopbits;
|
||||
|
||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||
int iflow = qSettings->value("defaultFlow").toInt();
|
||||
int iparity = qSettings->value("defaultParity").toInt();
|
||||
int istopbits = qSettings->value("defaultStopBits").toInt();
|
||||
QString port = qSettings->value("defaultPort").toString();
|
||||
|
||||
databits=(DataBitsType) idatabits;
|
||||
flow=(FlowType)iflow;
|
||||
parity=(ParityType)iparity;
|
||||
stopbits=(StopBitsType)istopbits;
|
||||
speed=(BaudRateType)ispeed;
|
||||
m_defaultPort=port;
|
||||
m_defaultSpeed=speed;
|
||||
m_defaultDataBits=databits;
|
||||
m_defaultFlow=flow;
|
||||
m_defaultParity=parity;
|
||||
m_defaultStopBits=stopbits;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones a configuration.
|
||||
*
|
||||
@ -96,20 +144,16 @@ IUAVGadgetConfiguration *UploaderGadgetConfiguration::clone()
|
||||
m->m_defaultPort=m_defaultPort;
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a configuration.
|
||||
*
|
||||
*/
|
||||
QByteArray UploaderGadgetConfiguration::saveState() const
|
||||
{
|
||||
QByteArray bytes;
|
||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||
stream << (int)m_defaultSpeed;
|
||||
stream << (int)m_defaultDataBits;
|
||||
stream << (int)m_defaultFlow;
|
||||
stream << (int)m_defaultParity;
|
||||
stream << (int)m_defaultStopBits;
|
||||
stream << m_defaultPort;
|
||||
return bytes;
|
||||
void UploaderGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
||||
qSettings->setValue("defaultSpeed", m_defaultSpeed);
|
||||
qSettings->setValue("defaultDataBits", m_defaultDataBits);
|
||||
qSettings->setValue("defaultFlow", m_defaultFlow);
|
||||
qSettings->setValue("defaultParity", m_defaultParity);
|
||||
qSettings->setValue("defaultStopBits", m_defaultStopBits);
|
||||
qSettings->setValue("defaultPort", m_defaultPort);
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,8 @@ class UploaderGadgetConfiguration : public IUAVGadgetConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UploaderGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
|
||||
explicit UploaderGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
|
||||
explicit UploaderGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
|
||||
|
||||
//set port configuration functions
|
||||
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
|
||||
@ -57,7 +58,7 @@ public:
|
||||
QString Port(){return m_defaultPort;}
|
||||
long TimeOut(){return m_defaultTimeOut;}
|
||||
|
||||
QByteArray saveState() const;
|
||||
void saveConfig(QSettings* settings) const;
|
||||
IUAVGadgetConfiguration *clone();
|
||||
|
||||
private:
|
||||
|
@ -52,6 +52,11 @@ IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(const QByteA
|
||||
return new UploaderGadgetConfiguration(QString("Uploader"), state);
|
||||
}
|
||||
|
||||
IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(QSettings* qSettings)
|
||||
{
|
||||
return new UploaderGadgetConfiguration(QString("Uploader"), qSettings);
|
||||
}
|
||||
|
||||
IOptionsPage *UploaderGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
|
||||
{
|
||||
return new UploaderGadgetOptionsPage(qobject_cast<UploaderGadgetConfiguration*>(config));
|
||||
|
@ -46,6 +46,7 @@ public:
|
||||
|
||||
Core::IUAVGadget *createGadget(QWidget *parent);
|
||||
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
|
||||
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
|
||||
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user