7 #include <QStringBuilder>
10 #include "ui_dbairlineicaocomponent.h"
19 using namespace swift::misc::network;
25 CDbAirlineIcaoComponent::CDbAirlineIcaoComponent(QWidget *parent)
28 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Missing sGui");
32 ui->tvp_AirlineIcao->setResizeMode(CAirlineIcaoCodeView::ResizingOff);
33 ui->tvp_AirlineIcao->setResizeMode(CAirlineIcaoCodeView::ResizingOff);
34 ui->tvp_AirlineIcao->allowDragDrop(
true,
false);
35 ui->tvp_AirlineIcao->setFilterWidget(ui->filter_AirlineIcao);
36 ui->tvp_AirlineIcao->menuAddItems(CViewBaseNonTemplate::MenuCopy);
38 connect(ui->tvp_AirlineIcao, &CAirlineIcaoCodeView::requestNewBackendData,
this,
39 &CDbAirlineIcaoComponent::onReload);
40 connect(
sGui->
getWebDataServices(), &CWebDataServices::dataRead,
this, &CDbAirlineIcaoComponent::onIcaoRead,
41 Qt::QueuedConnection);
43 &CDbAirlineIcaoComponent::onEntityDownloadProgress, Qt::QueuedConnection);
44 this->onIcaoRead(CEntityFlags::AirlineIcaoEntity, CEntityFlags::ReadFinished,
52 void CDbAirlineIcaoComponent::onIcaoRead(CEntityFlags::Entity entity,
CEntityFlags::ReadState readState,
int count,
55 using namespace std::chrono_literals;
60 if (!entity.testFlag(CEntityFlags::AirlineIcaoEntity)) {
return; }
62 if (CEntityFlags::isFinishedReadState(readState))
64 this->
showOverlayHTMLMessage(QStringLiteral(
"Updating %1").arg(CEntityFlags::entitiesToString(entity)), 2s);
70 CEntityFlags::stateToString(readState),
75 void CDbAirlineIcaoComponent::onEntityDownloadProgress(CEntityFlags::Entity entity,
int logId,
int progress,
76 qint64 current, qint64 max,
const QUrl &url)
78 using namespace std::chrono_literals;
79 if (!entity.testFlag(CEntityFlags::AirlineIcaoEntity)) {
return; }
84 void CDbAirlineIcaoComponent::onReload()
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
swift::misc::network::CEntityFlags::Entity triggerLoadingDirectlyFromDb(swift::misc::network::CEntityFlags::Entity whatToRead, const QDateTime &newerThan=QDateTime())
Trigger reload from DB, loads the DB data and bypasses the caches checks and info objects.
int getAirlineIcaoCodesCount() const
Airline ICAO codes count.
swift::misc::aviation::CAirlineIcaoCodeList getAirlineIcaoCodes() const
Airline ICAO codes.
void setViewWithIndicator(swift::gui::views::CViewBaseNonTemplate *viewWithIndicator)
Set the corresponding view.
bool showOverlayHTMLMessage(const QString &htmlMessage, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
HTML message.
void showDownloadProgress(int progress, qint64 current, qint64 max, const QUrl &url, std::chrono::milliseconds timeout=std::chrono::milliseconds(0))
Download progress.
Using this class provides a QFrame with the overlay functionality already integrated.
virtual ~CDbAirlineIcaoComponent()
Destructor.
swift::gui::views::CAirlineIcaoCodeView * view() const
Get the view.
Aircraft ICAO codes view.
ReadState
State of operation.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Backend services of the swift project, like dealing with the network or the simulators.
High level reusable GUI components.
Views, mainly QTableView.