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
e02f9ec0
Commit
e02f9ec0
authored
Aug 12, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better data model update debouncing
parent
11e1379a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
22 deletions
+25
-22
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+24
-20
QGCParamWidget.h
src/ui/QGCParamWidget.h
+1
-2
No files found.
src/ui/QGCParamWidget.cc
View file @
e02f9ec0
...
...
@@ -51,7 +51,8 @@ This file is part of the QGROUNDCONTROL project
*/
QGCParamWidget
::
QGCParamWidget
(
UASInterface
*
uas
,
QWidget
*
parent
)
:
QGCUASParamManager
(
uas
,
parent
),
componentItems
(
new
QMap
<
int
,
QTreeWidgetItem
*>
())
componentItems
(
new
QMap
<
int
,
QTreeWidgetItem
*>
()),
updatingParamNameLock
(
""
)
{
layoutWidget
();
...
...
@@ -202,20 +203,17 @@ void QGCParamWidget::addComponentItem(int compId, QString compName)
void
QGCParamWidget
::
handlePendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
)
{
qDebug
()
<<
"handlePendingParamUpdate:"
<<
paramName
<<
"with updat
edLineItem_weak:"
<<
updatedLineItem_wea
k
;
qDebug
()
<<
"handlePendingParamUpdate:"
<<
paramName
<<
"with updat
ingParamNameLock:"
<<
updatingParamNameLoc
k
;
if
(
updat
edLineItem_weak
)
{
QString
key
=
updatedLineItem_weak
->
data
(
0
,
Qt
::
DisplayRole
).
toString
()
;
if
(
paramName
==
key
)
{
//debounce echo from data model
return
;
}
if
(
updat
ingParamNameLock
==
paramName
)
{
qDebug
()
<<
"ignoring bounce from "
<<
paramName
;
return
;
}
else
{
updatingParamNameLock
=
paramName
;
}
QTreeWidgetItem
*
paramItem
=
updateParameterDisplay
(
compId
,
paramName
,
value
);
if
(
updatedLineItem_weak
==
NULL
)
{
updatedLineItem_weak
=
paramItem
;
}
if
(
isPending
)
{
paramItem
->
setBackground
(
0
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
paramItem
->
setBackground
(
1
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
...
...
@@ -225,17 +223,20 @@ void QGCParamWidget::handlePendingParamUpdate(int compId, const QString& paramNa
paramItem
->
setBackground
(
1
,
Qt
::
NoBrush
);
}
updatingParamNameLock
.
clear
();
}
void
QGCParamWidget
::
handleParameterUpdate
(
int
componentId
,
const
QString
&
paramName
,
QVariant
value
)
{
updatingParamNameLock
=
paramName
;
updateParameterDisplay
(
componentId
,
paramName
,
value
);
updatingParamNameLock
.
clear
();
}
void
QGCParamWidget
::
handleParameterListUpToDate
()
{
//turn off updates while we refresh the entire list
tree
->
setUpdatesEnabled
(
false
);
...
...
@@ -340,7 +341,6 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
);
}
parameterItem
->
setFlags
(
parameterItem
->
flags
()
|
Qt
::
ItemIsEditable
);
updatedLineItem_weak
=
parameterItem
;
//keep a temporary ref to the item that's being updated
//TODO insert alphabetically
parentItem
->
addChild
(
parameterItem
);
...
...
@@ -362,8 +362,6 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
}
}
updatedLineItem_weak
=
parameterItem
;
//keep a temporary ref to the item that's being updated
//update the parameterItem's data
if
(
value
.
type
()
==
QVariant
::
Char
)
{
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
.
toUInt
());
...
...
@@ -381,7 +379,6 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
parameterItem
->
setTextColor
(
0
,
QGC
::
colorDarkWhite
);
parameterItem
->
setTextColor
(
1
,
QGC
::
colorDarkWhite
);
updatedLineItem_weak
=
NULL
;
}
return
parameterItem
;
...
...
@@ -391,12 +388,19 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
void
QGCParamWidget
::
parameterItemChanged
(
QTreeWidgetItem
*
paramItem
,
int
column
)
{
if
(
paramItem
&&
column
>
0
)
{
if
(
!
paramItem
->
isSelected
()
||
(
paramItem
==
updatedLineItem_weak
))
{
//ignore updates reflected back from the data model, to avoid infinite loop
QString
key
=
paramItem
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
qDebug
()
<<
"parameterItemChanged:"
<<
key
<<
"with updatingParamNameLock:"
<<
updatingParamNameLock
;
if
(
key
==
updatingParamNameLock
)
{
qDebug
()
<<
"ignoring parameterItemChanged"
<<
key
;
return
;
}
else
{
updatingParamNameLock
=
key
;
}
QTreeWidgetItem
*
parent
=
paramItem
->
parent
();
while
(
parent
->
parent
()
!=
NULL
)
{
...
...
@@ -404,10 +408,9 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column
}
// Parent is now top-level component
int
componentId
=
componentItems
->
key
(
parent
);
QString
key
=
paramItem
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
QVariant
value
=
paramItem
->
data
(
1
,
Qt
::
DisplayRole
);
bool
pending
=
paramDataModel
->
updatePendingParamWithValue
(
componentId
,
key
,
value
);
// If the value will result in an update
...
...
@@ -430,6 +433,7 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* paramItem, int column
paramItem
->
setBackground
(
1
,
Qt
::
NoBrush
);
}
updatingParamNameLock
.
clear
();
}
}
...
...
src/ui/QGCParamWidget.h
View file @
e02f9ec0
...
...
@@ -100,8 +100,7 @@ protected:
QLabel
*
statusLabel
;
///< User-facing parameter status label
QMap
<
int
,
QTreeWidgetItem
*>*
componentItems
;
///< The tree of component items, stored by component ID
QMap
<
int
,
QMap
<
QString
,
QTreeWidgetItem
*>*
>
paramGroups
;
///< Parameter groups to organize component items
QTreeWidgetItem
*
updatedLineItem_weak
;
///< weak ref to user-edited line
// QTreeWidgetItem* updatedPendingItem_weak;///< weak ref to pending-modified line
QString
updatingParamNameLock
;
///< Name of param currently being updated-- used for reducing echo on param change
};
...
...
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