mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T292, adjusted UI components to reflect model loader changes
This commit is contained in:
@@ -44,22 +44,21 @@ namespace BlackGui
|
||||
connect(ui->rb_OwnModels, &QRadioButton::clicked, this, &CAircraftModelStringCompleter::initGui);
|
||||
connect(&m_modelCaches, &CModelCaches::cacheChanged, this, &CAircraftModelStringCompleter::setSimulator, Qt::QueuedConnection);
|
||||
|
||||
CSimulatorInfo sim = CSimulatorInfo(CSimulatorInfo::P3D); // default
|
||||
CSimulatorInfo simulator = CSimulatorInfo(CSimulatorInfo::P3D); // default
|
||||
if (sGui->getIContextSimulator())
|
||||
{
|
||||
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorStatusChanged, this, &CAircraftModelStringCompleter::onSimulatorConnected);
|
||||
sim = sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulator();
|
||||
if (sim.isSingleSimulator())
|
||||
CSimulatorInfo pluginSimulator = sGui->getIContextSimulator()->getSimulatorPluginInfo().getSimulator();
|
||||
if (pluginSimulator.isSingleSimulator())
|
||||
{
|
||||
m_modelCaches.setCurrentSimulator(sim);
|
||||
simulator = pluginSimulator;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setSourceVisible(OwnModels, false);
|
||||
sim = m_modelCaches.getCurrentSimulator();
|
||||
this->setSourceVisible(OwnModels, false); // hide own models
|
||||
}
|
||||
}
|
||||
this->setSimulator(sim);
|
||||
this->setSimulator(simulator);
|
||||
}
|
||||
|
||||
CAircraftModelStringCompleter::~CAircraftModelStringCompleter()
|
||||
@@ -106,9 +105,9 @@ namespace BlackGui
|
||||
|
||||
bool CAircraftModelStringCompleter::setSimulator(const CSimulatorInfo &simulator)
|
||||
{
|
||||
if (simulator.isSingleSimulator()) { return false; }
|
||||
if (this->getSimulator() == simulator) { return false; }
|
||||
m_currentSimulator = simulator;
|
||||
m_modelCaches.setCurrentSimulator(simulator); // all models
|
||||
QPointer<CAircraftModelStringCompleter> myself(this);
|
||||
QTimer::singleShot(100, this, [ = ]
|
||||
{
|
||||
@@ -150,7 +149,7 @@ namespace BlackGui
|
||||
else if (ui->rb_OwnModels->isChecked())
|
||||
{
|
||||
if (!simChanged && m_currentDataSource == OwnModels) { return; }
|
||||
modelStrings = m_modelCaches.getCurrentCachedModels().toCompleterStrings();
|
||||
modelStrings = m_modelCaches.getCachedModels(this->getSimulator()).toCompleterStrings();
|
||||
dataSource = OwnModels;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,8 +75,7 @@ namespace BlackGui
|
||||
if (set)
|
||||
{
|
||||
// inits current version cache
|
||||
m_modelSetCaches.setCurrentSimulator(sim);
|
||||
m_modelSetCaches.synchronizeCurrentCache();
|
||||
m_modelSetCaches.synchronizeCache(sim);
|
||||
|
||||
// get file name
|
||||
CAircraftModelList otherSet;
|
||||
@@ -86,7 +85,7 @@ namespace BlackGui
|
||||
CApplication::processEventsFor(250);
|
||||
if (this->confirmOverride(QString("Override model set for '%1'").arg(sim.toQString())))
|
||||
{
|
||||
m_modelSetCaches.setModels(otherSet, sim);
|
||||
m_modelSetCaches.setModelsForSimulator(otherSet, sim);
|
||||
}
|
||||
}
|
||||
} // set
|
||||
@@ -94,8 +93,7 @@ namespace BlackGui
|
||||
if (cache)
|
||||
{
|
||||
// inits current version cache
|
||||
m_modelCaches.setCurrentSimulator(sim);
|
||||
m_modelCaches.synchronizeCurrentCache();
|
||||
m_modelCaches.synchronizeCache(sim);
|
||||
|
||||
// get file name
|
||||
CAircraftModelList otherCache;
|
||||
@@ -105,7 +103,7 @@ namespace BlackGui
|
||||
CApplication::processEventsFor(250);
|
||||
if (this->confirmOverride(QString("Override model cache for '%1'").arg(sim.toQString())))
|
||||
{
|
||||
m_modelCaches.setModels(otherCache, sim);
|
||||
m_modelCaches.setModelsForSimulator(otherCache, sim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include <QDialogButtonBox>
|
||||
#include <QModelIndexList>
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -39,13 +40,11 @@ namespace BlackGui
|
||||
ui->bb_loadDataDialog->button(QDialogButtonBox::Apply)->setText("Load");
|
||||
ui->wi_WorkStatus->setVisible(false);
|
||||
ui->wi_Consolidate->setVisible(false);
|
||||
ui->comp_SimulatorSelector->setValue(m_sets.getCurrentSimulator());
|
||||
ui->comp_SimulatorSelector->setRememberSelection(true);
|
||||
connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadDataDialog::onDataRead, Qt::QueuedConnection);
|
||||
connect(ui->bb_loadDataDialog, &QDialogButtonBox::clicked, this, &CDbLoadDataDialog::onButtonClicked);
|
||||
connect(ui->pb_Consolidate, &QPushButton::clicked, this, &CDbLoadDataDialog::consolidate);
|
||||
connect(this, &CDbLoadDataDialog::rejected, this, &CDbLoadDataDialog::onRejected);
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, &m_sets, &CModelSetCaches::setCurrentSimulator, Qt::QueuedConnection);
|
||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, &m_models, &CModelCaches::setCurrentSimulator, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
CDbLoadDataDialog::~CDbLoadDataDialog()
|
||||
@@ -124,8 +123,10 @@ namespace BlackGui
|
||||
m_pendingEntitiesCount = -1;
|
||||
const bool defaultConsolidate = !ui->cb_AllModels->isChecked() && ui->cb_ModelSet->isChecked();
|
||||
|
||||
QPointer<CDbLoadDataDialog> myself(this);
|
||||
QTimer::singleShot(2000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
ui->wi_Consolidate->setVisible(true);
|
||||
ui->wi_WorkStatus->setVisible(false);
|
||||
if (defaultConsolidate)
|
||||
@@ -154,31 +155,35 @@ namespace BlackGui
|
||||
ui->wi_WorkStatus->setVisible(true);
|
||||
ui->pb_Loading->setValue(0);
|
||||
ui->pb_Loading->setMaximum(0); // 0/0 causing busy indicator
|
||||
const CSimulatorInfo simulator = ui->comp_SimulatorSelector->getValue();
|
||||
|
||||
do
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ui->le_Info->setText("Model set");
|
||||
CAircraftModelList models = m_sets.getCurrentCachedModels();
|
||||
CAircraftModelList models = m_sets.getCachedModels(simulator);
|
||||
const int c = CDatabaseUtils::consolidateModelsWithDbDataAllowsGuiRefresh(models, true, true);
|
||||
if (c > 0) { m_sets.setCachedModels(models, m_sets.getCurrentSimulator()); }
|
||||
if (c > 0) { m_sets.setCachedModels(models, simulator); }
|
||||
}
|
||||
|
||||
if (!this->isVisible()) { break; } // dialog closed?
|
||||
if (all)
|
||||
{
|
||||
ui->le_Info->setText("All models");
|
||||
CAircraftModelList models = m_models.getCurrentCachedModels();
|
||||
CAircraftModelList models = m_models.getCachedModels(simulator);
|
||||
const int c = CDatabaseUtils::consolidateModelsWithDbDataAllowsGuiRefresh(models, true, true);
|
||||
if (c > 0) { m_models.setCachedModels(models, m_models.getCurrentSimulator()); }
|
||||
if (c > 0) { m_models.setCachedModels(models, simulator); }
|
||||
}
|
||||
}
|
||||
while (false);
|
||||
|
||||
m_consolidating = false;
|
||||
|
||||
QPointer<CDbLoadDataDialog> myself(this);
|
||||
QTimer::singleShot(2000, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
ui->pb_Loading->setMaximum(100);
|
||||
ui->wi_WorkStatus->setVisible(false);
|
||||
if (m_autoConsolidate)
|
||||
|
||||
@@ -125,21 +125,22 @@ namespace BlackGui
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(cleanModelList);
|
||||
}
|
||||
|
||||
void CDbOwnModelSetComponent::replaceOrAddModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||
int CDbOwnModelSetComponent::replaceOrAddModelSet(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||
{
|
||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
|
||||
if (models.isEmpty()) { return; }
|
||||
if (models.isEmpty()) { return 0; }
|
||||
CAircraftModelList cleanModelList(models.matchesSimulator(simulator)); // remove those not matching the simulator
|
||||
const int diff = models.size() - cleanModelList.size();
|
||||
if (diff > 0)
|
||||
{
|
||||
CLogMessage(this).warning("Removed %1 models from set because not matching %2") << diff << simulator.toQString(true);
|
||||
}
|
||||
if (cleanModelList.isEmpty()) { return; }
|
||||
if (cleanModelList.isEmpty()) { return 0; }
|
||||
CAircraftModelList updatedModels(ui->tvp_OwnModelSet->container());
|
||||
updatedModels.replaceOrAddModelsWithString(cleanModelList, Qt::CaseInsensitive);
|
||||
updatedModels.resetOrder();
|
||||
ui->tvp_OwnModelSet->updateContainerMaybeAsync(updatedModels);
|
||||
return diff;
|
||||
}
|
||||
|
||||
const CAircraftModelList &CDbOwnModelSetComponent::getModelSetFromView() const
|
||||
@@ -233,7 +234,7 @@ namespace BlackGui
|
||||
const CAircraftModelList ml(ui->tvp_OwnModelSet->container());
|
||||
if (!ml.isEmpty())
|
||||
{
|
||||
const CStatusMessage m = m_modelSetLoader.setCachedModels(ml);
|
||||
const CStatusMessage m = m_modelSetLoader.setCachedModels(ml, this->getSelectedSimulator());
|
||||
CLogMessage::preformatted(m);
|
||||
}
|
||||
return;
|
||||
@@ -392,7 +393,7 @@ namespace BlackGui
|
||||
const CDistributorList distributors = preferences.getDistributors(simulator);
|
||||
if (distributors.isEmpty()) { return; }
|
||||
modelSet.updateDistributorOrder(distributors);
|
||||
m_modelSetLoader.setModels(modelSet, simulator);
|
||||
m_modelSetLoader.setModelsForSimulator(modelSet, simulator);
|
||||
|
||||
// display?
|
||||
const CSimulatorInfo currentSimulator(this->getModelSetSimulator());
|
||||
|
||||
@@ -50,16 +50,16 @@ namespace BlackGui
|
||||
public CDbMappingComponentAware,
|
||||
public BlackMisc::Simulation::IModelsSetable,
|
||||
public BlackMisc::Simulation::IModelsUpdatable,
|
||||
public BlackMisc::Simulation::IModelsPerSimulatorSetable,
|
||||
public BlackMisc::Simulation::IModelsPerSimulatorUpdatable,
|
||||
public BlackMisc::Simulation::IModelsForSimulatorSetable,
|
||||
public BlackMisc::Simulation::IModelsForSimulatorUpdatable,
|
||||
public BlackMisc::Simulation::ISimulatorSelectable
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(BlackGui::Components::CDbMappingComponentAware)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsSetable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsUpdatable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorSetable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsPerSimulatorUpdatable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsForSimulatorSetable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IModelsForSimulatorUpdatable)
|
||||
Q_INTERFACES(BlackMisc::Simulation::ISimulatorSelectable)
|
||||
|
||||
public:
|
||||
@@ -104,9 +104,9 @@ namespace BlackGui
|
||||
//! \name Implementations of the models interfaces
|
||||
//! @{
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setModelSet(models, this->getModelSetSimulator()); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->replaceOrAddModelSet(models, this->getModelSetSimulator()); }
|
||||
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { this->setModelSet(models, simulator); }
|
||||
virtual void updateModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { this->replaceOrAddModelSet(models, simulator); }
|
||||
virtual void setModelsForSimulator(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { this->setModelSet(models, simulator); }
|
||||
virtual int updateModels(const BlackMisc::Simulation::CAircraftModelList &models) override { return this->replaceOrAddModelSet(models, this->getModelSetSimulator()); }
|
||||
virtual int updateModelsForSimulator(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator) override { return this->replaceOrAddModelSet(models, simulator); }
|
||||
virtual BlackMisc::Simulation::CSimulatorInfo getSelectedSimulator() const override { return this->getModelSetSimulator(); }
|
||||
//! @}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace BlackGui
|
||||
void setModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
//! Replace or add models provided for a given simulator
|
||||
void replaceOrAddModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
int replaceOrAddModelSet(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
private:
|
||||
//! Tab has been changed
|
||||
|
||||
@@ -164,11 +164,14 @@
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_SelectedOnly">
|
||||
<property name="toolTip">
|
||||
<string>selected models only</string>
|
||||
<string>publish selected models only</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>selected</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -88,8 +88,8 @@ namespace BlackGui
|
||||
// we us the loader of the components directly,
|
||||
// avoid to fully init a loader logic here
|
||||
static const QString modelsNo("No models so far");
|
||||
const int modelsCount = this->modelLoader()->getAircraftModelsCount();
|
||||
ui->le_ModelsInfo->setText(modelsCount > 0 ? this->modelLoader()->getModelCacheCountAndTimestamp() : modelsNo);
|
||||
const int modelsCount = this->modelLoader()->getCachedModelsCount(simulator);
|
||||
ui->le_ModelsInfo->setText(modelsCount > 0 ? this->modelLoader()->getCacheCountAndTimestamp(simulator) : modelsNo);
|
||||
ui->pb_CreateModelSet->setEnabled(modelsCount > 0);
|
||||
|
||||
static const QString modelsSetNo("Model set is empty");
|
||||
@@ -214,7 +214,8 @@ namespace BlackGui
|
||||
|
||||
void CFirstModelSetComponent::createModelSet()
|
||||
{
|
||||
const int modelsCount = this->modelLoader()->getAircraftModelsCount();
|
||||
const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue();
|
||||
const int modelsCount = this->modelLoader()->getCachedModelsCount(sim);
|
||||
if (modelsCount < 1)
|
||||
{
|
||||
static const CStatusMessage msg = CStatusMessage(this).validationError("No models indexed so far. Try 'reload'!");
|
||||
@@ -237,14 +238,13 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
}
|
||||
CAircraftModelList modelsForSet = this->modelLoader()->getAircraftModels();
|
||||
CAircraftModelList modelsForSet = this->modelLoader()->getCachedModels(sim);
|
||||
if (!useAllModels)
|
||||
{
|
||||
const CDistributorList distributors = ui->comp_Distributors->getSelectedDistributors();
|
||||
modelsForSet = modelsForSet.findByDistributors(distributors);
|
||||
}
|
||||
|
||||
const CSimulatorInfo sim = ui->comp_SimulatorSelector->getValue();
|
||||
m_modelSetDialog->modelSetComponent()->setModelSet(modelsForSet, sim);
|
||||
ui->pb_ModelSet->click();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user