6 #include <QStringBuilder>
9 #include "ui_dbliverycomponent.h"
18 using namespace swift::misc::aviation;
19 using namespace swift::misc::network;
23 CDbLiveryComponent::CDbLiveryComponent(QWidget *parent)
28 connect(ui->tvp_Liveries, &CLiveryView::requestNewBackendData,
this, &CDbLiveryComponent::onReload);
31 ui->tvp_Liveries->setFilterWidget(ui->filter_Livery);
32 ui->tvp_Liveries->allowDragDrop(
true,
false);
33 ui->tvp_Liveries->menuAddItems(CViewBaseNonTemplate::MenuCopy);
35 connect(
sGui->
getWebDataServices(), &CWebDataServices::dataRead,
this, &CDbLiveryComponent::onLiveriesRead,
36 Qt::QueuedConnection);
38 &CDbLiveryComponent::onEntityDownloadProgress, Qt::QueuedConnection);
39 this->onLiveriesRead(CEntityFlags::LiveryEntity, CEntityFlags::ReadFinished,
51 void CDbLiveryComponent::onLiveriesRead(CEntityFlags::Entity entity,
CEntityFlags::ReadState readState,
int count)
53 using namespace std::chrono_literals;
57 if (!entity.testFlag(CEntityFlags::LiveryEntity)) {
return; }
59 if (CEntityFlags::isFinishedReadState(readState))
61 this->
showOverlayHTMLMessage(QStringLiteral(
"Updating %1").arg(CEntityFlags::entitiesToString(entity)), 2s);
67 CEntityFlags::stateToString(readState),
72 void CDbLiveryComponent::onEntityDownloadProgress(CEntityFlags::Entity entity,
int logId,
int progress,
73 qint64 current, qint64 max,
const QUrl &url)
75 using namespace std::chrono_literals;
77 if (!entity.testFlag(CEntityFlags::LiveryEntity)) {
return; }
82 void CDbLiveryComponent::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.
swift::misc::aviation::CLiveryList getLiveries() const
Liveries.
int getLiveriesCount() const
Liveries count.
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.
void filterByAirline(const swift::misc::aviation::CAirlineIcaoCode &icao)
Filter by airline ICAO.
swift::gui::views::CLiveryView * view()
The livery view.
void filter(const swift::misc::aviation::CLivery &livery)
Filter by livery.
virtual ~CDbLiveryComponent()
Destructor.
Value object for ICAO classification.
Value object encapsulating information about an airpot.
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.