AdvParameterList.cc 2.02 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#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->setHorizontalHeader(0);
    //ui.tableWidget->setVerticalHeader(0);
    ui.tableWidget->setColumnWidth(0,200);
    ui.tableWidget->setColumnWidth(1,100);
    ui.tableWidget->setColumnWidth(2,200);
    ui.tableWidget->setColumnWidth(3,800);

}

AdvParameterList::~AdvParameterList()
{
}
void AdvParameterList::setParameterMetaData(QString name,QString humanname,QString description)
{
    paramToNameMap[name] = humanname;
    paramToDescriptionMap[name] = description;
}

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

    if (!paramValueMap.contains(parameterName))
    {
        ui.tableWidget->setRowCount(ui.tableWidget->rowCount()+1);
        if (paramToNameMap.contains(parameterName))
        {
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,0,new QTableWidgetItem(paramToNameMap[parameterName]));
        }
        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 44 45 46 47 48 49 50 51 52 53
        ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,2,new QTableWidgetItem(parameterName));
        if (paramToDescriptionMap.contains(parameterName))
        {
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem(paramToDescriptionMap[parameterName]));
        }
        else
        {
            ui.tableWidget->setItem(ui.tableWidget->rowCount()-1,3,new QTableWidgetItem("Unknown"));
        }
        paramValueMap[parameterName] = ui.tableWidget->item(ui.tableWidget->rowCount()-1,1);
    }
54
    paramValueMap[parameterName]->setText(QString::number(value.toFloat(),'f',2));
55
}