mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
refs #709, smaller version of status bar component
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackgui/components/infobarwebreadersstatuscomponent.h"
|
||||
#include "blackgui/guiapplication.h"
|
||||
#include "blackgui/led.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "ui_infobarwebreadersstatuscomponent.h"
|
||||
|
||||
@@ -25,61 +24,61 @@ namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CInfoBarWebReadersStatusComponent::CInfoBarWebReadersStatusComponent(QWidget *parent) :
|
||||
QFrame(parent), ui(new Ui::CInfoBarWebReadersStatusComponent)
|
||||
CInfoBarWebReadersStatusBase::CInfoBarWebReadersStatusBase(QWidget *parent) : QFrame(parent)
|
||||
{ }
|
||||
|
||||
void CInfoBarWebReadersStatusBase::init()
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "No sGui");
|
||||
Q_ASSERT_X(sGui->hasWebDataServices(), Q_FUNC_INFO, "No web data services");
|
||||
ui->setupUi(this);
|
||||
this->initLeds();
|
||||
bool c = connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusComponent::ps_checkServerAndData);
|
||||
bool c = connect(&m_timer, &QTimer::timeout, this, &CInfoBarWebReadersStatusBase::ps_checkServerAndData);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
m_timer.setInterval(30 * 1000);
|
||||
m_timer.start();
|
||||
m_timer.setObjectName("CInfoBarWebReadersStatusComponent::CheckSwiftDbTimer");
|
||||
c = connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusComponent::ps_dataRead);
|
||||
m_timer.setObjectName("CInfoBarWebReadersStatusBase::CheckSwiftDbTimer");
|
||||
c = connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CInfoBarWebReadersStatusBase::ps_dataRead);
|
||||
Q_ASSERT_X(c, Q_FUNC_INFO, "Failed connect");
|
||||
Q_UNUSED(c);
|
||||
}
|
||||
|
||||
CInfoBarWebReadersStatusComponent::~CInfoBarWebReadersStatusComponent()
|
||||
CInfoBarWebReadersStatusBase::~CInfoBarWebReadersStatusBase()
|
||||
{
|
||||
m_timer.stop();
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::initLeds()
|
||||
void CInfoBarWebReadersStatusBase::initLeds()
|
||||
{
|
||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||
this->ui->led_DataReady->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "all data ready", "data missing", 14);
|
||||
this->led_DataReady->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "all data ready", "data missing", 14);
|
||||
|
||||
this->ui->led_IcaoAircraft->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->ui->led_IcaoAirline->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->ui->led_Countries->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
|
||||
this->ui->led_Models->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->ui->led_Liveries->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->ui->led_Distributors->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_IcaoAircraft->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_IcaoAirline->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_Countries->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_Models->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_Liveries->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
this->led_Distributors->setValues(CLedWidget::Yellow, CLedWidget::Black, CLedWidget::Red, shape, "reading", "idle", "failed", 14);
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::ps_dataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
void CInfoBarWebReadersStatusBase::ps_dataRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
QList<CLedWidget *> leds = this->entityToLeds(entity);
|
||||
if (!leds.isEmpty()) { this->setLedReadStates(leds, readState); }
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::ps_checkServerAndData()
|
||||
void CInfoBarWebReadersStatusBase::ps_checkServerAndData()
|
||||
{
|
||||
bool swift =
|
||||
sGui &&
|
||||
sGui->getWebDataServices()->canConnectSwiftDb();
|
||||
this->ui->led_SwiftDb->setOn(swift);
|
||||
this->led_SwiftDb->setOn(swift);
|
||||
|
||||
bool allData = hasAllData();
|
||||
this->ui->led_DataReady->setOn(allData);
|
||||
this->led_DataReady->setOn(allData);
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::setLedReadStates(const QList<CLedWidget *> &leds, CEntityFlags::ReadState readState)
|
||||
void CInfoBarWebReadersStatusBase::setLedReadStates(const QList<CLedWidget *> &leds, CEntityFlags::ReadState readState)
|
||||
{
|
||||
for (CLedWidget *led : leds)
|
||||
{
|
||||
@@ -87,7 +86,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusComponent::setLedReadState(CLedWidget *led, CEntityFlags::ReadState readState)
|
||||
void CInfoBarWebReadersStatusBase::setLedReadState(CLedWidget *led, CEntityFlags::ReadState readState)
|
||||
{
|
||||
Q_ASSERT_X(led, Q_FUNC_INFO, "no LED");
|
||||
int blinkTime = 2.5 * 1000;
|
||||
@@ -109,27 +108,50 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
QList<CLedWidget *> CInfoBarWebReadersStatusComponent::entityToLeds(CEntityFlags::Entity entity) const
|
||||
QList<CLedWidget *> CInfoBarWebReadersStatusBase::entityToLeds(CEntityFlags::Entity entity) const
|
||||
{
|
||||
QList<CLedWidget *> leds;
|
||||
if (entity.testFlag(CEntityFlags::CountryEntity)) { leds << ui->led_Countries; }
|
||||
if (entity.testFlag(CEntityFlags::DistributorEntity)) { leds << ui->led_Distributors; }
|
||||
if (entity.testFlag(CEntityFlags::AircraftIcaoEntity)) { leds << ui->led_IcaoAircraft; }
|
||||
if (entity.testFlag(CEntityFlags::AirlineIcaoEntity)) { leds << ui->led_IcaoAirline; }
|
||||
if (entity.testFlag(CEntityFlags::LiveryEntity)) { leds << ui->led_Liveries; }
|
||||
if (entity.testFlag(CEntityFlags::ModelEntity)) { leds << ui->led_Models; }
|
||||
if (entity.testFlag(CEntityFlags::CountryEntity)) { leds << this->led_Countries; }
|
||||
if (entity.testFlag(CEntityFlags::DistributorEntity)) { leds << this->led_Distributors; }
|
||||
if (entity.testFlag(CEntityFlags::AircraftIcaoEntity)) { leds << this->led_IcaoAircraft; }
|
||||
if (entity.testFlag(CEntityFlags::AirlineIcaoEntity)) { leds << this->led_IcaoAirline; }
|
||||
if (entity.testFlag(CEntityFlags::LiveryEntity)) { leds << this->led_Liveries; }
|
||||
if (entity.testFlag(CEntityFlags::ModelEntity)) { leds << this->led_Models; }
|
||||
return leds;
|
||||
}
|
||||
|
||||
bool CInfoBarWebReadersStatusComponent::hasAllData() const
|
||||
bool CInfoBarWebReadersStatusBase::hasAllData() const
|
||||
{
|
||||
if (!sGui) { return false; }
|
||||
return sGui->getWebDataServices()->getAirlineIcaoCodesCount() > 0 &&
|
||||
sGui->getWebDataServices()->getAircraftIcaoCodesCount() > 0 &&
|
||||
sGui->getWebDataServices()->getDistributorsCount() > 0 &&
|
||||
sGui->getWebDataServices()->getModelsCount() > 0 &&
|
||||
sGui->getWebDataServices()->getLiveriesCount() > 0;
|
||||
sGui->getWebDataServices()->getLiveriesCount() > 0 &&
|
||||
sGui->getWebDataServices()->getCountriesCount() > 0;
|
||||
}
|
||||
|
||||
void CInfoBarWebReadersStatusBase::setLeds(CLedWidget *ledDb, CLedWidget *dataReady, CLedWidget *ledIcaoAircraft, CLedWidget *ledIcaoAirline, CLedWidget *ledCountries, CLedWidget *ledDistributors, CLedWidget *ledLiveries, CLedWidget *ledModels)
|
||||
{
|
||||
this->led_SwiftDb = ledDb;
|
||||
this->led_DataReady = dataReady;
|
||||
this->led_IcaoAircraft = ledIcaoAircraft;
|
||||
this->led_IcaoAirline = ledIcaoAirline;
|
||||
this->led_Countries = ledCountries;
|
||||
this->led_Distributors = ledDistributors;
|
||||
this->led_Liveries = ledLiveries;
|
||||
this->led_Models = ledModels;
|
||||
}
|
||||
|
||||
CInfoBarWebReadersStatusComponent::CInfoBarWebReadersStatusComponent(QWidget *parent) :
|
||||
CInfoBarWebReadersStatusBase(parent), ui(new Ui::CInfoBarWebReadersStatusComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setLeds(ui->led_SwiftDb, ui->led_DataReady, ui->led_IcaoAircraft, ui->led_IcaoAirline, ui->led_Countries, ui->led_Distributors, ui->led_Liveries, ui->led_Models);
|
||||
this->init();
|
||||
}
|
||||
|
||||
CInfoBarWebReadersStatusComponent::~CInfoBarWebReadersStatusComponent()
|
||||
{ }
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user