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
7af96b27
Commit
7af96b27
authored
Dec 27, 2013
by
Thomas Gubler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorted parameters: make search more efficient
parent
61d4bc1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
13 deletions
+39
-13
QGCParamWidget.cc
src/ui/QGCParamWidget.cc
+36
-12
QGCParamWidget.h
src/ui/QGCParamWidget.h
+3
-1
No files found.
src/ui/QGCParamWidget.cc
View file @
7af96b27
...
...
@@ -311,6 +311,39 @@ QTreeWidgetItem* QGCParamWidget::getParentWidgetItemForParam(int compId, const Q
return
parentItem
;
}
void
QGCParamWidget
::
insertParamAlphabetical
(
int
indexLowerBound
,
int
indexUpperBound
,
QTreeWidgetItem
*
parentItem
,
QTreeWidgetItem
*
paramItem
)
{
if
(
indexLowerBound
>=
indexUpperBound
)
{
if
(
paramItem
->
text
(
0
).
compare
(
parentItem
->
child
(
indexLowerBound
)
->
text
(
0
))
<
0
)
{
parentItem
->
insertChild
(
indexLowerBound
,
paramItem
);
}
else
{
if
(
indexLowerBound
<
parentItem
->
childCount
()
-
1
)
{
parentItem
->
insertChild
(
indexLowerBound
+
1
,
paramItem
);
}
else
{
parentItem
->
addChild
(
paramItem
);
}
}
}
else
{
int
midpoint
=
indexLowerBound
+
floor
(
indexUpperBound
-
indexLowerBound
)
/
2
;
if
(
paramItem
->
text
(
0
).
compare
(
parentItem
->
child
(
midpoint
)
->
text
(
0
))
<
0
)
{
insertParamAlphabetical
(
indexLowerBound
,
midpoint
-
1
,
parentItem
,
paramItem
);
}
else
{
insertParamAlphabetical
(
midpoint
+
1
,
indexUpperBound
,
parentItem
,
paramItem
);
}
}
}
QTreeWidgetItem
*
QGCParamWidget
::
updateParameterDisplay
(
int
compId
,
QString
parameterName
,
QVariant
value
)
{
//qDebug() << "QGCParamWidget::updateParameterDisplay" << parameterName;
...
...
@@ -344,19 +377,10 @@ QTreeWidgetItem* QGCParamWidget::updateParameterDisplay(int compId, QString para
paramItem
->
setFlags
(
paramItem
->
flags
()
|
Qt
::
ItemIsEditable
);
//Insert alphabetically
bool
inserted
=
false
;
for
(
int
i
=
0
;
i
<
parentItem
->
childCount
();
i
++
)
{
if
(
parameterName
.
compare
(
parentItem
->
child
(
i
)
->
text
(
0
))
<
0
)
{
parentItem
->
insertChild
(
i
,
paramItem
);
inserted
=
true
;
break
;
}
}
if
(
!
inserted
)
if
(
parentItem
->
childCount
()
>
0
)
{
insertParamAlphabetical
(
0
,
parentItem
->
childCount
()
-
1
,
parentItem
,
paramItem
);
}
else
{
//Insert at the end
parentItem
->
addChild
(
paramItem
);
}
...
...
src/ui/QGCParamWidget.h
View file @
7af96b27
...
...
@@ -83,10 +83,12 @@ public slots:
virtual
void
clearOnboardParamDisplay
();
virtual
void
clearPendingParamDisplay
();
/** @brief Adds parameter at the correct location by a alphapetical comparison of the parameter names */
void
insertParamAlphabetical
(
int
indexLowerBound
,
int
indexUpperBound
,
QTreeWidgetItem
*
parentItem
,
QTreeWidgetItem
*
paramItem
);
/** @brief Ensure that view of parameter matches data in the model */
QTreeWidgetItem
*
updateParameterDisplay
(
int
component
,
QString
parameterName
,
QVariant
value
);
/** @brief Update when user changes parameters */
void
parameterItemChanged
(
QTreeWidgetItem
*
prev
,
int
column
);
...
...
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