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; }

View File

@@ -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();
};

View File

@@ -38,20 +38,89 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignLeft">
<widget class="BlackGui::Filters::CDistributorFilterBar" name="filter_Distributor">
<item>
<widget class="QFrame" name="fr_TopBar">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="hl_TopBar">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="BlackGui::Filters::CDistributorFilterBar" name="filter_Distributor">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<spacer name="hs_TopBar">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="wi_SimulatorSpecific" native="true">
<layout class="QHBoxLayout" name="hl_FSXSpecific">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pb_SelectAllFsFamily">
<property name="text">
<string>FS standard</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SelectXPlane">
<property name="text">
<string>XPlane standard</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
@@ -85,6 +154,11 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>pb_SelectAllFsFamily</tabstop>
<tabstop>pb_SelectXPlane</tabstop>
<tabstop>tvp_Distributors</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>