mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 01:05:34 +08:00
* adjustments to use deferred caches * removed simulator from CAircraftModelSetLoader`s signature as it was not used * only change current simulator when explicitly set (avoid unintended setting) * added function to obtain number of elements from model caches
This commit is contained in:
@@ -70,17 +70,15 @@ namespace BlackGui
|
||||
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);
|
||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelChanged, this, &CDbOwnModelSetComponent::ps_viewModelChanged);
|
||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::jsonModelsForSimulatorLoaded, this, &CDbOwnModelSetComponent::ps_onJsonDataLoaded);
|
||||
|
||||
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
|
||||
if (sim.isSingleSimulator())
|
||||
const CSimulatorInfo simulator = this->m_modelSetLoader.getSimulator();
|
||||
if (simulator.isSingleSimulator())
|
||||
{
|
||||
// update display when all is set up
|
||||
this->m_modelSetLoader.syncronizeCache(); // make sure data are loaded
|
||||
QTimer::singleShot(500, [this, sim]()
|
||||
QTimer::singleShot(500, [this]()
|
||||
{
|
||||
this->ps_changeSimulator(sim);
|
||||
this->updateViewToCurrentModels();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -162,7 +160,7 @@ namespace BlackGui
|
||||
"Cannot add data for " + simulator.toQString(true) + " to " + this->getModelSetSimulator().toQString(true), true);
|
||||
}
|
||||
CAircraftModelList updateModels(this->getModelSet());
|
||||
int d = updateModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||
const int d = updateModels.replaceOrAddModelsWithString(models, Qt::CaseInsensitive);
|
||||
if (d > 0)
|
||||
{
|
||||
this->ui->tvp_OwnModelSet->updateContainerMaybeAsync(updateModels);
|
||||
@@ -195,7 +193,8 @@ namespace BlackGui
|
||||
{
|
||||
// make sure both tabs display the same simulator
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "Missing mapping component");
|
||||
this->getMappingComponent()->setOwnModelsSimulator(this->getModelSetSimulator());
|
||||
const CSimulatorInfo sim(this->getModelSetSimulator());
|
||||
this->getMappingComponent()->setOwnModelsSimulator(sim);
|
||||
if (!this->m_modelSetDialog)
|
||||
{
|
||||
this->m_modelSetDialog.reset(new CDbOwnModelSetDialog(this));
|
||||
@@ -214,7 +213,7 @@ namespace BlackGui
|
||||
}
|
||||
else
|
||||
{
|
||||
static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << this->m_modelSetDialog->getSimulatorInfo().toQString(true);
|
||||
static const CStatusMessage m = CStatusMessage(this).error("No model data for %1") << sim.toQString(true);
|
||||
this->getMappingComponent()->showOverlayMessage(m);
|
||||
}
|
||||
}
|
||||
@@ -239,8 +238,7 @@ namespace BlackGui
|
||||
if (this->getModelSetSimulator() == simulator) { return; } // avoid endless loops
|
||||
|
||||
this->setModelSetSimulator(simulator);
|
||||
const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels());
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
|
||||
this->updateViewToCurrentModels();
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_onSimulatorChanged(const CSimulatorInfo &simulator)
|
||||
@@ -276,7 +274,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_preferencesChanged()
|
||||
void CDbOwnModelSetComponent::ps_distributorPreferencesChanged()
|
||||
{
|
||||
const CDistributorListPreferences preferences = this->m_distributorPreferences.get();
|
||||
const CSimulatorInfo simuulator = preferences.getLastUpdatedSimulator();
|
||||
@@ -286,7 +284,7 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::ps_modelChanged()
|
||||
void CDbOwnModelSetComponent::ps_viewModelChanged()
|
||||
{
|
||||
ui->pb_SaveAsSetForSimulator->setEnabled(true);
|
||||
}
|
||||
@@ -298,6 +296,12 @@ namespace BlackGui
|
||||
this->ui->tvp_OwnModelSet->setSaveFileName(name);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::updateViewToCurrentModels()
|
||||
{
|
||||
const CAircraftModelList models(this->m_modelSetLoader.getAircraftModels());
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(models);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::setModelSetSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
|
||||
|
||||
@@ -123,22 +123,27 @@ namespace BlackGui
|
||||
void ps_onJsonDataLoaded(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Preferences changed
|
||||
void ps_preferencesChanged();
|
||||
void ps_distributorPreferencesChanged();
|
||||
|
||||
//! Model has been changed
|
||||
void ps_modelChanged();
|
||||
//! Model (of view) has been changed
|
||||
void ps_viewModelChanged();
|
||||
|
||||
private:
|
||||
//! Default file name
|
||||
void setSaveFileName(const BlackMisc::Simulation::CSimulatorInfo &sim);
|
||||
|
||||
//! Update view to current models
|
||||
void updateViewToCurrentModels();
|
||||
|
||||
//! Update distributor order
|
||||
void updateDistributorOrder(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
|
||||
QScopedPointer<Ui::CDbOwnModelSetComponent> ui;
|
||||
QScopedPointer<CDbOwnModelSetDialog> m_modelSetDialog;
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this };
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::ps_preferencesChanged };
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this };
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &CDbOwnModelSetComponent::ps_distributorPreferencesChanged };
|
||||
|
||||
// -------------------------- custom menus -----------------------------------
|
||||
|
||||
//! The menu for loading and handling own models for mapping tasks
|
||||
//! \note This is specific for that very component
|
||||
|
||||
@@ -63,7 +63,9 @@ namespace BlackGui
|
||||
int CDbOwnModelSetDialog::exec()
|
||||
{
|
||||
Q_ASSERT_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
this->setSimulator(this->getMappingComponent()->getOwnModelsSimulator());
|
||||
const CSimulatorInfo sim(this->getMappingComponent()->getOwnModelsSimulator());
|
||||
Q_ASSERT_X(sim.isSingleSimulator(), Q_FUNC_INFO, "need single simulator");
|
||||
this->setSimulator(sim);
|
||||
this->checkData();
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace BlackGui
|
||||
private:
|
||||
BlackGui::COverlayMessagesFrame *m_overlayMessageFrame = nullptr;
|
||||
QScopedPointer<Ui::CDistributorPreferencesComponent> ui;
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this };
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this };
|
||||
BlackMisc::CSetting<BlackCore::Settings::Simulation::DistributorListPreferences> m_distributorPreferences { this, &CDistributorPreferencesComponent::ps_preferencesChanged };
|
||||
|
||||
void updateContainerMaybeAsync(const BlackMisc::Simulation::CDistributorList &models, bool sortByOrder = true);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace BlackGui
|
||||
BlackMisc::Simulation::CAircraftModel defaultModel() const;
|
||||
|
||||
QScopedPointer<Ui::CModelMatcherComponent> ui;
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { BlackMisc::Simulation::CSimulatorInfo(BlackMisc::Simulation::CSimulatorInfo::FSX), this };
|
||||
BlackMisc::Simulation::CAircraftModelSetLoader m_modelSetLoader { this };
|
||||
BlackCore::CAircraftMatcher m_matcher { BlackCore::CAircraftMatcher::All, this };
|
||||
};
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user