10 changed files with 172 additions and 32 deletions
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
#include "QGCWaypointListMulti.h" |
||||
#include "ui_QGCWaypointListMulti.h" |
||||
#include "UASManager.h" |
||||
|
||||
QGCWaypointListMulti::QGCWaypointListMulti(QWidget *parent) : |
||||
QWidget(parent), |
||||
ui(new Ui::QGCWaypointListMulti) |
||||
{ |
||||
ui->setupUi(this); |
||||
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(systemCreated(UASInterface*))); |
||||
connect(UASManager::instance(), SIGNAL(activeUASSet(int)), this, SLOT(systemSetActive(int))); |
||||
} |
||||
|
||||
void QGCWaypointListMulti::systemDeleted(QObject* uas) |
||||
{ |
||||
UASInterface* mav = dynamic_cast<UASInterface*>(uas); |
||||
if (mav) |
||||
{ |
||||
int id = mav->getUASID(); |
||||
WaypointList* list = lists.value(id, NULL); |
||||
if (list) |
||||
{ |
||||
delete list; |
||||
lists.remove(id); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void QGCWaypointListMulti::systemCreated(UASInterface* uas) |
||||
{ |
||||
WaypointList* list = new WaypointList(ui->stackedWidget, uas); |
||||
lists.insert(uas->getUASID(), list); |
||||
ui->stackedWidget->addWidget(list); |
||||
// Ensure widget is deleted when system is deleted
|
||||
connect(uas, SIGNAL(destroyed(QObject*)), this, SLOT(systemDeleted(QObject*))); |
||||
} |
||||
|
||||
void QGCWaypointListMulti::systemSetActive(int uas) |
||||
{ |
||||
WaypointList* list = lists.value(uas, NULL); |
||||
if (list) |
||||
{ |
||||
ui->stackedWidget->setCurrentWidget(list); |
||||
} |
||||
} |
||||
|
||||
QGCWaypointListMulti::~QGCWaypointListMulti() |
||||
{ |
||||
delete ui; |
||||
} |
||||
|
||||
void QGCWaypointListMulti::changeEvent(QEvent *e) |
||||
{ |
||||
QWidget::changeEvent(e); |
||||
switch (e->type()) { |
||||
case QEvent::LanguageChange: |
||||
ui->retranslateUi(this); |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
@ -0,0 +1,35 @@
@@ -0,0 +1,35 @@
|
||||
#ifndef QGCWAYPOINTLISTMULTI_H |
||||
#define QGCWAYPOINTLISTMULTI_H |
||||
|
||||
#include <QWidget> |
||||
#include <QMap> |
||||
|
||||
#include "WaypointList.h" |
||||
#include "UASInterface.h" |
||||
|
||||
namespace Ui { |
||||
class QGCWaypointListMulti; |
||||
} |
||||
|
||||
class QGCWaypointListMulti : public QWidget |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit QGCWaypointListMulti(QWidget *parent = 0); |
||||
~QGCWaypointListMulti(); |
||||
|
||||
public slots: |
||||
void systemDeleted(QObject* uas); |
||||
void systemCreated(UASInterface* uas); |
||||
void systemSetActive(int uas); |
||||
|
||||
protected: |
||||
void changeEvent(QEvent *e); |
||||
QMap<int, WaypointList*> lists; |
||||
|
||||
private: |
||||
Ui::QGCWaypointListMulti *ui; |
||||
}; |
||||
|
||||
#endif // QGCWAYPOINTLISTMULTI_H
|
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>QGCWaypointListMulti</class> |
||||
<widget class="QWidget" name="QGCWaypointListMulti"> |
||||
<property name="geometry"> |
||||
<rect> |
||||
<x>0</x> |
||||
<y>0</y> |
||||
<width>400</width> |
||||
<height>300</height> |
||||
</rect> |
||||
</property> |
||||
<property name="windowTitle"> |
||||
<string>Form</string> |
||||
</property> |
||||
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
<property name="margin"> |
||||
<number>0</number> |
||||
</property> |
||||
<item> |
||||
<widget class="QStackedWidget" name="stackedWidget"/> |
||||
</item> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
Loading…
Reference in new issue