mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
refs #576, updated mapping & stash components / form for auto stashing
* made some functions public * removed unused signal * comments * consolidate functions
This commit is contained in:
@@ -57,7 +57,7 @@ namespace BlackGui
|
|||||||
connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this, &CDbMappingComponent::ps_onModelsSuccessfullyPublished);
|
connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this, &CDbMappingComponent::ps_onModelsSuccessfullyPublished);
|
||||||
|
|
||||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingSimulatorModelMenu(this));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingOwnSimulatorModelMenu(this));
|
||||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CModelStashTools(this));
|
ui->tvp_OwnAircraftModels->setCustomMenu(new CModelStashTools(this));
|
||||||
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->m_cachedOwnModels.get());
|
ui->tvp_OwnAircraftModels->updateContainerMaybeAsync(this->m_cachedOwnModels.get());
|
||||||
|
|
||||||
@@ -92,6 +92,7 @@ namespace BlackGui
|
|||||||
connect(&m_vPilotReader, &CVPilotRulesReader::readFinished, this, &CDbMappingComponent::ps_onLoadVPilotDataFinished);
|
connect(&m_vPilotReader, &CVPilotRulesReader::readFinished, this, &CDbMappingComponent::ps_onLoadVPilotDataFinished);
|
||||||
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestStash, this, &CDbMappingComponent::stashSelectedModels);
|
||||||
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::toggledHighlightStashedModels, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||||
|
connect(this->ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestUpdate, this, &CDbMappingComponent::ps_requestVPilotDataUpdate);
|
||||||
|
|
||||||
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true));
|
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true));
|
||||||
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CModelStashTools(this));
|
this->ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CModelStashTools(this));
|
||||||
@@ -259,13 +260,14 @@ namespace BlackGui
|
|||||||
return ui->comp_StashAircraft->getStashedModelStrings();
|
return ui->comp_StashAircraft->getStashedModelStrings();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CDbMappingComponent::getOwnModelForModelString(const QString &modelString)
|
CAircraftModel CDbMappingComponent::getOwnModelForModelString(const QString &modelString) const
|
||||||
{
|
{
|
||||||
return m_cachedOwnModels.get().findFirstByModelString(modelString);
|
return m_cachedOwnModels.get().findFirstByModelString(modelString);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbMappingComponent::TabIndex CDbMappingComponent::currentTabIndex() const
|
CDbMappingComponent::TabIndex CDbMappingComponent::currentTabIndex() const
|
||||||
{
|
{
|
||||||
|
if (!ui->tw_ModelsToBeMapped) { return CDbMappingComponent::NoValidTab; }
|
||||||
int t = ui->tw_ModelsToBeMapped->currentIndex();
|
int t = ui->tw_ModelsToBeMapped->currentIndex();
|
||||||
return static_cast<TabIndex>(t);
|
return static_cast<TabIndex>(t);
|
||||||
}
|
}
|
||||||
@@ -312,7 +314,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CDbMappingComponent::ps_displayAutoStashingDialog()
|
void CDbMappingComponent::ps_displayAutoStashingDialog()
|
||||||
{
|
{
|
||||||
this->m_autostashDialog->setVisible(true);
|
this->m_autostashDialog->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::ps_removeDbModelsFromView()
|
void CDbMappingComponent::ps_removeDbModelsFromView()
|
||||||
@@ -325,6 +327,11 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::ps_toggleAutoFiltering()
|
||||||
|
{
|
||||||
|
this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews;
|
||||||
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::resizeForSelect()
|
void CDbMappingComponent::resizeForSelect()
|
||||||
{
|
{
|
||||||
int h = this->height();
|
int h = this->height();
|
||||||
@@ -406,6 +413,11 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::ps_requestVPilotDataUpdate()
|
||||||
|
{
|
||||||
|
this->ps_onVPilotCacheChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::ps_onStashedModelsChanged()
|
void CDbMappingComponent::ps_onStashedModelsChanged()
|
||||||
{
|
{
|
||||||
bool hlvp = this->ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModelStrings();
|
bool hlvp = this->ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModelStrings();
|
||||||
@@ -514,9 +526,12 @@ namespace BlackGui
|
|||||||
else { this->ui->editor_Distributor->clear(); }
|
else { this->ui->editor_Distributor->clear(); }
|
||||||
|
|
||||||
// request filtering
|
// request filtering
|
||||||
emit filterByLivery(model.getLivery());
|
if (this->m_autoFilterInDbViews)
|
||||||
emit filterByAircraftIcao(model.getAircraftIcaoCode());
|
{
|
||||||
emit filterByDistributor(model.getDistributor());
|
emit filterByLivery(model.getLivery());
|
||||||
|
emit filterByAircraftIcao(model.getAircraftIcaoCode());
|
||||||
|
emit filterByDistributor(model.getDistributor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo)
|
void CDbMappingComponent::ps_loadInstalledModels(const CSimulatorInfo &simInfo)
|
||||||
@@ -569,9 +584,9 @@ namespace BlackGui
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessage CDbMappingComponent::stashModel(const CAircraftModel &model)
|
CStatusMessage CDbMappingComponent::stashModel(const CAircraftModel &model, bool replace)
|
||||||
{
|
{
|
||||||
return this->ui->comp_StashAircraft->stashModel(model);
|
return this->ui->comp_StashAircraft->stashModel(model, replace);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList CDbMappingComponent::stashModels(const CAircraftModelList &models)
|
CStatusMessageList CDbMappingComponent::stashModels(const CAircraftModelList &models)
|
||||||
@@ -579,7 +594,17 @@ namespace BlackGui
|
|||||||
return this->ui->comp_StashAircraft->stashModels(models);
|
return this->ui->comp_StashAircraft->stashModels(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::CMappingSimulatorModelMenu::customMenu(QMenu &menu) const
|
CAircraftModel CDbMappingComponent::consolidateModel(const CAircraftModel &model) const
|
||||||
|
{
|
||||||
|
return this->ui->comp_StashAircraft->consolidateModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::replaceStashedModelsUnvalidated(const CAircraftModelList &models) const
|
||||||
|
{
|
||||||
|
this->ui->comp_StashAircraft->replaceModelsUnvalidated(models);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::CMappingOwnSimulatorModelMenu::customMenu(QMenu &menu) const
|
||||||
{
|
{
|
||||||
CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
|
CSimulatorInfo sims = CSimulatorInfo::getLocallyInstalledSimulators();
|
||||||
bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
bool noSims = sims.isNoSimulator() || sims.isUnspecified();
|
||||||
@@ -656,6 +681,16 @@ namespace BlackGui
|
|||||||
// we have keys and data where we could delete them from
|
// we have keys and data where we could delete them from
|
||||||
const QString msgAutoStash("Auto stashing");
|
const QString msgAutoStash("Auto stashing");
|
||||||
menu.addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, SLOT(ps_displayAutoStashingDialog()));
|
menu.addAction(CIcons::appDbStash16(), msgAutoStash, mapComp, SLOT(ps_displayAutoStashingDialog()));
|
||||||
|
|
||||||
|
if (mapComp->m_autostashDialog && mapComp->m_autostashDialog->isCompleted())
|
||||||
|
{
|
||||||
|
menu.addAction(CIcons::appDbStash16(), "Last auto stash run", mapComp->m_autostashDialog.data(), SLOT(showLastResults()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto filter in DB views
|
||||||
|
QAction *a = menu.addAction(CIcons::filter16(), "Auto filtering (DB views)", mapComp, SLOT(ps_toggleAutoFiltering()));
|
||||||
|
a->setCheckable(true);
|
||||||
|
a->setChecked(mapComp->m_autoFilterInDbViews);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->nestedCustomMenu(menu);
|
this->nestedCustomMenu(menu);
|
||||||
|
|||||||
@@ -85,11 +85,17 @@ namespace BlackGui
|
|||||||
QStringList getStashedModelStrings() const;
|
QStringList getStashedModelStrings() const;
|
||||||
|
|
||||||
//! Own (installed) model for given model string
|
//! Own (installed) model for given model string
|
||||||
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString);
|
BlackMisc::Simulation::CAircraftModel getOwnModelForModelString(const QString &modelString) const;
|
||||||
|
|
||||||
//! Current tab index
|
//! Current tab index
|
||||||
TabIndex currentTabIndex() const;
|
TabIndex currentTabIndex() const;
|
||||||
|
|
||||||
|
//! Current model view
|
||||||
|
const BlackGui::Views::CAircraftModelView *currentModelView() const;
|
||||||
|
|
||||||
|
//! Current model view
|
||||||
|
BlackGui::Views::CAircraftModelView *currentModelView();
|
||||||
|
|
||||||
//! Is stashed view
|
//! Is stashed view
|
||||||
bool isStashedTab() const;
|
bool isStashedTab() const;
|
||||||
|
|
||||||
@@ -98,11 +104,29 @@ namespace BlackGui
|
|||||||
BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const;
|
BlackMisc::Simulation::CAircraftModel getEditorAircraftModel() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Stash model
|
//! \copydoc CDbStashComponent::stashModel
|
||||||
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model);
|
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
||||||
|
|
||||||
|
//! \copydoc CDbStashComponent::stashModels
|
||||||
|
BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||||
|
|
||||||
|
//! \copydoc CDbStashComponent::consolidateModel
|
||||||
|
BlackMisc::Simulation::CAircraftModel consolidateModel(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||||
|
|
||||||
|
//! \copydoc CDbStashComponent::replaceModelsUnvalidated
|
||||||
|
void replaceStashedModelsUnvalidated(const BlackMisc::Simulation::CAircraftModelList &models) const;
|
||||||
|
|
||||||
|
//! Validate, empty list means OK
|
||||||
|
BlackMisc::CStatusMessageList validateCurrentModel(bool withNestedForms) const;
|
||||||
|
|
||||||
|
//! Resize so that selection is easy (larger table view)
|
||||||
|
void resizeForSelect();
|
||||||
|
|
||||||
|
//! Resize so that mapping is easier
|
||||||
|
void resizeForMapping();
|
||||||
|
|
||||||
//! Stash models
|
//! Stash models
|
||||||
BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
void stashSelectedModels();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Request to filter by livery
|
//! Request to filter by livery
|
||||||
@@ -117,19 +141,6 @@ namespace BlackGui
|
|||||||
//! Request latest (incrementall) data from backend
|
//! Request latest (incrementall) data from backend
|
||||||
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
|
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
|
||||||
|
|
||||||
public slots:
|
|
||||||
//! Validate, empty list means OK
|
|
||||||
BlackMisc::CStatusMessageList validateCurrentModel(bool withNestedForms) const;
|
|
||||||
|
|
||||||
//! Resize so that selection is easy (larger table view)
|
|
||||||
void resizeForSelect();
|
|
||||||
|
|
||||||
//! Resize so that mapping is easier
|
|
||||||
void resizeForMapping();
|
|
||||||
|
|
||||||
//! Stash models
|
|
||||||
void stashSelectedModels();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Load the vPilot rules
|
//! Load the vPilot rules
|
||||||
void ps_loadVPilotData();
|
void ps_loadVPilotData();
|
||||||
@@ -140,6 +151,9 @@ namespace BlackGui
|
|||||||
//! vPilot cached models changed
|
//! vPilot cached models changed
|
||||||
void ps_onVPilotCacheChanged();
|
void ps_onVPilotCacheChanged();
|
||||||
|
|
||||||
|
//! Request update of vPilot data
|
||||||
|
void ps_requestVPilotDataUpdate();
|
||||||
|
|
||||||
//! Stashed models changed
|
//! Stashed models changed
|
||||||
void ps_onStashedModelsChanged();
|
void ps_onStashedModelsChanged();
|
||||||
|
|
||||||
@@ -182,6 +196,9 @@ namespace BlackGui
|
|||||||
//! Remove DB models from current view
|
//! Remove DB models from current view
|
||||||
void ps_removeDbModelsFromView();
|
void ps_removeDbModelsFromView();
|
||||||
|
|
||||||
|
//! Toggle auto filtering
|
||||||
|
void ps_toggleAutoFiltering();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||||
QScopedArrayPointer<CDbAutoStashingComponent> m_autostashDialog { new CDbAutoStashingComponent(this) };
|
QScopedArrayPointer<CDbAutoStashingComponent> m_autostashDialog { new CDbAutoStashingComponent(this) };
|
||||||
@@ -190,8 +207,9 @@ namespace BlackGui
|
|||||||
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
std::unique_ptr<BlackMisc::Simulation::IAircraftModelLoader> m_modelLoader; //!< read own aircraft models
|
||||||
BlackMisc::CData<BlackCore::Data::OwnSimulatorAircraftModels> m_cachedOwnModels { this }; //!< cache for own installed models
|
BlackMisc::CData<BlackCore::Data::OwnSimulatorAircraftModels> m_cachedOwnModels { this }; //!< cache for own installed models
|
||||||
BlackMisc::CData<BlackCore::Data::AuthenticatedUser> m_user {this, &CDbMappingComponent::ps_userChanged};
|
BlackMisc::CData<BlackCore::Data::AuthenticatedUser> m_user {this, &CDbMappingComponent::ps_userChanged};
|
||||||
bool m_vPilot1stInit = true;
|
bool m_vPilot1stInit = true;
|
||||||
bool m_withVPilot = false;
|
bool m_withVPilot = false;
|
||||||
|
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
|
||||||
|
|
||||||
//! Init vPilot if rights and suitable
|
//! Init vPilot if rights and suitable
|
||||||
void initVPilotLoading();
|
void initVPilotLoading();
|
||||||
@@ -202,12 +220,6 @@ namespace BlackGui
|
|||||||
//! Model for given index from sender/current view
|
//! Model for given index from sender/current view
|
||||||
BlackMisc::Simulation::CAircraftModel getModelFromView(const QModelIndex &index) const;
|
BlackMisc::Simulation::CAircraftModel getModelFromView(const QModelIndex &index) const;
|
||||||
|
|
||||||
//! Current model view
|
|
||||||
const BlackGui::Views::CAircraftModelView *currentModelView() const;
|
|
||||||
|
|
||||||
//! Current model view
|
|
||||||
BlackGui::Views::CAircraftModelView *currentModelView();
|
|
||||||
|
|
||||||
//! Current tab text
|
//! Current tab text
|
||||||
QString currentTabText() const;
|
QString currentTabText() const;
|
||||||
|
|
||||||
@@ -215,11 +227,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
//! The menu for loading and handling own models for mapping tasks
|
//! The menu for loading and handling own models for mapping tasks
|
||||||
//! \note This is specific for that very component
|
//! \note This is specific for that very component
|
||||||
class CMappingSimulatorModelMenu : public BlackGui::IMenuDelegate
|
class CMappingOwnSimulatorModelMenu : public BlackGui::IMenuDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CMappingSimulatorModelMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
CMappingOwnSimulatorModelMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||||
BlackGui::IMenuDelegate(mappingComponent, separator)
|
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|||||||
@@ -76,37 +76,25 @@ namespace BlackGui
|
|||||||
if (!allowReplace && this->ui->tvp_StashAircraftModels->container().containsModelStringOrId(model))
|
if (!allowReplace && this->ui->tvp_StashAircraftModels->container().containsModelStringOrId(model))
|
||||||
{
|
{
|
||||||
const QString msg("Model \"%1\" already stashed");
|
const QString msg("Model \"%1\" already stashed");
|
||||||
return CStatusMessage(validationCats(), CStatusMessage::SeverityError, msg.arg(model.getModelString()));
|
return CStatusMessage(validationCategories(), CStatusMessage::SeverityError, msg.arg(model.getModelString()));
|
||||||
}
|
}
|
||||||
return CStatusMessage();
|
return CStatusMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessage CDbStashComponent::stashModel(const CAircraftModel &model, bool replace)
|
CStatusMessage CDbStashComponent::stashModel(const CAircraftModel &model, bool replace)
|
||||||
{
|
{
|
||||||
CAircraftModel pushModel(model);
|
|
||||||
|
|
||||||
// merge with own models if any
|
CAircraftModel stashModel(this->consolidateModel(model));
|
||||||
if (pushModel.getModelType() != CAircraftModel::TypeOwnSimulatorModel)
|
CStatusMessage m(validateStashModel(stashModel, replace));
|
||||||
{
|
|
||||||
pushModel = this->consolidateWithOwnModels(pushModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
// merge with DB data if any
|
|
||||||
if (!pushModel.hasValidDbKey())
|
|
||||||
{
|
|
||||||
pushModel = this->consolidateWithDbData(pushModel);
|
|
||||||
}
|
|
||||||
|
|
||||||
CStatusMessage m(validateStashModel(pushModel, replace));
|
|
||||||
if (!m.isWarningOrAbove())
|
if (!m.isWarningOrAbove())
|
||||||
{
|
{
|
||||||
if (replace)
|
if (replace)
|
||||||
{
|
{
|
||||||
this->ui->tvp_StashAircraftModels->replaceOrAdd(&CAircraftModel::getModelString, pushModel.getModelString(), pushModel);
|
this->ui->tvp_StashAircraftModels->replaceOrAdd(&CAircraftModel::getModelString, stashModel.getModelString(), stashModel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->ui->tvp_StashAircraftModels->insert(pushModel);
|
this->ui->tvp_StashAircraftModels->insert(stashModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
@@ -124,6 +112,11 @@ namespace BlackGui
|
|||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbStashComponent::replaceModelsUnvalidated(const CAircraftModelList &models)
|
||||||
|
{
|
||||||
|
this->ui->tvp_StashAircraftModels->updateContainerMaybeAsync(models);
|
||||||
|
}
|
||||||
|
|
||||||
int CDbStashComponent::unstashModels(QList<int> keys)
|
int CDbStashComponent::unstashModels(QList<int> keys)
|
||||||
{
|
{
|
||||||
if (keys.isEmpty()) { return 0; }
|
if (keys.isEmpty()) { return 0; }
|
||||||
@@ -228,7 +221,17 @@ namespace BlackGui
|
|||||||
if (!this->validateAndDisplay()) { return; }
|
if (!this->validateAndDisplay()) { return; }
|
||||||
CAircraftModelList models(getSelectedOrAllModels());
|
CAircraftModelList models(getSelectedOrAllModels());
|
||||||
if (models.isEmpty()) { return; }
|
if (models.isEmpty()) { return; }
|
||||||
CStatusMessageList msgs = this->asyncPublishModels(models);
|
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
if (models.size() > MaxModelPublished)
|
||||||
|
{
|
||||||
|
CAircraftModelList::iterator i = models.begin();
|
||||||
|
std::advance(i, MaxModelPublished);
|
||||||
|
models.erase(i, models.end());
|
||||||
|
msgs.push_back(CStatusMessage(validationCategories(), CStatusMessage::SeverityWarning, QString("More than %1 values, values skipped").arg(MaxModelPublished)));
|
||||||
|
}
|
||||||
|
|
||||||
|
msgs.push_back(this->asyncPublishModels(models));
|
||||||
if (msgs.hasWarningOrErrorMessages())
|
if (msgs.hasWarningOrErrorMessages())
|
||||||
{
|
{
|
||||||
this->showMessages(msgs);
|
this->showMessages(msgs);
|
||||||
@@ -276,7 +279,7 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
return CStatusMessageList(
|
return CStatusMessageList(
|
||||||
{
|
{
|
||||||
CStatusMessage(validationCats(), CStatusMessage::SeverityInfo, QString("No errors in %1 model(s)").arg(models.size()))
|
CStatusMessage(validationCategories(), CStatusMessage::SeverityInfo, QString("No errors in %1 model(s)").arg(models.size()))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -301,7 +304,7 @@ namespace BlackGui
|
|||||||
if (displayInfo)
|
if (displayInfo)
|
||||||
{
|
{
|
||||||
QString no = QString::number(this->getStashedModelsCount());
|
QString no = QString::number(this->getStashedModelsCount());
|
||||||
CStatusMessage msg(validationCats(), CStatusMessage::SeverityInfo, "Validation passed for " + no + " models");
|
CStatusMessage msg(validationCategories(), CStatusMessage::SeverityInfo, "Validation passed for " + no + " models");
|
||||||
this->showMessage(msg);
|
this->showMessage(msg);
|
||||||
}
|
}
|
||||||
return true; // no error
|
return true; // no error
|
||||||
@@ -320,7 +323,7 @@ namespace BlackGui
|
|||||||
this->ui->pb_Validate->setEnabled(e);
|
this->ui->pb_Validate->setEnabled(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CLogCategoryList &CDbStashComponent::validationCats() const
|
const CLogCategoryList &CDbStashComponent::validationCategories() const
|
||||||
{
|
{
|
||||||
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
static const CLogCategoryList cats(CLogCategoryList(this).join({ CLogCategory::validation()}));
|
||||||
return cats;
|
return cats;
|
||||||
@@ -333,19 +336,58 @@ namespace BlackGui
|
|||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CDbStashComponent::consolidateWithDbData(const CAircraftModel &model)
|
CAircraftModel CDbStashComponent::consolidateWithDbData(const CAircraftModel &model) const
|
||||||
{
|
{
|
||||||
if (!model.hasModelString()) { return model; }
|
if (!model.hasModelString()) { return model; }
|
||||||
CAircraftModel dbModel(this->getModelForModelString(model.getModelString()));
|
CAircraftModel dbModel(this->getModelForModelString(model.getModelString()));
|
||||||
|
|
||||||
if (!dbModel.hasValidDbKey()) { return model; }
|
// we try to best update by DB data here
|
||||||
|
if (!dbModel.hasValidDbKey())
|
||||||
|
{
|
||||||
|
// we have no(!) DB model, so we update ecach of it subobjects
|
||||||
|
CAircraftModel consolidatedModel(model); // copy over
|
||||||
|
if (!consolidatedModel.getLivery().hasValidDbKey() && consolidatedModel.hasAirlineDesignator())
|
||||||
|
{
|
||||||
|
// we try to find a DB livery for the airline
|
||||||
|
// maybe slow because all liveries always copied over
|
||||||
|
CLivery dbLivery(this->getLiveries().findStdLiveryByAirlineIcaoDesignator(model.getAirlineIcaoCode()));
|
||||||
|
if (dbLivery.hasValidDbKey())
|
||||||
|
{
|
||||||
|
consolidatedModel.setLivery(dbLivery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!consolidatedModel.getAircraftIcaoCode().hasValidDbKey() && consolidatedModel.hasAircraftDesignator())
|
||||||
|
{
|
||||||
|
// try to find DB aircraft ICAO here
|
||||||
|
CAircraftIcaoCode dbIcao(this->getAircraftIcaoCodeForDesignator(consolidatedModel.getAircraftIcaoCode().getDesignator()));
|
||||||
|
if (dbIcao.hasValidDbKey())
|
||||||
|
{
|
||||||
|
consolidatedModel.setAircraftIcaoCode(dbIcao);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// key alone here can be misleading, as the key can be valid but no DB key
|
||||||
|
// mostly happens when key is an alias
|
||||||
|
QString keyOrAlias(consolidatedModel.getDistributor().getDbKey());
|
||||||
|
CDistributor dbDistributor(this->getDistributors().findByKeyOrAlias(keyOrAlias));
|
||||||
|
|
||||||
|
// if no distributor is found, it is now empty because it was invalid
|
||||||
|
// otherwise replaced with the current DB data
|
||||||
|
consolidatedModel.setDistributor(dbDistributor);
|
||||||
|
|
||||||
|
// copy over
|
||||||
|
dbModel = consolidatedModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool someDbData = dbModel.hasValidDbKey() || dbModel.getLivery().hasValidDbKey() || dbModel.getAircraftIcaoCode().hasValidDbKey();
|
||||||
|
if (!someDbData) { return model; }
|
||||||
|
|
||||||
// use DB model as base, update everything else
|
// use DB model as base, update everything else
|
||||||
dbModel.updateMissingParts(model);
|
dbModel.updateMissingParts(model);
|
||||||
return dbModel;
|
return dbModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CDbStashComponent::consolidateWithOwnModels(const CAircraftModel &model)
|
CAircraftModel CDbStashComponent::consolidateWithOwnModels(const CAircraftModel &model) const
|
||||||
{
|
{
|
||||||
if (!model.hasModelString()) { return model; }
|
if (!model.hasModelString()) { return model; }
|
||||||
if (model.getModelType() == CAircraftModel::TypeOwnSimulatorModel) { return model; }
|
if (model.getModelType() == CAircraftModel::TypeOwnSimulatorModel) { return model; }
|
||||||
@@ -355,6 +397,25 @@ namespace BlackGui
|
|||||||
return ownModel;
|
return ownModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModel CDbStashComponent::consolidateModel(const CAircraftModel &model) const
|
||||||
|
{
|
||||||
|
CAircraftModel stashModel(model);
|
||||||
|
|
||||||
|
// merge with own models if any
|
||||||
|
if (stashModel.getModelType() != CAircraftModel::TypeOwnSimulatorModel)
|
||||||
|
{
|
||||||
|
stashModel = this->consolidateWithOwnModels(stashModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge with DB data if any
|
||||||
|
if (!stashModel.hasValidDbKey())
|
||||||
|
{
|
||||||
|
stashModel = this->consolidateWithDbData(stashModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stashModel;
|
||||||
|
}
|
||||||
|
|
||||||
void CDbStashComponent::ps_copyOverPartsToSelected()
|
void CDbStashComponent::ps_copyOverPartsToSelected()
|
||||||
{
|
{
|
||||||
QObject *sender = QObject::sender();
|
QObject *sender = QObject::sender();
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ namespace BlackGui
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Number of models which can be published at once
|
||||||
|
static const int MaxModelPublished = 1000;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CDbStashComponent(QWidget *parent = nullptr);
|
explicit CDbStashComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
@@ -91,13 +94,19 @@ namespace BlackGui
|
|||||||
//! Apply object to select objects
|
//! Apply object to select objects
|
||||||
void applyToSelected(const BlackMisc::Simulation::CDistributor &distributor, bool acceptWarnings = true);
|
void applyToSelected(const BlackMisc::Simulation::CDistributor &distributor, bool acceptWarnings = true);
|
||||||
|
|
||||||
|
//! Consolidate with other available data
|
||||||
|
BlackMisc::Simulation::CAircraftModel consolidateModel(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Stash given model
|
//! Stash given model (includes validation and consolidation with DB data)
|
||||||
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false);
|
||||||
|
|
||||||
//! Stash given models
|
//! Stash given models (includes validation and consolidation with DB data)
|
||||||
BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||||
|
|
||||||
|
//! Replace models, no validation
|
||||||
|
void replaceModelsUnvalidated(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Unstash
|
//! Unstash
|
||||||
void unstashed(BlackMisc::Simulation::CAircraftModel &model);
|
void unstashed(BlackMisc::Simulation::CAircraftModel &model);
|
||||||
@@ -151,16 +160,16 @@ namespace BlackGui
|
|||||||
void enableButtonRow();
|
void enableButtonRow();
|
||||||
|
|
||||||
//! Validation categories
|
//! Validation categories
|
||||||
const BlackMisc::CLogCategoryList &validationCats() const;
|
const BlackMisc::CLogCategoryList &validationCategories() const;
|
||||||
|
|
||||||
//! Get the selected only models or all models depending on checkbox
|
//! Get the selected only models or all models depending on checkbox
|
||||||
BlackMisc::Simulation::CAircraftModelList getSelectedOrAllModels() const;
|
BlackMisc::Simulation::CAircraftModelList getSelectedOrAllModels() const;
|
||||||
|
|
||||||
//! Consolidate with any DB data (if available).
|
//! Consolidate with any DB data (if available).
|
||||||
BlackMisc::Simulation::CAircraftModel consolidateWithDbData(const BlackMisc::Simulation::CAircraftModel &model);
|
BlackMisc::Simulation::CAircraftModel consolidateWithDbData(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||||
|
|
||||||
//! Consolidate with own models (if available).
|
//! Consolidate with own models (if available).
|
||||||
BlackMisc::Simulation::CAircraftModel consolidateWithOwnModels(const BlackMisc::Simulation::CAircraftModel &model);
|
BlackMisc::Simulation::CAircraftModel consolidateWithOwnModels(const BlackMisc::Simulation::CAircraftModel &model) const;
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -45,10 +45,10 @@ namespace BlackGui
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
CStatusMessageList CModelMappingForm::validate(bool withNestedForms) const
|
CStatusMessageList CModelMappingForm::validate(bool withNestedObjects) const
|
||||||
{
|
{
|
||||||
CAircraftModel model(getValue());
|
CAircraftModel model(getValue());
|
||||||
CStatusMessageList msgs(model.validate(withNestedForms));
|
CStatusMessageList msgs(model.validate(withNestedObjects));
|
||||||
this->ui->val_Indicator->setState(msgs);
|
this->ui->val_Indicator->setState(msgs);
|
||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace BlackGui
|
|||||||
BlackMisc::Simulation::CAircraftModel getValue() const;
|
BlackMisc::Simulation::CAircraftModel getValue() const;
|
||||||
|
|
||||||
//! Validate
|
//! Validate
|
||||||
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
|
BlackMisc::CStatusMessageList validate(bool withNestedObjects) const;
|
||||||
|
|
||||||
//! \copydoc CForm::setReadOnly
|
//! \copydoc CForm::setReadOnly
|
||||||
virtual void setReadOnly(bool readOnly) override;
|
virtual void setReadOnly(bool readOnly) override;
|
||||||
@@ -53,9 +53,6 @@ namespace BlackGui
|
|||||||
void setValue(BlackMisc::Simulation::CAircraftModel &model);
|
void setValue(BlackMisc::Simulation::CAircraftModel &model);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Request validation
|
|
||||||
void requestValidation();
|
|
||||||
|
|
||||||
//! Request stashing for model
|
//! Request stashing for model
|
||||||
void requestStash();
|
void requestStash();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user