Commit 3d12ff8d authored by Don Gagne's avatar Don Gagne

Change mission loading model

Vehicle change: All items removed
Vehicle add: Request sync is not already in progress
parent a982044a
...@@ -76,10 +76,10 @@ void MissionController::_newMissionItemsAvailableFromVehicle(void) ...@@ -76,10 +76,10 @@ void MissionController::_newMissionItemsAvailableFromVehicle(void)
if (!_editMode || _missionItemsRequested || _visualItems->count() == 1) { if (!_editMode || _missionItemsRequested || _visualItems->count() == 1) {
// Fly Mode: // Fly Mode:
// - Always accepts new items fromthe vehicle so Fly view is kept up to date // - Always accepts new items from the vehicle so Fly view is kept up to date
// Edit Mode: // Edit Mode:
// - Either a load from vehicle was manually requested or // - Either a load from vehicle was manually requested or
// - The initial automatic load from a vehicle completed and the current editor it empty // - The initial automatic load from a vehicle completed and the current editor is empty
QmlObjectListModel* newControllerMissionItems = new QmlObjectListModel(this); QmlObjectListModel* newControllerMissionItems = new QmlObjectListModel(this);
const QList<MissionItem*>& newMissionItems = _activeVehicle->missionManager()->missionItems(); const QList<MissionItem*>& newMissionItems = _activeVehicle->missionManager()->missionItems();
...@@ -948,6 +948,10 @@ void MissionController::_activeVehicleChanged(Vehicle* activeVehicle) ...@@ -948,6 +948,10 @@ void MissionController::_activeVehicleChanged(Vehicle* activeVehicle)
_activeVehicle = NULL; _activeVehicle = NULL;
} }
// We always remove all items on vehicle change. This leaves a user model hole:
// If the user has unsaved changes in the Plan view they will lose them
removeAllMissionItems();
_activeVehicle = activeVehicle; _activeVehicle = activeVehicle;
if (_activeVehicle) { if (_activeVehicle) {
...@@ -959,8 +963,9 @@ void MissionController::_activeVehicleChanged(Vehicle* activeVehicle) ...@@ -959,8 +963,9 @@ void MissionController::_activeVehicleChanged(Vehicle* activeVehicle)
connect(_activeVehicle, &Vehicle::homePositionAvailableChanged, this, &MissionController::_activeVehicleHomePositionAvailableChanged); connect(_activeVehicle, &Vehicle::homePositionAvailableChanged, this, &MissionController::_activeVehicleHomePositionAvailableChanged);
connect(_activeVehicle, &Vehicle::homePositionChanged, this, &MissionController::_activeVehicleHomePositionChanged); connect(_activeVehicle, &Vehicle::homePositionChanged, this, &MissionController::_activeVehicleHomePositionChanged);
if (!_editMode) { if (!syncInProgress()) {
removeAllMissionItems(); // We have to manually ask for the items from the Vehicle
getMissionItems();
} }
_activeVehicleHomePositionChanged(_activeVehicle->homePosition()); _activeVehicleHomePositionChanged(_activeVehicle->homePosition());
......
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