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
0ac171d9
Commit
0ac171d9
authored
Nov 08, 2019
by
olliw42
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move parameter category&group handling for components up to ParameterManager class
parent
142beec4
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
133 additions
and
58 deletions
+133
-58
ParameterManager.cc
src/FactSystem/ParameterManager.cc
+109
-27
ParameterManager.h
src/FactSystem/ParameterManager.h
+12
-7
ParameterEditorController.cc
src/QmlControls/ParameterEditorController.cc
+12
-23
ParameterEditorController.h
src/QmlControls/ParameterEditorController.h
+0
-1
No files found.
src/FactSystem/ParameterManager.cc
View file @
0ac171d9
This diff is collapsed.
Click to expand it.
src/FactSystem/ParameterManager.h
View file @
0ac171d9
...
...
@@ -56,7 +56,7 @@ public:
void
refreshAllParameters
(
uint8_t
componentID
=
MAV_COMP_ID_ALL
);
/// Request a refresh on the specific parameter
void
refreshParameter
(
int
componentId
,
const
QString
&
n
ame
);
void
refreshParameter
(
int
componentId
,
const
QString
&
paramN
ame
);
/// Request a refresh on all parameters that begin with the specified prefix
void
refreshParametersPrefix
(
int
componentId
,
const
QString
&
namePrefix
);
...
...
@@ -67,7 +67,7 @@ public:
/// Returns true if the specifed parameter exists
/// @param componentId Component id or FactSystem::defaultComponentId
/// @param name Parameter name
bool
parameterExists
(
int
componentId
,
const
QString
&
n
ame
);
bool
parameterExists
(
int
componentId
,
const
QString
&
paramN
ame
);
/// Returns all parameter names
QStringList
parameterNames
(
int
componentId
);
...
...
@@ -76,14 +76,16 @@ public:
/// a missing parameter error to user if parameter does not exist.
/// @param componentId Component id or FactSystem::defaultComponentId
/// @param name Parameter name
Fact
*
getParameter
(
int
componentId
,
const
QString
&
n
ame
);
Fact
*
getParameter
(
int
componentId
,
const
QString
&
paramN
ame
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
getDefaultComponentCategoryMap
(
void
);
int
getComponentId
(
const
QString
&
category
);
QString
getComponentCategory
(
int
componentId
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
getComponentCategoryMap
(
int
componentId
);
/// Returns error messages from loading
QString
readParametersFromStream
(
QTextStream
&
stream
);
void
writeParametersToStream
(
QTextStream
&
stream
);
void
writeParametersToStream
(
QTextStream
&
stream
);
/// Returns the version number for the parameter set, -1 if not known
int
parameterSetVersion
(
void
)
{
return
_parameterSetMajorVersion
;
}
...
...
@@ -133,6 +135,7 @@ private:
static
FirmwarePlugin
*
_anyVehicleTypeFirmwarePlugin
(
MAV_AUTOPILOT
firmwareType
);
int
_actualComponentId
(
int
componentId
);
void
_setupComponentCategoryMap
(
int
componentId
);
void
_setupDefaultComponentCategoryMap
(
void
);
void
_readParameterRaw
(
int
componentId
,
const
QString
&
paramName
,
int
paramIndex
);
void
_writeParameterRaw
(
int
componentId
,
const
QString
&
paramName
,
const
QVariant
&
value
);
...
...
@@ -155,8 +158,10 @@ private:
/// Second mapping is parameter name, to Fact* in QVariant
QMap
<
int
,
QVariantMap
>
_mapParameterName2Variant
;
// Category map of default component parameters
QMap
<
QString
/* category */
,
QMap
<
QString
/* group */
,
QStringList
/* parameter names */
>
>
_defaultComponentCategoryMap
;
// List of category map of component parameters
typedef
QMap
<
QString
,
QMap
<
QString
,
QStringList
>>
ComponentCategoryMapType
;
//<Key: category, Value: Map< Key: group, Value: parameter names list >>
QMap
<
int
,
ComponentCategoryMapType
>
_componentCategoryMaps
;
QHash
<
QString
,
int
>
_componentCategoryHash
;
double
_loadProgress
;
///< Parameter load progess, [0.0,1.0]
bool
_parametersReady
;
///< true: parameter load complete
...
...
src/QmlControls/ParameterEditorController.cc
View file @
0ac171d9
...
...
@@ -23,10 +23,9 @@ ParameterEditorController::ParameterEditorController(void)
:
_currentCategory
(
"Standard"
)
// FIXME: firmware specific
,
_parameters
(
new
QmlObjectListModel
(
this
))
,
_parameterMgr
(
_vehicle
->
parameterManager
())
,
_componentCategoryPrefix
(
tr
(
"Component "
))
,
_showModifiedOnly
(
false
)
{
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
get
DefaultComponentCategoryMap
(
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
get
ComponentCategoryMap
(
_vehicle
->
defaultComponentId
()
);
_categories
=
categoryMap
.
keys
();
// Move default category to front
...
...
@@ -36,7 +35,7 @@ ParameterEditorController::ParameterEditorController(void)
// There is a category for each non default component
for
(
int
compId
:
_parameterMgr
->
componentIds
())
{
if
(
compId
!=
_vehicle
->
defaultComponentId
())
{
_categories
.
append
(
QString
(
"%1%2"
).
arg
(
_componentCategoryPrefix
).
arg
(
compId
));
_categories
.
append
(
_parameterMgr
->
getComponentCategory
(
compId
));
}
}
...
...
@@ -44,6 +43,7 @@ ParameterEditorController::ParameterEditorController(void)
if
(
categoryMap
.
contains
(
_currentCategory
)
&&
categoryMap
[
_currentCategory
].
size
()
!=
0
)
{
_currentGroup
=
categoryMap
[
_currentCategory
].
keys
()[
0
];
}
_updateParameters
();
connect
(
this
,
&
ParameterEditorController
::
searchTextChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
...
...
@@ -59,13 +59,9 @@ ParameterEditorController::~ParameterEditorController()
QStringList
ParameterEditorController
::
getGroupsForCategory
(
const
QString
&
category
)
{
if
(
category
.
startsWith
(
_componentCategoryPrefix
))
{
return
QStringList
(
tr
(
"All"
));
}
else
{
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
getDefaultComponentCategoryMap
();
return
categoryMap
[
category
].
keys
();
}
int
compId
=
_parameterMgr
->
getComponentId
(
category
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
getComponentCategoryMap
(
compId
);
return
categoryMap
[
category
].
keys
();
}
QStringList
ParameterEditorController
::
searchParameters
(
const
QString
&
searchText
,
bool
searchInName
,
bool
searchInDescriptions
)
...
...
@@ -182,21 +178,14 @@ void ParameterEditorController::_updateParameters(void)
QStringList
searchItems
=
_searchText
.
split
(
' '
,
QString
::
SkipEmptyParts
);
if
(
searchItems
.
isEmpty
()
&&
!
_showModifiedOnly
)
{
if
(
_currentCategory
.
startsWith
(
_componentCategoryPrefix
))
{
int
compId
=
_currentCategory
.
right
(
_currentCategory
.
length
()
-
_componentCategoryPrefix
.
length
()).
toInt
();
for
(
const
QString
&
paramName
:
_parameterMgr
->
parameterNames
(
compId
))
{
newParameterList
.
append
(
_parameterMgr
->
getParameter
(
compId
,
paramName
));
}
}
else
{
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
getDefaultComponentCategoryMap
();
for
(
const
QString
&
parameter
:
categoryMap
[
_currentCategory
][
_currentGroup
])
{
newParameterList
.
append
(
_parameterMgr
->
getParameter
(
_vehicle
->
defaultComponentId
(),
parameter
));
}
int
compId
=
_parameterMgr
->
getComponentId
(
_currentCategory
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_parameterMgr
->
getComponentCategoryMap
(
compId
);
for
(
const
QString
&
paramName
:
categoryMap
[
_currentCategory
][
_currentGroup
])
{
newParameterList
.
append
(
_parameterMgr
->
getParameter
(
compId
,
paramName
));
}
}
else
{
for
(
const
QString
&
para
meter
:
_parameterMgr
->
parameterNames
(
_vehicle
->
defaultComponentId
()))
{
Fact
*
fact
=
_parameterMgr
->
getParameter
(
_vehicle
->
defaultComponentId
(),
para
meter
);
for
(
const
QString
&
para
Name
:
_parameterMgr
->
parameterNames
(
_vehicle
->
defaultComponentId
()))
{
Fact
*
fact
=
_parameterMgr
->
getParameter
(
_vehicle
->
defaultComponentId
(),
para
Name
);
bool
matched
=
_shouldShow
(
fact
);
// All of the search items must match in order for the parameter to be added to the list
if
(
matched
)
{
...
...
src/QmlControls/ParameterEditorController.h
View file @
0ac171d9
...
...
@@ -71,7 +71,6 @@ private:
QString
_currentGroup
;
QmlObjectListModel
*
_parameters
;
ParameterManager
*
_parameterMgr
;
QString
_componentCategoryPrefix
;
bool
_showModifiedOnly
;
};
...
...
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