1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10: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:
cranphin 2010-09-12 16:24:54 +00:00 committed by cranphin
parent ddf6ee46ee
commit f826ee0a20
57 changed files with 750 additions and 233 deletions

View File

@ -34,15 +34,18 @@ ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, const QByt
} }
ConfigGadgetConfiguration::ConfigGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) :
IUAVGadgetConfiguration(classId, parent)
{
}
IUAVGadgetConfiguration *ConfigGadgetConfiguration::clone() IUAVGadgetConfiguration *ConfigGadgetConfiguration::clone()
{ {
ConfigGadgetConfiguration *m = new ConfigGadgetConfiguration(this->classId()); ConfigGadgetConfiguration *m = new ConfigGadgetConfiguration(this->classId());
return m; return m;
} }
QByteArray ConfigGadgetConfiguration::saveState() const void ConfigGadgetConfiguration::saveConfig(QSettings* settings) const {
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
return bytes;
} }

View File

@ -36,8 +36,9 @@ class ConfigGadgetConfiguration : public IUAVGadgetConfiguration
Q_OBJECT Q_OBJECT
public: public:
explicit ConfigGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit ConfigGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
QByteArray saveState() const; explicit ConfigGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
}; };

View File

@ -51,6 +51,11 @@ IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(const QByteArr
return new ConfigGadgetConfiguration(QString("ConfigGadget"), state); return new ConfigGadgetConfiguration(QString("ConfigGadget"), state);
} }
IUAVGadgetConfiguration *ConfigGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new ConfigGadgetConfiguration(QString("ConfigGadget"), qSettings);
}
IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *ConfigGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new ConfigGadgetOptionsPage(qobject_cast<ConfigGadgetConfiguration*>(config)); return new ConfigGadgetOptionsPage(qobject_cast<ConfigGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
IUAVGadget *createGadget(QWidget *parent); IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -30,6 +30,7 @@
#include <coreplugin/core_global.h> #include <coreplugin/core_global.h>
#include <QObject> #include <QObject>
#include <QSettings>
namespace Core { namespace Core {
@ -46,7 +47,8 @@ public:
bool locked() const { return m_locked; } bool locked() const { return m_locked; }
void setLocked(bool locked) { m_locked = locked; } void setLocked(bool locked) { m_locked = locked; }
virtual QByteArray saveState() const = 0; virtual void saveConfig(QSettings* settings) const = 0;
virtual IUAVGadgetConfiguration *clone() = 0; virtual IUAVGadgetConfiguration *clone() = 0;
signals: signals:

View File

@ -31,6 +31,7 @@
#include "core_global.h" #include "core_global.h"
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QSettings>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QStringList; class QStringList;
@ -54,6 +55,7 @@ public:
virtual IUAVGadget *createGadget(QWidget *parent) = 0; virtual IUAVGadget *createGadget(QWidget *parent) = 0;
virtual IUAVGadgetConfiguration *createConfiguration(const QByteArray &/*state*/) { return 0; } virtual IUAVGadgetConfiguration *createConfiguration(const QByteArray &/*state*/) { return 0; }
virtual IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings) { return 0; }
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; } virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; }
QString classId() const { return m_classId; } QString classId() const { return m_classId; }
QString name() const { return m_name; } QString name() const { return m_name; }

View File

