mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #661, improved own model set handling
* fixed simulator selector * added simulator selector to own model set component * pinned last selections * fixed model cache to use "getCopy"
This commit is contained in:
@@ -62,10 +62,12 @@ namespace BlackGui
|
|||||||
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuOrderable);
|
ui->tvp_OwnModelSet->menuAddItems(CAircraftModelView::MenuOrderable);
|
||||||
ui->tvp_OwnModelSet->setSorting(CAircraftModel::IndexOrderString);
|
ui->tvp_OwnModelSet->setSorting(CAircraftModel::IndexOrderString);
|
||||||
ui->tvp_OwnModelSet->initAsOrderable();
|
ui->tvp_OwnModelSet->initAsOrderable();
|
||||||
|
ui->comp_SimulatorSelector->setMode(CSimulatorSelector::RadioButtons);
|
||||||
|
|
||||||
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
|
connect(ui->pb_CreateNewSet, &QPushButton::clicked, this, &CDbOwnModelSetComponent::ps_buttonClicked);
|
||||||
connect(ui->pb_LoadExistingSet, &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->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(&this->m_modelSetLoader, &CAircraftModelSetLoader::simulatorChanged, this, &CDbOwnModelSetComponent::ps_onSimulatorChanged);
|
||||||
connect(ui->tvp_OwnModelSet, &CAircraftModelView::modelDataChanged, this, &CDbOwnModelSetComponent::ps_onRowCountChanged);
|
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_modelChanged);
|
||||||
@@ -74,10 +76,13 @@ namespace BlackGui
|
|||||||
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
|
const CSimulatorInfo sim = this->m_modelSetLoader.getSimulator();
|
||||||
if (sim.isSingleSimulator())
|
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()
|
CDbOwnModelSetComponent::~CDbOwnModelSetComponent()
|
||||||
@@ -294,7 +299,8 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
|
if (this->m_modelSetLoader.getSimulator() == simulator) { return; } // avoid unnecessary signals
|
||||||
this->m_modelSetLoader.changeSimulator(simulator);
|
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)
|
void CDbOwnModelSetComponent::updateDistributorOrder(const CSimulatorInfo &simulator)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>600</width>
|
<width>796</width>
|
||||||
<height>400</height>
|
<height>224</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -64,7 +64,23 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="hs_Buttons">
|
<widget class="BlackGui::Components::CSimulatorSelector" name="comp_SimulatorSelector">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="hs_OwnModelSetButtons">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -158,6 +174,12 @@
|
|||||||
<extends>QTableView</extends>
|
<extends>QTableView</extends>
|
||||||
<header>blackgui/views/aircraftmodelview.h</header>
|
<header>blackgui/views/aircraftmodelview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CSimulatorSelector</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/simulatorselector.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|||||||
@@ -84,15 +84,17 @@ namespace BlackGui
|
|||||||
const CSimulatorInfo current(getValue());
|
const CSimulatorInfo current(getValue());
|
||||||
if (simulator == current) { return; } // avoid unnecessary signals
|
if (simulator == current) { return; } // avoid unnecessary signals
|
||||||
|
|
||||||
|
// checkboxes
|
||||||
this->ui->cb_FSX->setChecked(simulator.fsx());
|
this->ui->cb_FSX->setChecked(simulator.fsx());
|
||||||
this->ui->cb_FS9->setChecked(simulator.fs9());
|
this->ui->cb_FS9->setChecked(simulator.fs9());
|
||||||
this->ui->cb_XPlane->setChecked(simulator.xplane());
|
this->ui->cb_XPlane->setChecked(simulator.xplane());
|
||||||
this->ui->cb_P3D->setChecked(simulator.p3d());
|
this->ui->cb_P3D->setChecked(simulator.p3d());
|
||||||
|
|
||||||
if (simulator.fsx()) { this->ui->cb_FSX->setChecked(simulator.fsx()); return; }
|
// radio buttons
|
||||||
if (simulator.fs9()) { this->ui->cb_FS9->setChecked(simulator.fs9()); return; }
|
if (simulator.fsx()) { this->ui->rb_FSX->setChecked(simulator.fsx()); return; }
|
||||||
if (simulator.xplane()) { this->ui->cb_XPlane->setChecked(simulator.xplane()); return; }
|
if (simulator.fs9()) { this->ui->rb_FS9->setChecked(simulator.fs9()); return; }
|
||||||
if (simulator.p3d()) { this->ui->cb_P3D->setChecked(simulator.p3d()); 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()
|
void CSimulatorSelector::setAll()
|
||||||
|
|||||||
@@ -59,7 +59,8 @@ namespace BlackMisc
|
|||||||
void CAircraftModelSetLoader::changeSimulator(const CSimulatorInfo &simulator)
|
void CAircraftModelSetLoader::changeSimulator(const CSimulatorInfo &simulator)
|
||||||
{
|
{
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
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);
|
emit simulatorChanged(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,6 +75,11 @@ namespace BlackMisc
|
|||||||
return this->m_caches.getCachedModels(simulator);
|
return this->m_caches.getCachedModels(simulator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CAircraftModelSetLoader::getAircraftModelsCount() const
|
||||||
|
{
|
||||||
|
return getAircraftModels().size();
|
||||||
|
}
|
||||||
|
|
||||||
CAircraftModel CAircraftModelSetLoader::getModelForModelString(const QString &modelString) const
|
CAircraftModel CAircraftModelSetLoader::getModelForModelString(const QString &modelString) const
|
||||||
{
|
{
|
||||||
if (modelString.isEmpty()) { return CAircraftModel(); }
|
if (modelString.isEmpty()) { return CAircraftModel(); }
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ namespace BlackMisc
|
|||||||
//! Destructor
|
//! Destructor
|
||||||
virtual ~CAircraftModelSetLoader();
|
virtual ~CAircraftModelSetLoader();
|
||||||
|
|
||||||
|
//! Make sure cache is syncronized
|
||||||
|
bool syncronizeCache();
|
||||||
|
|
||||||
//! The loaded models
|
//! The loaded models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
||||||
@@ -61,7 +64,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
//! Count of loaded models
|
//! Count of loaded models
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
int getAircraftModelsCount() const;
|
||||||
|
|
||||||
//! Model for given model string
|
//! Model for given model string
|
||||||
//! \threadsafe
|
//! \threadsafe
|
||||||
@@ -110,9 +113,6 @@ namespace BlackMisc
|
|||||||
//! Cache timestamp
|
//! Cache timestamp
|
||||||
QDateTime getCacheTimestamp() const;
|
QDateTime getCacheTimestamp() const;
|
||||||
|
|
||||||
//! Make sure cache is syncronized
|
|
||||||
bool syncronizeCache();
|
|
||||||
|
|
||||||
//! Any cached data?
|
//! Any cached data?
|
||||||
bool hasCachedData() const;
|
bool hasCachedData() const;
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ namespace BlackMisc
|
|||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
switch (simulator.getSimulator())
|
switch (simulator.getSimulator())
|
||||||
{
|
{
|
||||||
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.get();
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getCopy();
|
||||||
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.get();
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getCopy();
|
||||||
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.get();
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getCopy();
|
||||||
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.get();
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getCopy();
|
||||||
default:
|
default:
|
||||||
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
return CAircraftModelList();
|
return CAircraftModelList();
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ namespace BlackMisc
|
|||||||
//! Last selection
|
//! Last selection
|
||||||
struct ModelCacheLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
struct ModelCacheLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||||
{
|
{
|
||||||
|
//! First load is synchronous
|
||||||
|
static constexpr bool isPinned() { return true; }
|
||||||
|
|
||||||
//! Key
|
//! Key
|
||||||
static const char *key() { return "modelcachelastselection"; }
|
static const char *key() { return "modelcachelastselection"; }
|
||||||
};
|
};
|
||||||
@@ -111,6 +114,9 @@ namespace BlackMisc
|
|||||||
//! Last selection
|
//! Last selection
|
||||||
struct ModelSetLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
struct ModelSetLastSelection : public BlackMisc::CDataTrait<BlackMisc::Simulation::CSimulatorInfo>
|
||||||
{
|
{
|
||||||
|
//! First load is synchronous
|
||||||
|
static constexpr bool isPinned() { return true; }
|
||||||
|
|
||||||
//! Key
|
//! Key
|
||||||
static const char *key() { return "modelsetlastselection"; }
|
static const char *key() { return "modelsetlastselection"; }
|
||||||
};
|
};
|
||||||
@@ -231,7 +237,6 @@ namespace BlackMisc
|
|||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! \todo Why can`t I keep the changed functions in IMultiSimulatorModelCaches -> C2039 not a member
|
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFsx> m_modelCacheFsx {this, &CModelSetCaches::changedFsx }; //!< FSX cache
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFsx> m_modelCacheFsx {this, &CModelSetCaches::changedFsx }; //!< FSX cache
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFs9> m_modelCacheFs9 {this, &CModelSetCaches::changedFs9}; //!< FS9 cache
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFs9> m_modelCacheFs9 {this, &CModelSetCaches::changedFs9}; //!< FS9 cache
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this, &CModelSetCaches::changedP3D }; //!< P3D cache
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this, &CModelSetCaches::changedP3D }; //!< P3D cache
|
||||||
|
|||||||
Reference in New Issue
Block a user