AdvParameterList.cc 1.97 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 28
}

void AdvParameterList::parameterChanged(int uas, int component, QString parameterName, QVariant value)
{

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