Improved version of "Allow to delete data directory from application view"

- split functions into dynamic loading and const versions (loading at startup)
- reload other versions from wizard in case they changed
- some renaming/formatting
This commit is contained in:
Klaus Basan
2018-12-02 04:27:59 +01:00
parent d18c763869
commit 7fc6fcb867
13 changed files with 104 additions and 55 deletions

View File

@@ -46,8 +46,8 @@ namespace BlackGui
void CCopyModelsFromOtherSwiftVersionsComponent::copy()
{
const CSimulatorInfo selectedSimulators = ui->comp_SimulatorSelector->getValue();
const QSet<CSimulatorInfo> sims = selectedSimulators.asSingleSimulatorSet();
if (sims.isEmpty())
const QSet<CSimulatorInfo> simulators = selectedSimulators.asSingleSimulatorSet();
if (simulators.isEmpty())
{
static const CStatusMessage m = CStatusMessage(this).validationError("No simulators selected");
this->showOverlayMessage(m);
@@ -73,22 +73,22 @@ namespace BlackGui
int sets = 0;
int caches = 0;
const CApplicationInfo otherVersion = ui->comp_OtherSwiftVersions->selectedOtherVersion();
for (const CSimulatorInfo &sim : sims)
for (const CSimulatorInfo &simulator : simulators)
{
if (set)
{
// inits current version cache
m_modelSetCaches.synchronizeCache(sim);
m_modelSetCaches.synchronizeCache(simulator);
// get file name
CAircraftModelList otherSet;
const QString thisVersionModelSetFile = m_modelSetCaches.getFilename(sim);
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, sim) && !otherSet.isEmpty())
const QString thisVersionModelSetFile = m_modelSetCaches.getFilename(simulator);
if (this->readDataFile(thisVersionModelSetFile, otherSet, otherVersion, simulator) && !otherSet.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model set for '%1'").arg(sim.toQString())))
if (this->confirmOverride(QString("Override model set for '%1'").arg(simulator.toQString())))
{
m_modelSetCaches.setModelsForSimulator(otherSet, sim);
m_modelSetCaches.setModelsForSimulator(otherSet, simulator);
}
}
sets++;
@@ -97,17 +97,17 @@ namespace BlackGui
if (cache)
{
// inits current version cache
m_modelCaches.synchronizeCache(sim);
m_modelCaches.synchronizeCache(simulator);
// get file name
CAircraftModelList otherCache;
const QString thisVersionModelCacheFile = m_modelCaches.getFilename(sim);
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, sim) && !otherCache.isEmpty())
const QString thisVersionModelCacheFile = m_modelCaches.getFilename(simulator);
if (this->readDataFile(thisVersionModelCacheFile, otherCache, otherVersion, simulator) && !otherCache.isEmpty())
{
CApplication::processEventsFor(250);
if (this->confirmOverride(QString("Override model cache for '%1'").arg(sim.toQString())))
if (this->confirmOverride(QString("Override model cache for '%1'").arg(simulator.toQString())))
{
m_modelCaches.setModelsForSimulator(otherCache, sim);
m_modelCaches.setModelsForSimulator(otherCache, simulator);
}
}
caches++;
@@ -186,6 +186,17 @@ namespace BlackGui
ui->comp_SimulatorSelector->setValue(setSims);
}
void CCopyModelsFromOtherSwiftVersionsComponent::reloadOtherVersions()
{
ui->comp_OtherSwiftVersions->reloadOtherVersions();
}
void CCopyModelsFromOtherSwiftVersionsWizardPage::initializePage()
{
// force reload as the other version could be changed
if (m_copyModels) { m_copyModels->reloadOtherVersions(); }
}
bool CCopyModelsFromOtherSwiftVersionsWizardPage::validatePage()
{
Q_ASSERT_X(m_copyModels, Q_FUNC_INFO, "Missing widget");