refs #618, functions allowing to validate and modify loaded JSON data

* models can be reduced to one simulator
* a JSON model list can be loaded and the simulator derived from the distribution
This commit is contained in:
Klaus Basan
2016-03-28 00:56:22 +02:00
parent 5c1ce9763e
commit fe677a5594
6 changed files with 131 additions and 35 deletions

View File

@@ -35,12 +35,14 @@ namespace BlackGui
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows | CAircraftModelView::MenuClear);
ui->tvp_OwnModelSet->addFilterDialog();
ui->tvp_OwnModelSet->setCustomMenu(new CLoadModelsMenu(this));
ui->tvp_OwnModelSet->setJsonLoad(CAircraftModelView::AllowOnlySingleSimulator | CAircraftModelView::ReduceToOneSimulator);
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(&this->m_modelSetLoader, &CModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::rowCountChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged);
connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::ps_onJsonDataLoaded);
this->ps_onRowCountChanged(ui->tvp_OwnModelSet->rowCount(), ui->tvp_OwnModelSet->hasFilter());
}
@@ -163,7 +165,6 @@ namespace BlackGui
}
else if (sender == ui->pb_LoadExistingSet)
{
this->ui->tvp_OwnModelSet->setLoadValidation(CAircraftModelView::AllowOnlySingeSimulator);
this->ui->tvp_OwnModelSet->showFileLoadDialog();
}
else if (sender == ui->pb_SaveAsSetForSimulator)
@@ -210,6 +211,14 @@ namespace BlackGui
}
}
void CDbOwnModelSetComponent::ps_onJsonDataLoaded(const CSimulatorInfo &simulator)
{
if (simulator.isSingleSimulator())
{
this->setSimulator(simulator);
}
}
void CDbOwnModelSetComponent::setSaveFileName(const CSimulatorInfo &sim)
{
Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");

View File

@@ -83,6 +83,9 @@ namespace BlackGui
//! View has changed row count
void ps_onRowCountChanged(int count, bool withFilter);
//! JSON data have been loaded from disk
void ps_onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator);
private:
//! Default file name
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);