1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

GCS/core+gadgets: Final cleanup of uav gadget interface.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@401 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
ephy 2010-03-27 21:46:49 +00:00 committed by ephy
parent 35f4fc06a0
commit cd04e7c201
9 changed files with 29 additions and 27 deletions

View File

@ -29,11 +29,11 @@
using namespace Core;
IUAVGadgetConfiguration::IUAVGadgetConfiguration(bool locked, QString classId, QString name, QObject *parent) :
IUAVGadgetConfiguration::IUAVGadgetConfiguration(QString classId, QObject *parent) :
QObject(parent),
m_locked(locked),
m_locked(false),
m_classId(classId),
m_name(name),
m_provisionalName(name)
m_name(tr("default")),
m_provisionalName(tr("default"))
{
}

View File

@ -37,14 +37,16 @@ class CORE_EXPORT IUAVGadgetConfiguration : public QObject
{
Q_OBJECT
public:
explicit IUAVGadgetConfiguration(bool locked, QString classId, QString name, QObject *parent = 0);
virtual QByteArray saveState() const = 0;
explicit IUAVGadgetConfiguration(QString classId, QObject *parent = 0);
QString classId() { return m_classId; }
QString name() { return m_name; }
void setName(QString name) { m_name = name; }
QString provisionalName() { return m_provisionalName; }
void setProvisionalName(QString name) { m_provisionalName = name; }
bool locked() const { return m_locked; }
void setLocked(bool locked) { m_locked = locked; }
virtual QByteArray saveState() const = 0;
virtual IUAVGadgetConfiguration *clone(QString name) = 0;
signals:

View File

@ -53,15 +53,13 @@ public:
virtual ~IUAVGadgetFactory() {}
virtual IUAVGadget *createGadget(QWidget *parent) = 0;
virtual IUAVGadgetConfiguration *createConfiguration(bool /*locked*/,
const QString /*configName*/,
const QByteArray &/*state*/) { return 0; }
virtual IUAVGadgetConfiguration *createConfiguration(const QByteArray &/*state*/) { return 0; }
virtual IOptionsPage *createOptionsPage(IUAVGadgetConfiguration */*config*/) { return 0; }
QString classId() const { return m_classId; }
QString name() const { return m_name; }
private:
QString m_classId;
QString m_name;
QString m_classId; // unique class id
QString m_name; // display name, should also be unique
};
} // namespace Core

View File

@ -83,17 +83,23 @@ void UAVGadgetInstanceManager::readConfigurations()
stream >> locked;
QByteArray state;
stream >> state;
IUAVGadgetConfiguration *config = f->createConfiguration(locked, configName, state);
IUAVGadgetConfiguration *config = f->createConfiguration(state);
config->setName(configName);
config->setProvisionalName(configName);
config->setLocked(locked);
if (config)
m_configurations.append(config);
}
if (configs.count() == 0) {
IUAVGadgetConfiguration *config = f->createConfiguration(false, tr("default"), 0);
IUAVGadgetConfiguration *config = f->createConfiguration(0);
// it is not mandatory for uavgadgets to have any configurations (settings)
// and therefore we have to check for that
if (config)
if (config) {
config->setName(tr("default"));
config->setProvisionalName(tr("default"));
m_configurations.append(config);
}
}
qs->endGroup();
}

View File

@ -28,8 +28,8 @@
#include "mapgadgetconfiguration.h"
#include <QtCore/QDataStream>
MapGadgetConfiguration::MapGadgetConfiguration(bool locked, QString classId, QString name, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(locked, classId, name, parent),
MapGadgetConfiguration::MapGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_defaultZoom(10)
{
if (state.count() > 0) {
@ -49,7 +49,9 @@ MapGadgetConfiguration::MapGadgetConfiguration(bool locked, QString classId, QSt
IUAVGadgetConfiguration *MapGadgetConfiguration::clone(QString name)
{
MapGadgetConfiguration *m = new MapGadgetConfiguration(this->locked(), this->classId(), name);
MapGadgetConfiguration *m = new MapGadgetConfiguration(this->classId());
m->setName(name);
m->setProvisionalName(name);
m->m_defaultZoom = m_defaultZoom;
m->m_defaultLatitude = m_defaultLatitude;
m->m_defaultLongitude = m_defaultLongitude;

View File

@ -36,7 +36,7 @@ class MapGadgetConfiguration : public IUAVGadgetConfiguration
{
Q_OBJECT
public:
explicit MapGadgetConfiguration(bool locked, QString classId, QString name, const QByteArray &state = 0, QObject *parent = 0);
explicit MapGadgetConfiguration(QString classId, const QByteArray &state = 0, QObject *parent = 0);
int zoom() { return m_defaultZoom; }
void setZoom(int zoom) { m_defaultZoom = zoom; }
double latitude() { return m_defaultLatitude; }

View File

@ -46,11 +46,9 @@ Core::IUAVGadget* MapGadgetFactory::createGadget(QWidget *parent)
return new MapGadget(QString("MapGadget"), gadgetWidget, parent);
}
IUAVGadgetConfiguration *MapGadgetFactory::createConfiguration(bool locked,
const QString configName,
const QByteArray &state)
IUAVGadgetConfiguration *MapGadgetFactory::createConfiguration(const QByteArray &state)
{
return new MapGadgetConfiguration(locked, QString("MapGadget"), configName, state);
return new MapGadgetConfiguration(QString("MapGadget"), state);
}
IOptionsPage *MapGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config)

View File

@ -45,9 +45,7 @@ public:
~MapGadgetFactory();
Core::IUAVGadget *createGadget(QWidget *parent);
IUAVGadgetConfiguration *createConfiguration(bool locked,
const QString configName,
const QByteArray &state);
IUAVGadgetConfiguration *createConfiguration(const QByteArray &state);
IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config);
};

View File

@ -26,12 +26,10 @@
*/
#include "mapplugin.h"
#include "mapgadgetfactory.h"
#include <QDebug>
#include <QtPlugin>
#include <QStringList>
#include <extensionsystem/pluginmanager.h>
MapPlugin::MapPlugin()
{
// Do nothing