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
b0f60168
Commit
b0f60168
authored
Jan 06, 2018
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parameter Editor Category->Group hierarchy support
parent
c90bc0bd
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
266 additions
and
220 deletions
+266
-220
Fact.cc
src/FactSystem/Fact.cc
+10
-0
Fact.h
src/FactSystem/Fact.h
+2
-0
FactMetaData.cc
src/FactSystem/FactMetaData.cc
+53
-46
FactMetaData.h
src/FactSystem/FactMetaData.h
+6
-0
ParameterManager.cc
src/FactSystem/ParameterManager.cc
+106
-108
ParameterManager.h
src/FactSystem/ParameterManager.h
+5
-6
APMParameterMetaData.cc
src/FirmwarePlugin/APM/APMParameterMetaData.cc
+9
-3
APMParameterMetaData.h
src/FirmwarePlugin/APM/APMParameterMetaData.h
+1
-0
PX4ParameterMetaData.cc
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
+7
-1
SectionHeader.qml
src/PlanView/SectionHeader.qml
+3
-2
ParameterEditor.qml
src/QmlControls/ParameterEditor.qml
+35
-26
ParameterEditorController.cc
src/QmlControls/ParameterEditorController.cc
+21
-20
ParameterEditorController.h
src/QmlControls/ParameterEditorController.h
+8
-8
No files found.
src/FactSystem/Fact.cc
View file @
b0f60168
...
...
@@ -497,6 +497,16 @@ int Fact::decimalPlaces(void) const
}
}
QString
Fact
::
category
(
void
)
const
{
if
(
_metaData
)
{
return
_metaData
->
category
();
}
else
{
qWarning
()
<<
kMissingMetadata
<<
name
();
return
QString
();
}
}
QString
Fact
::
group
(
void
)
const
{
if
(
_metaData
)
{
...
...
src/FactSystem/Fact.h
View file @
b0f60168
...
...
@@ -48,6 +48,7 @@ public:
Q_PROPERTY
(
QStringList
enumStrings
READ
enumStrings
NOTIFY
enumsChanged
)
Q_PROPERTY
(
QString
enumStringValue
READ
enumStringValue
WRITE
setEnumStringValue
NOTIFY
valueChanged
)
Q_PROPERTY
(
QVariantList
enumValues
READ
enumValues
NOTIFY
enumsChanged
)
Q_PROPERTY
(
QString
category
READ
category
CONSTANT
)
Q_PROPERTY
(
QString
group
READ
group
CONSTANT
)
Q_PROPERTY
(
QString
longDescription
READ
longDescription
CONSTANT
)
Q_PROPERTY
(
QVariant
max
READ
cookedMax
CONSTANT
)
...
...
@@ -91,6 +92,7 @@ public:
QStringList
enumStrings
(
void
)
const
;
QString
enumStringValue
(
void
);
// This is not const, since an unknown value can modify the enum lists
QVariantList
enumValues
(
void
)
const
;
QString
category
(
void
)
const
;
QString
group
(
void
)
const
;
QString
longDescription
(
void
)
const
;
QVariant
rawMax
(
void
)
const
;
...
...
src/FactSystem/FactMetaData.cc
View file @
b0f60168
...
...
@@ -32,6 +32,9 @@ const qreal FactMetaData::UnitConsts_s::milesToMeters = 1609.344;
const
qreal
FactMetaData
::
UnitConsts_s
::
feetToMeters
=
0.3048
;
const
qreal
FactMetaData
::
UnitConsts_s
::
inchesToCentimeters
=
2.54
;
const
QString
FactMetaData
::
defaultCategory
=
tr
(
"Other"
);
const
QString
FactMetaData
::
defaultGroup
=
tr
(
"Misc"
);
// Built in translations for all Facts
const
FactMetaData
::
BuiltInTranslation_s
FactMetaData
::
_rgBuiltInTranslations
[]
=
{
{
"centi-degrees"
,
"deg"
,
FactMetaData
::
_centiDegreesToDegrees
,
FactMetaData
::
_degreesToCentiDegrees
},
...
...
@@ -76,43 +79,45 @@ const char* FactMetaData::_maxJsonKey = "max";
const
char
*
FactMetaData
::
_hasControlJsonKey
=
"control"
;
FactMetaData
::
FactMetaData
(
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
valueTypeInt32
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
:
QObject
(
parent
)
,
_type
(
valueTypeInt32
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
,
_category
(
defaultCategory
)
,
_group
(
defaultGroup
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
{
}
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
,
_category
(
defaultCategory
)
,
_group
(
defaultGroup
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
{
}
...
...
@@ -124,23 +129,24 @@ FactMetaData::FactMetaData(const FactMetaData& other, QObject* parent)
}
FactMetaData
::
FactMetaData
(
ValueType_t
type
,
const
QString
name
,
QObject
*
parent
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
:
QObject
(
parent
)
,
_type
(
type
)
,
_decimalPlaces
(
unknownDecimalPlaces
)
,
_rawDefaultValue
(
0
)
,
_defaultValueAvailable
(
false
)
,
_group
(
"*Default Group"
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_name
(
name
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
,
_category
(
defaultCategory
)
,
_group
(
defaultGroup
)
,
_rawMax
(
_maxForType
())
,
_maxIsDefaultForType
(
true
)
,
_rawMin
(
_minForType
())
,
_minIsDefaultForType
(
true
)
,
_name
(
name
)
,
_rawTranslator
(
_defaultTranslator
)
,
_cookedTranslator
(
_defaultTranslator
)
,
_rebootRequired
(
false
)
,
_increment
(
std
::
numeric_limits
<
double
>::
quiet_NaN
())
,
_hasControl
(
true
)
,
_readOnly
(
false
)
{
}
...
...
@@ -154,6 +160,7 @@ const FactMetaData& FactMetaData::operator=(const FactMetaData& other)
_bitmaskValues
=
other
.
_bitmaskValues
;
_enumStrings
=
other
.
_enumStrings
;
_enumValues
=
other
.
_enumValues
;
_category
=
other
.
_category
;
_group
=
other
.
_group
;
_longDescription
=
other
.
_longDescription
;
_rawMax
=
other
.
_rawMax
;
...
...
src/FactSystem/FactMetaData.h
View file @
b0f60168
...
...
@@ -84,6 +84,7 @@ public:
QVariantList
bitmaskValues
(
void
)
const
{
return
_bitmaskValues
;
}
QStringList
enumStrings
(
void
)
const
{
return
_enumStrings
;
}
QVariantList
enumValues
(
void
)
const
{
return
_enumValues
;
}
QString
category
(
void
)
const
{
return
_category
;
}
QString
group
(
void
)
const
{
return
_group
;
}
QString
longDescription
(
void
)
const
{
return
_longDescription
;}
QVariant
rawMax
(
void
)
const
{
return
_rawMax
;
}
...
...
@@ -118,6 +119,7 @@ public:
void
setRawDefaultValue
(
const
QVariant
&
rawDefaultValue
);
void
setBitmaskInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
void
setEnumInfo
(
const
QStringList
&
strings
,
const
QVariantList
&
values
);
void
setCategory
(
const
QString
&
category
)
{
_category
=
category
;
}
void
setGroup
(
const
QString
&
group
)
{
_group
=
group
;
}
void
setLongDescription
(
const
QString
&
longDescription
)
{
_longDescription
=
longDescription
;}
void
setRawMax
(
const
QVariant
&
rawMax
);
...
...
@@ -158,6 +160,9 @@ public:
static
ValueType_t
stringToType
(
const
QString
&
typeString
,
bool
&
unknownType
);
static
size_t
typeToSize
(
ValueType_t
type
);
static
const
QString
defaultCategory
;
static
const
QString
defaultGroup
;
private:
QVariant
_minForType
(
void
)
const
;
QVariant
_maxForType
(
void
)
const
;
...
...
@@ -217,6 +222,7 @@ private:
QVariantList
_bitmaskValues
;
QStringList
_enumStrings
;
QVariantList
_enumValues
;
QString
_category
;
QString
_group
;
QString
_longDescription
;
QVariant
_rawMax
;
...
...
src/FactSystem/ParameterManager.cc
View file @
b0f60168
This diff is collapsed.
Click to expand it.
src/FactSystem/ParameterManager.h
View file @
b0f60168
...
...
@@ -84,7 +84,7 @@ public:
/// @param name Parameter name
Fact
*
getParameter
(
int
componentId
,
const
QString
&
name
);
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
getGroup
Map
(
void
);
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
getCategory
Map
(
void
);
/// Returns error messages from loading
QString
readParametersFromStream
(
QTextStream
&
stream
);
...
...
@@ -137,7 +137,7 @@ protected:
private:
static
QVariant
_stringToTypedVariant
(
const
QString
&
string
,
FactMetaData
::
ValueType_t
type
,
bool
failOk
=
false
);
int
_actualComponentId
(
int
componentId
);
void
_setup
Group
Map
(
void
);
void
_setup
Category
Map
(
void
);
void
_readParameterRaw
(
int
componentId
,
const
QString
&
paramName
,
int
paramIndex
);
void
_writeParameterRaw
(
int
componentId
,
const
QString
&
paramName
,
const
QVariant
&
value
);
void
_writeLocalParamCache
(
int
vehicleId
,
int
componentId
);
...
...
@@ -159,10 +159,9 @@ private:
QMap
<
int
,
QVariantMap
>
_mapParameterName2Variant
;
QMap
<
int
,
QMap
<
int
,
QString
>
>
_mapParameterId2Name
;
/// First mapping is by component id
/// Second mapping is group name, to Fact
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>
_mapGroup2ParameterName
;
// Category map of default component parameters
QMap
<
QString
/* category */
,
QMap
<
QString
/* group */
,
QStringList
/* parameter names */
>
>
_categoryMap
;
double
_loadProgress
;
///< Parameter load progess, [0.0,1.0]
bool
_parametersReady
;
///< true: parameter load complete
...
...
src/FirmwarePlugin/APM/APMParameterMetaData.cc
View file @
b0f60168
...
...
@@ -233,14 +233,18 @@ void APMParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
QString
group
=
name
.
split
(
'_'
).
first
();
group
=
group
.
remove
(
QRegExp
(
"[0-9]*$"
));
// remove any numbers from the end
QString
category
=
xml
.
attributes
().
value
(
"user"
).
toString
();
if
(
category
.
isEmpty
())
{
category
=
QStringLiteral
(
"Advanced"
);
}
QString
shortDescription
=
xml
.
attributes
().
value
(
"humanName"
).
toString
();
QString
longDescription
=
xml
.
attributes
().
value
(
"documentation"
).
toString
();
QString
userLevel
=
xml
.
attributes
().
value
(
"user"
).
toString
();
qCDebug
(
APMParameterMetaDataVerboseLog
)
<<
"Found parameter name:"
<<
name
<<
"short Desc:"
<<
shortDescription
<<
"longDescription:"
<<
longDescription
<<
"
user level: "
<<
userLevel
<<
"
category: "
<<
category
<<
"group: "
<<
group
;
Q_ASSERT
(
!
rawMetaData
);
...
...
@@ -254,6 +258,7 @@ void APMParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
}
qCDebug
(
APMParameterMetaDataVerboseLog
)
<<
"inserting metadata for field"
<<
name
;
rawMetaData
->
name
=
name
;
rawMetaData
->
category
=
category
;
rawMetaData
->
group
=
group
;
rawMetaData
->
shortDescription
=
shortDescription
;
rawMetaData
->
longDescription
=
longDescription
;
...
...
@@ -301,7 +306,7 @@ void APMParameterMetaData::correctGroupMemberships(ParameterNametoFactMetaDataMa
foreach
(
const
QString
&
groupName
,
groupMembers
.
keys
())
{
if
(
groupMembers
[
groupName
].
count
()
==
1
)
{
foreach
(
const
QString
&
parameter
,
groupMembers
.
value
(
groupName
))
{
parameterToFactMetaDataMap
[
parameter
]
->
group
=
"others"
;
parameterToFactMetaDataMap
[
parameter
]
->
group
=
FactMetaData
::
defaultGroup
;
}
}
}
...
...
@@ -434,6 +439,7 @@ void APMParameterMetaData::addMetaDataToFact(Fact* fact, MAV_TYPE vehicleType)
}
metaData
->
setName
(
rawMetaData
->
name
);
metaData
->
setCategory
(
rawMetaData
->
category
);
metaData
->
setGroup
(
rawMetaData
->
group
);
metaData
->
setRebootRequired
(
rawMetaData
->
rebootRequired
);
...
...
src/FirmwarePlugin/APM/APMParameterMetaData.h
View file @
b0f60168
...
...
@@ -32,6 +32,7 @@ public:
{
}
QString
name
;
QString
category
;
QString
group
;
QString
shortDescription
;
QString
longDescription
;
...
...
src/FirmwarePlugin/PX4/PX4ParameterMetaData.cc
View file @
b0f60168
...
...
@@ -181,6 +181,11 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
QString
type
=
xml
.
attributes
().
value
(
"type"
).
toString
();
QString
strDefault
=
xml
.
attributes
().
value
(
"default"
).
toString
();
QString
category
=
xml
.
attributes
().
value
(
"category"
).
toString
();
if
(
category
.
isEmpty
())
{
category
=
QStringLiteral
(
"Standard"
);
}
qCDebug
(
PX4ParameterMetaDataLog
)
<<
"Found parameter name:"
<<
name
<<
" type:"
<<
type
<<
" default:"
<<
strDefault
;
// Convert type from string to FactMetaData::ValueType_t
...
...
@@ -196,7 +201,7 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
metaData
=
new
FactMetaData
(
foundType
);
Q_CHECK_PTR
(
metaData
);
if
(
_mapParameterName2FactMetaData
.
contains
(
name
))
{
// We can't trust the meta da
f
a since we have dups
// We can't trust the meta da
t
a since we have dups
qCWarning
(
PX4ParameterMetaDataLog
)
<<
"Duplicate parameter found:"
<<
name
;
badMetaData
=
true
;
// Reset to default meta data
...
...
@@ -204,6 +209,7 @@ void PX4ParameterMetaData::loadParameterFactMetaDataFile(const QString& metaData
}
else
{
_mapParameterName2FactMetaData
[
name
]
=
metaData
;
metaData
->
setName
(
name
);
metaData
->
setCategory
(
category
);
metaData
->
setGroup
(
factGroup
);
if
(
xml
.
attributes
().
hasAttribute
(
"default"
)
&&
!
strDefault
.
isEmpty
())
{
...
...
src/PlanView/SectionHeader.qml
View file @
b0f60168
...
...
@@ -46,8 +46,9 @@ FocusScope {
}
QGCLabel
{
id
:
label
Layout.fillWidth
:
true
id
:
label
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
QGCColoredImage
{
id
:
image
...
...
src/QmlControls/ParameterEditor.qml
View file @
b0f60168
...
...
@@ -7,13 +7,10 @@
*
****************************************************************************/
/// @file
/// @author Don Gagne <don@thegagnes.com>
import
QtQuick
2.3
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Dialogs
1.2
import
QtQuick
2.3
import
QtQuick
.
Controls
1.2
import
QtQuick
.
Dialogs
1.2
import
QtQuick
.
Layouts
1.2
import
QGroundControl
1.0
import
QGroundControl
.
Controls
1.0
...
...
@@ -44,6 +41,8 @@ QGCView {
}
}
ExclusiveGroup
{
id
:
sectionGroup
}
QGCViewPanel
{
id
:
panel
anchors.fill
:
parent
...
...
@@ -158,48 +157,58 @@ QGCView {
anchors.bottom
:
parent
.
bottom
clip
:
true
pixelAligned
:
true
contentHeight
:
groupedViewComponentColumn
.
height
contentWidth
:
groupedViewComponentColumn
.
width
contentHeight
:
groupedViewCategoryColumn
.
height
flickableDirection
:
Flickable
.
VerticalFlick
visible
:
!
_searchFilter
Column
{
id
:
groupedViewComponentColumn
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
ColumnLayout
{
id
:
groupedViewCategoryColumn
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
Repeater
{
model
:
controller
.
c
omponentId
s
model
:
controller
.
c
ategorie
s
Column
{
id
:
componentColumn
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
Layout.fillWidth
:
true
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
readonly
property
int
componentId
:
modelData
readonly
property
string
category
:
modelData
QGCLabel
{
text
:
qsTr
(
"
Component #: %1
"
).
arg
(
componentId
.
toString
())
font.family
:
ScreenTools
.
demiboldFontFamily
anchors.horizontalCenter
:
parent
.
horizontalCenter
SectionHeader
{
id
:
categoryHeader
text
:
category
checked
:
controller
.
currentCategory
==
text
exclusiveGroup
:
sectionGroup
onCheckedChanged
:
{
if
(
checked
)
{
controller
.
currentCategory
=
category
controller
.
currentGroup
=
controller
.
getGroupsForCategory
(
category
)[
0
]
}
}
}
ExclusiveGroup
{
id
:
group
Group
}
ExclusiveGroup
{
id
:
button
Group
}
Repeater
{
model
:
c
ontroller
.
getGroupsForComponent
(
componentId
)
model
:
c
ategoryHeader
.
checked
?
controller
.
getGroupsForCategory
(
category
)
:
0
QGCButton
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
25
text
:
groupName
height
:
_rowHeight
exclusiveGroup
:
setupButtonGroup
checked
:
controller
.
currentGroup
==
text
exclusiveGroup
:
buttonGroup
readonly
property
string
groupName
:
modelData
onClicked
:
{
checked
=
true
_rowWidth
=
10
controller
.
currentC
omponentId
=
componentId
controller
.
currentGroup
=
groupName
_rowWidth
=
10
controller
.
currentC
ategory
=
category
controller
.
currentGroup
=
groupName
}
}
}
...
...
src/QmlControls/ParameterEditorController.cc
View file @
b0f60168
...
...
@@ -27,22 +27,23 @@
/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens.
ParameterEditorController
::
ParameterEditorController
(
void
)
:
_currentC
omponentId
(
_vehicle
->
defaultComponentId
())
:
_currentC
ategory
(
"Standard"
)
// FIXME: firmware specific
,
_parameters
(
new
QmlObjectListModel
(
this
))
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_vehicle
->
parameterManager
()
->
getGroupMap
();
foreach
(
int
componentId
,
groupMap
.
keys
())
{
_componentIds
+=
QString
(
"%1"
).
arg
(
componentId
);
}
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_vehicle
->
parameterManager
()
->
getCategoryMap
();
_categories
=
categoryMap
.
keys
();
// Move default category to front
_categories
.
removeOne
(
_currentCategory
);
_categories
.
prepend
(
_currentCategory
);
// Be careful about no parameters
if
(
groupMap
.
contains
(
_currentComponentId
)
&&
groupMap
[
_currentComponentId
].
size
()
!=
0
)
{
_currentGroup
=
groupMap
[
_currentComponentId
].
keys
()[
0
];
if
(
categoryMap
.
contains
(
_currentCategory
)
&&
categoryMap
[
_currentCategory
].
size
()
!=
0
)
{
_currentGroup
=
categoryMap
[
_currentCategory
].
keys
()[
0
];
}
_updateParameters
();
connect
(
this
,
&
ParameterEditorController
::
searchTextChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
connect
(
this
,
&
ParameterEditorController
::
currentComponentIdChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
connect
(
this
,
&
ParameterEditorController
::
currentGroupChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
}
...
...
@@ -51,29 +52,29 @@ ParameterEditorController::~ParameterEditorController()
}
QStringList
ParameterEditorController
::
getGroupsForC
omponent
(
int
componentId
)
QStringList
ParameterEditorController
::
getGroupsForC
ategory
(
const
QString
&
category
)
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_vehicle
->
parameterManager
()
->
getGroup
Map
();
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_vehicle
->
parameterManager
()
->
getCategory
Map
();
return
groupMap
[
componentId
].
keys
();
return
categoryMap
[
category
].
keys
();
}
QStringList
ParameterEditorController
::
getParametersForGroup
(
int
componentId
,
QString
group
)
QStringList
ParameterEditorController
::
getParametersForGroup
(
const
QString
&
category
,
const
QString
&
group
)
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_vehicle
->
parameterManager
()
->
getGroup
Map
();
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_vehicle
->
parameterManager
()
->
getCategory
Map
();
return
groupMap
[
componentId
][
group
];
return
categoryMap
[
category
][
group
];
}
QStringList
ParameterEditorController
::
searchParameters
ForComponent
(
int
componentId
,
const
QString
&
searchText
,
bool
searchInName
,
bool
searchInDescriptions
)
QStringList
ParameterEditorController
::
searchParameters
(
const
QString
&
searchText
,
bool
searchInName
,
bool
searchInDescriptions
)
{
QStringList
list
;
foreach
(
const
QString
&
paramName
,
_vehicle
->
parameterManager
()
->
parameterNames
(
componentId
))
{
foreach
(
const
QString
&
paramName
,
_vehicle
->
parameterManager
()
->
parameterNames
(
_vehicle
->
defaultComponentId
()
))
{
if
(
searchText
.
isEmpty
())
{
list
+=
paramName
;
}
else
{
Fact
*
fact
=
_vehicle
->
parameterManager
()
->
getParameter
(
componentId
,
paramName
);
Fact
*
fact
=
_vehicle
->
parameterManager
()
->
getParameter
(
_vehicle
->
defaultComponentId
()
,
paramName
);
if
(
searchInName
&&
fact
->
name
().
contains
(
searchText
,
Qt
::
CaseInsensitive
))
{
list
+=
paramName
;
...
...
@@ -161,9 +162,9 @@ void ParameterEditorController::_updateParameters(void)
QStringList
searchItems
=
_searchText
.
split
(
' '
,
QString
::
SkipEmptyParts
);
if
(
searchItems
.
isEmpty
())
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_vehicle
->
parameterManager
()
->
getGroup
Map
();
foreach
(
const
QString
&
parameter
,
groupMap
[
_currentComponentId
][
_currentGroup
])
{
newParameterList
.
append
(
_vehicle
->
parameterManager
()
->
getParameter
(
_
currentComponentId
,
parameter
));
const
QMap
<
QString
,
QMap
<
QString
,
QStringList
>
>&
categoryMap
=
_vehicle
->
parameterManager
()
->
getCategory
Map
();
foreach
(
const
QString
&
parameter
,
categoryMap
[
_currentCategory
][
_currentGroup
])
{
newParameterList
.
append
(
_vehicle
->
parameterManager
()
->
getParameter
(
_
vehicle
->
defaultComponentId
()
,
parameter
));
}
}
else
{
foreach
(
const
QString
&
parameter
,
_vehicle
->
parameterManager
()
->
parameterNames
(
_vehicle
->
defaultComponentId
()))
{
...
...
src/QmlControls/ParameterEditorController.h
View file @
b0f60168
...
...
@@ -31,14 +31,14 @@ public:
~
ParameterEditorController
();
Q_PROPERTY
(
QString
searchText
MEMBER
_searchText
NOTIFY
searchTextChanged
)
Q_PROPERTY
(
int
currentComponentId
MEMBER
_currentComponentId
NOTIFY
currentComponentId
Changed
)
Q_PROPERTY
(
QString
currentCategory
MEMBER
_currentCategory
NOTIFY
currentCategory
Changed
)
Q_PROPERTY
(
QString
currentGroup
MEMBER
_currentGroup
NOTIFY
currentGroupChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
parameters
MEMBER
_parameters
CONSTANT
)
Q_PROPERTY
(
Q
VariantList
componentIds
MEMBER
_componentIds
CONSTANT
)
Q_PROPERTY
(
Q
StringList
categories
MEMBER
_categories
CONSTANT
)
Q_INVOKABLE
QStringList
getGroupsForC
omponent
(
int
componentId
);
Q_INVOKABLE
QStringList
getParametersForGroup
(
int
componentId
,
QString
group
);
Q_INVOKABLE
QStringList
searchParameters
ForComponent
(
int
componentId
,
const
QString
&
searchText
,
bool
searchInName
=
true
,
bool
searchInDescriptions
=
true
);
Q_INVOKABLE
QStringList
getGroupsForC
ategory
(
const
QString
&
category
);
Q_INVOKABLE
QStringList
getParametersForGroup
(
const
QString
&
category
,
const
QString
&
group
);
Q_INVOKABLE
QStringList
searchParameters
(
const
QString
&
searchText
,
bool
searchInName
=
true
,
bool
searchInDescriptions
=
true
);
Q_INVOKABLE
void
clearRCToParam
(
void
);
Q_INVOKABLE
void
saveToFile
(
const
QString
&
filename
);
...
...
@@ -51,7 +51,7 @@ public:
signals:
void
searchTextChanged
(
QString
searchText
);
void
currentC
omponentIdChanged
(
int
componentId
);
void
currentC
ategoryChanged
(
QString
category
);
void
currentGroupChanged
(
QString
group
);
void
showErrorMessage
(
const
QString
&
errorMsg
);
...
...
@@ -59,9 +59,9 @@ private slots:
void
_updateParameters
(
void
);
private:
Q
VariantList
_componentId
s
;
Q
StringList
_categorie
s
;
QString
_searchText
;
int
_currentComponentId
;
QString
_currentCategory
;
QString
_currentGroup
;
QmlObjectListModel
*
_parameters
;
};
...
...
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