@ -96,29 +96,63 @@ void UAVGadgetInstanceManager::readConfigs_1_0_0(QSettings *qs)
{ {
IUAVGadgetFactory *f = factory(classId); IUAVGadgetFactory *f = factory(classId);
qs->beginGroup(classId); qs->beginGroup(classId);
QStringList configs = qs->childKeys();
foreach (QString configName, configs) { // New style: each config is a group, old style: each config is a value
QByteArray ba = QByteArray::fromBase64(qs->value(configName).toByteArray()); QStringList groups = qs->childGroups();
QDataStream stream(ba); bool oldStyle = groups.size() == 0;
bool locked; QStringList configs = QStringList();
stream >> locked; if(oldStyle) {
QByteArray state; // Old style configuration
stream >> state; configs = qs->childKeys();
IUAVGadgetConfiguration *config = f->createConfiguration(state);
if (config){ foreach (QString configName, configs) {
config->setName(configName); QByteArray ba = QByteArray::fromBase64(qs->value(configName).toByteArray());
config->setProvisionalName(configName); QDataStream stream(ba);
config->setLocked(locked); bool locked;
int idx = indexForConfig(m_configurations, classId, configName); stream >> locked;
if ( idx >= 0 ){ QByteArray state;
// We should replace the config, but it might be used, so just stream >> state;
// throw it out of the list. The GCS should be reinitialised soon. IUAVGadgetConfiguration *config = f->createConfiguration(state);
m_configurations[idx] = config; 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);
}
} }
else{ }
m_configurations.append(config); } 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();
} }
} }
@ -145,11 +179,11 @@ void UAVGadgetInstanceManager::writeConfigurations(QSettings *qs)
foreach (IUAVGadgetConfiguration *config, m_configurations) foreach (IUAVGadgetConfiguration *config, m_configurations)
{ {
qs->beginGroup(config->classId()); qs->beginGroup(config->classId());
QByteArray ba; qs->beginGroup(config->name());
QDataStream stream(&ba, QIODevice::WriteOnly); // TODO: Someone could accidentially use the same name?
stream << config->locked(); qs->setValue("config.locked", config->locked());
stream << config->saveState(); config->saveConfig(qs);
qs->setValue(config->name(), ba.toBase64()); qs->endGroup();
qs->endGroup(); qs->endGroup();
} }
qs->endGroup(); qs->endGroup();

View File

@ -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. * Clones a configuration.
* *
@ -123,40 +182,43 @@ IUAVGadgetConfiguration *DialGadgetConfiguration::clone()
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray DialGadgetConfiguration::saveState() const void DialGadgetConfiguration::saveConfig(QSettings* settings) const {
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial); QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
stream << dialFile; settings->setValue("dialFile", 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;
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);
} }

View File

@ -40,7 +40,9 @@ class DialGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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 //set dial configuration functions
void setDialFile(QString dialFile){m_defaultDial=dialFile;} void setDialFile(QString dialFile){m_defaultDial=dialFile;}
@ -97,7 +99,7 @@ public:
QString getN3Move() { return needle3Move; } QString getN3Move() { return needle3Move; }
QString getFont() { return font;} QString getFont() { return font;}
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -54,6 +54,11 @@ IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(const QByteArray
return new DialGadgetConfiguration(QString("DialGadget"), state); return new DialGadgetConfiguration(QString("DialGadget"), state);
} }
IUAVGadgetConfiguration *DialGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new DialGadgetConfiguration(QString("DialGadget"), qSettings);
}
IOptionsPage *DialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *DialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new DialGadgetOptionsPage(qobject_cast<DialGadgetConfiguration*>(config)); return new DialGadgetOptionsPage(qobject_cast<DialGadgetConfiguration*>(config));

View File

@ -47,6 +47,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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. * Clones a configuration.
* *
@ -106,16 +153,13 @@ IUAVGadgetConfiguration *GpsDisplayGadgetConfiguration::clone()
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray GpsDisplayGadgetConfiguration::saveState() const void GpsDisplayGadgetConfiguration::saveConfig(QSettings* settings) const {
{ settings->setValue("defaultSpeed", m_defaultSpeed);
QByteArray bytes; settings->setValue("defaultDataBits", m_defaultDataBits);
QDataStream stream(&bytes, QIODevice::WriteOnly); settings->setValue("defaultFlow", m_defaultFlow);
stream << (int)m_defaultSpeed; settings->setValue("defaultParity", m_defaultParity);
stream << (int)m_defaultDataBits; settings->setValue("defaultStopBits", m_defaultStopBits);
stream << (int)m_defaultFlow; settings->setValue("defaultPort", m_defaultPort);
stream << (int)m_defaultParity; settings->setValue("connectionMode", m_connectionMode);
stream << (int)m_defaultStopBits;
stream << m_defaultPort;
stream << m_connectionMode;
return bytes;
} }

View File

