Ref T246, added distributor selection to 1st model set

This commit is contained in:
Klaus Basan
2018-02-10 19:36:33 +01:00
parent 9ad8b9b980
commit b0f7e9e8f6
6 changed files with 58 additions and 19 deletions

View File

@@ -7,13 +7,14 @@
* contained in the LICENSE file.
*/
#include "blackcore/webdataservices.h"
#include "dbdistributorcomponent.h"
#include "ui_dbdistributorcomponent.h"
#include "blackgui/components/dbdistributorcomponent.h"
#include "blackgui/guiapplication.h"
#include "blackgui/views/distributorview.h"
#include "blackgui/views/viewbase.h"
#include "dbdistributorcomponent.h"
#include "ui_dbdistributorcomponent.h"
#include "blackcore/webdataservices.h"
#include "blackmisc/simulation/simulatorinfo.h"
#include <QFrame>
#include <QScopedPointer>
@@ -21,6 +22,7 @@
using namespace BlackCore;
using namespace BlackMisc::Network;
using namespace BlackMisc::Simulation;
using namespace BlackGui::Views;
namespace BlackGui
@@ -35,9 +37,11 @@ namespace BlackGui
this->setViewWithIndicator(ui->tvp_Distributors);
ui->tvp_Distributors->setResizeMode(CViewBaseNonTemplate::ResizingAuto);
ui->tvp_Distributors->allowDragDrop(true, false);
connect(ui->tvp_Distributors, &CDistributorView::requestNewBackendData, this, &CDbDistributorComponent::ps_reload);
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorComponent::ps_distributorsRead);
this->ps_distributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getDistributorsCount());
ui->tvp_Distributors->setFilterWidget(ui->filter_Distributor);
connect(ui->tvp_Distributors, &CDistributorView::requestNewBackendData, this, &CDbDistributorComponent::reload);
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbDistributorComponent::distributorsRead);
this->distributorsRead(CEntityFlags::DistributorEntity, CEntityFlags::ReadFinished, sGui->getWebDataServices()->getDistributorsCount());
}
CDbDistributorComponent::~CDbDistributorComponent()
@@ -48,7 +52,12 @@ namespace BlackGui
return ui->tvp_Distributors;
}
void CDbDistributorComponent::ps_distributorsRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
void CDbDistributorComponent::filterBySimulator(const CSimulatorInfo &simulator)
{
ui->filter_Distributor->setSimulator(simulator);
}
void CDbDistributorComponent::distributorsRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
{
Q_UNUSED(count);
if (entity.testFlag(CEntityFlags::DistributorEntity) && readState == CEntityFlags::ReadFinished)
@@ -57,7 +66,7 @@ namespace BlackGui
}
}
void CDbDistributorComponent::ps_reload()
void CDbDistributorComponent::reload()
{
if (!sGui) { return; }
sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(CEntityFlags::DistributorEntity);

View File

@@ -21,7 +21,9 @@
#include <QScopedPointer>
class QWidget;
namespace Ui { class CDbDistributorComponent; }
namespace BlackMisc { namespace Simulation { class CSimulatorInfo; }}
namespace BlackGui
{
namespace Views { class CDistributorView; }
@@ -42,22 +44,23 @@ namespace BlackGui
explicit CDbDistributorComponent(QWidget *parent = nullptr);
//! Destructor
~CDbDistributorComponent();
virtual ~CDbDistributorComponent();
//! Get the view
BlackGui::Views::CDistributorView *view() const;
private slots:
//! Distributors have been read
void ps_distributorsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
//! Reload models
void ps_reload();
//! Filter by simulator
void filterBySimulator(const BlackMisc::Simulation::CSimulatorInfo &simulator);
private:
QScopedPointer<Ui::CDbDistributorComponent> ui;
};
//! Distributors have been read
void distributorsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
//! Reload models
void reload();
};
} // ns
} // ns

View File

@@ -38,8 +38,14 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_Selector">
<item alignment="Qt::AlignLeft">
<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>
@@ -72,6 +78,12 @@
<extends>QTableView</extends>
<header>blackgui/views/distributorview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Filters::CDistributorFilterBar</class>
<extends>QFrame</extends>
<header>blackgui/filters/distributorfilterbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -52,6 +52,8 @@ namespace BlackGui
Q_ASSERT_X(m_modelSetDialog, Q_FUNC_INFO, "No model set dialog");
m_modelSetDialog->setSimulator(simulator);
ui->comp_Distributors->filterBySimulator(simulator);
// kind of hack, but simplest solution
// we us the loader of the components directly,
// avoid to fully init a loader logic here

View File

@@ -20,7 +20,7 @@
<item row="0" column="1">
<widget class="QLabel" name="lbl_Explaination">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;The model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:9pt; font-weight:600; color:#ff0000;&quot;&gt;WORK IN PROGRESS, not finished &lt;/span&gt;&lt;span style=&quot; font-size:9pt;&quot;&gt;The model set defines which aircraft you will use in the simulator. From all models you have installed on your disk you can select a subset actually being used.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
@@ -158,6 +158,12 @@
</item>
<item row="4" column="1">
<widget class="BlackGui::Components::CDbDistributorComponent" name="comp_Distributors">
<property name="minimumSize">
<size>
<width>0</width>
<height>125</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>

View File

@@ -178,6 +178,13 @@ BlackGui--Components--CDbOwnModelSetDialog
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
BlackGui--Components--CFirstModelSetComponent
BlackGui--Components--CDbDistributorComponent
{
background: black; /* background is background color here */
background-image: url(:/textures/icons/textures/texture-inner.jpg);
}
/* default for buttons */
QToolButton {
background-color: transparent; /* transparent tool buttons */