Commit dcdcc96a authored by DonLakeFlyer's avatar DonLakeFlyer

Clear current item before adding new one

This closes out all value editing before the new item is added. Fixes
the bug where you enter a new altitude in last waypoint, don't press
enter and then add a new one. In that case altitude would be set after
new item was added. Hence it would not carry to new item.
parent b7da6015
...@@ -246,6 +246,8 @@ QGCView { ...@@ -246,6 +246,8 @@ QGCView {
id: _mapTypeButtonsExclusiveGroup id: _mapTypeButtonsExclusiveGroup
} }
/// Sets a new current mission item
/// @param sequenceNumber - index for new item, -1 to clear current item
function setCurrentItem(sequenceNumber) { function setCurrentItem(sequenceNumber) {
if (sequenceNumber !== _currentMissionIndex) { if (sequenceNumber !== _currentMissionIndex) {
_currentMissionItem = undefined _currentMissionItem = undefined
...@@ -263,6 +265,15 @@ QGCView { ...@@ -263,6 +265,15 @@ QGCView {
} }
} }
/// Inserts a new simple mission item
/// @param coordinate Location to insert item
/// @param index Insert item at this index
function insertSimpleMissionItem(coordinate, index) {
setCurrentItem(-1)
var sequenceNumber = missionController.insertSimpleMissionItem(coordinate, index)
setCurrentItem(sequenceNumber)
}
property int _moveDialogMissionItemIndex property int _moveDialogMissionItemIndex
Component { Component {
...@@ -379,8 +390,7 @@ QGCView { ...@@ -379,8 +390,7 @@ QGCView {
switch (_editingLayer) { switch (_editingLayer) {
case _layerMission: case _layerMission:
if (_addWaypointOnClick) { if (_addWaypointOnClick) {
var sequenceNumber = missionController.insertSimpleMissionItem(coordinate, missionController.visualItems.count) insertSimpleMissionItem(coordinate, missionController.visualItems.count)
setCurrentItem(sequenceNumber)
} }
break break
case _layerGeoFence: case _layerGeoFence:
...@@ -591,12 +601,8 @@ QGCView { ...@@ -591,12 +601,8 @@ QGCView {
setCurrentItem(removeIndex) setCurrentItem(removeIndex)
} }
onInsert: { onInsert: insertSimpleMissionItem(editorMap.center, index)
var sequenceNumber = missionController.insertSimpleMissionItem(editorMap.center, index) onMoveHomeToMapCenter: _visualItems.get(0).coordinate = editorMap.center
setCurrentItem(sequenceNumber)
}
onMoveHomeToMapCenter: _visualItems.get(0).coordinate = editorMap.center
} }
} // QGCListView } // QGCListView
} // Item - Mission Item editor } // Item - Mission Item editor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment