6 #include <QStringBuilder>
8 #include "ui_dbaircraftcategorycomponent.h"
14 using namespace swift::misc::network;
15 using namespace swift::misc::aviation;
20 CDbAircraftCategoryComponent::CDbAircraftCategoryComponent(QWidget *parent)
26 ui->tvp_AircraftCategoryView->setResizeMode(CAircraftCategoryView::ResizingOff);
27 ui->tvp_AircraftCategoryView->allowDragDrop(
true,
false);
28 ui->tvp_AircraftCategoryView->menuAddItems(CViewBaseNonTemplate::MenuCopy);
31 connect(ui->tvp_AircraftCategoryView, &CAircraftCategoryView::requestNewBackendData,
this,
32 &CDbAircraftCategoryComponent::onReload);
34 &CDbAircraftCategoryComponent::onCategoryRead, Qt::QueuedConnection);
36 &CDbAircraftCategoryComponent::onEntityDownloadProgress, Qt::QueuedConnection);
37 this->onCategoryRead(CEntityFlags::AircraftCategoryEntity, CEntityFlags::ReadFinished,
43 void CDbAircraftCategoryComponent::onCategoryRead(CEntityFlags::Entity entity,
CEntityFlags::ReadState readState,
46 using namespace std::chrono_literals;
49 if (!entity.testFlag(CEntityFlags::AircraftCategoryEntity)) {
return; }
51 if (CEntityFlags::isFinishedReadState(readState))
53 this->
showOverlayHTMLMessage(QStringLiteral(
"Updating %1").arg(CEntityFlags::entitiesToString(entity)), 2s);
55 ui->tvp_AircraftCategoryView->updateContainerMaybeAsync(categories);
56 ui->tvp_AircraftCategoryTree->updateContainer(categories);
61 CEntityFlags::stateToString(readState),
66 void CDbAircraftCategoryComponent::onEntityDownloadProgress(CEntityFlags::Entity entity,
int logId,
int progress,
67 qint64 current, qint64 max,
const QUrl &url)
69 using namespace std::chrono_literals;
71 if (!entity.testFlag(CEntityFlags::AircraftCategoryEntity)) {
return; }
76 void CDbAircraftCategoryComponent::onReload()
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
int getAircraftCategoriesCount() const
Aircraft categories count.
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::CAircraftCategoryList getAircraftCategories() const
Aircraft categories.
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 ~CDbAircraftCategoryComponent()
Destructor.
Value object encapsulating a list of ICAO codes.
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.