ParameterInterface.cc 1.87 KB
Newer Older
1 2
#include <QTreeWidget>

pixhawk's avatar
pixhawk committed
3 4 5
#include "ParameterInterface.h"
#include "UASManager.h"
#include "ui_ParameterInterface.h"
lm's avatar
lm committed
6
#include "QGCSensorSettingsWidget.h"
pixhawk's avatar
pixhawk committed
7

8 9
#include <QDebug>

pixhawk's avatar
pixhawk committed
10
ParameterInterface::ParameterInterface(QWidget *parent) :
11
        QWidget(parent),
pixhawk's avatar
pixhawk committed
12 13
        paramWidgets(new QMap<int, QGCParamWidget*>()),
        curr(-1),
14
        m_ui(new Ui::parameterWidget)
pixhawk's avatar
pixhawk committed
15 16
{
    m_ui->setupUi(this);
17 18 19
    // Make sure the combo box is empty
    // because else indices get messed up
    m_ui->vehicleComboBox->clear();
20

pixhawk's avatar
pixhawk committed
21 22
    // Setup UI connections
    connect(m_ui->vehicleComboBox, SIGNAL(activated(int)), this, SLOT(selectUAS(int)));
23

pixhawk's avatar
pixhawk committed
24 25
    // Setup MAV connections
    connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
26
    this->setVisible(false);
pixhawk's avatar
pixhawk committed
27 28 29 30 31 32 33
}

ParameterInterface::~ParameterInterface()
{
    delete m_ui;
}

pixhawk's avatar
pixhawk committed
34 35
void ParameterInterface::selectUAS(int index)
{
36 37 38
    // FIXME plus 2 shouldn't be there
    m_ui->stackedWidget->setCurrentIndex(index+2);
    m_ui->sensorSettings->setCurrentIndex(index+2);
pixhawk's avatar
pixhawk committed
39 40 41
    curr = index;
}

pixhawk's avatar
pixhawk committed
42 43 44 45 46 47 48
/**
 *
 * @param uas System to add to list
 */
void ParameterInterface::addUAS(UASInterface* uas)
{
    m_ui->vehicleComboBox->addItem(uas->getUASName());
49

pixhawk's avatar
pixhawk committed
50 51 52
    QGCParamWidget* param = new QGCParamWidget(uas, this);
    paramWidgets->insert(uas->getUASID(), param);
    m_ui->stackedWidget->addWidget(param);
lm's avatar
lm committed
53 54 55 56 57 58


    QGCSensorSettingsWidget* sensor = new QGCSensorSettingsWidget(uas, this);
    m_ui->sensorSettings->addWidget(sensor);

    // Set widgets as default
pixhawk's avatar
pixhawk committed
59 60
    if (curr == -1)
    {
61
        // Clear
62
        m_ui->sensorSettings->setCurrentWidget(sensor);
pixhawk's avatar
pixhawk committed
63
        m_ui->stackedWidget->setCurrentWidget(param);
64
        curr = 0;
pixhawk's avatar
pixhawk committed
65
    }
pixhawk's avatar
pixhawk committed
66 67 68 69 70 71 72 73 74 75 76 77
}

void ParameterInterface::changeEvent(QEvent *e)
{
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}