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
...
@@ -30,14 +30,20 @@ import QGroundControl.Vehicle 1.0
/// Marker for displaying a mission item on the map
/// Marker for displaying a mission item on the map
MapQuickItem
{
MapQuickItem
{
id
:
_item
property
alias
label
:
_label
.
label
property
alias
label
:
_label
.
label
property
alias
isCurrentItem
:
_label
.
isCurrentItem
property
alias
isCurrentItem
:
_label
.
isCurrentItem
signal
clicked
anchorPoint.x
:
sourceItem
.
width
/
2
anchorPoint.x
:
sourceItem
.
width
/
2
anchorPoint.y
:
sourceItem
.
height
/
2
anchorPoint.y
:
sourceItem
.
height
/
2
sourceItem
:
sourceItem
:
MissionItemIndexLabel
{
MissionItemIndexLabel
{
id
:
_label
id
:
_label
onClicked
:
_item
.
clicked
()
}
}
}
}
src/MissionEditor/MissionEditor.cc
View file @
cd2d960a
...
@@ -36,16 +36,11 @@ MissionEditor::MissionEditor(QWidget *parent)
...
@@ -36,16 +36,11 @@ MissionEditor::MissionEditor(QWidget *parent)
:
QGCQmlWidgetHolder
(
parent
)
:
QGCQmlWidgetHolder
(
parent
)
,
_missionItems
(
NULL
)
,
_missionItems
(
NULL
)
{
{
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
MinimumExpanding
);
// Get rid of layout default margins
// Get rid of layout default margins
QLayout
*
pl
=
layout
();
QLayout
*
pl
=
layout
();
if
(
pl
)
{
if
(
pl
)
{
pl
->
setContentsMargins
(
0
,
0
,
0
,
0
);
pl
->
setContentsMargins
(
0
,
0
,
0
,
0
);
}
}
#ifndef __android__
setMinimumWidth
(
31
*
ScreenToolsController
::
defaultFontPixelSize_s
());
setMinimumHeight
(
33
*
ScreenToolsController
::
defaultFontPixelSize_s
());
#endif
Vehicle
*
activeVehicle
=
MultiVehicleManager
::
instance
()
->
activeVehicle
();
Vehicle
*
activeVehicle
=
MultiVehicleManager
::
instance
()
->
activeVehicle
();
if
(
activeVehicle
)
{
if
(
activeVehicle
)
{
...
@@ -72,6 +67,8 @@ void MissionEditor::_newMissionItemsAvailable(void)
...
@@ -72,6 +67,8 @@ void MissionEditor::_newMissionItemsAvailable(void)
}
}
_missionItems
=
MultiVehicleManager
::
instance
()
->
activeVehicle
()
->
missionManager
()
->
copyMissionItems
();
_missionItems
=
MultiVehicleManager
::
instance
()
->
activeVehicle
()
->
missionManager
()
->
copyMissionItems
();
_reSequence
();
emit
missionItemsChanged
();
emit
missionItemsChanged
();
}
}
...
@@ -93,30 +90,63 @@ void MissionEditor::setMissionItems(void)
...
@@ -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
;
MissionItem
*
newItem
=
new
MissionItem
(
this
,
_missionItems
->
count
(),
coordinate
);
if
(
_missionItems
->
count
()
==
0
)
{
settings
.
beginGroup
(
_settingsGroup
);
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
()
<
2
||
index
>=
_missionItems
->
count
()
-
1
)
{
if
(
_missionItems
->
count
()
==
0
)
{
return
;
newItem
->
setCommand
(
MavlinkQmlSingleton
::
MAV_CMD_NAV_TAKEOFF
);
}
}
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:
...
@@ -37,12 +37,12 @@ public:
Q_PROPERTY
(
QmlObjectListModel
*
missionItems
READ
missionItemsModel
NOTIFY
missionItemsChanged
)
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
getMissionItems
(
void
);
Q_INVOKABLE
void
setMissionItems
(
void
);
Q_INVOKABLE
void
setMissionItems
(
void
);
Q_INVOKABLE
void
removeMissionItem
(
int
index
);
Q_INVOKABLE
void
saveSetting
(
const
QString
&
key
,
const
QString
&
value
);
Q_INVOKABLE
void
moveUp
(
int
index
);
Q_INVOKABLE
QString
loadSetting
(
const
QString
&
key
,
const
QString
&
defaultValue
);
Q_INVOKABLE
void
moveDown
(
int
index
);
// Property accessors
// Property accessors
...
@@ -54,6 +54,9 @@ signals:
...
@@ -54,6 +54,9 @@ signals:
private
slots
:
private
slots
:
void
_newMissionItemsAvailable
();
void
_newMissionItemsAvailable
();
private:
void
_reSequence
(
void
);
private:
private:
QmlObjectListModel
*
_missionItems
;
QmlObjectListModel
*
_missionItems
;
...
...
src/MissionEditor/MissionEditor.qml
View file @
cd2d960a
...
@@ -44,8 +44,16 @@ QGCView {
...
@@ -44,8 +44,16 @@ QGCView {
readonly
property
real
_verticalMargin
:
ScreenTools
.
defaultFontPixelHeight
/
2
readonly
property
real
_verticalMargin
:
ScreenTools
.
defaultFontPixelHeight
/
2
readonly
property
var
_activeVehicle
:
multiVehicleManager
.
activeVehicle
readonly
property
var
_activeVehicle
:
multiVehicleManager
.
activeVehicle
property
var
_missionItems
:
controller
.
missionItems
QGCPalette
{
id
:
_qgcPal
;
colorGroupEnabled
:
enabled
}
QGCPalette
{
id
:
_qgcPal
;
colorGroupEnabled
:
enabled
}
function
setCurrentItem
(
index
)
{
for
(
var
i
=
0
;
i
<
_missionItems
.
count
;
i
++
)
{
_missionItems
.
get
(
i
).
isCurrentItem
=
(
i
==
index
)
}
}
QGCViewPanel
{
QGCViewPanel
{
id
:
panel
id
:
panel
anchors.fill
:
parent
anchors.fill
:
parent
...
@@ -76,7 +84,8 @@ QGCView {
...
@@ -76,7 +84,8 @@ QGCView {
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
latitude
=
coordinate
.
latitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
longitude
=
coordinate
.
longitude
.
toFixed
(
_decimalPlaces
)
coordinate
.
altitude
=
0
coordinate
.
altitude
=
0
controller
.
addMissionItem
(
coordinate
)
var
index
=
controller
.
addMissionItem
(
coordinate
)
setCurrentItem
(
index
)
}
}
}
}
...
@@ -90,6 +99,8 @@ QGCView {
...
@@ -90,6 +99,8 @@ QGCView {
isCurrentItem
:
object
.
isCurrentItem
isCurrentItem
:
object
.
isCurrentItem
coordinate
:
object
.
coordinate
coordinate
:
object
.
coordinate
onClicked
:
setCurrentItem
(
object
.
sequenceNumber
)
Component.onCompleted
:
console
.
log
(
"
Indicator
"
,
object
.
coordinate
)
Component.onCompleted
:
console
.
log
(
"
Indicator
"
,
object
.
coordinate
)
}
}
}
}
...
@@ -171,6 +182,20 @@ QGCView {
...
@@ -171,6 +182,20 @@ QGCView {
MissionItemEditor
{
MissionItemEditor
{
missionItem
:
object
missionItem
:
object
width
:
parent
.
width
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
}
// ListView
}
// Item
}
// Item
...
...
src/QmlControls/MissionItemEditor.qml
View file @
cd2d960a
...
@@ -11,11 +11,20 @@ import QGroundControl.Palette 1.0
...
@@ -11,11 +11,20 @@ import QGroundControl.Palette 1.0
/// Mission item edit control
/// Mission item edit control
Rectangle
{
Rectangle
{
id
:
_root
property
var
missionItem
property
var
missionItem
height
:
((
missionItem
.
factCount
+
3
)
*
(
latitudeField
.
height
+
_margin
))
+
commandPicker
.
height
+
(
_margin
*
5
)
signal
clicked
color
:
missionItem
.
isCurrentItem
?
qgcPal
.
buttonHighlight
:
qgcPal
.
windowShade
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
_editFieldWidth
:
ScreenTools
.
defaultFontPixelWidth
*
13
readonly
property
real
_margin
:
ScreenTools
.
defaultFontPixelWidth
/
3
readonly
property
real
_margin
:
ScreenTools
.
defaultFontPixelWidth
/
3
...
@@ -30,14 +39,23 @@ Rectangle {
...
@@ -30,14 +39,23 @@ Rectangle {
anchors.fill
:
parent
anchors.fill
:
parent
MissionItemIndexLabel
{
MissionItemIndexLabel
{
id
:
label
id
:
label
isCurrentItem
:
missionItem
.
isCurrentItem
anchors.verticalCenter
:
commandPicker
.
verticalCenter
label
:
missionItem
.
sequenceNumber
isCurrentItem
:
missionItem
.
isCurrentItem
label
:
missionItem
.
sequenceNumber
}
MouseArea
{
anchors.fill
:
parent
visible
:
!
missionItem
.
isCurrentItem
onClicked
:
_root
.
clicked
()
}
}
QGCComboBox
{
QGCComboBox
{
id
:
commandPicker
id
:
commandPicker
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
4
anchors.leftMargin
:
ScreenTools
.
defaultFontPixelWidth
*
10
anchors.left
:
label
.
right
anchors.left
:
label
.
right
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
currentIndex
:
missionItem
.
commandByIndex
currentIndex
:
missionItem
.
commandByIndex
...
@@ -53,6 +71,7 @@ Rectangle {
...
@@ -53,6 +71,7 @@ Rectangle {
anchors.left
:
parent
.
left
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
color
:
qgcPal
.
windowShadeDark
color
:
qgcPal
.
windowShadeDark
visible
:
missionItem
.
isCurrentItem
Item
{
Item
{
anchors.margins
:
_margin
anchors.margins
:
_margin
...
@@ -120,7 +139,7 @@ Rectangle {
...
@@ -120,7 +139,7 @@ Rectangle {
anchors.topMargin
:
_margin
anchors.topMargin
:
_margin
anchors.left
:
parent
.
left
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.right
:
parent
.
right
anchors.top
:
missionItem
.
specifiesCoordinate
?
altitudeField
.
bottom
:
commandPicker
.
bottom
anchors.top
:
missionItem
.
specifiesCoordinate
?
altitudeField
.
bottom
:
parent
.
top
spacing
:
_margin
spacing
:
_margin
Repeater
{
Repeater
{
...
@@ -145,6 +164,38 @@ Rectangle {
...
@@ -145,6 +164,38 @@ Rectangle {
}
}
}
}
}
// Column - Values column
}
// 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
}
// Item
}
// Rectangle
}
// Rectangle
}
// Item
}
// Item
...
...
src/QmlControls/MissionItemIndexLabel.qml
View file @
cd2d960a
...
@@ -8,6 +8,8 @@ Rectangle {
...
@@ -8,6 +8,8 @@ Rectangle {
property
alias
label
:
_label
.
text
property
alias
label
:
_label
.
text
property
bool
isCurrentItem
:
false
property
bool
isCurrentItem
:
false
signal
clicked
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
width
:
ScreenTools
.
defaultFontPixelHeight
*
1.5
height
:
width
height
:
width
radius
:
width
/
2
radius
:
width
/
2
...
@@ -15,6 +17,12 @@ Rectangle {
...
@@ -15,6 +17,12 @@ Rectangle {
border.color
:
"
white
"
border.color
:
"
white
"
color
:
isCurrentItem
?
"
green
"
:
"
orange
"
color
:
isCurrentItem
?
"
green
"
:
"
orange
"
MouseArea
{
anchors.fill
:
parent
onClicked
:
parent
.
clicked
()
}
QGCLabel
{
QGCLabel
{
id
:
_label
id
:
_label
anchors.fill
:
parent
anchors.fill
:
parent
...
...
src/QmlControls/QmlObjectListModel.cc
View file @
cd2d960a
...
@@ -89,6 +89,10 @@ bool QmlObjectListModel::insertRows(int position, int rows, const QModelIndex& p
...
@@ -89,6 +89,10 @@ bool QmlObjectListModel::insertRows(int position, int rows, const QModelIndex& p
{
{
Q_UNUSED
(
parent
);
Q_UNUSED
(
parent
);
if
(
position
<
0
||
position
>
_objectList
.
count
()
+
1
)
{
qWarning
()
<<
"Invalid position position:count"
<<
position
<<
_objectList
.
count
();
}
beginInsertRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
beginInsertRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
endInsertRows
();
endInsertRows
();
...
@@ -101,10 +105,19 @@ bool QmlObjectListModel::removeRows(int position, int rows, const QModelIndex& p
...
@@ -101,10 +105,19 @@ bool QmlObjectListModel::removeRows(int position, int rows, const QModelIndex& p
{
{
Q_UNUSED
(
parent
);
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
);
beginRemoveRows
(
QModelIndex
(),
position
,
position
+
rows
-
1
);
for
(
int
row
=
0
;
row
<
rows
;
row
++
)
{
for
(
int
row
=
0
;
row
<
rows
;
row
++
)
{
// FIXME: Need to figure our correct memory management for here
//_objectList[position]->deleteLater();
_objectList
.
removeAt
(
position
);
_objectList
.
removeAt
(
position
);
}
}
qDebug
()
<<
_objectList
;
endRemoveRows
();
endRemoveRows
();
emit
countChanged
(
count
());
emit
countChanged
(
count
());
...
@@ -134,10 +147,19 @@ void QmlObjectListModel::removeAt(int i)
...
@@ -134,10 +147,19 @@ void QmlObjectListModel::removeAt(int i)
removeRows
(
i
,
1
);
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
)
void
QmlObjectListModel
::
append
(
QObject
*
object
)
{
{
_objectList
+=
object
;
insert
(
_objectList
.
count
(),
object
);
insertRows
(
_objectList
.
count
()
-
1
,
1
);
}
}
int
QmlObjectListModel
::
count
(
void
)
const
int
QmlObjectListModel
::
count
(
void
)
const
...
...
src/QmlControls/QmlObjectListModel.h
View file @
cd2d960a
...
@@ -42,6 +42,7 @@ public:
...
@@ -42,6 +42,7 @@ public:
void
append
(
QObject
*
object
);
void
append
(
QObject
*
object
);
void
clear
(
void
);
void
clear
(
void
);
void
removeAt
(
int
i
);
void
removeAt
(
int
i
);
void
insert
(
int
i
,
QObject
*
object
);
QObject
*
operator
[](
int
i
);
QObject
*
operator
[](
int
i
);
const
QObject
*
operator
[](
int
i
)
const
;
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