1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-37 GCS/MapPlugin Things were getting messy, created new Helper class (only static functions).

Small bug fix on refreshing after maptype change.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@754 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
zedamota 2010-06-12 23:05:09 +00:00 committed by zedamota
parent 8efae87949
commit 53e2949d04
6 changed files with 37 additions and 13 deletions

View File

@ -8,8 +8,8 @@ MainWindow::MainWindow(QWidget *parent) :
{
map=new mapcontrol::OPMapWidget();
ui->setupUi(this);
ui->comboBox->addItems(map->MapTypes());
ui->comboBox->setCurrentIndex(map->MapTypes().indexOf("GoogleHybrid"));
ui->comboBox->addItems(mapcontrol::Helper::MapTypes());
ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
QHBoxLayout *layout=new QHBoxLayout(parent);
layout->addWidget(map);
layout->addWidget(ui->widget);
@ -80,7 +80,7 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_pushButtonGO_clicked()
{
core::GeoCoderStatusCode::Types x=map->SetCurrentPositionByKeywords(ui->lineEdit->text());
ui->label->setText( map->StrFromGeoCoderStatusCode(x));
ui->label->setText( mapcontrol::Helper::StrFromGeoCoderStatusCode(x));
}
@ -92,5 +92,10 @@ void MainWindow::on_checkBox_2_clicked(bool checked)
void MainWindow::on_comboBox_currentIndexChanged(QString value)
{
if (map->isStarted())
map->SetMapType(map->MapTypeFromString(value));
map->SetMapType(mapcontrol::Helper::MapTypeFromString(value));
}
void MainWindow::on_pushButton_2_clicked()
{
map->X();
}

View File

@ -21,6 +21,7 @@ private:
mapcontrol::OPMapWidget *map;
private slots:
void on_pushButton_2_clicked();
void on_comboBox_currentIndexChanged(QString );
void on_checkBox_2_clicked(bool checked);
void on_pushButtonGO_clicked();

View File

@ -53,6 +53,13 @@
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'mainwindow.ui'
**
** Created: Sat 12. Jun 23:14:21 2010
** Created: Sun 13. Jun 00:01:04 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
@ -42,6 +42,7 @@ public:
QGroupBox *groupBox_5;
QVBoxLayout *verticalLayout_8;
QComboBox *comboBox;
QPushButton *pushButton_2;
QGroupBox *groupBox;
QVBoxLayout *verticalLayout_6;
QVBoxLayout *verticalLayout_5;
@ -105,6 +106,11 @@ public:
verticalLayout_8->addWidget(comboBox);
pushButton_2 = new QPushButton(groupBox_5);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
verticalLayout_8->addWidget(pushButton_2);
verticalLayout_3->addWidget(groupBox_5);
@ -261,6 +267,7 @@ public:
{
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
groupBox_5->setTitle(QApplication::translate("MainWindow", "MapType", 0, QApplication::UnicodeUTF8));
pushButton_2->setText(QApplication::translate("MainWindow", "PushButton", 0, QApplication::UnicodeUTF8));
groupBox->setTitle(QApplication::translate("MainWindow", "Goto Place", 0, QApplication::UnicodeUTF8));
pushButtonGO->setText(QApplication::translate("MainWindow", "GO", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("MainWindow", "GeoCoderStatusCode", 0, QApplication::UnicodeUTF8));

View File

@ -319,6 +319,7 @@ namespace internals {
OnMapSizeChanged(Width, Height);
GoToCurrentPosition();
ReloadMap();
GoToCurrentPosition();
emit OnMapTypeChanged(value);
}

View File

@ -11,7 +11,12 @@ namespace mapcontrol
{
class Helper
{
public:
static MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
static QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
static QStringList MapTypes(){return MapType::TypesList();}
static GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
static QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
};
class OPMapWidget:public QGraphicsView
@ -28,13 +33,8 @@ namespace mapcontrol
Q_ENUMS(internals::MouseWheelZoomType::Types)
Q_ENUMS(internals::GeoCoderStatusCode::Types)
public:
GeoCoderStatusCode x;
MapType y;
MapType::Types MapTypeFromString(QString const& value){return MapType::TypeByStr(value);}
QString StrFromMapType(MapType::Types const& value){return MapType::StrByType(value);}
QStringList MapTypes(){return MapType::TypesList();}
GeoCoderStatusCode::Types GeoCoderStatusCodeFromString(QString const& value){return GeoCoderStatusCode::TypeByStr(value);}
QString StrFromGeoCoderStatusCode(GeoCoderStatusCode::Types const& value){return GeoCoderStatusCode::StrByType(value);}
// GeoCoderStatusCode x;
// MapType y;
QSize sizeHint() const;
OPMapWidget(QWidget *parent=0);
~OPMapWidget();
@ -65,11 +65,14 @@ namespace mapcontrol
MapType::Types GetMapType(){return map->core->GetMapType();}
void SetMapType(MapType::Types const& value){map->core->SetMapType(value);}
bool isStarted(){return map->core->isStarted();}
void X(){map->core->GoToCurrentPosition();}
private:
Core *core;
MapGraphicItem *map;
QGraphicsScene mscene;
bool useOpenGL;
GeoCoderStatusCode x;
MapType y;
protected:
void resizeEvent(QResizeEvent *event);
void showEvent ( QShowEvent * event );