mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Allow to update model directories
This commit is contained in:
@@ -100,7 +100,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
if (m_messageFrame && !model.getIconPath().isEmpty())
|
||||
if (m_messageFrame && !model.getIconFile().isEmpty())
|
||||
{
|
||||
added = true;
|
||||
menuActions.addMenuSimulator();
|
||||
@@ -133,7 +133,7 @@ namespace BlackGui
|
||||
const CAircraftModelView *mv = modelView();
|
||||
if (!mv->hasSingleSelectedRow()) { return; }
|
||||
const CAircraftModel model(mv->selectedObject());
|
||||
if (model.getIconPath().isEmpty()) { return; }
|
||||
if (model.getIconFile().isEmpty()) { return; }
|
||||
CStatusMessage msg(this);
|
||||
const CPixmap pm(model.loadIcon(msg));
|
||||
if (msg.isSuccess())
|
||||
@@ -288,11 +288,14 @@ namespace BlackGui
|
||||
|
||||
menuActions.addMenuConsolidateModels();
|
||||
|
||||
// consolidate
|
||||
m_consolidateAll = menuActions.addAction(m_consolidateAll, CIcons::appModels16(), "All with simulator models", CMenuAction::pathModelConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateData });
|
||||
if (mv->hasSelection())
|
||||
{
|
||||
m_consolidateSelected = menuActions.addAction(m_consolidateSelected, CIcons::appModels16(), "Selected with simulator models", CMenuAction::pathModelConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateSelectedData });
|
||||
}
|
||||
if (mv->hasSelection()) { m_consolidateSelected = menuActions.addAction(m_consolidateSelected, CIcons::appModels16(), "Selected with simulator models", CMenuAction::pathModelConsolidate(), { this, &CConsolidateWithSimulatorModels::consolidateSelectedData }); }
|
||||
|
||||
// update directories
|
||||
m_updateDirsAll = menuActions.addAction(m_updateDirsAll, CIcons::disk16(), "Update all directories", CMenuAction::pathModelConsolidate(), { this, &CConsolidateWithSimulatorModels::updateDirectoryData });
|
||||
if (mv->hasSelection()) { m_updateDirsSelected = menuActions.addAction(m_updateDirsSelected, CIcons::disk16(), "Update directories for selected", CMenuAction::pathModelConsolidate(), { this, &CConsolidateWithSimulatorModels::updateDirectorySelectedData }); }
|
||||
|
||||
this->nestedCustomMenu(menuActions);
|
||||
}
|
||||
|
||||
@@ -354,6 +357,64 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CConsolidateWithSimulatorModels::updateDirectoryData()
|
||||
{
|
||||
bool filtered = false;
|
||||
const CAircraftModelList models(this->getAllOrAllFilteredAircraftModels(&filtered));
|
||||
if (models.isEmpty()) { return; }
|
||||
QStringList removedModelStrings;
|
||||
const int i = this->modelView()->showLoadIndicator();
|
||||
const CAircraftModelList consolidated = CDatabaseUtils::updateModelsDirectoriesAllowsGuiRefresh(models, this->getSimulatorModels(), removedModelStrings, true);
|
||||
const CSimulatorInfo sim(this->getSimulator());
|
||||
|
||||
if (!filtered)
|
||||
{
|
||||
this->modelsTargetSetable()->setModelsForSimulator(consolidated, sim);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this->modelsTargetUpdatable())
|
||||
{
|
||||
CLogMessage(this).warning(u"No updatable target");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->modelsTargetUpdatable()->updateModelsForSimulator(consolidated, sim);
|
||||
}
|
||||
}
|
||||
this->modelView()->hideLoadIndicator(i);
|
||||
if (!removedModelStrings.isEmpty() && this->getMappingComponent())
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).info(u"Removed %1 model(s)") << removedModelStrings.size();
|
||||
this->getMappingComponent()->showOverlayMessage(m, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
void CConsolidateWithSimulatorModels::updateDirectorySelectedData()
|
||||
{
|
||||
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||
const CAircraftModelList models(this->getSelectedAircraftModels());
|
||||
if (models.isEmpty()) { return; }
|
||||
if (!this->modelsTargetUpdatable())
|
||||
{
|
||||
CLogMessage(this).warning(u"No updatable target");
|
||||
return;
|
||||
}
|
||||
|
||||
QStringList removedModelStrings;
|
||||
const int i = this->modelView()->showLoadIndicator();
|
||||
const CAircraftModelList consolidated = CDatabaseUtils::updateModelsDirectoriesAllowsGuiRefresh(models, this->getSimulatorModels(), removedModelStrings, true);
|
||||
const CSimulatorInfo sim(this->getSimulator());
|
||||
|
||||
this->modelsTargetUpdatable()->updateModelsForSimulator(consolidated, sim);
|
||||
this->modelView()->hideLoadIndicator(i);
|
||||
if (!removedModelStrings.isEmpty() && this->getMappingComponent())
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).info(u"Removed %1 model(s)") << removedModelStrings.size();
|
||||
this->getMappingComponent()->showOverlayMessage(m, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftModelList CConsolidateWithSimulatorModels::getSimulatorModels() const
|
||||
{
|
||||
CDbMappingComponent *mc = this->getMappingComponent();
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace BlackGui
|
||||
QAction *m_consolidateSelected = nullptr; //!< consolidate data with DB (selected)
|
||||
};
|
||||
|
||||
//! Merge with simulator models (e.g. remove no longer existing models)
|
||||
//! Merge/update with simulator models (e.g. remove no longer existing models)
|
||||
class CConsolidateWithSimulatorModels : public IAircraftModelViewMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -136,6 +136,8 @@ namespace BlackGui
|
||||
private:
|
||||
void consolidateData();
|
||||
void consolidateSelectedData();
|
||||
void updateDirectoryData();
|
||||
void updateDirectorySelectedData();
|
||||
|
||||
//! Get models
|
||||
BlackMisc::Simulation::CAircraftModelList getSimulatorModels() const;
|
||||
@@ -151,6 +153,8 @@ namespace BlackGui
|
||||
QObject *m_modelsTarget = nullptr; //!< optional target for setting/updating the models
|
||||
QAction *m_consolidateAll = nullptr; //!< consolidate data with DB (all)
|
||||
QAction *m_consolidateSelected = nullptr; //!< consolidate data with DB (selected)
|
||||
QAction *m_updateDirsAll = nullptr; //!< consolidate file name/dir (all)
|
||||
QAction *m_updateDirsSelected = nullptr; //!< consolidate file name/dir (selected)
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user