mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #253, faster updates of ATC stations by changedAtcStationConnectionStatus(const
This commit is contained in:
@@ -37,6 +37,7 @@ namespace BlackGui
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline);
|
||||
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked);
|
||||
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus);
|
||||
}
|
||||
|
||||
void CAtcStationComponent::update()
|
||||
@@ -79,9 +80,16 @@ namespace BlackGui
|
||||
|
||||
void CAtcStationComponent::changedAtcStationsOnline()
|
||||
{
|
||||
// just update timestamp, data will be pulled by time
|
||||
// the timestamp will tell if there are newer data
|
||||
this->m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
|
||||
}
|
||||
|
||||
void CAtcStationComponent::changedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool added)
|
||||
{
|
||||
this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added);
|
||||
}
|
||||
|
||||
void CAtcStationComponent::changedAtcStationsBooked()
|
||||
{
|
||||
this->reloadAtcStationsBooked();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "blackgui/runtimebasedcomponent.h"
|
||||
#include "blackgui/timerbasedcomponent.h"
|
||||
#include "blackmisc/avatcstation.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QModelIndex>
|
||||
|
||||
@@ -27,10 +29,6 @@ namespace BlackGui
|
||||
//! Timer for updating
|
||||
CTimerBasedComponent *getTimerComponent() { return this->m_timerComponent; }
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
void runtimeHasBeenSet() override;
|
||||
|
||||
public slots:
|
||||
//! Update users
|
||||
void update();
|
||||
@@ -47,6 +45,13 @@ namespace BlackGui
|
||||
//! Get METAR for given ICAO airport code
|
||||
void getMetar(const QString &airportIcaoCode = "");
|
||||
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
void runtimeHasBeenSet() override;
|
||||
|
||||
private slots:
|
||||
|
||||
//! Request new ATIS
|
||||
|
||||
@@ -68,4 +68,26 @@ namespace BlackGui
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CAtcStationListModel::changedAtcStationConnectionStatus(const CAtcStation &station, bool added)
|
||||
{
|
||||
if (station.getCallsign().isEmpty()) return;
|
||||
if (added)
|
||||
{
|
||||
if (this->m_container.contains(&CAtcStation::getCallsign, station.getCallsign()))
|
||||
{
|
||||
this->m_container.replaceIf(&CAtcStation::getCallsign, station.getCallsign(), station);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->insert(station);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
beginRemoveRows(QModelIndex(), 0, 0);
|
||||
this->m_container.removeIf(&CAtcStation::getCallsign, station.getCallsign());
|
||||
endRemoveRows();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace BlackGui
|
||||
//! Set station mode
|
||||
void setStationMode(AtcStationMode stationMode);
|
||||
|
||||
public slots:
|
||||
//! Used to quickly update single station (better response for the user)
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
private:
|
||||
AtcStationMode m_stationMode;
|
||||
};
|
||||
|
||||
@@ -21,4 +21,11 @@ namespace BlackGui
|
||||
Q_ASSERT(this->m_model);
|
||||
this->m_model->setStationMode(stationMode);
|
||||
}
|
||||
|
||||
void CAtcStationView::changedAtcStationConnectionStatus(const Aviation::CAtcStation &station, bool added)
|
||||
{
|
||||
this->m_model->changedAtcStationConnectionStatus(station, added);
|
||||
this->resizeColumnsToContents();
|
||||
this->resizeRowsToContents();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ namespace BlackGui
|
||||
|
||||
//! Set station mode
|
||||
void setStationMode(CAtcStationListModel::AtcStationMode stationMode);
|
||||
|
||||
public slots:
|
||||
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||
|
||||
};
|
||||
}
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user