refs #661, improved own model set handling

* fixed simulator selector
* added simulator selector to own model set component
* pinned last selections
* fixed model cache to use "getCopy"
This commit is contained in:
Klaus Basan
2016-05-24 18:24:23 +02:00
parent 0ff7791532
commit c0fda8687d
7 changed files with 62 additions and 21 deletions

View File

@@ -62,10 +62,12 @@ namespace BlackGui
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuOrderable);
ui->tvp_OwnModelSet->setSorting(CAircraftModel::IndexOrderString);
ui->tvp_OwnModelSet->initAsOrderable();
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
connect(&this->m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::ps_modelChanged);
@@ -74,10 +76,13 @@ namespace BlackGui
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
if (sim.isSingleSimulator())
{
ui->tvp_OwnModelSet->updateContainerMaybeAsync(this->m_modelSetLoader.getAircraftModels());
// update display when all is set up
this->m_modelSetLoader.syncronizeCache(); // make sure data are loaded
QTimer::singleShot(500, [this, sim]()
{
this->ps_changeSimulator(sim);
});
}
const int c = this->m_modelSetLoader.getAircraftModelsCount();
this->ps_onRowCountChanged(c, ui->tvp_OwnModelSet->hasFilter());
}
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
@@ -294,7 +299,8 @@ namespace BlackGui
{
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
this->m_modelSetLoader.changeSimulator(simulator);
this->ui->le_Simulator->setText(simulator.toQString(true));
ui->le_Simulator->setText(simulator.toQString(true));
ui->comp_SimulatorSelector->setValue(simulator);
}
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>400</height>
<width>796</width>
<height>224</height>
</rect>
</property>
<property name="windowTitle">
@@ -64,7 +64,23 @@
<number>0</number>
</property>
<item>
<spacer name="hs_Buttons">
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
<property name="minimumSize">
<size>
<width>200</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_OwnModelSetButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -158,6 +174,12 @@
<extends>QTableView</extends>
<header>blackgui/views/aircraftmodelview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::Components::CSimulatorSelector</class>
<extends>QFrame</extends>
<header>blackgui/components/simulatorselector.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -84,15 +84,17 @@ namespace BlackGui
const CSimulatorInfo current(getValue());
if (simulator == current) { return; } // avoid unnecessary signals
// checkboxes
this->ui->cb_FSX->setChecked(simulator.fsx());
this->ui->cb_FS9->setChecked(simulator.fs9());
this->ui->cb_XPlane->setChecked(simulator.xplane());
this->ui->cb_P3D->setChecked(simulator.p3d());
if (simulator.fsx()) { this->ui->cb_FSX->setChecked(simulator.fsx()); return; }
if (simulator.fs9()) { this->ui->cb_FS9->setChecked(simulator.fs9()); return; }
if (simulator.xplane()) { this->ui->cb_XPlane->setChecked(simulator.xplane()); return; }
if (simulator.p3d()) { this->ui->cb_P3D->setChecked(simulator.p3d()); return; }
// radio buttons
if (simulator.fsx()) { this->ui->rb_FSX->setChecked(simulator.fsx()); return; }
if (simulator.fs9()) { this->ui->rb_FS9->setChecked(simulator.fs9()); return; }
if (simulator.xplane()) { this->ui->rb_XPlane->setChecked(simulator.xplane()); return; }
if (simulator.p3d()) { this->ui->rb_P3D->setChecked(simulator.p3d()); return; }
}
void CSimulatorSelector::setAll()