Commit ea5e80af authored by tstellanova's avatar tstellanova

Move handleParameterUpdate into data model class

parent ca208533
#include "UASParameterDataModel.h"
#include <QDebug>
#include <QVariant>
UASParameterDataModel::UASParameterDataModel(QObject *parent) :
......@@ -31,7 +32,7 @@ void UASParameterDataModel::setPendingParameter(int componentId, QString& key,
params->insert(key,value);
}
void UASParameterDataModel::setOnboardParameter(int componentId, QString& key, QVariant &value)
void UASParameterDataModel::setOnboardParameter(int componentId, QString& key, QVariant& value)
{
//ensure we have a placeholder map for this component
addComponent(componentId);
......@@ -48,3 +49,24 @@ void UASParameterDataModel::addComponent(int componentId)
pendingParameters.insert(componentId, new QMap<QString, QVariant>());
}
}
void UASParameterDataModel::handleParameterUpdate(int componentId, QString& key, QVariant& value)
{
//verify that the value requested by the user matches the set value
//if it doesn't match, leave the pending parameter in the pending list!
if (pendingParameters.contains(componentId)) {
QMap<QString , QVariant> *pendingParams = pendingParameters.value(componentId);
if ((NULL != pendingParams) && pendingParams->contains(key)) {
QVariant reqVal = pendingParams->value(key);
if (reqVal == value) {
pendingParams->remove(key);
}
else {
qDebug() << "Pending commit for " << key << " want: " << reqVal << " got: " << value;
}
}
}
setOnboardParameter(componentId,key, value);
}
......@@ -22,6 +22,8 @@ public:
virtual void addPendingIfParameterChanged(int componentId, QString& key, QVariant &value);
void handleParameterUpdate(int componentId, QString& key, QVariant& value);
QMap<QString , QVariant>* getPendingParametersForComponent(int componentId) {
return pendingParameters.value(componentId);
}
......
......@@ -636,18 +636,8 @@ void QGCParamWidget::receivedParameterUpdate(int uas, int component, QString par
parameterItem->setToolTip(0, tooltipFormat);
parameterItem->setToolTip(1, tooltipFormat);
//verify that the value requested by the user matches the set value
//if it doesn't match, leave the pending parameter in the pending list!
QMap<int, QMap<QString , QVariant> *> changedValues = this->paramDataModel->getPendingParameters();
if (changedValues.contains(component)) {
QMap<QString , QVariant> *compReqVals = changedValues.value(component);
if ((NULL != compReqVals) && compReqVals->contains(parameterName)) {
QVariant reqVal = compReqVals->value(parameterName);
if (reqVal == value) {
compReqVals->remove(parameterName);
}
}
}
paramDataModel->handleParameterUpdate(component,parameterName,value);
}
/**
......
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