|
|
@ -34,7 +34,8 @@ This file is part of the PIXHAWK project |
|
|
|
#include "ParamTreeModel.h" |
|
|
|
#include "ParamTreeModel.h" |
|
|
|
|
|
|
|
|
|
|
|
ParamTreeModel::ParamTreeModel(QObject *parent) |
|
|
|
ParamTreeModel::ParamTreeModel(QObject *parent) |
|
|
|
: QAbstractItemModel(parent) |
|
|
|
: QAbstractItemModel(parent), |
|
|
|
|
|
|
|
components() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QVariant> rootData; |
|
|
|
QList<QVariant> rootData; |
|
|
|
rootData << tr("ID") << tr("Parameter") << tr("Value"); |
|
|
|
rootData << tr("ID") << tr("Parameter") << tr("Value"); |
|
|
@ -43,7 +44,8 @@ ParamTreeModel::ParamTreeModel(QObject *parent) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ParamTreeModel::ParamTreeModel(const QString &data, QObject *parent) |
|
|
|
ParamTreeModel::ParamTreeModel(const QString &data, QObject *parent) |
|
|
|
: QAbstractItemModel(parent) |
|
|
|
: QAbstractItemModel(parent), |
|
|
|
|
|
|
|
components() |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<QVariant> rootData; |
|
|
|
QList<QVariant> rootData; |
|
|
|
rootData << tr("Parameter") << tr("Value"); |
|
|
|
rootData << tr("Parameter") << tr("Value"); |
|
|
@ -142,6 +144,33 @@ int ParamTreeModel::rowCount(const QModelIndex &parent) const |
|
|
|
return parentItem->childCount(); |
|
|
|
return parentItem->childCount(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ParamTreeItem* ParamTreeModel::getNodeForComponentId(int id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return components.value(id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParamTreeModel::appendComponent(int componentId, QString name) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!components.contains(componentId)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ParamTreeItem* item = new ParamTreeItem(componentId, name, 0, rootItem); |
|
|
|
|
|
|
|
components.insert(componentId, item); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ParamTreeModel::appendParam(int componentId, int id, QString name, float value) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ParamTreeItem* comp = components.value(componentId); |
|
|
|
|
|
|
|
// If component does not exist yet
|
|
|
|
|
|
|
|
if (comp == NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
appendComponent(componentId, name); |
|
|
|
|
|
|
|
comp = components.value(componentId); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// FIXME Children may be double here
|
|
|
|
|
|
|
|
comp->appendChild(new ParamTreeItem(id, name, value, comp)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ParamTreeModel::setupModelData(const QStringList &lines, ParamTreeItem *parent) |
|
|
|
void ParamTreeModel::setupModelData(const QStringList &lines, ParamTreeItem *parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QList<ParamTreeItem*> parents; |
|
|
|
QList<ParamTreeItem*> parents; |
|
|
|