Ref T285, allow to re-init all aircraft

* aircraft will be removed, then added again as new
* this will go thru the full cycle and matching
This commit is contained in:
Klaus Basan
2018-06-27 01:37:47 +02:00
parent 1f689a8830
commit 8898bf6be5
8 changed files with 72 additions and 4 deletions

View File

@@ -340,6 +340,14 @@ namespace BlackCore
QObject::disconnect(this);
}
int CAirspaceMonitor::reInitializeAllAircraft()
{
const CSimulatedAircraftList aircraft = this->getAircraftInRange();
CRemoteAircraftProvider::removeAllAircraft();
this->asyncAddNewAircraftInRange(aircraft, true);
return aircraft.size();
}
void CAirspaceMonitor::onRealNameReplyReceived(const CCallsign &callsign, const QString &realname)
{
if (!this->isConnected() || realname.isEmpty()) { return; }
@@ -756,6 +764,25 @@ namespace BlackCore
return CRemoteAircraftProvider::addNewAircraftInRange(newAircraft);
}
void CAirspaceMonitor::asyncAddNewAircraftInRange(const CSimulatedAircraftList &aircraft, bool readyForModelMatching)
{
if (aircraft.isEmpty()) { return; }
if (!sApp || sApp->isShuttingDown()) { return; }
int c = 1;
QPointer<CAirspaceMonitor> myself(this);
for (const CSimulatedAircraft &ac : aircraft)
{
QTimer::singleShot(c * 25, this, [ = ]
{
if (!myself) { return; }
myself->addNewAircraftInRange(ac);
if (!readyForModelMatching) { return; }
myself->sendReadyForModelMatching(ac.getCallsign());
});
}
}
int CAirspaceMonitor::updateOnlineStation(const CCallsign &callsign, const CPropertyIndexVariantMap &vm, bool skipEqualValues, bool sendSignal)
{
const int c = m_atcStationsOnline.applyIfCallsign(callsign, vm, skipEqualValues);