Reselect ATC station if data are updated, and update the ATIS info

This commit is contained in:
Klaus Basan
2019-07-20 18:06:26 +02:00
committed by Mat Sutcliffe
parent b87d0f5f15
commit eb014639fe
3 changed files with 30 additions and 3 deletions

View File

@@ -241,10 +241,21 @@ namespace BlackGui
ui->tvp_AtcStationsOnline->showOverlayHTMLMessage(msg, 5000); ui->tvp_AtcStationsOnline->showOverlayHTMLMessage(msg, 5000);
ui->tvp_AtcStationsOnlineTree->showOverlayHTMLMessage(msg, 5000); ui->tvp_AtcStationsOnlineTree->showOverlayHTMLMessage(msg, 5000);
} }
if (stationsCount < 1)
{
m_selectedCallsign.clear();
}
else if (!m_selectedCallsign.isEmpty() && onlineStations.containsCallsign(m_selectedCallsign))
{
const CAtcStation lastSelected = onlineStations.findFirstByCallsign(m_selectedCallsign);
this->triggerOnlineAtcStationSelected(lastSelected);
}
} }
} }
else else
{ {
m_selectedCallsign.clear();
ui->tvp_AtcStationsOnline->clear(); ui->tvp_AtcStationsOnline->clear();
this->updateTreeView(); this->updateTreeView();
} }
@@ -444,6 +455,16 @@ namespace BlackGui
this->onOnlineAtcStationSelected(station); this->onOnlineAtcStationSelected(station);
} }
void CAtcStationComponent::triggerOnlineAtcStationSelected(const CAtcStation &station)
{
// pass copy, not reference -> can crash
QPointer<CAtcStationComponent> myself(this);
QTimer::singleShot(500, this, [ = ]
{
if (myself) { myself->onOnlineAtcStationSelected(station); }
});
}
void CAtcStationComponent::onOnlineAtcStationSelected(const CAtcStation &station) void CAtcStationComponent::onOnlineAtcStationSelected(const CAtcStation &station)
{ {
if (!station.hasCallsign()) { return; } if (!station.hasCallsign()) { return; }
@@ -452,6 +473,7 @@ namespace BlackGui
(station.hasAtis() ? u"\n\n" % station.getAtis().getMessage() : QStringLiteral("")) % (station.hasAtis() ? u"\n\n" % station.getAtis().getMessage() : QStringLiteral("")) %
(station.hasMetar() ? u"\n\n" % station.getMetar().getMessage() : QStringLiteral("")); (station.hasMetar() ? u"\n\n" % station.getMetar().getMessage() : QStringLiteral(""));
ui->te_AtcStationsOnlineInfo->setText(infoMessage); ui->te_AtcStationsOnlineInfo->setText(infoMessage);
m_selectedCallsign = station.getCallsign();
} }
void CAtcStationComponent::atcStationsTabChanged() void CAtcStationComponent::atcStationsTabChanged()
@@ -491,6 +513,7 @@ namespace BlackGui
{ {
ui->tvp_AtcStationsOnline->clear(); ui->tvp_AtcStationsOnline->clear();
ui->tvp_AtcStationsOnlineTree->clear(); ui->tvp_AtcStationsOnlineTree->clear();
m_selectedCallsign.clear();
} }
void CAtcStationComponent::showOverlayInlineTextMessage() void CAtcStationComponent::showOverlayInlineTextMessage()

View File

@@ -99,12 +99,15 @@ namespace BlackGui
//! Request new ATIS //! Request new ATIS
void requestAtisUpdates(); void requestAtisUpdates();
//! A tree view station has been selected //! A station has been selected
void onOnlineAtcStationSelected(const BlackMisc::Aviation::CAtcStation &station); void onOnlineAtcStationSelected(const BlackMisc::Aviation::CAtcStation &station);
//! Online ATC station selected //! Online ATC station selected
void onOnlineAtcStationVariantSelected(const BlackMisc::CVariant &object); void onOnlineAtcStationVariantSelected(const BlackMisc::CVariant &object);
//! Trigger a selection of an onlie station (async)
void triggerOnlineAtcStationSelected(const BlackMisc::Aviation::CAtcStation &station);
//! Tab changed //! Tab changed
void atcStationsTabChanged(); void atcStationsTabChanged();
@@ -168,6 +171,7 @@ namespace BlackGui
QScopedPointer<Ui::CAtcStationComponent> ui; QScopedPointer<Ui::CAtcStationComponent> ui;
QTimer m_updateTimer; QTimer m_updateTimer;
QList<int> m_stretch; QList<int> m_stretch;
BlackMisc::Aviation::CCallsign m_selectedCallsign;
QDateTime m_timestampLastReadOnlineStations; //!< stations read QDateTime m_timestampLastReadOnlineStations; //!< stations read
QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed
QDateTime m_timestampLastReadBookedStations; //!< stations read QDateTime m_timestampLastReadBookedStations; //!< stations read

View File

@@ -58,7 +58,7 @@ namespace BlackMisc
bool CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer) bool CAtcStationList::updateIfMessageChanged(const CInformationMessage &im, const CCallsign &callsign, bool overrideWithNewer)
{ {
const CInformationMessage::InformationType t = im.getType(); const CInformationMessage::InformationType type = im.getType();
// for loop just to get reference // for loop just to get reference
bool unequal = false; bool unequal = false;
@@ -66,7 +66,7 @@ namespace BlackMisc
{ {
if (station.getCallsign() != callsign) { continue; } if (station.getCallsign() != callsign) { continue; }
const CInformationMessage m = station.getInformationMessage(t); const CInformationMessage m = station.getInformationMessage(type);
if (m.getType() == CInformationMessage::Unspecified) { break; } if (m.getType() == CInformationMessage::Unspecified) { break; }
if (m.getMessage() == im.getMessage()) if (m.getMessage() == im.getMessage())