Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
24ae7b64
Commit
24ae7b64
authored
Oct 14, 2015
by
Don Gagne
Browse files
Better home position handling
Also remove Move Up and Move Down support
parent
2440526f
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/MissionEditor/MissionEditor.cc
View file @
24ae7b64
...
...
@@ -142,52 +142,6 @@ void MissionEditor::removeMissionItem(int index)
_recalcAll
();
}
void
MissionEditor
::
moveUp
(
int
index
)
{
if
(
!
_canEdit
)
{
qWarning
()
<<
"addMissionItem called with _canEdit == false"
;
return
;
}
if
(
_missionItems
->
count
()
<
2
||
index
<=
0
||
index
>=
_missionItems
->
count
())
{
return
;
}
MissionItem
item1
=
*
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
index
-
1
));
MissionItem
item2
=
*
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
index
));
_missionItems
->
removeAt
(
index
-
1
);
_missionItems
->
removeAt
(
index
-
1
);
_missionItems
->
insert
(
index
-
1
,
new
MissionItem
(
item2
,
_missionItems
));
_missionItems
->
insert
(
index
,
new
MissionItem
(
item1
,
_missionItems
));
_recalcAll
();
}
void
MissionEditor
::
moveDown
(
int
index
)
{
if
(
!
_canEdit
)
{
qWarning
()
<<
"addMissionItem called with _canEdit == false"
;
return
;
}
if
(
_missionItems
->
count
()
<
2
||
index
>=
_missionItems
->
count
()
-
1
)
{
return
;
}
MissionItem
item1
=
*
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
index
));
MissionItem
item2
=
*
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
index
+
1
));
_missionItems
->
removeAt
(
index
);
_missionItems
->
removeAt
(
index
);
_missionItems
->
insert
(
index
,
new
MissionItem
(
item2
,
_missionItems
));
_missionItems
->
insert
(
index
+
1
,
new
MissionItem
(
item1
,
_missionItems
));
_recalcAll
();
}
void
MissionEditor
::
loadMissionFromFile
(
void
)
{
QString
errorString
;
...
...
src/MissionEditor/MissionEditor.h
View file @
24ae7b64
...
...
@@ -48,8 +48,6 @@ public:
Q_INVOKABLE
void
loadMissionFromFile
(
void
);
Q_INVOKABLE
void
saveMissionToFile
(
void
);
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
Q_INVOKABLE
void
moveUp
(
int
index
);
Q_INVOKABLE
void
moveDown
(
int
index
);
// Property accessors
...
...
src/MissionEditor/MissionEditor.qml
View file @
24ae7b64
...
...
@@ -440,6 +440,7 @@ QGCView {
MissionItemEditor
{
missionItem
:
object
width
:
parent
.
width
readOnly
:
object
.
sequenceNumber
==
0
&&
liveHomePositionAvailable
onClicked
:
setCurrentItem
(
object
.
sequenceNumber
)
...
...
@@ -451,9 +452,6 @@ QGCView {
setCurrentItem
(
newCurrentItem
)
}
}
onMoveUp
:
controller
.
moveUp
(
object
.
sequenceNumber
)
onMoveDown
:
controller
.
moveDown
(
object
.
sequenceNumber
)
}
}
// ListView
...
...
src/QmlControls/MissionItemEditor.qml
View file @
24ae7b64
...
...
@@ -13,17 +13,16 @@ import QGroundControl.Palette 1.0
Rectangle
{
id
:
_root
property
var
missionItem
property
var
missionItem
///< MissionItem associated with this editor
property
bool
readOnly
///< true: read only view, false: full editing view
signal
clicked
signal
remove
signal
moveUp
signal
moveDown
height
:
missionItem
.
isCurrentItem
?
(
missionItem
.
textFieldFacts
.
count
*
(
measureTextField
.
height
+
_margin
))
+
(
missionItem
.
checkboxFacts
.
count
*
(
measureCheckbox
.
height
+
_margin
))
+
commandPicker
.
height
+
deleteButton
.
height
+
(
_margin
*
9
)
:
commandPicker
.
height
+
(
deleteButton
.
visible
?
deleteButton
.
height
:
0
)
+
(
_margin
*
9
)
:
commandPicker
.
height
+
(
_margin
*
2
)
color
:
missionItem
.
isCurrentItem
?
qgcPal
.
buttonHighlight
:
qgcPal
.
windowShade
...
...
@@ -63,7 +62,6 @@ Rectangle {
onClicked
:
_root
.
clicked
()
}
QGCComboBox
{
id
:
commandPicker
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
10
...
...
@@ -71,7 +69,7 @@ Rectangle {
anchors.right
:
parent
.
right
currentIndex
:
missionItem
.
commandByIndex
model
:
missionItem
.
commandNames
visible
:
missionItem
.
sequenceNumber
!=
0
visible
:
missionItem
.
sequenceNumber
!=
0
// Item 0 is home position, can't change item type
onActivated
:
missionItem
.
commandByIndex
=
index
}
...
...
@@ -79,7 +77,7 @@ Rectangle {
Rectangle
{
anchors.fill
:
commandPicker
color
:
qgcPal
.
button
visible
:
missionItem
.
sequenceNumber
==
0
visible
:
missionItem
.
sequenceNumber
==
0
// Item 0 is home position, can't change item type
QGCLabel
{
id
:
homeLabel
...
...
@@ -119,6 +117,7 @@ Rectangle {
height
:
textField
.
height
QGCLabel
{
id
:
textFieldLabel
anchors.baseline
:
textField
.
baseline
text
:
object
.
name
}
...
...
@@ -129,6 +128,14 @@ Rectangle {
width
:
_editFieldWidth
showUnits
:
true
fact
:
object
visible
:
!
_root
.
readOnly
}
FactLabel
{
anchors.baseline
:
textFieldLabel
.
baseline
anchors.right
:
parent
.
right
fact
:
object
visible
:
_root
.
readOnly
}
}
}
...
...
@@ -160,26 +167,13 @@ Rectangle {
readonly
property
real
buttonWidth
:
(
width
-
(
_margin
*
2
))
/
3
QGCButton
{
id
:
deleteButton
width
:
parent
.
buttonWidth
text
:
"
Delete
"
id
:
deleteButton
width
:
parent
.
buttonWidth
text
:
"
Delete
"
visible
:
!
readOnly
onClicked
:
_root
.
remove
()
}
QGCButton
{
width
:
parent
.
buttonWidth
text
:
"
Up
"
onClicked
:
_root
.
moveUp
()
}
QGCButton
{
width
:
parent
.
buttonWidth
text
:
"
Down
"
onClicked
:
_root
.
moveDown
()
}
}
}
// Column
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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