@ -37,7 +37,8 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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; } void setConnectionMode(QString mode) { m_connectionMode = mode; }
QString connectionMode() { return m_connectionMode; } QString connectionMode() { return m_connectionMode; }
@ -60,7 +61,7 @@ class GpsDisplayGadgetConfiguration : public IUAVGadgetConfiguration
ParityType parity() {return m_defaultParity;} ParityType parity() {return m_defaultParity;}
long timeOut(){return m_defaultTimeOut;} long timeOut(){return m_defaultTimeOut;}
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -53,6 +53,11 @@ IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(const QByt
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), state); return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), state);
} }
IUAVGadgetConfiguration *GpsDisplayGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new GpsDisplayGadgetConfiguration(QString("GpsDisplayGadget"), qSettings);
}
IOptionsPage *GpsDisplayGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *GpsDisplayGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new GpsDisplayGadgetOptionsPage(qobject_cast<GpsDisplayGadgetConfiguration*>(config)); return new GpsDisplayGadgetOptionsPage(qobject_cast<GpsDisplayGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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() IUAVGadgetConfiguration *HITLConfiguration::clone()
{ {
HITLConfiguration *m = new HITLConfiguration(this->classId()); HITLConfiguration *m = new HITLConfiguration(this->classId());
@ -64,20 +91,19 @@ IUAVGadgetConfiguration *HITLConfiguration::clone()
return m; return m;
} }
QByteArray HITLConfiguration::saveState() const /**
{ * Saves a configuration.
QByteArray bytes; *
QDataStream stream(&bytes, QIODevice::WriteOnly); */
void HITLConfiguration::saveConfig(QSettings* qSettings) const {
stream << settings.simulatorId; qSettings->setValue("simulatorId", settings.simulatorId);
stream << settings.binPath; qSettings->setValue("binPath", settings.binPath);
stream << settings.dataPath; qSettings->setValue("dataPath", settings.dataPath);
stream << settings.manual; qSettings->setValue("manual", settings.manual);
stream << settings.hostAddress; qSettings->setValue("hostAddress", settings.hostAddress);
stream << settings.outPort; qSettings->setValue("outPort", settings.outPort);
stream << settings.inPort; qSettings->setValue("inPort", settings.inPort);
stream << settings.latitude; qSettings->setValue("latitude", settings.latitude);
stream << settings.longitude; qSettings->setValue("longitude", settings.longitude);
return bytes;
} }

View File

@ -44,8 +44,10 @@ class HITLConfiguration : public IUAVGadgetConfiguration
Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings) Q_PROPERTY(SimulatorSettings settings READ Settings WRITE setSimulatorSettings)
public: public:
explicit HITLConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit HITLConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
QByteArray saveState() const; explicit HITLConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
SimulatorSettings Settings() const { return settings; } SimulatorSettings Settings() const { return settings; }

View File

