Allow deletion of certain types of waypoints

Resolves #60
NAV/REFUEL/DIVERT waypoints should have no effect on the timings.
This commit is contained in:
Raffson
2023-05-29 00:11:27 +02:00
parent 8363a7e8fa
commit 198ff7d8a3
17 changed files with 96 additions and 24 deletions

View File

@@ -109,13 +109,28 @@ class QFlightWaypointTab(QFrame):
# Need to degrade to a custom flight plan and remove the waypoint.
# If the waypoint is a target waypoint and is not the last target
# waypoint, we don't need to degrade.
if isinstance(self.flight.flight_plan, FormationAttackFlightPlan):
is_target = waypoint in self.flight.flight_plan.target_area_waypoint.targets
count = len(self.flight.flight_plan.target_area_waypoint.targets)
fp = self.flight.flight_plan
if isinstance(fp, FormationAttackFlightPlan):
is_target = waypoint in fp.target_area_waypoint.targets
count = len(fp.target_area_waypoint.targets)
if is_target and count > 1:
self.flight.flight_plan.target_area_waypoint.targets.remove(waypoint)
fp.target_area_waypoint.targets.remove(waypoint)
return
if fp.layout.delete_waypoint(waypoint):
return
result = QMessageBox.warning(
self,
"Degrade flight-plan?",
"Deleting the selected waypoint(s) will require degradation to a custom flight-plan. "
"A custom flight-plan will no longer respect the TOTs of the package.<br><br>"
"<b>Are you sure you wish to continue?</b>",
QMessageBox.Yes,
QMessageBox.No,
)
if result == QMessageBox.No:
return
self.degrade_to_custom_flight_plan()
assert isinstance(self.flight.flight_plan, CustomFlightPlan)
self.flight.flight_plan.layout.custom_waypoints.remove(waypoint)