mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Do not update model set in mapping component if same value
This commit is contained in:
@@ -13,8 +13,10 @@
|
|||||||
#include "blackgui/uppercasevalidator.h"
|
#include "blackgui/uppercasevalidator.h"
|
||||||
#include "blackcore/webdataservices.h"
|
#include "blackcore/webdataservices.h"
|
||||||
#include "blackcore/context/contextsimulator.h"
|
#include "blackcore/context/contextsimulator.h"
|
||||||
|
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
using namespace BlackCore::Context;
|
using namespace BlackCore::Context;
|
||||||
@@ -107,7 +109,12 @@ namespace BlackGui
|
|||||||
if (this->getSimulator() == simulator) { return false; }
|
if (this->getSimulator() == simulator) { return false; }
|
||||||
m_currentSimulator = simulator;
|
m_currentSimulator = simulator;
|
||||||
m_modelCaches.setCurrentSimulator(simulator); // all models
|
m_modelCaches.setCurrentSimulator(simulator); // all models
|
||||||
QTimer::singleShot(100, this, [ = ] { this->setCompleter(true); });
|
QPointer<CAircraftModelStringCompleter> myself(this);
|
||||||
|
QTimer::singleShot(100, this, [ = ]
|
||||||
|
{
|
||||||
|
if (!myself) { return; }
|
||||||
|
this->setCompleter(true);
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace BlackGui
|
|||||||
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CMappingComponent::onModelSetSimulatorChanged);
|
connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CMappingComponent::onModelSetSimulatorChanged);
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CMappingComponent::onModelSetChanged);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::modelSetChanged, this, &CMappingComponent::onModelSetChanged, Qt::QueuedConnection);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::modelMatchingCompleted, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::aircraftRenderingChanged, this, &CMappingComponent::tokenBucketUpdateAircraft);
|
||||||
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::tokenBucketUpdate);
|
connect(sGui->getIContextSimulator(), &IContextSimulator::airspaceSnapshotHandled, this, &CMappingComponent::tokenBucketUpdate);
|
||||||
@@ -149,8 +149,9 @@ namespace BlackGui
|
|||||||
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
connect(ui->tvp_RenderedAircraft, &CAircraftModelView::objectChanged, this, &CMappingComponent::onChangedSimulatedAircraftInView);
|
||||||
|
|
||||||
// with external core models might be already available
|
// with external core models might be already available
|
||||||
|
// nevertheless, wait some time to allow to init
|
||||||
QPointer<CMappingComponent> myself(this);
|
QPointer<CMappingComponent> myself(this);
|
||||||
QTimer::singleShot(2500, this, [ = ]
|
QTimer::singleShot(10000, this, [ = ]
|
||||||
{
|
{
|
||||||
if (!myself) { return; }
|
if (!myself) { return; }
|
||||||
const CSimulatorInfo simulator(myself->getConnectedOrSelectedSimulator());
|
const CSimulatorInfo simulator(myself->getConnectedOrSelectedSimulator());
|
||||||
@@ -180,8 +181,15 @@ namespace BlackGui
|
|||||||
return ui->tvp_AircraftModels->container().findModelsStartingWith(modelName, cs);
|
return ui->tvp_AircraftModels->container().findModelsStartingWith(modelName, cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::onModelSetChanged(const CSimulatorInfo &simulator)
|
void CMappingComponent::onModelSetChanged(const CSimulatorInfo &dummy)
|
||||||
{
|
{
|
||||||
|
// change model set, which can be any model set
|
||||||
|
Q_UNUSED(dummy); // we do not use the passed simulator
|
||||||
|
|
||||||
|
const CSimulatorInfo simulator(ui->comp_SimulatorSelector->getValue()); // UI value
|
||||||
|
const bool changed = ui->completer_ModelStrings->setSimulator(simulator);
|
||||||
|
if (!changed) { return; }
|
||||||
|
|
||||||
if (ui->tvp_AircraftModels->displayAutomatically())
|
if (ui->tvp_AircraftModels->displayAutomatically())
|
||||||
{
|
{
|
||||||
this->onModelsUpdateRequested();
|
this->onModelsUpdateRequested();
|
||||||
@@ -190,9 +198,6 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CLogMessage(this).info("Model set loaded ('%1'), you can update the model view") << simulator.toQString(true);
|
CLogMessage(this).info("Model set loaded ('%1'), you can update the model view") << simulator.toQString(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// change completer
|
|
||||||
ui->completer_ModelStrings->setSimulator(ui->comp_SimulatorSelector->getValue());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMappingComponent::onRowCountChanged(int count, bool withFilter)
|
void CMappingComponent::onRowCountChanged(int count, bool withFilter)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
//! Aircraft models available
|
//! Aircraft models available
|
||||||
void onModelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void onModelSetChanged(const BlackMisc::Simulation::CSimulatorInfo &dummy);
|
||||||
|
|
||||||
//! Changed count of rendered or aircraft model count
|
//! Changed count of rendered or aircraft model count
|
||||||
void onRowCountChanged(int count, bool withFilter);
|
void onRowCountChanged(int count, bool withFilter);
|
||||||
|
|||||||
Reference in New Issue
Block a user