diff --git a/src/blackgui/components/dbownmodelsetcomponent.cpp b/src/blackgui/components/dbownmodelsetcomponent.cpp
index 8ad5a7302..8c55f98df 100644
--- a/src/blackgui/components/dbownmodelsetcomponent.cpp
+++ b/src/blackgui/components/dbownmodelsetcomponent.cpp
@@ -62,10 +62,12 @@ namespace BlackGui
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuOrderable);
ui->tvp_OwnModelSet->setSorting(CAircraftModel::IndexOrderString);
ui->tvp_OwnModelSet->initAsOrderable();
+ ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_LoadExistingSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
connect(ui->pb_SaveAsSetForSimulator, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
+ 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);
@@ -74,10 +76,13 @@ namespace BlackGui
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
if (sim.isSingleSimulator())
{
- ui->tvp_OwnModelSet->updateContainerMaybeAsync(this->m_modelSetLoader.getAircraftModels());
+ // update display when all is set up
+ this->m_modelSetLoader.syncronizeCache(); // make sure data are loaded
+ QTimer::singleShot(500, [this, sim]()
+ {
+ this->ps_changeSimulator(sim);
+ });
}
- const int c = this->m_modelSetLoader.getAircraftModelsCount();
- this->ps_onRowCountChanged(c, ui->tvp_OwnModelSet->hasFilter());
}
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
@@ -294,7 +299,8 @@ namespace BlackGui
{
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
this->m_modelSetLoader.changeSimulator(simulator);
- this->ui->le_Simulator->setText(simulator.toQString(true));
+ ui->le_Simulator->setText(simulator.toQString(true));
+ ui->comp_SimulatorSelector->setValue(simulator);
}
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)
diff --git a/src/blackgui/components/dbownmodelsetcomponent.ui b/src/blackgui/components/dbownmodelsetcomponent.ui
index 3f7fab378..3fccb4b70 100644
--- a/src/blackgui/components/dbownmodelsetcomponent.ui
+++ b/src/blackgui/components/dbownmodelsetcomponent.ui
@@ -6,8 +6,8 @@
0
0
- 600
- 400
+ 796
+ 224
@@ -64,7 +64,23 @@
0
-
-
+
+
+
+ 200
+ 0
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Raised
+
+
+
+ -
+
Qt::Horizontal
@@ -158,6 +174,12 @@
QTableView
blackgui/views/aircraftmodelview.h
+
+ BlackGui::Components::CSimulatorSelector
+ QFrame
+ blackgui/components/simulatorselector.h
+ 1
+
diff --git a/src/blackgui/components/simulatorselector.cpp b/src/blackgui/components/simulatorselector.cpp
index 10300038a..534b66745 100644
--- a/src/blackgui/components/simulatorselector.cpp
+++ b/src/blackgui/components/simulatorselector.cpp
@@ -84,15 +84,17 @@ namespace BlackGui
const CSimulatorInfo current(getValue());
if (simulator == current) { return; } // avoid unnecessary signals
+ // checkboxes
this->ui->cb_FSX->setChecked(simulator.fsx());
this->ui->cb_FS9->setChecked(simulator.fs9());
this->ui->cb_XPlane->setChecked(simulator.xplane());
this->ui->cb_P3D->setChecked(simulator.p3d());
- if (simulator.fsx()) { this->ui->cb_FSX->setChecked(simulator.fsx()); return; }
- if (simulator.fs9()) { this->ui->cb_FS9->setChecked(simulator.fs9()); return; }
- if (simulator.xplane()) { this->ui->cb_XPlane->setChecked(simulator.xplane()); return; }
- if (simulator.p3d()) { this->ui->cb_P3D->setChecked(simulator.p3d()); return; }
+ // radio buttons
+ if (simulator.fsx()) { this->ui->rb_FSX->setChecked(simulator.fsx()); return; }
+ if (simulator.fs9()) { this->ui->rb_FS9->setChecked(simulator.fs9()); return; }
+ if (simulator.xplane()) { this->ui->rb_XPlane->setChecked(simulator.xplane()); return; }
+ if (simulator.p3d()) { this->ui->rb_P3D->setChecked(simulator.p3d()); return; }
}
void CSimulatorSelector::setAll()
diff --git a/src/blackmisc/simulation/aircraftmodelsetloader.cpp b/src/blackmisc/simulation/aircraftmodelsetloader.cpp
index 74d93af08..4974ec5ab 100644
--- a/src/blackmisc/simulation/aircraftmodelsetloader.cpp
+++ b/src/blackmisc/simulation/aircraftmodelsetloader.cpp
@@ -59,7 +59,8 @@ namespace BlackMisc
void CAircraftModelSetLoader::changeSimulator(const CSimulatorInfo &simulator)
{
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
- this->m_caches.syncronizeCache(simulator);
+ if (this->getSimulator() == simulator) { return; }
+ this->m_caches.syncronizeCache(simulator); // also changes current simulator of caches
emit simulatorChanged(simulator);
}
@@ -74,6 +75,11 @@ namespace BlackMisc
return this->m_caches.getCachedModels(simulator);
}
+ int CAircraftModelSetLoader::getAircraftModelsCount() const
+ {
+ return getAircraftModels().size();
+ }
+
CAircraftModel CAircraftModelSetLoader::getModelForModelString(const QString &modelString) const
{
if (modelString.isEmpty()) { return CAircraftModel(); }
diff --git a/src/blackmisc/simulation/aircraftmodelsetloader.h b/src/blackmisc/simulation/aircraftmodelsetloader.h
index 029fe27ba..77c4eb4a9 100644
--- a/src/blackmisc/simulation/aircraftmodelsetloader.h
+++ b/src/blackmisc/simulation/aircraftmodelsetloader.h
@@ -51,6 +51,9 @@ namespace BlackMisc
//! Destructor
virtual ~CAircraftModelSetLoader();
+ //! Make sure cache is syncronized
+ bool syncronizeCache();
+
//! The loaded models
//! \threadsafe
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
@@ -61,7 +64,7 @@ namespace BlackMisc
//! Count of loaded models
//! \threadsafe
- int getAircraftModelsCount() const { return getAircraftModels().size(); }
+ int getAircraftModelsCount() const;
//! Model for given model string
//! \threadsafe
@@ -110,9 +113,6 @@ namespace BlackMisc
//! Cache timestamp
QDateTime getCacheTimestamp() const;
- //! Make sure cache is syncronized
- bool syncronizeCache();
-
//! Any cached data?
bool hasCachedData() const;
diff --git a/src/blackmisc/simulation/data/modelcaches.cpp b/src/blackmisc/simulation/data/modelcaches.cpp
index ce6985c65..d637e70a0 100644
--- a/src/blackmisc/simulation/data/modelcaches.cpp
+++ b/src/blackmisc/simulation/data/modelcaches.cpp
@@ -50,10 +50,10 @@ namespace BlackMisc
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
switch (simulator.getSimulator())
{
- case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get();
- case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get();
- case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get();
- case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get();
+ case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy();
+ case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy();
+ case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy();
+ case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy();
default:
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
return CAircraftModelList();
diff --git a/src/blackmisc/simulation/data/modelcaches.h b/src/blackmisc/simulation/data/modelcaches.h
index d8dace5ab..a05017d7f 100644
--- a/src/blackmisc/simulation/data/modelcaches.h
+++ b/src/blackmisc/simulation/data/modelcaches.h
@@ -72,6 +72,9 @@ namespace BlackMisc
//! Last selection
struct ModelCacheLastSelection : public BlackMisc::CDataTrait
{
+ //! First load is synchronous
+ static constexpr bool isPinned() { return true; }
+
//! Key
static const char *key() { return "modelcachelastselection"; }
};
@@ -111,6 +114,9 @@ namespace BlackMisc
//! Last selection
struct ModelSetLastSelection : public BlackMisc::CDataTrait
{
+ //! First load is synchronous
+ static constexpr bool isPinned() { return true; }
+
//! Key
static const char *key() { return "modelsetlastselection"; }
};
@@ -231,7 +237,6 @@ namespace BlackMisc
//! @}
private:
- //! \todo Why can`t I keep the changed functions in IMultiSimulatorModelCaches -> C2039 not a member
BlackMisc::CData m_modelCacheFsx {this, &CModelSetCaches::changedFsx }; //!< FSX cache
BlackMisc::CData m_modelCacheFs9 {this, &CModelSetCaches::changedFs9}; //!< FS9 cache
BlackMisc::CData m_modelCacheP3D {this, &CModelSetCaches::changedP3D }; //!< P3D cache