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
d937bd2b
Commit
d937bd2b
authored
Jul 19, 2016
by
Don Gagne
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3826 from DonLakeFlyer/ParamTypedown
Parameter search is now typedown style
parents
478b0edd
10e1b31e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
194 additions
and
248 deletions
+194
-248
ParameterEditor.qml
src/QmlControls/ParameterEditor.qml
+122
-220
ParameterEditorController.cc
src/QmlControls/ParameterEditorController.cc
+52
-23
ParameterEditorController.h
src/QmlControls/ParameterEditorController.h
+18
-3
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+1
-1
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+1
-1
No files found.
src/QmlControls/ParameterEditor.qml
View file @
d937bd2b
...
...
@@ -32,9 +32,8 @@ QGCView {
property
Fact
_editorDialogFact
:
Fact
{
}
property
int
_rowHeight
:
ScreenTools
.
defaultFontPixelHeight
*
2
property
int
_rowWidth
:
10
// Dynamic adjusted at runtime
property
bool
_searchFilter
:
false
///< true: showing results of search
property
bool
_searchFilter
:
searchText
.
text
!=
""
///< true: showing results of search
property
var
_searchResults
///< List of parameter names from search results
property
string
_currentGroup
:
""
property
bool
_showRCToParam
:
!
ScreenTools
.
isMobile
&&
QGroundControl
.
multiVehicleManager
.
activeVehicle
.
px4Firmware
ParameterEditorController
{
...
...
@@ -55,34 +54,24 @@ QGCView {
id
:
header
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
height
:
searchText
.
height
+
ScreenTools
.
defaultFontPixelHeight
/
3
spacing
:
ScreenTools
.
defaultFontPixelWidth
QGCTextField
{
id
:
searchText
QGCLabel
{
anchors.baseline
:
clearButton
.
baseline
text
:
qsTr
(
"
Search:
"
)
}
QGCButton
{
anchors.top
:
searchText
.
top
anchors.bottom
:
searchText
.
bottom
text
:
qsTr
(
"
Search
"
)
onClicked
:
{
_searchResults
=
controller
.
searchParametersForComponent
(
-
1
,
searchText
.
text
)
_searchFilter
=
true
}
QGCTextField
{
id
:
searchText
anchors.baseline
:
clearButton
.
baseline
text
:
controller
.
searchText
onDisplayTextChanged
:
controller
.
searchText
=
displayText
}
QGCButton
{
anchors.top
:
searchText
.
top
anchors.bottom
:
searchText
.
bottom
id
:
clearButton
text
:
qsTr
(
"
Clear
"
)
visible
:
_searchFilter
onClicked
:
{
searchText
.
text
=
""
_searchFilter
=
false
hideDialog
()
}
onClicked
:
searchText
.
text
=
""
}
}
// Row - Header
...
...
@@ -132,65 +121,56 @@ QGCView {
}
}
//---------------------------------------------
//-- Contents
Loader
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.top
:
header
.
bottom
anchors.bottom
:
parent
.
bottom
sourceComponent
:
_searchFilter
?
searchResultsViewComponent
:
groupedViewComponent
}
}
//-- Parameter Groups
Component
{
id
:
groupedViewComponent
Row
{
spacing
:
ScreenTools
.
defaultFontPixelWidth
*
0.5
//-- Parameter Groups
/// Group buttons
QGCFlickable
{
id
:
groupScroll
width
:
ScreenTools
.
defaultFontPixelWidth
*
25
height
:
parent
.
height
anchors.top
:
header
.
bottom
anchors.bottom
:
parent
.
bottom
clip
:
true
pixelAligned
:
true
contentHeight
:
groupedViewComponentColumn
.
height
contentWidth
:
groupedViewComponentColumn
.
width
flickableDirection
:
Flickable
.
VerticalFlick
visible
:
!
_searchFilter
Column
{
id
:
groupedViewComponentColumn
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
Repeater
{
model
:
controller
.
componentIds
Column
{
id
:
componentColumn
readonly
property
int
componentId
:
parseInt
(
modelData
)
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
readonly
property
int
componentId
:
modelData
QGCLabel
{
text
:
qsTr
(
"
Component #: %1
"
).
arg
(
componentId
.
toString
())
font.family
:
ScreenTools
.
demiboldFontFamily
anchors.horizontalCenter
:
parent
.
horizontalCenter
}
ExclusiveGroup
{
id
:
groupGroup
}
Repeater
{
model
:
controller
.
getGroupsForComponent
(
componentId
)
QGCButton
{
width
:
ScreenTools
.
defaultFontPixelWidth
*
25
text
:
modelData
text
:
groupName
height
:
_rowHeight
exclusiveGroup
:
setupButtonGroup
readonly
property
string
groupName
:
modelData
onClicked
:
{
checked
=
true
// Clear the rows from the component first. This allows us to change the componentId without
// breaking any bindings.
factRowsLoader
.
parameterNames
=
[
]
_rowWidth
=
10
factRowsLoader
.
componentId
=
componentId
factRowsLoader
.
parameterNames
=
controller
.
getParametersForGroup
(
componentId
,
modelData
)
_currentGroup
=
modelData
factScrollView
.
contentX
=
0
factScrollView
.
contentY
=
0
controller
.
currentComponentId
=
componentId
controller
.
currentGroup
=
groupName
}
}
}
...
...
@@ -198,82 +178,39 @@ QGCView {
}
}
}
Rectangle
{
color
:
__qgcPal
.
text
width
:
1
height
:
parent
.
height
opacity
:
0.1
}
//-- Parameters
QGCFlickable
{
id
:
factScrollView
width
:
parent
.
width
-
groupScroll
.
width
height
:
parent
.
height
contentHeight
:
factRowsLoader
.
height
contentWidth
:
_rowWidth
boundsBehavior
:
Flickable
.
OvershootBounds
pixelAligned
:
true
clip
:
true
Loader
{
id
:
factRowsLoader
sourceComponent
:
factRowsComponent
property
int
componentId
:
controller
.
componentIds
[
0
]
property
var
parameterNames
:
controller
.
getParametersForGroup
(
componentId
,
controller
.
getGroupsForComponent
(
componentId
)[
0
])
onLoaded
:
{
_currentGroup
=
controller
.
getGroupsForComponent
(
controller
.
componentIds
[
0
])[
0
]
}
}
}
}
}
//---------------------------------------------
// Search result view
Component
{
id
:
searchResultsViewComponent
Item
{
QGCFlickable
{
id
:
factScrollView
width
:
parent
.
width
height
:
parent
.
height
contentHeight
:
factRowsLoader
.
height
contentWidth
:
_rowWidth
boundsBehavior
:
Flickable
.
OvershootBounds
pixelAligned
:
true
/// Parameter list
ListView
{
id
:
editorListView
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
anchors.left
:
_searchFilter
?
parent
.
left
:
groupScroll
.
right
anchors.right
:
parent
.
right
anchors.top
:
header
.
bottom
anchors.bottom
:
parent
.
bottom
orientation
:
ListView
.
Vertical
model
:
controller
.
parameters
cacheBuffer
:
height
>
0
?
height
*
2
:
0
clip
:
true
Loader
{
id
:
factRowsLoader
sourceComponent
:
factRowsComponent
property
int
componentId
:
-
1
property
var
parameterNames
:
_searchResults
}
}
}
}
//---------------------------------------------
// Paremeters view
Component
{
id
:
factRowsComponent
Column
{
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelHeight
*
0.25
)
Repeater
{
model
:
parameterNames
Rectangle
{
delegate
:
Rectangle
{
height
:
_rowHeight
width
:
_rowWidth
color
:
Qt
.
rgba
(
0
,
0
,
0
,
0
)
Row
{
id
:
factRow
property
Fact
modelFact
:
controller
.
getParameterFact
(
componentId
,
modelData
)
spacing
:
Math
.
ceil
(
ScreenTools
.
defaultFontPixelWidth
*
0.5
)
anchors.verticalCenter
:
parent
.
verticalCenter
property
Fact
modelFact
:
object
QGCLabel
{
id
:
nameLabel
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
text
:
factRow
.
modelFact
.
name
clip
:
true
}
QGCLabel
{
id
:
valueLabel
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
...
...
@@ -281,15 +218,18 @@ QGCView {
text
:
factRow
.
modelFact
.
enumStrings
.
length
==
0
?
factRow
.
modelFact
.
valueString
+
"
"
+
factRow
.
modelFact
.
units
:
factRow
.
modelFact
.
enumStringValue
clip
:
true
}
QGCLabel
{
text
:
factRow
.
modelFact
.
shortDescription
}
Component.onCompleted
:
{
if
(
_rowWidth
<
factRow
.
width
+
ScreenTools
.
defaultFontPixelWidth
)
{
_rowWidth
=
factRow
.
width
+
ScreenTools
.
defaultFontPixelWidth
}
}
}
Rectangle
{
width
:
_rowWidth
height
:
1
...
...
@@ -298,6 +238,7 @@ QGCView {
anchors.bottom
:
parent
.
bottom
anchors.left
:
parent
.
left
}
MouseArea
{
anchors.fill
:
parent
acceptedButtons
:
Qt
.
LeftButton
...
...
@@ -308,8 +249,7 @@ QGCView {
}
}
}
}
}
}
// QGCViewPanel
Component
{
id
:
editorDialogComponent
...
...
@@ -320,44 +260,6 @@ QGCView {
}
}
Component
{
id
:
searchDialogComponent
QGCViewDialog
{
function
accept
()
{
_searchResults
=
controller
.
searchParametersForComponent
(
-
1
,
searchFor
.
text
,
true
/*searchInName.checked*/
,
true
/*searchInDescriptions.checked*/
)
_searchFilter
=
true
hideDialog
()
}
function
reject
()
{
_searchFilter
=
false
hideDialog
()
}
QGCLabel
{
id
:
searchForLabel
text
:
qsTr
(
"
Search for:
"
)
}
QGCTextField
{
id
:
searchFor
anchors.topMargin
:
defaultTextHeight
/
3
anchors.top
:
searchForLabel
.
bottom
width
:
ScreenTools
.
defaultFontPixelWidth
*
20
}
QGCLabel
{
anchors.topMargin
:
defaultTextHeight
anchors.top
:
searchFor
.
bottom
width
:
parent
.
width
wrapMode
:
Text
.
WordWrap
text
:
qsTr
(
"
Hint: Leave 'Search For' blank and click Apply to list all parameters sorted by name.
"
)
}
}
}
Component
{
id
:
mobileFilePicker
...
...
src/QmlControls/ParameterEditorController.cc
View file @
d937bd2b
...
...
@@ -25,14 +25,20 @@
/// @Brief Constructs a new ParameterEditorController Widget. This widget is used within the PX4VehicleConfig set of screens.
ParameterEditorController
::
ParameterEditorController
(
void
)
:
_currentComponentId
(
_vehicle
->
defaultComponentId
())
,
_parameters
(
new
QmlObjectListModel
(
this
))
{
if
(
_autopilot
)
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_autopilot
->
getGroupMap
();
foreach
(
int
componentId
,
groupMap
.
keys
())
{
_componentIds
+=
QString
(
"%1"
).
arg
(
componentId
);
}
}
_currentGroup
=
groupMap
[
_currentComponentId
].
keys
()[
0
];
_updateParameters
();
connect
(
this
,
&
ParameterEditorController
::
searchTextChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
connect
(
this
,
&
ParameterEditorController
::
currentComponentIdChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
connect
(
this
,
&
ParameterEditorController
::
currentGroupChanged
,
this
,
&
ParameterEditorController
::
_updateParameters
);
}
ParameterEditorController
::~
ParameterEditorController
()
...
...
@@ -175,3 +181,26 @@ void ParameterEditorController::setRCToParam(const QString& paramName)
d
->
exec
();
#endif
}
void
ParameterEditorController
::
_updateParameters
(
void
)
{
QObjectList
newParameterList
;
if
(
_searchText
.
isEmpty
())
{
const
QMap
<
int
,
QMap
<
QString
,
QStringList
>
>&
groupMap
=
_autopilot
->
getGroupMap
();
foreach
(
const
QString
&
parameter
,
groupMap
[
_currentComponentId
][
_currentGroup
])
{
newParameterList
.
append
(
_autopilot
->
getParameterFact
(
_currentComponentId
,
parameter
));
}
}
else
{
foreach
(
const
QString
&
parameter
,
_autopilot
->
parameterNames
(
_vehicle
->
defaultComponentId
()))
{
Fact
*
fact
=
_autopilot
->
getParameterFact
(
_vehicle
->
defaultComponentId
(),
parameter
);
if
(
fact
->
name
().
contains
(
_searchText
,
Qt
::
CaseInsensitive
)
||
fact
->
shortDescription
().
contains
(
_searchText
,
Qt
::
CaseInsensitive
)
||
fact
->
longDescription
().
contains
(
_searchText
,
Qt
::
CaseInsensitive
))
{
newParameterList
.
append
(
fact
);
}
}
}
_parameters
->
swapObjectList
(
newParameterList
);
}
src/QmlControls/ParameterEditorController.h
View file @
d937bd2b
...
...
@@ -20,6 +20,7 @@
#include "AutoPilotPlugin.h"
#include "UASInterface.h"
#include "FactPanelController.h"
#include "QmlObjectListModel.h"
class
ParameterEditorController
:
public
FactPanelController
{
...
...
@@ -29,7 +30,11 @@ public:
ParameterEditorController
(
void
);
~
ParameterEditorController
();
Q_PROPERTY
(
QStringList
componentIds
MEMBER
_componentIds
CONSTANT
)
Q_PROPERTY
(
QString
searchText
MEMBER
_searchText
NOTIFY
searchTextChanged
)
Q_PROPERTY
(
int
currentComponentId
MEMBER
_currentComponentId
NOTIFY
currentComponentIdChanged
)
Q_PROPERTY
(
QString
currentGroup
MEMBER
_currentGroup
NOTIFY
currentGroupChanged
)
Q_PROPERTY
(
QmlObjectListModel
*
parameters
MEMBER
_parameters
CONSTANT
)
Q_PROPERTY
(
QVariantList
componentIds
MEMBER
_componentIds
CONSTANT
)
Q_INVOKABLE
QStringList
getGroupsForComponent
(
int
componentId
);
Q_INVOKABLE
QStringList
getParametersForGroup
(
int
componentId
,
QString
group
);
...
...
@@ -47,10 +52,20 @@ public:
QList
<
QObject
*>
model
(
void
);
signals:
void
searchTextChanged
(
QString
searchText
);
void
currentComponentIdChanged
(
int
componentId
);
void
currentGroupChanged
(
QString
group
);
void
showErrorMessage
(
const
QString
&
errorMsg
);
private
slots
:
void
_updateParameters
(
void
);
private:
QStringList
_componentIds
;
QVariantList
_componentIds
;
QString
_searchText
;
int
_currentComponentId
;
QString
_currentGroup
;
QmlObjectListModel
*
_parameters
;
};
#endif
src/QmlControls/QmlObjectListModel.cc
View file @
d937bd2b
...
...
@@ -179,7 +179,7 @@ void QmlObjectListModel::append(QObject* object)
insert
(
_objectList
.
count
(),
object
);
}
QObjectList
QmlObjectListModel
::
swapObjectList
(
QObjectList
newlist
)
QObjectList
QmlObjectListModel
::
swapObjectList
(
const
QObjectList
&
newlist
)
{
QObjectList
oldlist
(
_objectList
);
beginResetModel
();
...
...
src/QmlControls/QmlObjectListModel.h
View file @
d937bd2b
...
...
@@ -37,7 +37,7 @@ public:
void
setDirty
(
bool
dirty
);
void
append
(
QObject
*
object
);
QObjectList
swapObjectList
(
QObjectList
newlist
);
QObjectList
swapObjectList
(
const
QObjectList
&
newlist
);
void
clear
(
void
);
QObject
*
removeAt
(
int
i
);
QObject
*
removeOne
(
QObject
*
object
)
{
return
removeAt
(
indexOf
(
object
));
}
...
...
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