@ -54,6 +54,11 @@ IUAVGadgetConfiguration *HITLFactory::createConfiguration(const QByteArray &stat
return new HITLConfiguration(QString("HITL"), state); return new HITLConfiguration(QString("HITL"), state);
} }
IUAVGadgetConfiguration *HITLFactory::createConfiguration(QSettings* qSettings)
{
return new HITLConfiguration(QString("HITL"), qSettings);
}
IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *HITLFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new HITLOptionsPage(qobject_cast<HITLConfiguration*>(config)); return new HITLOptionsPage(qobject_cast<HITLConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
IUAVGadget *createGadget(QWidget *parent); IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -44,6 +44,21 @@ ImportExportGadgetConfiguration::ImportExportGadgetConfiguration(QString classId
stream >> dialFile; 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. * Clones a configuration.
* *
@ -54,16 +69,13 @@ IUAVGadgetConfiguration *ImportExportGadgetConfiguration::clone()
m->dialFile = dialFile; m->dialFile = dialFile;
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray ImportExportGadgetConfiguration::saveState() const void ImportExportGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{ qSettings->setValue("dialFile", dialFile);
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << dialFile;
return bytes;
} }
/** /**

View File

@ -39,7 +39,8 @@ class IMPORTEXPORT_EXPORT ImportExportGadgetConfiguration : public IUAVGadgetCon
{ {
Q_OBJECT Q_OBJECT
public: 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 //set dial configuration functions
void setDialFile(QString filename) { void setDialFile(QString filename) {
@ -51,7 +52,7 @@ public:
return dialFile; return dialFile;
} }
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -56,6 +56,12 @@ IUAVGadgetConfiguration *ImportExportGadgetFactory::createConfiguration(const QB
return lastConfig; return lastConfig;
} }
IUAVGadgetConfiguration *ImportExportGadgetFactory::createConfiguration(QSettings* qSettings)
{
lastConfig = new ImportExportGadgetConfiguration(QString("ImportExportGadget"), qSettings);
return lastConfig;
}
IOptionsPage *ImportExportGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *ImportExportGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new ImportExportGadgetOptionsPage(qobject_cast<ImportExportGadgetConfiguration*>(config)); return new ImportExportGadgetOptionsPage(qobject_cast<ImportExportGadgetConfiguration*>(config));

View File

@ -48,6 +48,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
private: private:

View File

@ -37,9 +37,20 @@ IPconnectionConfiguration::IPconnectionConfiguration(QString classId, const QByt
{ {
settings = Core::ICore::instance()->settings(); 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() IPconnectionConfiguration::~IPconnectionConfiguration()
{ {
} }
IUAVGadgetConfiguration *IPconnectionConfiguration::clone() IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
{ {
IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId()); IPconnectionConfiguration *m = new IPconnectionConfiguration(this->classId());
@ -49,18 +60,16 @@ IUAVGadgetConfiguration *IPconnectionConfiguration::clone()
return m; return m;
} }
QByteArray IPconnectionConfiguration::saveState() const /**
{ * Saves a configuration.
QByteArray bytes; *
QDataStream stream(&bytes, QIODevice::WriteOnly); */
stream << m_Port; void IPconnectionConfiguration::saveConfig(QSettings* qSettings) const {
stream << m_HostName; qSettings->setValue("port", m_Port);
stream << m_UseTCP; qSettings->setValue("hostName", m_HostName);
return bytes; qSettings->setValue("useTCP", m_UseTCP);
} }
void IPconnectionConfiguration::savesettings() const void IPconnectionConfiguration::savesettings() const
{ {
settings->beginGroup(QLatin1String("IPconnection")); settings->beginGroup(QLatin1String("IPconnection"));

View File

@ -42,9 +42,11 @@ Q_PROPERTY(int Port READ Port WRITE setPort)
Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP) Q_PROPERTY(int UseTCP READ UseTCP WRITE setUseTCP)
public: 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(); virtual ~IPconnectionConfiguration();
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
//void savesettings(QSettings* settings) const; //void savesettings(QSettings* settings) const;
//void restoresettings(QSettings* settings); //void restoresettings(QSettings* settings);
void savesettings() const; void savesettings() const;

View File

@ -70,6 +70,47 @@ LineardialGadgetConfiguration::LineardialGadgetConfiguration(QString classId, co
stream >> factor; 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. * Clones a configuration.
* *
@ -94,29 +135,25 @@ IUAVGadgetConfiguration *LineardialGadgetConfiguration::clone()
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray LineardialGadgetConfiguration::saveState() const void LineardialGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{ QString dFile = Utils::PathUtils().RemoveDataPath(dialFile);
QByteArray bytes; qSettings->setValue("dFile", dFile);
QDataStream stream(&bytes, QIODevice::WriteOnly); qSettings->setValue("sourceDataObject", sourceDataObject);
QString dFile = Utils::PathUtils().RemoveDataPath(dialFile); qSettings->setValue("sourceObjectField", sourceObjectField);
stream << dFile; qSettings->setValue("minValue", minValue);
stream << sourceDataObject; qSettings->setValue("maxValue", maxValue);
stream << sourceObjectField; qSettings->setValue("redMin", redMin);
stream << minValue; qSettings->setValue("redMax", redMax);
stream << maxValue; qSettings->setValue("yellowMin", yellowMin);
stream << redMin; qSettings->setValue("yellowMax", yellowMax);
stream << redMax; qSettings->setValue("greenMin", greenMin);
stream << yellowMin; qSettings->setValue("greenMax", greenMax);
stream << yellowMax; qSettings->setValue("font", font);
stream << greenMin; qSettings->setValue("decimalPlaces", decimalPlaces);
stream << greenMax; qSettings->setValue("factor", factor);
stream << font;
stream << decimalPlaces;
stream << factor;
return bytes;
} }

View File

@ -39,7 +39,8 @@ class LineardialGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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 //set dial configuration functions
void setDialFile(QString filename){dialFile=filename;} void setDialFile(QString filename){dialFile=filename;}
@ -72,7 +73,7 @@ public:
int getDecimalPlaces() { return decimalPlaces; } int getDecimalPlaces() { return decimalPlaces; }
double getFactor() { return factor; } double getFactor() { return factor; }
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -53,6 +53,11 @@ IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(const QByt
return new LineardialGadgetConfiguration(QString("LineardialGadget"), state); return new LineardialGadgetConfiguration(QString("LineardialGadget"), state);
} }
IUAVGadgetConfiguration *LineardialGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new LineardialGadgetConfiguration(QString("LineardialGadget"), qSettings);
}
IOptionsPage *LineardialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *LineardialGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new LineardialGadgetOptionsPage(qobject_cast<LineardialGadgetConfiguration*>(config)); return new LineardialGadgetOptionsPage(qobject_cast<LineardialGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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() IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
{ {
ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId()); ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId());
@ -56,14 +72,12 @@ IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
return mv; return mv;
} }
QByteArray ModelViewGadgetConfiguration::saveState() const /**
{ * Saves a configuration.
*
QByteArray bytes; */
QDataStream stream(&bytes, QIODevice::WriteOnly); void ModelViewGadgetConfiguration::saveConfig(QSettings* qSettings) const {
stream << Utils::PathUtils().RemoveDataPath(m_acFilename); qSettings->setValue("acFilename", Utils::PathUtils().RemoveDataPath(m_acFilename));
stream << Utils::PathUtils().RemoveDataPath(m_bgFilename); qSettings->setValue("bgFilename", Utils::PathUtils().RemoveDataPath(m_bgFilename));
stream << m_enableVbo; qSettings->setValue("enableVbo", m_enableVbo);
return bytes;
} }

