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
0af58499
Commit
0af58499
authored
Aug 09, 2013
by
tstellanova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
propagate pending list updates
fix pending items indicator
parent
1bc43cab
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
55 deletions
+95
-55
UASParameterDataModel.cc
src/uas/UASParameterDataModel.cc
+6
-0
UASParameterDataModel.h
src/uas/UASParameterDataModel.h
+3
-0
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+80
-50
QGCParamWidget.h
src/ui/QGCParamWidget.h
+6
-5
No files found.
src/uas/UASParameterDataModel.cc
View file @
0af58499
...
...
@@ -49,6 +49,10 @@ void UASParameterDataModel::removePendingParam(int compId, QString& key)
QMap
<
QString
,
QVariant
>
*
params
=
getPendingParamsForComponent
(
compId
);
if
(
params
)
{
params
->
remove
(
key
);
//broadcast the existing value
QVariant
existVal
;
bool
ok
=
getOnboardParamValue
(
compId
,
key
,
existVal
);
emit
pendingParamUpdate
(
compId
,
key
,
existVal
,
false
);
}
}
...
...
@@ -59,6 +63,8 @@ void UASParameterDataModel::setPendingParam(int compId, QString& key, const QVa
addComponent
(
compId
);
QMap
<
QString
,
QVariant
>
*
params
=
getPendingParamsForComponent
(
compId
);
params
->
insert
(
key
,
value
);
emit
pendingParamUpdate
(
compId
,
key
,
value
,
true
);
}
void
UASParameterDataModel
::
setOnboardParam
(
int
compId
,
QString
&
key
,
const
QVariant
&
value
)
...
...
src/uas/UASParameterDataModel.h
View file @
0af58499
...
...
@@ -85,6 +85,9 @@ signals:
/** @brief We've received an update of a parameter's value */
void
parameterUpdated
(
int
compId
,
QString
paramName
,
QVariant
value
);
/** @brief Notifies listeners that a param was added to or removed from the pending list */
void
pendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
);
public
slots
:
...
...
src/ui/QGCParamWidget.cc
View file @
0af58499
...
...
@@ -66,6 +66,9 @@ QGCParamWidget::QGCParamWidget(UASInterface* uas, QWidget *parent) :
connect
(
paramDataModel
,
SIGNAL
(
parameterUpdated
(
int
,
QString
,
QVariant
)),
this
,
SLOT
(
handleParameterUpdate
(
int
,
QString
,
QVariant
)));
connect
(
paramDataModel
,
SIGNAL
(
pendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
)),
this
,
SLOT
(
handlePendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
)));
// Listen for param list reload finished
connect
(
paramCommsMgr
,
SIGNAL
(
parameterListUpToDate
()),
this
,
SLOT
(
handleParameterListUpToDate
()));
...
...
@@ -197,6 +200,19 @@ void QGCParamWidget::addComponentItem(int compId, QString compName)
}
void
QGCParamWidget
::
handlePendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
)
{
QTreeWidgetItem
*
paramItem
=
updateParameterDisplay
(
compId
,
paramName
,
value
);
if
(
isPending
)
{
paramItem
->
setBackground
(
0
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
paramItem
->
setBackground
(
1
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
}
else
{
paramItem
->
setBackground
(
0
,
Qt
::
NoBrush
);
paramItem
->
setBackground
(
1
,
Qt
::
NoBrush
);
}
}
void
QGCParamWidget
::
handleParameterUpdate
(
int
componentId
,
const
QString
&
paramName
,
QVariant
value
)
{
...
...
@@ -206,7 +222,6 @@ void QGCParamWidget::handleParameterUpdate(int componentId, const QString& param
void
QGCParamWidget
::
handleParameterListUpToDate
()
{
// tree->collapseAll();
//turn off updates while we refresh the entire list
tree
->
setUpdatesEnabled
(
false
);
...
...
@@ -231,27 +246,30 @@ void QGCParamWidget::handleParameterListUpToDate()
}
void
QGCParamWidget
::
updateParameterDisplay
(
int
compId
,
QString
parameterName
,
QVariant
value
)
QTreeWidgetItem
*
QGCParamWidget
::
findChildWidgetItemForParam
(
QTreeWidgetItem
*
parentItem
,
const
QString
&
paramName
)
{
// qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName
;
// Reference to item in tree
QTreeWidgetItem
*
parameterItem
=
NULL
;
// Add component item if necessary
if
(
!
componentItems
->
contains
(
compId
))
{
QString
componentName
=
tr
(
"Component #%1"
).
arg
(
compId
)
;
addComponentItem
(
compId
,
componentName
);
QTreeWidgetItem
*
childItem
=
NULL
;
for
(
int
i
=
0
;
i
<
parentItem
->
childCount
();
i
++
)
{
QTreeWidgetItem
*
child
=
parentItem
->
child
(
i
)
;
QString
key
=
child
->
data
(
0
,
Qt
::
DisplayRole
).
toString
();
if
(
key
==
paramName
)
{
childItem
=
child
;
break
;
}
}
//default parent item for this parameter widget item will be the top level component item
return
childItem
;
}
QTreeWidgetItem
*
QGCParamWidget
::
getParentWidgetItemForParam
(
int
compId
,
const
QString
&
paramName
)
{
QTreeWidgetItem
*
parentItem
=
componentItems
->
value
(
compId
);
QString
splitToken
=
"_"
;
// Check if auto-grouping can work
if
(
param
eter
Name
.
contains
(
splitToken
))
{
QString
parentStr
=
param
eter
Name
.
section
(
splitToken
,
0
,
0
,
QString
::
SectionSkipEmpty
);
if
(
paramName
.
contains
(
splitToken
))
{
QString
parentStr
=
paramName
.
section
(
splitToken
,
0
,
0
,
QString
::
SectionSkipEmpty
);
QMap
<
QString
,
QTreeWidgetItem
*>*
compParamGroups
=
paramGroups
.
value
(
compId
);
if
(
!
compParamGroups
->
contains
(
parentStr
))
{
// Insert group item
...
...
@@ -271,29 +289,31 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
parentItem
=
compParamGroups
->
value
(
parentStr
);
}
else
{
//parent item for this parameter will be the top level
component
widget item
//parent item for this parameter will be the top level
(component)
widget item
parentItem
=
componentItems
->
value
(
compId
);
}
if
(
parentItem
)
{
bool
found
=
false
;
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
;
}
}
return
parentItem
;
}
QTreeWidgetItem
*
QGCParamWidget
::
updateParameterDisplay
(
int
compId
,
QString
parameterName
,
QVariant
value
)
{
// qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName;
// Reference to item in tree
QTreeWidgetItem
*
parameterItem
=
NULL
;
if
(
!
found
)
{
// Add component item if necessary
if
(
!
componentItems
->
contains
(
compId
))
{
QString
componentName
=
tr
(
"Component #%1"
).
arg
(
compId
);
addComponentItem
(
compId
,
componentName
);
}
//default parent item for this parameter widget item will be the top level component item
QTreeWidgetItem
*
parentItem
=
getParentWidgetItemForParam
(
compId
,
parameterName
);
if
(
parentItem
)
{
parameterItem
=
findChildWidgetItemForParam
(
parentItem
,
parameterName
);
if
(
!
parameterItem
)
{
// Insert parameter into map
QStringList
plist
;
plist
.
append
(
parameterName
);
...
...
@@ -309,6 +329,30 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
parameterItem
->
setFlags
(
parameterItem
->
flags
()
|
Qt
::
ItemIsEditable
);
//TODO insert alphabetically
parentItem
->
addChild
(
parameterItem
);
//only add the tooltip when the parameter item is first added
QString
paramDesc
=
paramDataModel
->
getParamDescription
(
parameterName
);
if
(
!
paramDesc
.
isEmpty
())
{
QString
tooltipFormat
;
if
(
paramDataModel
->
isParamDefaultKnown
(
parameterName
))
{
tooltipFormat
=
tr
(
"Default: %1, %2"
);
double
paramDefValue
=
paramDataModel
->
getParamDefault
(
parameterName
);
tooltipFormat
=
tooltipFormat
.
arg
(
paramDefValue
).
arg
(
paramDesc
);
}
else
{
tooltipFormat
=
paramDesc
;
}
parameterItem
->
setToolTip
(
0
,
tooltipFormat
);
parameterItem
->
setToolTip
(
1
,
tooltipFormat
);
}
}
//update the parameterItem's data
if
(
value
.
type
()
==
QVariant
::
Char
)
{
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
.
toUInt
());
}
else
{
parameterItem
->
setData
(
1
,
Qt
::
DisplayRole
,
value
);
}
}
...
...
@@ -319,21 +363,7 @@ void QGCParamWidget::updateParameterDisplay(int compId, QString parameterName, Q
parameterItem
->
setTextColor
(
0
,
QGC
::
colorDarkWhite
);
parameterItem
->
setTextColor
(
1
,
QGC
::
colorDarkWhite
);
// Add tooltip
QString
paramDesc
=
paramDataModel
->
getParamDescription
(
parameterName
);
if
(
!
paramDesc
.
isEmpty
())
{
QString
tooltipFormat
;
if
(
paramDataModel
->
isParamDefaultKnown
(
parameterName
))
{
tooltipFormat
=
tr
(
"Default: %1, %2"
);
double
paramDefValue
=
paramDataModel
->
getParamDefault
(
parameterName
);
tooltipFormat
=
tooltipFormat
.
arg
(
paramDefValue
).
arg
(
paramDesc
);
}
else
{
tooltipFormat
=
paramDesc
;
}
parameterItem
->
setToolTip
(
0
,
tooltipFormat
);
parameterItem
->
setToolTip
(
1
,
tooltipFormat
);
}
return
parameterItem
;
}
...
...
@@ -367,7 +397,7 @@ void QGCParamWidget::parameterItemChanged(QTreeWidgetItem* current, int column)
current
->
setBackground
(
1
,
QBrush
(
QColor
(
QGC
::
colorOrange
)));
}
else
{
QMap
<
QString
,
QVariant
>*
pendingParams
=
paramDataModel
->
get
Onboard
ParamsForComponent
(
componentId
);
QMap
<
QString
,
QVariant
>*
pendingParams
=
paramDataModel
->
get
Pending
ParamsForComponent
(
componentId
);
int
pendingCount
=
pendingParams
->
count
();
statusLabel
->
setText
(
tr
(
"Pending items: %1"
).
arg
(
pendingCount
));
current
->
setBackground
(
0
,
Qt
::
NoBrush
);
...
...
src/ui/QGCParamWidget.h
View file @
0af58499
...
...
@@ -52,10 +52,11 @@ public:
protected:
virtual
void
setParameterStatusMsg
(
const
QString
&
msg
);
virtual
void
layoutWidget
();
virtual
QTreeWidgetItem
*
getParentWidgetItemForParam
(
int
compId
,
const
QString
&
paramName
);
virtual
QTreeWidgetItem
*
findChildWidgetItemForParam
(
QTreeWidgetItem
*
parentItem
,
const
QString
&
paramName
);
signals:
/** @brief A parameter was changed in the widget, NOT onboard */
//void parameterChanged(int component, QString parametername, float value); // defined in QGCUASParamManager already
public
slots
:
...
...
@@ -65,16 +66,16 @@ public slots:
*/
void
addComponentItem
(
int
compId
,
QString
compName
);
/** @brief Add a parameter to the list with retransmission / safety checks */
// void receivedParameterUpdate(int uas, int component, int paramCount, int paramId, QString parameterName, QVariant value);
virtual
void
handleParameterUpdate
(
int
component
,
const
QString
&
parameterName
,
QVariant
value
);
virtual
void
handlePendingParamUpdate
(
int
compId
,
const
QString
&
paramName
,
QVariant
value
,
bool
isPending
);
virtual
void
handleParameterListUpToDate
();
virtual
void
handleParamStatusMsgUpdate
(
QString
msg
,
int
level
);
/** @brief Ensure that view of parameter matches data in the model */
void
updateParameterDisplay
(
int
component
,
QString
parameterName
,
QVariant
value
);
QTreeWidgetItem
*
updateParameterDisplay
(
int
component
,
QString
parameterName
,
QVariant
value
);
/** @brief Request list of parameters from MAV */
void
requestAllParamsUpdate
();
...
...
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