1
0
Fork 0

Make route editing sane.

Drag&drop, insert and remove now update the current waypoint as expected.
This commit is contained in:
ThorstenB 2011-01-23 00:45:06 +01:00 committed by James Turner
parent 0ad9ac4f3d
commit 59d06d130d
2 changed files with 16 additions and 6 deletions

View file

@ -352,11 +352,6 @@ flightgear::WayptRef FGRouteMgr::removeWayptAtIndex(int aIndex)
SG_LOG(SG_AUTOPILOT, SG_WARN, "removeWayptAtIndex with invalid index:" << aIndex);
return NULL;
}
if (_currentIndex > index) {
--_currentIndex; // shift current index down if necessary
}
WayptVec::iterator it = _route.begin();
it += index;
@ -364,6 +359,15 @@ flightgear::WayptRef FGRouteMgr::removeWayptAtIndex(int aIndex)
_route.erase(it);
update_mirror();
if (_currentIndex == index) {
currentWaypointChanged(); // current waypoint was removed
}
else
if (_currentIndex > index) {
--_currentIndex; // shift current index down if necessary
}
_edited->fireValueChanged();
checkFinished();
@ -680,7 +684,7 @@ void FGRouteMgr::insertWayptAtIndex(Waypt* aWpt, int aIndex)
WayptVec::iterator it = _route.begin();
it += index;
if (_currentIndex > index) {
if (_currentIndex >= index) {
++_currentIndex;
}

View file

@ -83,9 +83,15 @@ public:
--destIndex;
}
int currentWpIndex = currentWaypoint();
WayptRef w(_rm->removeWayptAtIndex(srcIndex));
SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
_rm->insertWayptAtIndex(w, destIndex);
if (srcIndex == currentWpIndex) {
// current waypoint was moved
_rm->jumpToIndex(destIndex);
}
}
virtual void setUpdateCallback(SGCallback* cb)