View File

@ -36,8 +36,10 @@ class ModelViewGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ModelViewGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit ModelViewGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
QByteArray saveState() const; explicit ModelViewGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
QString acFilename() {return m_acFilename;} QString acFilename() {return m_acFilename;}
void setAcFilename(QString acFile) { m_acFilename = acFile; } void setAcFilename(QString acFile) { m_acFilename = acFile; }

View File

@ -52,6 +52,11 @@ IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(const QByte
return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), state); return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), state);
} }
IUAVGadgetConfiguration *ModelViewGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new ModelViewGadgetConfiguration(QString("ModelViewGadget"), qSettings);
}
IOptionsPage *ModelViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *ModelViewGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new ModelViewGadgetOptionsPage(qobject_cast<ModelViewGadgetConfiguration*>(config)); return new ModelViewGadgetOptionsPage(qobject_cast<ModelViewGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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() IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
{ {
OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId()); OPMapGadgetConfiguration *m = new OPMapGadgetConfiguration(this->classId());
@ -95,20 +133,14 @@ IUAVGadgetConfiguration * OPMapGadgetConfiguration::clone()
return m; return m;
} }
QByteArray OPMapGadgetConfiguration::saveState() const void OPMapGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{ qSettings->setValue("mapProvider", m_mapProvider);
QByteArray bytes; qSettings->setValue("defaultZoom", m_defaultZoom);
QDataStream stream(&bytes, QIODevice::WriteOnly); qSettings->setValue("defaultLatitude", m_defaultLatitude);
qSettings->setValue("defaultLongitude", m_defaultLongitude);
stream << m_mapProvider; qSettings->setValue("useOpenGL", m_useOpenGL);
stream << m_defaultZoom; qSettings->setValue("showTileGridLines", m_showTileGridLines);
stream << m_defaultLatitude; qSettings->setValue("accessMode", m_accessMode);
stream << m_defaultLongitude; qSettings->setValue("useMemoryCache", m_useMemoryCache);
stream << m_useOpenGL; qSettings->setValue("cacheLocation", m_cacheLocation);
stream << m_showTileGridLines;
stream << m_accessMode;
stream << m_useMemoryCache;
stream << m_cacheLocation;
return bytes;
} }

View File

@ -48,8 +48,10 @@ Q_PROPERTY(bool useMemoryCache READ useMemoryCache WRITE setUseMemoryCache)
Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation) Q_PROPERTY(QString cacheLocation READ cacheLocation WRITE setCacheLocation)
public: public:
explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit OPMapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
QByteArray saveState() const; explicit OPMapGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
QString mapProvider() const { return m_mapProvider; } QString mapProvider() const { return m_mapProvider; }

