Commit 63b29b1c authored by Don Gagne's avatar Don Gagne

Fix remove item/current item bug

Plus remove unused code
parent 99fda356
......@@ -248,13 +248,9 @@ QGCView {
id: _mapTypeButtonsExclusiveGroup
}
ExclusiveGroup {
id: _dropButtonsExclusiveGroup
}
function setCurrentItem(sequenceNumber) {
if (sequenceNumber !== _currentMissionIndex) {
//editorMap.polygonDraw.cancelPolygonEdit()
console.log("setCurrentItem", sequenceNumber)
_currentMissionItem = undefined
_currentMissionIndex = -1
for (var i=0; i<_visualItems.count; i++) {
......@@ -457,59 +453,6 @@ QGCView {
}
}
Component {
id: missionItemComponent
MissionItemIndicator {
id: itemIndicator
coordinate: object.coordinate
visible: object.isSimpleItem && object.specifiesCoordinate
z: QGroundControl.zOrderMapItems
missionItem: object
sequenceNumber: object.sequenceNumber
//-- If you don't want to allow selecting items beneath the
// toolbar, the code below has to check and see if mouse.y
// is greater than (map.height - ScreenTools.availableHeight)
onClicked: setCurrentItem(object.sequenceNumber)
function updateItemIndicator() {
if (object.isCurrentItem && itemIndicator.visible && object.specifiesCoordinate && object.isSimpleItem) {
// Setup our drag item
itemDragger.visible = true
itemDragger.coordinateItem = Qt.binding(function() { return object })
itemDragger.mapCoordinateIndicator = Qt.binding(function() { return itemIndicator })
}
}
Connections {
target: object
onIsCurrentItemChanged: updateItemIndicator()
onSpecifiesCoordinateChanged: updateItemIndicator()
}
// These are the non-coordinate child mission items attached to this item
Row {
anchors.top: parent.top
anchors.left: parent.right
Repeater {
model: object.isSimpleItem ? object.childItems : 0
delegate: MissionItemIndexLabel {
label: object.abbreviation
checked: object.isCurrentItem
z: 2
specifiesCoordinate: false
onClicked: setCurrentItem(object.sequenceNumber)
}
}
}
}
}
// Add lines between waypoints
MissionLineView {
model: _editingLayer == _layerMission ? missionController.waypointLines : undefined
......@@ -635,9 +578,13 @@ QGCView {
onClicked: setCurrentItem(object.sequenceNumber)
onRemove: {
var removeIndex = index
itemDragger.clearItem()
missionController.removeMissionItem(index)
editorMap.polygonDraw.cancelPolygonEdit()
missionController.removeMissionItem(removeIndex)
if (removeIndex >= missionController.visualItems.count) {
removeIndex--
}
setCurrentItem(removeIndex)
}
onInsert: {
......@@ -750,17 +697,6 @@ QGCView {
}
}
//-- Dismiss Drop Down (if any)
MouseArea {
anchors.fill: parent
enabled: _dropButtonsExclusiveGroup.current != null
onClicked: {
if(_dropButtonsExclusiveGroup.current)
_dropButtonsExclusiveGroup.current.checked = false
_dropButtonsExclusiveGroup.current = null
}
}
ToolStrip {
id: toolStrip
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
......
......@@ -258,16 +258,6 @@ void MissionController::removeMissionItem(int index)
item->deleteLater();
_recalcAll();
// Set the new current item
if (index >= _visualItems->count()) {
index--;
}
for (int i=0; i<_visualItems->count(); i++) {
VisualMissionItem* item = qobject_cast<VisualMissionItem*>(_visualItems->get(i));
item->setIsCurrentItem(i == index);
}
_visualItems->setDirty(true);
}
......
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