ParameterInterface.cc 1.84 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*)));
pixhawk's avatar
pixhawk committed
26 27 28 29 30 31 32
}

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

pixhawk's avatar
pixhawk committed
33 34
void ParameterInterface::selectUAS(int index)
{
35 36 37
    // FIXME plus 2 shouldn't be there
    m_ui->stackedWidget->setCurrentIndex(index+2);
    m_ui->sensorSettings->setCurrentIndex(index+2);
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
        // Clear
61
        m_ui->sensorSettings->setCurrentWidget(sensor);
pixhawk's avatar
pixhawk committed
62
        m_ui->stackedWidget->setCurrentWidget(param);
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;
    }
}