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

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

9 10
#include <QDebug>

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

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

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

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

pixhawk's avatar
pixhawk committed
34 35 36
void ParameterInterface::selectUAS(int index)
{
    m_ui->stackedWidget->setCurrentIndex(index);
lm's avatar
lm committed
37
    m_ui->sensorSettings->setCurrentIndex(index);
pixhawk's avatar
pixhawk committed
38 39 40
    curr = index;
}

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

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


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

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

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