Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3c6bc561
Commit
3c6bc561
authored
Aug 09, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix change checking for params; better pending status indication
parent
25150144
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
84 deletions
+20
-84
UASParameterDataModel.cc
src/uas/UASParameterDataModel.cc
+6
-10
UASParameterDataModel.h
src/uas/UASParameterDataModel.h
+1
-1
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+13
-73
No files found.
src/uas/UASParameterDataModel.cc
View file @
3c6bc561
...
...
@@ -18,25 +18,21 @@ UASParameterDataModel::UASParameterDataModel(QObject *parent) :
bool
UASParameterDataModel
::
checkParameterChanged
(
int
comp
onentId
,
const
QString
&
key
,
const
QVariant
&
value
)
bool
UASParameterDataModel
::
checkParameterChanged
(
int
comp
Id
,
const
QString
&
key
,
const
QVariant
&
value
)
{
bool
changed
=
true
;
addComponent
(
componentId
);
QMap
<
QString
,
QVariant
>*
existParams
=
getOnbardParametersForComponent
(
componentId
);
//ensure we have this component in our onboard and pending lists already
addComponent
(
compId
);
QMap
<
QString
,
QVariant
>*
existParams
=
getOnbardParametersForComponent
(
compId
);
if
(
existParams
->
contains
(
key
))
{
QVariant
existValue
=
existParams
->
value
(
key
);
QMap
<
QString
,
QVariant
>*
pendParams
=
getPendingParametersForComponent
(
componentId
);
if
(
pendParams
->
contains
(
key
))
{
QVariant
pendValue
=
pendParams
->
value
(
key
);
if
(
existValue
==
pendValue
)
{
changed
=
false
;
}
if
(
existValue
==
value
)
{
changed
=
false
;
}
}
return
changed
;
}
bool
UASParameterDataModel
::
addPendingIfParameterChanged
(
int
componentId
,
QString
&
key
,
QVariant
&
value
)
...
...
src/uas/UASParameterDataModel.h
View file @
3c6bc561
...
...
@@ -45,7 +45,7 @@ public:
virtual
void
forgetAllOnboardParameters
();
/**
* @return true if the
parameter has changed
* @return true if the
given value for the parameter is different from the existing value
*/
virtual
bool
checkParameterChanged
(
int
componentId
,
const
QString
&
key
,
const
QVariant
&
value
);
...
...
src/ui/QGCParamWidget.cc
View file @
3c6bc561
...
...
@@ -267,72 +267,12 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
componentItems
->
value
(
compId
)
->
insertChild
(
insertIdx
,
groupItem
);
}
// Append child to group
//bool found = false;
//parent item for this tree widget item will be a group widget item
//parent item for this parameter item will be a group widget item
parentItem
=
compParamGroups
->
value
(
parentStr
);
// for (int i = 0; i < parentItem->childCount(); i++) {
// QTreeWidgetItem* child = parentItem->child(i);
// QString key = child->data(0, Qt::DisplayRole).toString();
// if (key == parameterName) {
// //qDebug() << "UPDATED CHILD";
// parameterItem = child;
// if (value.type() == QVariant::Char) {
// parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
// }
// else {
// parameterItem->setData(1, Qt::DisplayRole, value);
// }
// found = true;
// }
// }
// if (!found) {
// // Insert parameter into map
// QStringList plist;
// plist.append(parameterName);
// // CREATE PARAMETER ITEM
// parameterItem = new QTreeWidgetItem(plist);
// // CONFIGURE PARAMETER ITEM
// if (value.type() == QVariant::Char) {
// parameterItem->setData(1, Qt::DisplayRole, value.toUInt());
// }
// else {
// parameterItem->setData(1, Qt::DisplayRole, value);
// }
// parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
// parentItem->addChild(parameterItem);
// }
}
else
{
//
bool found = false;
//
parent item for this parameter will be the top level component widget item
parentItem
=
componentItems
->
value
(
compId
);
// for (int i = 0; i < parent->childCount(); i++) {
// QTreeWidgetItem* child = parent->child(i);
// QString key = child->data(0, Qt::DisplayRole).toString();
// if (key == parameterName) {
// //qDebug() << "UPDATED CHILD";
// parameterItem = child;
// parameterItem->setData(1, Qt::DisplayRole, value);
// found = true;
// }
// }
// if (!found) {
// // Insert parameter into map
// QStringList plist;
// plist.append(parameterName);
// // CREATE PARAMETER ITEM
// parameterItem = new QTreeWidgetItem(plist);
// // CONFIGURE PARAMETER ITEM
// parameterItem->setData(1, Qt::DisplayRole, value);
// componentItems->value(compId)->addChild(parameterItem);
// parameterItem->setFlags(parameterItem->flags() | Qt::ItemIsEditable);
// }
}
if
(
parentItem
)
{
...
...
@@ -367,7 +307,7 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
);
}
parameterItem
->
setFlags
(
parameterItem
->
flags
()
|
Qt
::
ItemIsEditable
);
//TODO insert alphabetically
parentItem
->
addChild
(
parameterItem
);
}
}
...
...
@@ -411,25 +351,25 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
QString
key
=
current
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
QVariant
value
=
current
->
data
(
1
,
Qt
::
DisplayRole
);
// Set parameter on changed list to be transmitted to MAV
QPalette
pal
=
statusLabel
->
palette
();
pal
.
setColor
(
backgroundRole
(),
QGC
::
colorOrange
);
statusLabel
->
setPalette
(
pal
);
statusLabel
->
setText
(
tr
(
"Transmit pend. %1:%2: %3"
).
arg
(
componentId
).
arg
(
key
).
arg
(
value
.
toFloat
(),
5
,
'f'
,
1
,
QChar
(
' '
)));
//qDebug() << "PARAM CHANGED: COMP:" << key << "KEY:" << str << "VALUE:" << value;
// Changed values list
bool
changed
=
paramDataModel
->
addPendingIfParameterChanged
(
componentId
,
key
,
value
);
// If the value was numerically changed, display it differently
if
(
changed
)
{
// Set parameter on changed list to be transmitted to MAV
statusLabel
->
setText
(
tr
(
"Transmit pend. %1:%2: %3"
).
arg
(
componentId
).
arg
(
key
).
arg
(
value
.
toFloat
(),
5
,
'f'
,
1
,
QChar
(
' '
)));
if
(
current
==
tree
->
currentItem
())
{
//need to unset current item to clear highlighting (green by default)
tree
->
setCurrentItem
(
NULL
);
//clear the selected line
}
current
->
setBackground
(
0
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
current
->
setBackground
(
1
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
//TODO this seems incorrect-- we're pre-updating the onboard value before we've received confirmation
//paramDataModel->setOnboardParameterWithType(componentId,key,value);
tree
->
update
();
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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