View File

@ -51,6 +51,11 @@ IUAVGadgetConfiguration * OPMapGadgetFactory::createConfiguration(const QByteArr
return new OPMapGadgetConfiguration(QString("OPMapGadget"), state); return new OPMapGadgetConfiguration(QString("OPMapGadget"), state);
} }
IUAVGadgetConfiguration *OPMapGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new OPMapGadgetConfiguration(QString("OPMapGadget"), qSettings);
}
IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage * OPMapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new OPMapGadgetOptionsPage(qobject_cast<OPMapGadgetConfiguration*>(config)); return new OPMapGadgetOptionsPage(qobject_cast<OPMapGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -47,6 +47,24 @@ PFDGadgetConfiguration::PFDGadgetConfiguration(QString classId, const QByteArray
m_defaultDial=Utils::PathUtils().InsertDataPath(dialFile); 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. * Clones a configuration.
* *
@ -59,18 +77,14 @@ IUAVGadgetConfiguration *PFDGadgetConfiguration::clone()
m->hqFonts = hqFonts; m->hqFonts = hqFonts;
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray PFDGadgetConfiguration::saveState() const void PFDGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial); QString dialFile = Utils::PathUtils().RemoveDataPath(m_defaultDial);
stream << dialFile; qSettings->setValue("dialFile", dialFile);
stream << useOpenGLFlag; qSettings->setValue("useOpenGLFlag", useOpenGLFlag);
stream << hqFonts; qSettings->setValue("hqFonts", hqFonts);
return bytes;
} }

View File

@ -36,7 +36,8 @@ class PFDGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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 //set dial configuration functions
void setDialFile(QString dialFile){m_defaultDial=dialFile;} void setDialFile(QString dialFile){m_defaultDial=dialFile;}
@ -47,7 +48,7 @@ public:
bool useOpenGL() { return useOpenGLFlag; } bool useOpenGL() { return useOpenGLFlag; }
bool getHqFonts() { return hqFonts; } bool getHqFonts() { return hqFonts; }
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -53,6 +53,11 @@ IUAVGadgetConfiguration *PFDGadgetFactory::createConfiguration(const QByteArray
return new PFDGadgetConfiguration(QString("PFDGadget"), state); return new PFDGadgetConfiguration(QString("PFDGadget"), state);
} }
IUAVGadgetConfiguration *PFDGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new PFDGadgetConfiguration(QString("PFDGadget"), qSettings);
}
IOptionsPage *PFDGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *PFDGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new PFDGadgetOptionsPage(qobject_cast<PFDGadgetConfiguration*>(config)); return new PFDGadgetOptionsPage(qobject_cast<PFDGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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() void ScopeGadgetConfiguration::clearPlotData()
{ {
PlotCurveConfiguration* poltCurveConfig; PlotCurveConfiguration* poltCurveConfig;
@ -129,31 +181,31 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray ScopeGadgetConfiguration::saveState() const void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{
int plotCurveCount = m_PlotCurveConfigs.size(); int plotCurveCount = m_PlotCurveConfigs.size();
int plotDatasLoadIndex = 0; int plotDatasLoadIndex = 0;
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly); qSettings->setValue("configurationStreamVersion", m_configurationStreamVersion);
stream << m_configurationStreamVersion; qSettings->setValue("plotType", m_plotType);
stream << m_plotType; qSettings->setValue("dataSize", m_dataSize);
stream << m_dataSize; qSettings->setValue("refreshInterval", m_refreshInterval);
stream << m_refreshInterval; qSettings->setValue("plotCurveCount", plotCurveCount);
stream << plotCurveCount;
for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++) for(plotDatasLoadIndex = 0; plotDatasLoadIndex < plotCurveCount; plotDatasLoadIndex++)
{ {
qSettings->beginGroup(QString("plotCurve") + QString().number(plotDatasLoadIndex));
PlotCurveConfiguration* plotCurveConf = m_PlotCurveConfigs.at(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; qSettings->endGroup();
stream << plotCurveConf->uavField;
stream << plotCurveConf->color;
stream << plotCurveConf->yScalePower;
stream << plotCurveConf->yMinimum;
stream << plotCurveConf->yMaximum;
} }
return bytes;
} }
void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration*> newPlotCurveConfigs) void ScopeGadgetConfiguration::replacePlotCurveConfig(QList<PlotCurveConfiguration*> newPlotCurveConfigs)

View File

@ -49,7 +49,9 @@ class ScopeGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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(); ~ScopeGadgetConfiguration();
//configuration setter functions //configuration setter functions
@ -66,7 +68,7 @@ public:
int refreshInterval(){return m_refreshInterval;} int refreshInterval(){return m_refreshInterval;}
QList<PlotCurveConfiguration*> plotCurveConfigs(){return m_PlotCurveConfigs;} QList<PlotCurveConfiguration*> plotCurveConfigs(){return m_PlotCurveConfigs;}
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -53,6 +53,11 @@ IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(const QByteArra
return new ScopeGadgetConfiguration(QString("ScopeGadget"), state); return new ScopeGadgetConfiguration(QString("ScopeGadget"), state);
} }
IUAVGadgetConfiguration *ScopeGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new ScopeGadgetConfiguration(QString("ScopeGadget"), qSettings);
}
IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *ScopeGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new ScopeGadgetOptionsPage(qobject_cast<ScopeGadgetConfiguration*>(config)); return new ScopeGadgetOptionsPage(qobject_cast<ScopeGadgetConfiguration*>(config));

View File

@ -47,6 +47,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -45,6 +45,22 @@ SystemHealthGadgetConfiguration::SystemHealthGadgetConfiguration(QString classId
systemFile = Utils::PathUtils().InsertDataPath(diagram); 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. * Clones a configuration.
* *
@ -55,16 +71,12 @@ IUAVGadgetConfiguration *SystemHealthGadgetConfiguration::clone()
m->systemFile=systemFile; m->systemFile=systemFile;
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray SystemHealthGadgetConfiguration::saveState() const void SystemHealthGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{
QByteArray bytes;
QDataStream stream(&bytes, QIODevice::WriteOnly);
QString diagram = Utils::PathUtils().RemoveDataPath(systemFile); QString diagram = Utils::PathUtils().RemoveDataPath(systemFile);
stream << diagram; qSettings->setValue("diagram", diagram);
return bytes;
} }

View File

@ -39,7 +39,8 @@ class SystemHealthGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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 //set system health configuration functions
void setSystemFile(QString filename){systemFile=filename;} void setSystemFile(QString filename){systemFile=filename;}
@ -47,7 +48,7 @@ public:
//get dial configuration functions //get dial configuration functions
QString getSystemFile() {return systemFile;} QString getSystemFile() {return systemFile;}
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -53,6 +53,11 @@ IUAVGadgetConfiguration *SystemHealthGadgetFactory::createConfiguration(const QB
return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), state); return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), state);
} }
IUAVGadgetConfiguration *SystemHealthGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new SystemHealthGadgetConfiguration(QString("SystemHealthGadget"), qSettings);
}
IOptionsPage *SystemHealthGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *SystemHealthGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new SystemHealthGadgetOptionsPage(qobject_cast<SystemHealthGadgetConfiguration*>(config)); return new SystemHealthGadgetOptionsPage(qobject_cast<SystemHealthGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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() IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
{ {
UAVObjectBrowserConfiguration *m = new UAVObjectBrowserConfiguration(this->classId()); UAVObjectBrowserConfiguration *m = new UAVObjectBrowserConfiguration(this->classId());
@ -57,13 +75,12 @@ IUAVGadgetConfiguration *UAVObjectBrowserConfiguration::clone()
return m; return m;
} }
QByteArray UAVObjectBrowserConfiguration::saveState() const /**
{ * Saves a configuration.
QByteArray bytes; *
QDataStream stream(&bytes, QIODevice::WriteOnly); */
stream << m_recentlyUpdatedColor; void UAVObjectBrowserConfiguration::saveConfig(QSettings* qSettings) const {
stream << m_manuallyChangedColor; qSettings->setValue("recentlyUpdatedColor", m_recentlyUpdatedColor);
stream << m_recentlyUpdatedTimeout; qSettings->setValue("manuallyChangedColor", m_manuallyChangedColor);
return bytes; qSettings->setValue("recentlyUpdatedTimeout", m_recentlyUpdatedTimeout);
} }

View File

