diff --git a/src/ui/ParameterInterface.cc b/src/ui/ParameterInterface.cc index c18c4df988127c37a897dab37746c6b79fdd1e8a..d977e47be5b0b1a3e41ba4e12fcf5f81fbb9270e 100644 --- a/src/ui/ParameterInterface.cc +++ b/src/ui/ParameterInterface.cc @@ -14,6 +14,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) : m_ui->setupUi(this); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); + components = new QMap(); tree = new ParamTreeModel(); //treeView = new QTreeView(this); @@ -74,9 +75,17 @@ void ParameterInterface::requestParameterList() * @param component id of the component * @param componentName human friendly name of the component */ -void ParameterInterface::addComponent(UASInterface* uas, int component, QString componentName) +void ParameterInterface::addComponent(int uas, int component, QString componentName) { Q_UNUSED(uas); + QStringList list; + list.append(componentName); + list.append(QString::number(component)); + QTreeWidgetItem* comp = new QTreeWidgetItem(list); + bool updated = false; + if (components->contains(component)) updated = true; + components->insert(component, comp); + if (!updated) treeWidget->addTopLevelItem(comp); } void ParameterInterface::receiveParameter(int uas, int component, QString parameterName, float value) @@ -84,10 +93,18 @@ void ParameterInterface::receiveParameter(int uas, int component, QString parame Q_UNUSED(uas); // Insert parameter into map //tree->appendParam(component, parameterName, value); - QStringList list; - list.append(parameterName); - list.append(QString::number(value)); - treeWidget->addTopLevelItem(new QTreeWidgetItem(list)); + QStringList plist; + plist.append(parameterName); + plist.append(QString::number(value)); + QTreeWidgetItem* item = new QTreeWidgetItem(plist); + + // Get component + if (!components->contains(component)) + { + addComponent(uas, component, "Component #" + QString::number(component)); + } + components->value(component)->addChild(item); + //treeWidget->addTopLevelItem(new QTreeWidgetItem(list)); } /** diff --git a/src/ui/ParameterInterface.h b/src/ui/ParameterInterface.h index 266014d3ed3ecf6c91daaf7d15a803f30db20ffb..57f1657839bf6d7c89f448c03a06cbb4b3700d80 100644 --- a/src/ui/ParameterInterface.h +++ b/src/ui/ParameterInterface.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "ui_ParameterInterface.h" #include "UASInterface.h" #include "ParamTreeModel.h" @@ -20,7 +21,7 @@ public: public slots: void addUAS(UASInterface* uas); - void addComponent(UASInterface* uas, int component, QString componentName); + void addComponent(int uas, int component, QString componentName); void receiveParameter(int uas, int component, QString parameterName, float value); void requestParameterList(); void setParameter(UASInterface* uas, int component, QString parameterName, float value); @@ -33,6 +34,7 @@ protected: ParamTreeModel* tree; QTreeView* treeView; QTreeWidget* treeWidget; + QMap* components; private: Ui::parameterWidget *m_ui;