Allow to select FSX/P3D or XPlane standard models

This commit is contained in:
Klaus Basan
2018-11-14 04:41:47 +01:00
parent 21506293f3
commit 5b4960ec5b
3 changed files with 120 additions and 12 deletions

View File

@@ -17,7 +17,7 @@
#include "blackmisc/simulation/simulatorinfo.h"
#include <QFrame>
#include <QScopedPointer>
#include <QPointer>
#include <QtGlobal>
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<QString> 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<QString>({ CDistributor::standardXPlane() });
}
// deferred because filter must first work and update
const QPointer<CDbDistributorComponent> 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; }