ParameterInterface.cc 1.89 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
void ParameterInterface::selectUAS(int index)
{
lm's avatar
lm committed
36
    qDebug() << "SELECTING INDEX " << index << "SIZE:" << m_ui->stackedWidget->count();
pixhawk's avatar
pixhawk committed
37
    m_ui->stackedWidget->setCurrentIndex(index);
lm's avatar
lm committed
38
    m_ui->sensorSettings->setCurrentIndex(index);
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
        m_ui->sensorSettings->setCurrentWidget(sensor);
pixhawk's avatar
pixhawk committed
62
        m_ui->stackedWidget->setCurrentWidget(param);
lm's avatar
lm committed
63
        curr = 0;
pixhawk's avatar
pixhawk committed
64
    }
pixhawk's avatar
pixhawk committed
65 66 67 68 69 70 71 72 73 74 75 76
}

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