mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +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());
|
Q_ASSERT(this->getIContextNetwork());
|
||||||
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline);
|
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, this, &CAtcStationComponent::changedAtcStationsOnline);
|
||||||
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked);
|
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, this, &CAtcStationComponent::changedAtcStationsBooked);
|
||||||
|
this->connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationOnlineConnectionStatus, this, &CAtcStationComponent::changedAtcStationOnlineConnectionStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAtcStationComponent::update()
|
void CAtcStationComponent::update()
|
||||||
@@ -79,9 +80,16 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CAtcStationComponent::changedAtcStationsOnline()
|
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();
|
this->m_timestampOnlineStationsChanged = QDateTime::currentDateTimeUtc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAtcStationComponent::changedAtcStationOnlineConnectionStatus(const CAtcStation &station, bool added)
|
||||||
|
{
|
||||||
|
this->ui->tvp_AtcStationsOnline->changedAtcStationConnectionStatus(station, added);
|
||||||
|
}
|
||||||
|
|
||||||
void CAtcStationComponent::changedAtcStationsBooked()
|
void CAtcStationComponent::changedAtcStationsBooked()
|
||||||
{
|
{
|
||||||
this->reloadAtcStationsBooked();
|
this->reloadAtcStationsBooked();
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include "blackgui/runtimebasedcomponent.h"
|
#include "blackgui/runtimebasedcomponent.h"
|
||||||
#include "blackgui/timerbasedcomponent.h"
|
#include "blackgui/timerbasedcomponent.h"
|
||||||
|
#include "blackmisc/avatcstation.h"
|
||||||
|
|
||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
|
||||||
@@ -27,10 +29,6 @@ namespace BlackGui
|
|||||||
//! Timer for updating
|
//! Timer for updating
|
||||||
CTimerBasedComponent *getTimerComponent() { return this->m_timerComponent; }
|
CTimerBasedComponent *getTimerComponent() { return this->m_timerComponent; }
|
||||||
|
|
||||||
protected:
|
|
||||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
|
||||||
void runtimeHasBeenSet() override;
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Update users
|
//! Update users
|
||||||
void update();
|
void update();
|
||||||
@@ -47,6 +45,13 @@ namespace BlackGui
|
|||||||
//! Get METAR for given ICAO airport code
|
//! Get METAR for given ICAO airport code
|
||||||
void getMetar(const QString &airportIcaoCode = "");
|
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:
|
private slots:
|
||||||
|
|
||||||
//! Request new ATIS
|
//! Request new ATIS
|
||||||
|
|||||||
@@ -68,4 +68,26 @@ namespace BlackGui
|
|||||||
break;
|
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
|
//! Set station mode
|
||||||
void setStationMode(AtcStationMode stationMode);
|
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:
|
private:
|
||||||
AtcStationMode m_stationMode;
|
AtcStationMode m_stationMode;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,4 +21,11 @@ namespace BlackGui
|
|||||||
Q_ASSERT(this->m_model);
|
Q_ASSERT(this->m_model);
|
||||||
this->m_model->setStationMode(stationMode);
|
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
|
//! Set station mode
|
||||||
void setStationMode(CAtcStationListModel::AtcStationMode stationMode);
|
void setStationMode(CAtcStationListModel::AtcStationMode stationMode);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//! \copydoc CAtcStationListModel::changedAtcStationConnectionStatus
|
||||||
|
void changedAtcStationConnectionStatus(const BlackMisc::Aviation::CAtcStation &station, bool added);
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
Reference in New Issue
Block a user