diff --git a/src/blackgui/components/dbdistributorcomponent.cpp b/src/blackgui/components/dbdistributorcomponent.cpp index aa8dc372d..4f9de6971 100644 --- a/src/blackgui/components/dbdistributorcomponent.cpp +++ b/src/blackgui/components/dbdistributorcomponent.cpp @@ -17,7 +17,7 @@ #include "blackmisc/simulation/simulatorinfo.h" #include -#include +#include #include using namespace BlackCore; @@ -40,7 +40,14 @@ namespace BlackGui ui->tvp_Distributors->setFilterWidget(ui->filter_Distributor); connect(ui->tvp_Distributors, &CDistributorView::requestNewBackendData, this, &CDbDistributorComponent::reload); - connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorComponent::onDistributorsRead, Qt::QueuedConnection); + connect(ui->pb_SelectAllFsFamily, &QPushButton::released, this, &CDbDistributorComponent::selectStandardModels); + connect(ui->pb_SelectXPlane, &QPushButton::released, this, &CDbDistributorComponent::selectStandardModels); + + if (sGui && sGui->getWebDataServices()) + { + connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorComponent::onDistributorsRead, Qt::QueuedConnection); + } + this->onDistributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getDistributorsCount()); } @@ -77,6 +84,30 @@ namespace BlackGui } } + void CDbDistributorComponent::selectStandardModels() + { + const QObject *s = QObject::sender(); + QSet keys; + if (s == ui->pb_SelectAllFsFamily) + { + this->filterBySimulator(CSimulatorInfo::AllFsFamily); + keys = CDistributor::standardAllFsFamily(); + } + else if (s == ui->pb_SelectXPlane) + { + this->filterBySimulator(CSimulatorInfo::XPLANE); + keys = QSet({ CDistributor::standardXPlane() }); + } + + // deferred because filter must first work and update + const QPointer myself(this); + QTimer::singleShot(2000, this, [ = ] + { + if (!myself || !sApp || sApp->isShuttingDown()) { return; } + ui->tvp_Distributors->selectDbKeys(keys); + }); + } + void CDbDistributorComponent::reload() { if (!sGui || sGui->isShuttingDown() || !sGui->hasWebDataServices()) { return; } diff --git a/src/blackgui/components/dbdistributorcomponent.h b/src/blackgui/components/dbdistributorcomponent.h index d90067f82..c01f741b6 100644 --- a/src/blackgui/components/dbdistributorcomponent.h +++ b/src/blackgui/components/dbdistributorcomponent.h @@ -63,6 +63,9 @@ namespace BlackGui //! Distributors have been read void onDistributorsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); + //! Select all FSX standard models + void selectStandardModels(); + //! Reload models void reload(); }; diff --git a/src/blackgui/components/dbdistributorcomponent.ui b/src/blackgui/components/dbdistributorcomponent.ui index 67ce071ea..c74f72980 100644 --- a/src/blackgui/components/dbdistributorcomponent.ui +++ b/src/blackgui/components/dbdistributorcomponent.ui @@ -38,20 +38,89 @@ 0 - - + + - 150 - 0 + 0 + 25 - - QFrame::StyledPanel - - - QFrame::Raised - + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + 150 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + FS standard + + + + + + + XPlane standard + + + + + + + @@ -85,6 +154,11 @@ 1 + + pb_SelectAllFsFamily + pb_SelectXPlane + tvp_Distributors +