1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "QGCWaypointListMulti.h"
#include "ui_QGCWaypointListMulti.h"
#include "UASManager.h"
void* QGCWaypointListMulti::_offlineUAS = NULL;
QGCWaypointListMulti::QGCWaypointListMulti(QWidget *parent) :
QWidget(parent),
_ui(new Ui::QGCWaypointListMulti)
{
_ui->setupUi(this);
setMinimumSize(600, 80);
connect(UASManager::instance(), &UASManager::UASCreated, this, &QGCWaypointListMulti::_systemCreated);
connect(UASManager::instance(), &UASManager::activeUASSet, this, &QGCWaypointListMulti::_systemSetActive);
WaypointList* list = new WaypointList(_ui->stackedWidget, UASManager::instance()->getActiveUASWaypointManager());
_lists.insert(_offlineUAS, list);
_ui->stackedWidget->addWidget(list);
if (UASManager::instance()->getActiveUAS()) {
_systemCreated(UASManager::instance()->getActiveUAS());
_systemSetActive(UASManager::instance()->getActiveUAS());
}
}
QGCWaypointListMulti::~QGCWaypointListMulti()
{
delete _ui;
}
void QGCWaypointListMulti::_systemDeleted(QObject* uas)
{
// Do not dynamic cast or de-reference QObject, since object is either in destructor or may have already
// been destroyed.
if (uas) {
WaypointList* list = _lists.value(uas, NULL);
if (list) {
delete list;
_lists.remove(uas);
}
}
}
void QGCWaypointListMulti::_systemCreated(UASInterface* uas)
{
WaypointList* list = new WaypointList(_ui->stackedWidget, uas->getWaypointManager());
_lists.insert(uas, list);
_ui->stackedWidget->addWidget(list);
// Ensure widget is deleted when system is deleted
connect(uas, &QObject::destroyed, this, &QGCWaypointListMulti::_systemDeleted);
}
void QGCWaypointListMulti::_systemSetActive(UASInterface* uas)
{
WaypointList* list = _lists.value(uas, NULL);
if (list) {
_ui->stackedWidget->setCurrentWidget(list);
}
}
void QGCWaypointListMulti::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
_ui->retranslateUi(this);
break;
default:
break;
}
}