Fork me on GitHub
2.15.20
FGx
A cross-platform launcher for FlightGear
mpmapxwidget.cpp
Go to the documentation of this file.
1 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
2 // FGx FlightGear Launcher // mpmapxwidget.cpp
3 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-
4 // (c) 2010-2012
5 // Yves Sablonier, Pete Morgan
6 // Geoff McLane
7 // GNU GPLv2, see main.cpp and shipped licence.txt for further information
8 
9 #include <QByteArray>
10 #include <QFile>
11 #include <QStringList>
12 
13 
14 #include <QVBoxLayout>
15 #include <QToolBar>
16 #include <QAction>
17 #include <QActionGroup>
18 #include <QToolButton>
19 #include <QMenu>
20 #include <QLabel>
21 
22 #include <QtWebKit/QWebFrame>
23 #include <QDesktopServices>
24 
25 #include "mpmap/mpmapxwidget.h"
26 
27 
28 
30  QWidget(parent)
31 {
32 
33  mainObject = mob;
34 
36 
37  setWindowTitle(tr("FGx Multiplayer Map"));
38  setWindowIcon(QIcon(":/icon/mpmap"));
39 
40 
41  //======================================================
42  //= Main Layout and Splitter
43  QVBoxLayout *mainLayout = new QVBoxLayout(this);
44  mainLayout->setContentsMargins(0,0,0,0);
45  mainLayout->setSpacing(0);
46 
47 
48  splitter = new QSplitter();
49  mainLayout->addWidget(splitter, 200);
50 
51 
52  //======================================================
53  //= Map
55  splitter->addWidget(mapWidget);
56  mapWidget->load_map("radar");
57 
58 
59  //================================================================================
60  //= Pilots widget
61  //================================================================================
63  splitter->addWidget(pilotsWidget);
65 
66  //====================================================================
67 
68  splitter->setStretchFactor(0, 2);
69  splitter->setStretchFactor(1, 1);
70  splitter->restoreState(mainObject->settings->value("mpmapxwidget_splitter").toByteArray());
71  connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(on_splitter_moved()));
72 
73  /*
74  connect(pilotsWidget, SIGNAL(radar(QString,QString,QString, QString, QString, bool)),
75  mapWidget, SLOT(show_radar(QString,QString,QString, QString, QString, bool)));
76  connect(pilotsWidget, SIGNAL(clear_radar()),
77  mapWidget, SLOT(clear_radar())
78  );
79 
80  connect(pilotsWidget, SIGNAL(aircraft_selected(XAero)),
81  this, SLOT(focus_aero(XAero)));
82 
83  */
84 
85 }
86 
88  //TODO make this cleaner
89  if(pilotsWidget->checkBoxAutoRefresh->isChecked()){
91  }
92 }
93 
94 //= window close
95 void MpMapXWidget::closeEvent(QCloseEvent *event){
97  event->accept();
98 }
99 
100 //void MpMapXWidget::on_freeze_map(bool freeze)
101 //{
102  //mapWidget->webView->setUpdatesEnabled(freeze);
103  //qDebug() << "freeze=" << freeze;
104 //}
105 
106 
107 void MpMapXWidget::add_airport(QString airport){
108  Q_UNUSED(airport);
109  //mapWidget->add_airport(airport);
110 }
111 
112 void MpMapXWidget::show_airport(QString airport){
113  mapWidget->zoom_to_airport(airport);
114 }
115 void MpMapXWidget::add_runway(QString airport, QString rwy1, QString rwy2, QString lat1, QString lng1, QString lat2, QString lng2){
116  mapWidget->add_runway(airport, rwy1, rwy2, lat1, lng1, lat2, lng2);
117 }
118 
120  mapWidget->zoom_to_latlon(aero.lat, aero.lon, 10);
121 }
122 
123 
125 {
126  mainObject->settings->setValue("mpmapxwidget_splitter", splitter->saveState());
127 }
MainObject * mainObject
Definition: mpmapxwidget.h:50
MpMapXWidget(MainObject *mob, QWidget *parent=0)
PilotsWidget * pilotsWidget
Definition: mpmapxwidget.h:53
void show_airport(QString airport)
void zoom_to_latlon(QString lat, QString lon, int zoom)
void focus_aero(XAero aero)
The MainObject is an extended QObject, and the main "controller" for FGx.
Definition: mainobject.h:66
QCheckBox * checkBoxAutoRefresh
Definition: pilotswidget.h:61
void on_splitter_moved()
void set_map_widget(OpenLayerWidget *mapWidget)
void saveWindow(QWidget *widget)
Saves a window's size and position.
Definition: xsettings.cpp:90
void add_airport(QString airport)
OpenLayerWidget * mapWidget
Definition: mpmapxwidget.h:52
void restoreWindow(QWidget *widget)
Restores a size window position.
Definition: xsettings.cpp:101
void add_runway(QString apt, QString rwy1, QString rwy2, QString lat1, QString lon1, QString lat2, QString lon2)
QString lat
Definition: xaero.h:20
void load_map(QString map_type)
QSplitter * splitter
Definition: mpmapxwidget.h:55
void initialize()
Definition: xaero.h:14
QString lon
Definition: xaero.h:21
void fetch_pilots()
void zoom_to_airport(QString apt)
void closeEvent(QCloseEvent *event)
void add_runway(QString airport, QString rwy1, QString rwy2, QString lat1, QString lng1, QString lat2, QString lng2)
XSettings * settings
Definition: mainobject.h:85