Commit 529a0873 authored by tstellanova's avatar tstellanova

Move handleParameterUpdate into data model class

parent 83409be5
#include "UASParameterDataModel.h" #include "UASParameterDataModel.h"
#include <QDebug>
#include <QVariant> #include <QVariant>
UASParameterDataModel::UASParameterDataModel(QObject *parent) : UASParameterDataModel::UASParameterDataModel(QObject *parent) :
...@@ -31,7 +32,7 @@ void UASParameterDataModel::setPendingParameter(int componentId, QString& key, ...@@ -31,7 +32,7 @@ void UASParameterDataModel::setPendingParameter(int componentId, QString& key,
params->insert(key,value); 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 //ensure we have a placeholder map for this component
addComponent(componentId); addComponent(componentId);
...@@ -48,3 +49,24 @@ void UASParameterDataModel::addComponent(int componentId) ...@@ -48,3 +49,24 @@ void UASParameterDataModel::addComponent(int componentId)
pendingParameters.insert(componentId, new QMap<QString, QVariant>()); 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: ...@@ -22,6 +22,8 @@ public:
virtual void addPendingIfParameterChanged(int componentId, QString& key, QVariant &value); virtual void addPendingIfParameterChanged(int componentId, QString& key, QVariant &value);
void handleParameterUpdate(int componentId, QString& key, QVariant& value);
QMap<QString , QVariant>* getPendingParametersForComponent(int componentId) { QMap<QString , QVariant>* getPendingParametersForComponent(int componentId) {
return pendingParameters.value(componentId); return pendingParameters.value(componentId);
} }
......
...@@ -636,18 +636,8 @@ void QGCParamWidget::receivedParameterUpdate(int uas, int component, QString par ...@@ -636,18 +636,8 @@ void QGCParamWidget::receivedParameterUpdate(int uas, int component, QString par
parameterItem->setToolTip(0, tooltipFormat); parameterItem->setToolTip(0, tooltipFormat);
parameterItem->setToolTip(1, tooltipFormat); parameterItem->setToolTip(1, tooltipFormat);
//verify that the value requested by the user matches the set value paramDataModel->handleParameterUpdate(component,parameterName,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);
}
}
}
} }
/** /**
......
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