Make route editing sane.
Drag&drop, insert and remove now update the current waypoint as expected.
This commit is contained in:
parent
0ad9ac4f3d
commit
59d06d130d
2 changed files with 16 additions and 6 deletions
|
@ -352,11 +352,6 @@ flightgear::WayptRef FGRouteMgr::removeWayptAtIndex(int aIndex)
|
||||||
SG_LOG(SG_AUTOPILOT, SG_WARN, "removeWayptAtIndex with invalid index:" << aIndex);
|
SG_LOG(SG_AUTOPILOT, SG_WARN, "removeWayptAtIndex with invalid index:" << aIndex);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_currentIndex > index) {
|
|
||||||
--_currentIndex; // shift current index down if necessary
|
|
||||||
}
|
|
||||||
|
|
||||||
WayptVec::iterator it = _route.begin();
|
WayptVec::iterator it = _route.begin();
|
||||||
it += index;
|
it += index;
|
||||||
|
|
||||||
|
@ -364,6 +359,15 @@ flightgear::WayptRef FGRouteMgr::removeWayptAtIndex(int aIndex)
|
||||||
_route.erase(it);
|
_route.erase(it);
|
||||||
|
|
||||||
update_mirror();
|
update_mirror();
|
||||||
|
|
||||||
|
if (_currentIndex == index) {
|
||||||
|
currentWaypointChanged(); // current waypoint was removed
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (_currentIndex > index) {
|
||||||
|
--_currentIndex; // shift current index down if necessary
|
||||||
|
}
|
||||||
|
|
||||||
_edited->fireValueChanged();
|
_edited->fireValueChanged();
|
||||||
checkFinished();
|
checkFinished();
|
||||||
|
|
||||||
|
@ -680,7 +684,7 @@ void FGRouteMgr::insertWayptAtIndex(Waypt* aWpt, int aIndex)
|
||||||
WayptVec::iterator it = _route.begin();
|
WayptVec::iterator it = _route.begin();
|
||||||
it += index;
|
it += index;
|
||||||
|
|
||||||
if (_currentIndex > index) {
|
if (_currentIndex >= index) {
|
||||||
++_currentIndex;
|
++_currentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,9 +83,15 @@ public:
|
||||||
--destIndex;
|
--destIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int currentWpIndex = currentWaypoint();
|
||||||
WayptRef w(_rm->removeWayptAtIndex(srcIndex));
|
WayptRef w(_rm->removeWayptAtIndex(srcIndex));
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
|
SG_LOG(SG_GENERAL, SG_INFO, "wpt:" << w->ident());
|
||||||
_rm->insertWayptAtIndex(w, destIndex);
|
_rm->insertWayptAtIndex(w, destIndex);
|
||||||
|
|
||||||
|
if (srcIndex == currentWpIndex) {
|
||||||
|
// current waypoint was moved
|
||||||
|
_rm->jumpToIndex(destIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setUpdateCallback(SGCallback* cb)
|
virtual void setUpdateCallback(SGCallback* cb)
|
||||||
|
|
Loading…
Add table
Reference in a new issue