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
cd2d960a
Commit
cd2d960a
authored
Sep 11, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1867 from DonLakeFlyer/MissionDeleteUpDown
Add Delete, Move Up, Move Down
parents
46fd2413
5f5ff580
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
180 additions
and
34 deletions
+180
-34
MissionItemIndicator.qml
src/FlightMap/MapItems/MissionItemIndicator.qml
+6
-0
MissionEditor.cc
src/MissionEditor/MissionEditor.cc
+50
-20
MissionEditor.h
src/MissionEditor/MissionEditor.h
+7
-4
MissionEditor.qml
src/MissionEditor/MissionEditor.qml
+26
-1
MissionItemEditor.qml
src/QmlControls/MissionItemEditor.qml
+58
-7
MissionItemIndexLabel.qml
src/QmlControls/MissionItemIndexLabel.qml
+8
-0
QmlObjectListModel.cc
src/QmlControls/QmlObjectListModel.cc
+24
-2
QmlObjectListModel.h
src/QmlControls/QmlObjectListModel.h
+1
-0
No files found.
src/FlightMap/MapItems/MissionItemIndicator.qml
View file @
cd2d960a
...
...
@@ -30,14 +30,20 @@ import QGroundControl.Vehicle 1.0
/// Marker for displaying a mission item on the map
MapQuickItem
{
id
:
_item
property
alias
label
:
_label
.
label
property
alias
isCurrentItem
:
_label
.
isCurrentItem
signal
clicked
anchorPoint.x
:
sourceItem
.
width
/
2
anchorPoint.y
:
sourceItem
.
height
/
2
sourceItem
:
MissionItemIndexLabel
{
id
:
_label
onClicked
:
_item
.
clicked
()
}
}
src/MissionEditor/MissionEditor.cc
View file @
cd2d960a
...
...
@@ -36,16 +36,11 @@ MissionEditor::MissionEditor(QWidget *parent)
:
QGCQmlWidgetHolder
(
parent
)
,
_missionItems
(
NULL
)
{
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
MinimumExpanding
);
// Get rid of layout default margins
QLayout
*
pl
=
layout
();
if
(
pl
)
{
pl
->
setContentsMargins
(
0
,
0
,
0
,
0
);
}
#ifndef __android__
setMinimumWidth
(
31
*
ScreenToolsController
::
defaultFontPixelSize_s
());
setMinimumHeight
(
33
*
ScreenToolsController
::
defaultFontPixelSize_s
());
#endif
Vehicle
*
activeVehicle
=
MultiVehicleManager
::
instance
()
->
activeVehicle
();
if
(
activeVehicle
)
{
...
...
@@ -72,6 +67,8 @@ void MissionEditor::_newMissionItemsAvailable(void)
}
_missionItems
=
MultiVehicleManager
::
instance
()
->
activeVehicle
()
->
missionManager
()
->
copyMissionItems
();
_reSequence
();
emit
missionItemsChanged
();
}
...
...
@@ -93,30 +90,63 @@ void MissionEditor::setMissionItems(void)
}
}
void
MissionEditor
::
saveSetting
(
const
QString
&
name
,
const
QString
&
valu
e
)
int
MissionEditor
::
addMissionItem
(
QGeoCoordinate
coordinat
e
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
MissionItem
*
newItem
=
new
MissionItem
(
this
,
_missionItems
->
count
(),
coordinate
);
if
(
_missionItems
->
count
()
==
0
)
{
newItem
->
setCommand
(
MavlinkQmlSingleton
::
MAV_CMD_NAV_TAKEOFF
);
}
qDebug
()
<<
"MissionItem"
<<
newItem
->
coordinate
();
_missionItems
->
append
(
newItem
);
settings
.
setValue
(
name
,
value
)
;
return
_missionItems
->
count
()
-
1
;
}
QString
MissionEditor
::
loadSetting
(
const
QString
&
name
,
const
QString
&
defaultValue
)
void
MissionEditor
::
_reSequence
(
void
)
{
QSettings
settings
;
for
(
int
i
=
0
;
i
<
_missionItems
->
count
();
i
++
)
{
qobject_cast
<
MissionItem
*>
(
_missionItems
->
get
(
i
))
->
setSequenceNumber
(
i
);
}
}
void
MissionEditor
::
removeMissionItem
(
int
index
)
{
_missionItems
->
removeAt
(
index
);
_reSequence
();
}
void
MissionEditor
::
moveUp
(
int
index
)
{
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
);
settings
.
beginGroup
(
_settingsGroup
);
_missionItems
->
insert
(
index
-
1
,
new
MissionItem
(
item2
,
_missionItems
));
_missionItems
->
insert
(
index
,
new
MissionItem
(
item1
,
_missionItems
));
return
settings
.
value
(
name
,
defaultValue
).
toString
();
_reSequence
();
}
void
MissionEditor
::
addMissionItem
(
QGeoCoordinate
coordinate
)
void
MissionEditor
::
moveDown
(
int
index
)
{
MissionItem
*
newItem
=
new
MissionItem
(
this
,
_missionItems
->
count
(),
coordinate
);
if
(
_missionItems
->
count
()
==
0
)
{
newItem
->
setCommand
(
MavlinkQmlSingleton
::
MAV_CMD_NAV_TAKEOFF
);
if
(
_missionItems
->
count
()
<
2
||
index
>=
_missionItems
->
count
()
-
1
)
{
return
;
}
qDebug
()
<<
"MissionItem"
<<
newItem
->
coordinate
();
_missionItems
->
append
(
newItem
);
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
));
_reSequence
();
}
src/MissionEditor/MissionEditor.h
View file @
cd2d960a
...
...
@@ -37,12 +37,12 @@ public:
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItemsModel
NOTIFY
missionItemsChanged
)
Q_INVOKABLE
void
addMissionItem
(
QGeoCoordinate
coordinate
);
Q_INVOKABLE
int
addMissionItem
(
QGeoCoordinate
coordinate
);
Q_INVOKABLE
void
getMissionItems
(
void
);
Q_INVOKABLE
void
setMissionItems
(
void
);
Q_INVOKABLE
void
saveSetting
(
const
QString
&
key
,
const
QString
&
value
);
Q_INVOKABLE
QString
loadSetting
(
const
QString
&
key
,
const
QString
&
defaultValue
);
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
Q_INVOKABLE
void
moveUp
(
int
index
);
Q_INVOKABLE
void
moveDown
(
int
index
);
// Property accessors
...
...
@@ -54,6 +54,9 @@ signals:
private
slots
:
void
_newMissionItemsAvailable
();
private:
void
_reSequence
(
void
);
private:
QmlObjectListModel
*
_missionItems
;
...
...
src/MissionEditor/MissionEditor.qml
View file @
cd2d960a
...
...
@@ -44,8 +44,16 @@ QGCView {
readonly
property
real
_verticalMargin
:
ScreenTools
.
defaultFontPixelHeight
/
2
readonly
property
var
_activeVehicle
:
multiVehicleManager
.
activeVehicle
property
var
_missionItems
:
controller
.
missionItems
QGCPalette
{
id
:
_qgcPal
;
colorGroupEnabled
:
enabled
}
function
setCurrentItem
(
index
)
{
for
(
var
i
=
0
;
i
<
_missionItems
.
count
;
i
++
)
{
_missionItems
.
get
(
i
).
isCurrentItem
=
(
i
==
index
)
}
}
QGCViewPanel
{
id
:
panel
anchors.fill
:
parent
...
...
@@ -76,7 +84,8 @@ QGCView {
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
0
controller
.
addMissionItem
(
coordinate
)
var
index
=
controller
.
addMissionItem
(
coordinate
)
setCurrentItem
(
index
)
}
}
...
...
@@ -90,6 +99,8 @@ QGCView {
isCurrentItem
:
object
.
isCurrentItem
coordinate
:
object
.
coordinate
onClicked
:
setCurrentItem
(
object
.
sequenceNumber
)
Component.onCompleted
:
console
.
log
(
"
Indicator
"
,
object
.
coordinate
)
}
}
...
...
@@ -171,6 +182,20 @@ QGCView {
MissionItemEditor
{
missionItem
:
object
width
:
parent
.
width
onClicked
:
setCurrentItem
(
object
.
sequenceNumber
)
onRemove
:
{
var
newCurrentItem
=
object
.
sequenceNumber
-
1
controller
.
removeMissionItem
(
object
.
sequenceNumber
)
if
(
_missionItems
.
count
)
{
newCurrentItem
=
Math
.
min
(
_missionItems
.
count
-
1
,
newCurrentItem
)
setCurrentItem
(
newCurrentItem
)
}
}
onMoveUp
:
controller
.
moveUp
(
object
.
sequenceNumber
)
onMoveDown
:
controller
.
moveDown
(
object
.
sequenceNumber
)
}
}
// ListView
}
// Item
...
...
src/QmlControls/MissionItemEditor.qml
View file @
cd2d960a
...
...
@@ -11,11 +11,20 @@ import QGroundControl.Palette 1.0
/// Mission item edit control
Rectangle
{
id
:
_root
property
var
missionItem
height
:
((
missionItem
.
factCount
+
3
)
*
(
latitudeField
.
height
+
_margin
))
+
commandPicker
.
height
+
(
_margin
*
5
)
color
:
missionItem
.
isCurrentItem
?
qgcPal
.
buttonHighlight
:
qgcPal
.
windowShade
signal
clicked
signal
remove
signal
moveUp
signal
moveDown
// FIXME: THis doesn't work right for RTL
height
:
missionItem
.
isCurrentItem
?
((
missionItem
.
factCount
+
(
missionItem
.
specifiesCoordinate
?
3
:
0
))
*
(
latitudeField
.
height
+
_margin
))
+
commandPicker
.
height
+
deleteButton
.
height
+
(
_margin
*
6
)
:
commandPicker
.
height
+
(
_margin
*
2
)
color
:
missionItem
.
isCurrentItem
?
qgcPal
.
buttonHighlight
:
qgcPal
.
windowShade
readonly
property
real
_editFieldWidth
:
ScreenTools
.
defaultFontPixelWidth
*
13
readonly
property
real
_margin
:
ScreenTools
.
defaultFontPixelWidth
/
3
...
...
@@ -30,14 +39,23 @@ Rectangle {
anchors.fill
:
parent
MissionItemIndexLabel
{
id
:
label
isCurrentItem
:
missionItem
.
isCurrentItem
label
:
missionItem
.
sequenceNumber
id
:
label
anchors.verticalCenter
:
commandPicker
.
verticalCenter
isCurrentItem
:
missionItem
.
isCurrentItem
label
:
missionItem
.
sequenceNumber
}
MouseArea
{
anchors.fill
:
parent
visible
:
!
missionItem
.
isCurrentItem
onClicked
:
_root
.
clicked
()
}
QGCComboBox
{
id
:
commandPicker
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
4
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
10
anchors.left
:
label
.
right
anchors.right
:
parent
.
right
currentIndex
:
missionItem
.
commandByIndex
...
...
@@ -53,6 +71,7 @@ Rectangle {
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
color
:
qgcPal
.
windowShadeDark
visible
:
missionItem
.
isCurrentItem
Item
{
anchors.margins
:
_margin
...
...
@@ -120,7 +139,7 @@ Rectangle {
anchors.topMargin
:
_margin
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.top
:
missionItem
.
specifiesCoordinate
?
altitudeField
.
bottom
:
commandPicker
.
bottom
anchors.top
:
missionItem
.
specifiesCoordinate
?
altitudeField
.
bottom
:
parent
.
top
spacing
:
_margin
Repeater
{
...
...
@@ -145,6 +164,38 @@ Rectangle {
}
}
}
// Column - Values column
Row
{
anchors.topMargin
:
_margin
anchors.top
:
valueColumn
.
bottom
width
:
parent
.
width
spacing
:
_margin
readonly
property
real
buttonWidth
:
(
width
-
(
_margin
*
2
))
/
3
QGCButton
{
id
:
deleteButton
width
:
parent
.
buttonWidth
text
:
"
Delete
"
onClicked
:
_root
.
remove
()
}
QGCButton
{
width
:
parent
.
buttonWidth
text
:
"
Up
"
onClicked
:
_root
.
moveUp
()
}
QGCButton
{
width
:
parent
.
buttonWidth
text
:
"
Down
"
onClicked
:
_root
.
moveDown
()
}
}
}
// Item
}
// Rectangle
}
// Item
...
...
src/QmlControls/MissionItemIndexLabel.qml
View file @
cd2d960a
...
...
@@ -8,6 +8,8 @@ Rectangle {
property
alias
label
:
_label
.
text
property
bool
isCurrentItem
:
false
signal
clicked
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
height
:
width
radius
:
width
/
2
...
...
@@ -15,6 +17,12 @@ Rectangle {
border.color
:
"
white
"
color
:
isCurrentItem
?
"
green
"
:
"
orange
"
MouseArea
{
anchors.fill
:
parent
onClicked
:
parent
.
clicked
()
}
QGCLabel
{
id
:
_label
anchors.fill
:
parent
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
cd2d960a
...
...
@@ -89,6 +89,10 @@ bool QmlObjectListModel::insertRows(int position, int rows, const QModelIndex& p
{
Q_UNUSED
(
parent
);
if
(
position
<
0
||
position
>
_objectList
.
count
()
+
1
)
{
qWarning
()
<<
"Invalid position position:count"
<<
position
<<
_objectList
.
count
();
}
beginInsertRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
endInsertRows
();
...
...
@@ -101,10 +105,19 @@ bool QmlObjectListModel::removeRows(int position, int rows, const QModelIndex& p
{
Q_UNUSED
(
parent
);
if
(
position
<
0
||
position
>=
_objectList
.
count
())
{
qWarning
()
<<
"Invalid position position:count"
<<
position
<<
_objectList
.
count
();
}
else
if
(
position
+
rows
>
_objectList
.
count
())
{
qWarning
()
<<
"Invalid rows position:rows:count"
<<
position
<<
rows
<<
_objectList
.
count
();
}
beginRemoveRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
for
(
int
row
=
0
;
row
<
rows
;
row
++
)
{
// FIXME: Need to figure our correct memory management for here
//_objectList[position]->deleteLater();
_objectList
.
removeAt
(
position
);
}
qDebug
()
<<
_objectList
;
endRemoveRows
();
emit
countChanged
(
count
());
...
...
@@ -134,10 +147,19 @@ void QmlObjectListModel::removeAt(int i)
removeRows
(
i
,
1
);
}
void
QmlObjectListModel
::
insert
(
int
i
,
QObject
*
object
)
{
if
(
i
<
0
||
i
>
_objectList
.
count
())
{
qWarning
()
<<
"Invalid index index:count"
<<
i
<<
_objectList
.
count
();
}
_objectList
.
insert
(
i
,
object
);
insertRows
(
i
,
1
);
}
void
QmlObjectListModel
::
append
(
QObject
*
object
)
{
_objectList
+=
object
;
insertRows
(
_objectList
.
count
()
-
1
,
1
);
insert
(
_objectList
.
count
(),
object
);
}
int
QmlObjectListModel
::
count
(
void
)
const
...
...
src/QmlControls/QmlObjectListModel.h
View file @
cd2d960a
...
...
@@ -42,6 +42,7 @@ public:
void
append
(
QObject
*
object
);
void
clear
(
void
);
void
removeAt
(
int
i
);
void
insert
(
int
i
,
QObject
*
object
);
QObject
*
operator
[](
int
i
);
const
QObject
*
operator
[](
int
i
)
const
;
...
...
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