mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
GCS/map: Updates to try out settings functionality.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@388 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
4b3bfa361f
commit
2f3848e7ec
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "mapgadget.h"
|
#include "mapgadget.h"
|
||||||
#include "mapgadgetwidget.h"
|
#include "mapgadgetwidget.h"
|
||||||
|
#include "mapgadgetconfiguration.h"
|
||||||
|
|
||||||
MapGadget::MapGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, MapGadgetWidget *widget) :
|
MapGadget::MapGadget(QString classId, QList<IUAVGadgetConfiguration*> *configurations, MapGadgetWidget *widget) :
|
||||||
IUAVGadget(classId, configurations, widget),
|
IUAVGadget(classId, configurations, widget),
|
||||||
@ -17,3 +18,13 @@ MapGadget::~MapGadget()
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
||||||
|
{
|
||||||
|
MapGadgetConfiguration *m = qobject_cast<MapGadgetConfiguration*>(config);
|
||||||
|
m_widget->setZoom(m->zoom());
|
||||||
|
m_widget->setPosition(QPointF(m->longitude(), m->latitude()));
|
||||||
|
int index = m_toolbar->findText(config->name());
|
||||||
|
m_toolbar->setCurrentIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#define MAPGADGET_H_
|
#define MAPGADGET_H_
|
||||||
|
|
||||||
#include <coreplugin/iuavgadget.h>
|
#include <coreplugin/iuavgadget.h>
|
||||||
|
#include "mapgadgetwidget.h"
|
||||||
|
|
||||||
class IUAVGadget;
|
class IUAVGadget;
|
||||||
//class QList<int>;
|
//class QList<int>;
|
||||||
@ -28,9 +29,10 @@ public:
|
|||||||
QList<int> context() const { return m_context; }
|
QList<int> context() const { return m_context; }
|
||||||
QWidget *widget() { return m_widget; }
|
QWidget *widget() { return m_widget; }
|
||||||
QString contextHelpId() const { return QString(); }
|
QString contextHelpId() const { return QString(); }
|
||||||
|
void loadConfiguration(IUAVGadgetConfiguration* config);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget *m_widget;
|
MapGadgetWidget *m_widget;
|
||||||
QList<int> m_context;
|
QList<int> m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,14 +35,25 @@ MapGadgetConfiguration::MapGadgetConfiguration(bool locked, QString classId, QSt
|
|||||||
if (state.count() > 0) {
|
if (state.count() > 0) {
|
||||||
QDataStream stream(state);
|
QDataStream stream(state);
|
||||||
int zoom;
|
int zoom;
|
||||||
|
double latitude;
|
||||||
|
double longitude;
|
||||||
stream >> zoom;
|
stream >> zoom;
|
||||||
|
stream >> latitude;
|
||||||
|
stream >> longitude;
|
||||||
m_defaultZoom = zoom;
|
m_defaultZoom = zoom;
|
||||||
|
m_defaultLatitude = latitude;
|
||||||
|
m_defaultLongitude = longitude;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IUAVGadgetConfiguration *MapGadgetConfiguration::clone(QString name)
|
IUAVGadgetConfiguration *MapGadgetConfiguration::clone(QString name)
|
||||||
{
|
{
|
||||||
return new MapGadgetConfiguration(this->locked(), this->classId(), name);
|
MapGadgetConfiguration *m = new MapGadgetConfiguration(this->locked(), this->classId(), name);
|
||||||
|
m->m_defaultZoom = m_defaultZoom;
|
||||||
|
m->m_defaultLatitude = m_defaultLatitude;
|
||||||
|
m->m_defaultLongitude = m_defaultLongitude;
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray MapGadgetConfiguration::saveState() const
|
QByteArray MapGadgetConfiguration::saveState() const
|
||||||
@ -50,6 +61,8 @@ QByteArray MapGadgetConfiguration::saveState() const
|
|||||||
QByteArray bytes;
|
QByteArray bytes;
|
||||||
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
QDataStream stream(&bytes, QIODevice::WriteOnly);
|
||||||
stream << m_defaultZoom;
|
stream << m_defaultZoom;
|
||||||
|
stream << m_defaultLatitude;
|
||||||
|
stream << m_defaultLongitude;
|
||||||
return bytes;
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,11 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit MapGadgetConfiguration(bool locked, QString classId, QString name, const QByteArray &state = 0, QObject *parent = 0);
|
explicit MapGadgetConfiguration(bool locked, QString classId, QString name, const QByteArray &state = 0, QObject *parent = 0);
|
||||||
int zoom() { return m_defaultZoom; }
|
int zoom() { return m_defaultZoom; }
|
||||||
|
void setZoom(int zoom) { m_defaultZoom = zoom; }
|
||||||
|
double latitude() { return m_defaultLatitude; }
|
||||||
|
void setLatitude(double lat) { m_defaultLatitude = lat; }
|
||||||
|
double longitude() { return m_defaultLongitude; }
|
||||||
|
void setLongitude(double lon) { m_defaultLongitude = lon; }
|
||||||
QByteArray saveState() const;
|
QByteArray saveState() const;
|
||||||
IUAVGadgetConfiguration *clone(QString name);
|
IUAVGadgetConfiguration *clone(QString name);
|
||||||
signals:
|
signals:
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
#include "mapgadgetoptionspage.h"
|
#include "mapgadgetoptionspage.h"
|
||||||
#include "mapgadgetconfiguration.h"
|
#include "mapgadgetconfiguration.h"
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
#include <QtGui/QSpinBox>
|
||||||
|
#include <QtGui/QDoubleSpinBox>
|
||||||
|
#include <QtGui/QHBoxLayout>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
|
||||||
|
|
||||||
MapGadgetOptionsPage::MapGadgetOptionsPage(IUAVGadgetConfiguration *config, QObject *parent) :
|
MapGadgetOptionsPage::MapGadgetOptionsPage(IUAVGadgetConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
@ -37,14 +42,59 @@ MapGadgetOptionsPage::MapGadgetOptionsPage(IUAVGadgetConfiguration *config, QObj
|
|||||||
|
|
||||||
QWidget *MapGadgetOptionsPage::createPage(QWidget *parent)
|
QWidget *MapGadgetOptionsPage::createPage(QWidget *parent)
|
||||||
{
|
{
|
||||||
QWidget *label = new QLabel("Settings will be here.", parent);
|
QWidget *widget = new QWidget;
|
||||||
// QLabel *label = new QLabel(QString(m_config->zoom()));
|
QVBoxLayout *vl = new QVBoxLayout();
|
||||||
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
widget->setLayout(vl);
|
||||||
return label;
|
|
||||||
|
QHBoxLayout *zoomLayout = new QHBoxLayout();
|
||||||
|
QWidget *x = new QWidget;
|
||||||
|
x->setLayout(zoomLayout);
|
||||||
|
QWidget *label = new QLabel("Default zoom:");
|
||||||
|
m_zoomSpin = new QSpinBox();
|
||||||
|
m_zoomSpin->setMaximum(18);
|
||||||
|
zoomLayout->addWidget(label);
|
||||||
|
zoomLayout->addWidget(m_zoomSpin);
|
||||||
|
|
||||||
|
QHBoxLayout *latLayout = new QHBoxLayout();
|
||||||
|
QWidget *y = new QWidget;
|
||||||
|
y->setLayout(latLayout);
|
||||||
|
label = new QLabel("Default latitude:");
|
||||||
|
m_latSpin = new QDoubleSpinBox();
|
||||||
|
m_latSpin->setDecimals(8);
|
||||||
|
m_latSpin->setMinimum(-90);
|
||||||
|
m_latSpin->setMaximum(90);
|
||||||
|
latLayout->addWidget(label);
|
||||||
|
latLayout->addWidget(m_latSpin);
|
||||||
|
|
||||||
|
|
||||||
|
QHBoxLayout *longLayout = new QHBoxLayout();
|
||||||
|
QWidget *z = new QWidget;
|
||||||
|
z->setLayout(longLayout);
|
||||||
|
label = new QLabel("Default longitude:");
|
||||||
|
m_longSpin = new QDoubleSpinBox();
|
||||||
|
m_longSpin->setDecimals(8);
|
||||||
|
m_longSpin->setMinimum(-180);
|
||||||
|
m_longSpin->setMaximum(180);
|
||||||
|
longLayout->addWidget(label);
|
||||||
|
longLayout->addWidget(m_longSpin);
|
||||||
|
QSpacerItem *item = new QSpacerItem(100, 100, QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
|
||||||
|
vl->addWidget(x);
|
||||||
|
vl->addWidget(y);
|
||||||
|
vl->addWidget(z);
|
||||||
|
|
||||||
|
m_zoomSpin->setValue(m_config->zoom());
|
||||||
|
m_latSpin->setValue(m_config->latitude());
|
||||||
|
m_longSpin->setValue(m_config->longitude());
|
||||||
|
|
||||||
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapGadgetOptionsPage::apply()
|
void MapGadgetOptionsPage::apply()
|
||||||
{
|
{
|
||||||
|
m_config->setZoom(m_zoomSpin->value());
|
||||||
|
m_config->setLatitude(m_latSpin->value());
|
||||||
|
m_config->setLongitude(m_longSpin->value());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,8 @@ namespace Core {
|
|||||||
class IUAVGadgetConfiguration;
|
class IUAVGadgetConfiguration;
|
||||||
}
|
}
|
||||||
class MapGadgetConfiguration;
|
class MapGadgetConfiguration;
|
||||||
|
class QSpinBox;
|
||||||
|
class QDoubleSpinBox;
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@ -56,6 +58,9 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
private:
|
private:
|
||||||
MapGadgetConfiguration *m_config;
|
MapGadgetConfiguration *m_config;
|
||||||
|
QSpinBox *m_zoomSpin;
|
||||||
|
QDoubleSpinBox *m_latSpin;
|
||||||
|
QDoubleSpinBox *m_longSpin;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,6 +36,18 @@ MapGadgetWidget::~MapGadgetWidget()
|
|||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
void MapGadgetWidget::setZoom(int value)
|
||||||
|
{
|
||||||
|
mc->setZoom(value);
|
||||||
|
mc->updateRequestNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapGadgetWidget::setPosition(QPointF pos)
|
||||||
|
{
|
||||||
|
mc->setView(pos);
|
||||||
|
mc->updateRequestNew();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapGadgetWidget::resizeEvent(QResizeEvent *event)
|
void MapGadgetWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "qmapcontrol/qmapcontrol.h"
|
#include "qmapcontrol/qmapcontrol.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
|
|
||||||
using namespace qmapcontrol;
|
using namespace qmapcontrol;
|
||||||
|
|
||||||
class MapGadgetWidget : public QWidget
|
class MapGadgetWidget : public QWidget
|
||||||
@ -20,6 +21,8 @@ class MapGadgetWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
MapGadgetWidget(QWidget *parent = 0);
|
MapGadgetWidget(QWidget *parent = 0);
|
||||||
~MapGadgetWidget();
|
~MapGadgetWidget();
|
||||||
|
void setZoom(int value);
|
||||||
|
void setPosition(QPointF pos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
Loading…
Reference in New Issue
Block a user