Skip to content
Snippets Groups Projects
Commit 85be7c6a authored by pixhawk's avatar pixhawk
Browse files

Parameter view works with components now

parent 06244548
No related branches found
No related tags found
No related merge requests found
......@@ -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<int, QTreeWidgetItem*>();
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));
}
/**
......
......@@ -4,6 +4,7 @@
#include <QtGui/QWidget>
#include <QtGui/QTreeView>
#include <QtGui/QTreeWidget>
#include <QtGui/QTreeWidgetItem>
#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<int, QTreeWidgetItem*>* components;
private:
Ui::parameterWidget *m_ui;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment