refs #253, faster updates of ATC stations by changedAtcStationConnectionStatus(const

This commit is contained in:
Klaus Basan
2014-05-28 13:14:56 +02:00
parent 421cd61195
commit f1ac4deda6
6 changed files with 55 additions and 4 deletions

View File

@@ -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();

View File

@@ -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

View File

@@ -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();
}
}
}

View File

@@ -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;
};

View File

@@ -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();
}
}

View File

@@ -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