7 #include <QStringBuilder>
11 #include "ui_dbaircrafticaocomponent.h"
20 using namespace swift::misc::network;
21 using namespace swift::misc::aviation;
26 CDbAircraftIcaoComponent::CDbAircraftIcaoComponent(QWidget *parent)
31 ui->tvp_AircraftIcao->setResizeMode(CAircraftIcaoCodeView::ResizingOff);
33 ui->tvp_AircraftIcao->allowDragDrop(
true,
false);
34 ui->tvp_AircraftIcao->setFilterWidget(ui->filter_AircraftIcao);
35 ui->tvp_AircraftIcao->menuAddItems(CViewBaseNonTemplate::MenuCopy);
37 connect(ui->tvp_AircraftIcao, &CAircraftIcaoCodeView::requestNewBackendData,
this,
38 &CDbAircraftIcaoComponent::onReload);
39 connect(
sGui->
getWebDataServices(), &CWebDataServices::dataRead,
this, &CDbAircraftIcaoComponent::onIcaoRead,
40 Qt::QueuedConnection);
42 &CDbAircraftIcaoComponent::onEntityDownloadProgress, Qt::QueuedConnection);
43 this->onIcaoRead(CEntityFlags::AircraftIcaoEntity, CEntityFlags::ReadFinished,
56 return ui->tvp_AircraftIcao->selectDbKey(icao.
getDbKey());
59 void CDbAircraftIcaoComponent::onIcaoRead(CEntityFlags::Entity entity,
CEntityFlags::ReadState readState,
int count)
61 using namespace std::chrono_literals;
65 if (!entity.testFlag(CEntityFlags::AircraftIcaoEntity)) {
return; }
67 if (CEntityFlags::isFinishedReadState(readState))
69 this->
showOverlayHTMLMessage(QStringLiteral(
"Updating %1").arg(CEntityFlags::entitiesToString(entity)), 2s);
75 CEntityFlags::stateToString(readState),
80 void CDbAircraftIcaoComponent::onEntityDownloadProgress(CEntityFlags::Entity entity,
int logId,
int progress,
81 qint64 current, qint64 max,
const QUrl &url)
83 using namespace std::chrono_literals;
85 if (CEntityFlags::AircraftIcaoEntity != entity) {
return; }
90 void CDbAircraftIcaoComponent::onReload()
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 getAircraftIcaoCodesCount() const
Aircraft ICAO codes count.
swift::misc::aviation::CAircraftIcaoCodeList getAircraftIcaoCodes() const
Aircraft 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.
swift::gui::views::CAircraftIcaoCodeView * view() const
Get the view.
virtual ~CDbAircraftIcaoComponent()
Destructor.
bool selectAircraftIcao(const swift::misc::aviation::CAircraftIcaoCode &icao)
Select aircraft ICAO object.
void filter(const swift::misc::aviation::CAircraftIcaoCode &icao)
Filter by ICAO as default.
Aircraft ICAO codes view.
Value object for ICAO classification.
int getDbKey() const
Get DB key.
bool isLoadedFromDb() const
Loaded from DB.
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.