AdvParameterList.cc 2.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#include "AdvParameterList.h"


AdvParameterList::AdvParameterList(QWidget *parent) : AP2ConfigWidget(parent)
{
    ui.setupUi(this);
    ui.tableWidget->setColumnCount(4);
    ui.tableWidget->horizontalHeader()->hide();
    ui.tableWidget->verticalHeader()->hide();
    ui.tableWidget->setColumnWidth(0,200);
    ui.tableWidget->setColumnWidth(1,100);
    ui.tableWidget->setColumnWidth(2,200);
    ui.tableWidget->setColumnWidth(3,800);
14
    initConnections();
15 16 17 18 19 20 21
}

AdvParameterList::~AdvParameterList()
{
}
void AdvParameterList::setParameterMetaData(QString name,QString humanname,QString description)
{
22 23
    m_paramToNameMap[name] = humanname;
    m_paramToDescriptionMap[name] = description;
24 25 26 27
}

void AdvParameterList::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{
28 29 30
    Q_UNUSED(uas);
    Q_UNUSED(component);
    
31
    if (!m_paramValueMap.contains(parameterName))
32 33
    {
        ui.tableWidget->setRowCount(ui.tableWidget->rowCount()+1);
34
        if (m_paramToNameMap.contains(parameterName))
35
        {
36
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem(m_paramToNameMap[parameterName]));
37 38 39 40 41
        }
        else
        {
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem("Unknown"));
        }
42
        ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,1,new QTableWidgetItem(QString::number(value.toFloat(),'f',2)));
43
        ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,2,new QTableWidgetItem(parameterName));
44
        if (m_paramToDescriptionMap.contains(parameterName))
45
        {
46
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem(m_paramToDescriptionMap[parameterName]));
47 48 49 50 51
        }
        else
        {
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem("Unknown"));
        }
52
        m_paramValueMap[parameterName] = ui.tableWidget->item(ui.tableWidget->rowCount()-1,1);
53
    }
54
    m_paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'f',2));
55
}