10 #include "ui_dbdistributorcomponent.h"
19 using namespace swift::misc::network;
20 using namespace swift::misc::simulation;
25 CDbDistributorComponent::CDbDistributorComponent(QWidget *parent)
30 ui->tvp_Distributors->setResizeMode(CViewBaseNonTemplate::ResizingAuto);
31 ui->tvp_Distributors->allowDragDrop(
true,
false);
32 ui->tvp_Distributors->setFilterWidget(ui->filter_Distributor);
34 connect(ui->tvp_Distributors, &CDistributorView::requestNewBackendData,
this, &CDbDistributorComponent::reload);
35 connect(ui->pb_SelectAllFsFamily, &QPushButton::released,
this, &CDbDistributorComponent::selectStandardModels);
36 connect(ui->pb_SelectXPlaneBB, &QPushButton::released,
this, &CDbDistributorComponent::selectStandardModels);
37 connect(ui->pb_SelectXplaneXCSL, &QPushButton::released,
this, &CDbDistributorComponent::selectStandardModels);
42 &CDbDistributorComponent::onDistributorsRead, Qt::QueuedConnection);
43 this->onDistributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished,
54 ui->filter_Distributor->setSimulator(simulator);
59 return ui->tvp_Distributors->selectedObjects();
64 if (ui->tvp_Distributors->isEmpty() || !distributor.
isLoadedFromDb()) {
return false; }
65 return ui->tvp_Distributors->selectDbKey(distributor.
getDbKey());
70 void CDbDistributorComponent::onDistributorsRead(CEntityFlags::Entity entity,
CEntityFlags::ReadState readState,
75 if (entity.testFlag(CEntityFlags::DistributorEntity) && CEntityFlags::isFinishedReadState(readState))
78 ui->tvp_Distributors->updateContainer(distributors);
82 void CDbDistributorComponent::selectStandardModels()
84 const QObject *s = QObject::sender();
86 if (s == ui->pb_SelectAllFsFamily)
89 keys = CDistributor::standardAllFsFamily();
91 else if (s == ui->pb_SelectXPlaneBB)
94 keys = QSet<QString>({ CDistributor::xplaneBlueBell() });
96 else if (s == ui->pb_SelectXplaneXCSL)
99 keys = QSet<QString>({ CDistributor::xplaneXcsl() });
103 const QPointer<CDbDistributorComponent> myself(
this);
106 ui->tvp_Distributors->selectDbKeys(keys);
110 void CDbDistributorComponent::reload()
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 getDistributorsCount() const
Distributors count.
swift::misc::simulation::CDistributorList getDistributors() const
Distributors.
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.
swift::gui::views::CDistributorView * view() const
Get the view.
bool selectDistributor(const swift::misc::simulation::CDistributor &distributor)
Select the given distributor.
bool hasSelectedDistributors() const
Having selected distributors.
void filterBySimulator(const swift::misc::simulation::CSimulatorInfo &simulator)
Filter by simulator.
virtual ~CDbDistributorComponent()
Destructor.
swift::misc::simulation::CDistributorList getSelectedDistributors() const
The selected distributors.
bool isLoadedFromDb() const
Loaded from DB.
const QString & getDbKey() const
Get DB key.
ReadState
State of operation.
Value object encapsulating information of software distributor.
Value object encapsulating a list of distributors.
Simple hardcoded info about the corresponding simulator.
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.
auto singleShot(int msec, QObject *target, F &&task)
Starts a single-shot timer which will call a task in the thread of the given object when it times out...