7 #include <QStringBuilder>
11 #include "ui_dbmodelcomponent.h"
23 using namespace swift::misc::network;
24 using namespace swift::misc::simulation;
31 CDbModelComponent::CDbModelComponent(QWidget *parent)
34 Q_ASSERT_X(
sGui, Q_FUNC_INFO,
"Missing sGui");
39 ui->tvp_AircraftModel->setAircraftModelMode(CAircraftModelListModel::Database);
40 ui->tvp_AircraftModel->menuAddItems(CAircraftModelView::MenuStashing);
41 ui->tvp_AircraftModel->menuAddItems(CViewBaseNonTemplate::MenuCopy);
42 ui->tvp_AircraftModel->menuRemoveItems(CAircraftModelView::MenuHighlightStashed);
45 ui->tvp_AircraftModel->setFilterWidget(ui->filter_AircraftModelFilter);
46 ui->tvp_AircraftModel->allowDragDrop(
true,
false);
48 connect(ui->tvp_AircraftModel, &CAircraftModelView::requestNewBackendData,
this, &CDbModelComponent::onReload);
51 Qt::QueuedConnection);
54 &CDbModelComponent::onEntityDownloadProgress, Qt::QueuedConnection);
55 this->onModelsRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished,
71 if (!ui->tvp_AircraftModel->isEmpty())
73 CAircraftModel model(ui->tvp_AircraftModel->container().latestObject());
82 using namespace std::chrono_literals;
87 if (!entity.testFlag(CEntityFlags::ModelEntity)) {
return; }
89 if (CEntityFlags::isFinishedReadState(readState))
91 this->
showOverlayHTMLMessage(QStringLiteral(
"Updating %1").arg(CEntityFlags::entitiesToString(entity)), 2s);
97 CEntityFlags::stateToString(readState),
102 void CDbModelComponent::onReload()
108 void CDbModelComponent::onStyleSheetChanged()
113 void CDbModelComponent::onEntityDownloadProgress(CEntityFlags::Entity entity,
int logId,
int progress,
114 qint64 current, qint64 max,
const QUrl &url)
116 using namespace std::chrono_literals;
117 if (!entity.testFlag(CEntityFlags::ModelEntity)) {
return; }
SWIFT_CORE_EXPORT swift::core::CApplication * sApp
Single instance of application object.
bool hasWebDataServices() const
Web data services available?
bool isShuttingDown() const
Is application shutting down?
CWebDataServices * getWebDataServices() const
Get the web data services.
int getModelsCount() const
Models count.
swift::misc::simulation::CAircraftModelList getModels() const
Models.
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.
void setViewWithIndicator(swift::gui::views::CViewBaseNonTemplate *viewWithIndicator)
Set the corresponding view.
void styleSheetsChanged()
Style sheet changed.
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.
Allows subcomponents to gain access to model component.
void requestUpdatedData()
Load new data.
virtual ~CDbModelComponent()
Destructor.
bool hasModels() const
Models loaded?
void requestStash(const swift::misc::simulation::CAircraftModelList &models)
Request to stash the selected models.
QDateTime getUtcTimestamp() const
Get timestamp.
ReadState
State of operation.
Aircraft model (used by another pilot, my models on disk)
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.
Models to be used with views, mainly QTableView.
Views, mainly QTableView.
Free functions in swift::misc.