Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
529a0873
Commit
529a0873
authored
Aug 05, 2013
by
tstellanova
Browse files
Move handleParameterUpdate into data model class
parent
83409be5
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/uas/UASParameterDataModel.cc
View file @
529a0873
#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
);
}
src/uas/UASParameterDataModel.h
View file @
529a0873
...
...
@@ -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
);
}
...
...
src/ui/QGCParamWidget.cc
View file @
529a0873
...
...
@@ -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
);
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment