1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-21 11:54:15 +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(); map=new mapcontrol::OPMapWidget();
ui->setupUi(this); ui->setupUi(this);
ui->comboBox->addItems(map->MapTypes()); ui->comboBox->addItems(mapcontrol::Helper::MapTypes());
ui->comboBox->setCurrentIndex(map->MapTypes().indexOf("GoogleHybrid")); ui->comboBox->setCurrentIndex(mapcontrol::Helper::MapTypes().indexOf("GoogleHybrid"));
QHBoxLayout *layout=new QHBoxLayout(parent); QHBoxLayout *layout=new QHBoxLayout(parent);
layout->addWidget(map); layout->addWidget(map);
layout->addWidget(ui->widget); layout->addWidget(ui->widget);
@ -80,7 +80,7 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_pushButtonGO_clicked() void MainWindow::on_pushButtonGO_clicked()
{ {
core::GeoCoderStatusCode::Types x=map->SetCurrentPositionByKeywords(ui->lineEdit->text()); 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) void MainWindow::on_comboBox_currentIndexChanged(QString value)
{ {
if (map->isStarted()) 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; mapcontrol::OPMapWidget *map;
private slots: private slots:
void on_pushButton_2_clicked();
void on_comboBox_currentIndexChanged(QString ); void on_comboBox_currentIndexChanged(QString );
void on_checkBox_2_clicked(bool checked); void on_checkBox_2_clicked(bool checked);
void on_pushButtonGO_clicked(); void on_pushButtonGO_clicked();

View File

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

View File

@ -1,7 +1,7 @@
/******************************************************************************** /********************************************************************************
** Form generated from reading UI file 'mainwindow.ui' ** 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 ** by: Qt User Interface Compiler version 4.6.2
** **
** WARNING! All changes made in this file will be lost when recompiling UI file! ** WARNING! All changes made in this file will be lost when recompiling UI file!
@ -42,6 +42,7 @@ public:
QGroupBox *groupBox_5; QGroupBox *groupBox_5;
QVBoxLayout *verticalLayout_8; QVBoxLayout *verticalLayout_8;
QComboBox *comboBox; QComboBox *comboBox;
QPushButton *pushButton_2;
QGroupBox *groupBox; QGroupBox *groupBox;
QVBoxLayout *verticalLayout_6; QVBoxLayout *verticalLayout_6;
QVBoxLayout *verticalLayout_5; QVBoxLayout *verticalLayout_5;
@ -105,6 +106,11 @@ public:
verticalLayout_8->addWidget(comboBox); 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); verticalLayout_3->addWidget(groupBox_5);
@ -261,6 +267,7 @@ public:
{ {
MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
groupBox_5->setTitle(QApplication::translate("MainWindow", "MapType", 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)); groupBox->setTitle(QApplication::translate("MainWindow", "Goto Place", 0, QApplication::UnicodeUTF8));
pushButtonGO->setText(QApplication::translate("MainWindow", "GO", 0, QApplication::UnicodeUTF8)); pushButtonGO->setText(QApplication::translate("MainWindow", "GO", 0, QApplication::UnicodeUTF8));
label->setText(QApplication::translate("MainWindow", "GeoCoderStatusCode", 0, QApplication::UnicodeUTF8)); label->setText(QApplication::translate("MainWindow", "GeoCoderStatusCode", 0, QApplication::UnicodeUTF8));

View File

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

View File

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