@ -40,8 +40,10 @@ Q_PROPERTY(QColor m_recentlyUpdatedColor READ recentlyUpdatedColor WRITE setRece
Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor) Q_PROPERTY(QColor m_manuallyChangedColor READ manuallyChangedColor WRITE setManuallyChangedColor)
Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout) Q_PROPERTY(int m_recentlyUpdatedTimeout READ recentlyUpdatedTimeout WRITE setRecentlyUpdatedTimeout)
public: public:
explicit UAVObjectBrowserConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0); explicit UAVObjectBrowserConfiguration(QString classId, const QByteArray &state, QObject *parent = 0);
QByteArray saveState() const; explicit UAVObjectBrowserConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0);
void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
QColor recentlyUpdatedColor() const { return m_recentlyUpdatedColor; } QColor recentlyUpdatedColor() const { return m_recentlyUpdatedColor; }

View File

@ -51,6 +51,12 @@ IUAVGadgetConfiguration *UAVObjectBrowserFactory::createConfiguration(const QByt
return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), state); return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), state);
} }
IUAVGadgetConfiguration *UAVObjectBrowserFactory::createConfiguration(QSettings* qSettings)
{
return new UAVObjectBrowserConfiguration(QString("UAVObjectBrowser"), qSettings);
}
IOptionsPage *UAVObjectBrowserFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *UAVObjectBrowserFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new UAVObjectBrowserOptionsPage(qobject_cast<UAVObjectBrowserConfiguration*>(config)); return new UAVObjectBrowserOptionsPage(qobject_cast<UAVObjectBrowserConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };

View File

@ -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. * Clones a configuration.
* *
@ -96,20 +144,16 @@ IUAVGadgetConfiguration *UploaderGadgetConfiguration::clone()
m->m_defaultPort=m_defaultPort; m->m_defaultPort=m_defaultPort;
return m; return m;
} }
/** /**
* Saves a configuration. * Saves a configuration.
* *
*/ */
QByteArray UploaderGadgetConfiguration::saveState() const void UploaderGadgetConfiguration::saveConfig(QSettings* qSettings) const {
{ qSettings->setValue("defaultSpeed", m_defaultSpeed);
QByteArray bytes; qSettings->setValue("defaultDataBits", m_defaultDataBits);
QDataStream stream(&bytes, QIODevice::WriteOnly); qSettings->setValue("defaultFlow", m_defaultFlow);
stream << (int)m_defaultSpeed; qSettings->setValue("defaultParity", m_defaultParity);
stream << (int)m_defaultDataBits; qSettings->setValue("defaultStopBits", m_defaultStopBits);
stream << (int)m_defaultFlow; qSettings->setValue("defaultPort", m_defaultPort);
stream << (int)m_defaultParity;
stream << (int)m_defaultStopBits;
stream << m_defaultPort;
return bytes;
} }

View File

@ -37,7 +37,8 @@ class UploaderGadgetConfiguration : public IUAVGadgetConfiguration
{ {
Q_OBJECT Q_OBJECT
public: 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 //set port configuration functions
void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;} void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;}
@ -57,7 +58,7 @@ public:
QString Port(){return m_defaultPort;} QString Port(){return m_defaultPort;}
long TimeOut(){return m_defaultTimeOut;} long TimeOut(){return m_defaultTimeOut;}
QByteArray saveState() const; void saveConfig(QSettings* settings) const;
IUAVGadgetConfiguration *clone(); IUAVGadgetConfiguration *clone();
private: private:

View File

@ -52,6 +52,11 @@ IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(const QByteA
return new UploaderGadgetConfiguration(QString("Uploader"), state); return new UploaderGadgetConfiguration(QString("Uploader"), state);
} }
IUAVGadgetConfiguration *UploaderGadgetFactory::createConfiguration(QSettings* qSettings)
{
return new UploaderGadgetConfiguration(QString("Uploader"), qSettings);
}
IOptionsPage *UploaderGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) IOptionsPage *UploaderGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)
{ {
return new UploaderGadgetOptionsPage(qobject_cast<UploaderGadgetConfiguration*>(config)); return new UploaderGadgetOptionsPage(qobject_cast<UploaderGadgetConfiguration*>(config));

View File

@ -46,6 +46,7 @@ public:
Core::IUAVGadget *createGadget(QWidget *parent); Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state); IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
}; };