Commit 85be7c6a authored by pixhawk's avatar pixhawk

Parameter view works with components now

parent 06244548
...@@ -14,6 +14,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) : ...@@ -14,6 +14,7 @@ ParameterInterface::ParameterInterface(QWidget *parent) :
m_ui->setupUi(this); m_ui->setupUi(this);
connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*))); connect(UASManager::instance(), SIGNAL(UASCreated(UASInterface*)), this, SLOT(addUAS(UASInterface*)));
components = new QMap<int, QTreeWidgetItem*>();
tree = new ParamTreeModel(); tree = new ParamTreeModel();
//treeView = new QTreeView(this); //treeView = new QTreeView(this);
...@@ -74,9 +75,17 @@ void ParameterInterface::requestParameterList() ...@@ -74,9 +75,17 @@ void ParameterInterface::requestParameterList()
* @param component id of the component * @param component id of the component
* @param componentName human friendly name 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); 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) void ParameterInterface::receiveParameter(int uas, int component, QString parameterName, float value)
...@@ -84,10 +93,18 @@ void ParameterInterface::receiveParameter(int uas, int component, QString parame ...@@ -84,10 +93,18 @@ void ParameterInterface::receiveParameter(int uas, int component, QString parame
Q_UNUSED(uas); Q_UNUSED(uas);
// Insert parameter into map // Insert parameter into map
//tree->appendParam(component, parameterName, value); //tree->appendParam(component, parameterName, value);
QStringList list; QStringList plist;
list.append(parameterName); plist.append(parameterName);
list.append(QString::number(value)); plist.append(QString::number(value));
treeWidget->addTopLevelItem(new QTreeWidgetItem(list)); 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 @@ ...@@ -4,6 +4,7 @@
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QTreeWidget> #include <QtGui/QTreeWidget>
#include <QtGui/QTreeWidgetItem>
#include "ui_ParameterInterface.h" #include "ui_ParameterInterface.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "ParamTreeModel.h" #include "ParamTreeModel.h"
...@@ -20,7 +21,7 @@ public: ...@@ -20,7 +21,7 @@ public:
public slots: public slots:
void addUAS(UASInterface* uas); 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 receiveParameter(int uas, int component, QString parameterName, float value);
void requestParameterList(); void requestParameterList();
void setParameter(UASInterface* uas, int component, QString parameterName, float value); void setParameter(UASInterface* uas, int component, QString parameterName, float value);
...@@ -33,6 +34,7 @@ protected: ...@@ -33,6 +34,7 @@ protected:
ParamTreeModel* tree; ParamTreeModel* tree;
QTreeView* treeView; QTreeView* treeView;
QTreeWidget* treeWidget; QTreeWidget* treeWidget;
QMap<int, QTreeWidgetItem*>* components;
private: private:
Ui::parameterWidget *m_ui; Ui::parameterWidget *m_ui;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment