Ref T246, function to display model count and timestamp of model/set caches

This commit is contained in:
Klaus Basan
2018-07-17 18:56:22 +02:00
parent 3b460af8a6
commit 0023fbb57f
7 changed files with 53 additions and 8 deletions

View File

@@ -21,6 +21,7 @@
#include <QStringList> #include <QStringList>
#include <QFileDialog> #include <QFileDialog>
#include <QPointer> #include <QPointer>
#include <QMessageBox>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
@@ -53,9 +54,9 @@ namespace BlackGui
bool s = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CFirstModelSetComponent::onSimulatorChanged); bool s = connect(ui->comp_SimulatorSelector, &CSimulatorSelector::changed, this, &CFirstModelSetComponent::onSimulatorChanged);
Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect selector signal"); Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect selector signal");
connect(&m_simulatorSettings, &CMultiSimulatorSettings::settingsChanged, this, &CFirstModelSetComponent::onSettingsChanged); connect(&m_simulatorSettings, &CMultiSimulatorSettings::settingsChanged, this, &CFirstModelSetComponent::onSettingsChanged, Qt::QueuedConnection);
Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect settings signal"); Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect settings signal");
connect(m_modelsDialog.data(), &CDbOwnModelsDialog::successfullyLoadedModels, this, &CFirstModelSetComponent::onModelsLoaded); connect(m_modelsDialog.data(), &CDbOwnModelsDialog::successfullyLoadedModels, this, &CFirstModelSetComponent::onModelsLoaded, Qt::QueuedConnection);
Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect models signal"); Q_ASSERT_X(s, Q_FUNC_INFO, "Cannot connect models signal");
connect(ui->pb_ModelSet, &QPushButton::clicked, this, &CFirstModelSetComponent::openOwnModelSetDialog); connect(ui->pb_ModelSet, &QPushButton::clicked, this, &CFirstModelSetComponent::openOwnModelSetDialog);
@@ -86,25 +87,27 @@ namespace BlackGui
// kind of hack, but simplest solution // kind of hack, but simplest solution
// we us the loader of the components directly, // we us the loader of the components directly,
// avoid to fully init a loader logic here // avoid to fully init a loader logic here
static const QString modelInfo("Models indexed: %1");
static const QString modelsNo("No models so far"); static const QString modelsNo("No models so far");
const int modelsCount = this->modelLoader()->getAircraftModelsCount(); const int modelsCount = this->modelLoader()->getAircraftModelsCount();
ui->le_ModelsInfo->setText(modelsCount > 0 ? modelInfo.arg(modelsCount) : modelsNo); ui->le_ModelsInfo->setText(modelsCount > 0 ? this->modelLoader()->getModelCacheCountAndTimestamp() : modelsNo);
ui->pb_CreateModelSet->setEnabled(modelsCount > 0); ui->pb_CreateModelSet->setEnabled(modelsCount > 0);
static const QString modelSetInfo("Models in set: %1");
static const QString modelsSetNo("Model set is empty"); static const QString modelsSetNo("Model set is empty");
const int modelSet = this->modelSetLoader().getAircraftModelsCount(); const int modelsSetCount = this->modelSetLoader().getAircraftModelsCount();
ui->le_ModelSetInfo->setText(modelsCount > 0 ? modelSetInfo.arg(modelSet) : modelsSetNo); ui->le_ModelSetInfo->setText(modelsSetCount > 0 ? this->modelSetLoader().getModelCacheCountAndTimestamp(simulator) : modelsSetNo);
} }
void CFirstModelSetComponent::onSettingsChanged(const CSimulatorInfo &simulator) void CFirstModelSetComponent::onSettingsChanged(const CSimulatorInfo &simulator)
{ {
const CSimulatorInfo currentSimulator = ui->comp_SimulatorSelector->getValue();
if (simulator != currentSimulator) { return; } // ignore changes not for my selected simulator
this->onSimulatorChanged(simulator); this->onSimulatorChanged(simulator);
} }
void CFirstModelSetComponent::onModelsLoaded(const CSimulatorInfo &simulator) void CFirstModelSetComponent::onModelsLoaded(const CSimulatorInfo &simulator)
{ {
const CSimulatorInfo currentSimulator = ui->comp_SimulatorSelector->getValue();
if (simulator != currentSimulator) { return; } // ignore changes not for my selected simulator
this->onSimulatorChanged(simulator); this->onSimulatorChanged(simulator);
} }

View File

@@ -281,6 +281,16 @@ namespace BlackMisc
return m_caches.getInfoStringFsFamily(); return m_caches.getInfoStringFsFamily();
} }
QString IAircraftModelLoader::getModelCacheCountAndTimestamp() const
{
return m_caches.getCacheCountAndTimestamp(this->getSimulator());
}
QString IAircraftModelLoader::getModelCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
{
return m_caches.getCacheCountAndTimestamp(simulator);
}
CSpecializedSimulatorSettings IAircraftModelLoader::getCurrentSimulatorSettings() const CSpecializedSimulatorSettings IAircraftModelLoader::getCurrentSimulatorSettings() const
{ {
return m_settings.getSpecializedSettings(this->getSimulator()); return m_settings.getSpecializedSettings(this->getSimulator());

View File

@@ -150,6 +150,12 @@ namespace BlackMisc
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
QString getModelCacheInfoStringFsFamily() const; QString getModelCacheInfoStringFsFamily() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getCacheCountAndTimestamp
QString getModelCacheCountAndTimestamp() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getCacheCountAndTimestamp
QString getModelCacheCountAndTimestamp(const CSimulatorInfo &simulator) const;
//! \copydoc BlackMisc::Simulation::Data::IMultiSimulatorModelCaches::synchronizeCache //! \copydoc BlackMisc::Simulation::Data::IMultiSimulatorModelCaches::synchronizeCache
void synchronizeModelCache(const CSimulatorInfo &simulator); void synchronizeModelCache(const CSimulatorInfo &simulator);

View File

@@ -160,5 +160,15 @@ namespace BlackMisc
{ {
return m_caches.getInfoStringFsFamily(); return m_caches.getInfoStringFsFamily();
} }
QString CAircraftModelSetLoader::getModelCacheCountAndTimestamp() const
{
return m_caches.getCacheCountAndTimestamp(this->getSimulator());
}
QString CAircraftModelSetLoader::getModelCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
{
return m_caches.getCacheCountAndTimestamp(simulator);
}
} // ns } // ns
} // ns } // ns

View File

@@ -64,7 +64,7 @@ namespace BlackMisc
//! The loaded models for given simulator //! The loaded models for given simulator
//! \threadsafe //! \threadsafe
//! \remark non-const because it synchronizes cache //! \remark non-const because it synchronizes cache
BlackMisc::Simulation::CAircraftModelList getAircraftModels(const BlackMisc::Simulation::CSimulatorInfo &simulator); BlackMisc::Simulation::CAircraftModelList getAircraftModels(const CSimulatorInfo &simulator);
//! Count of loaded models //! Count of loaded models
//! \threadsafe //! \threadsafe
@@ -79,6 +79,7 @@ namespace BlackMisc
BlackMisc::Simulation::CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const; BlackMisc::Simulation::CAircraftModelList getCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Current simulator //! Current simulator
//! \threadsafe
CSimulatorInfo getSimulator() const; CSimulatorInfo getSimulator() const;
//! Supported simulators as string //! Supported simulators as string
@@ -103,6 +104,12 @@ namespace BlackMisc
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily //! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
QString getInfoStringFsFamily() const; QString getInfoStringFsFamily() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getCacheCountAndTimestamp
QString getModelCacheCountAndTimestamp() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getCacheCountAndTimestamp
QString getModelCacheCountAndTimestamp(const CSimulatorInfo &simulator) const;
//! \name Implementations of the models interfaces //! \name Implementations of the models interfaces
//! @{ //! @{
virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); } virtual void setModels(const BlackMisc::Simulation::CAircraftModelList &models) override { this->setCachedModels(models, this->getSimulator()); }

View File

@@ -38,6 +38,12 @@ namespace BlackMisc
return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9)); return is.arg(this->getCachedModelsCount(CSimulatorInfo::FSX)).arg(this->getCachedModelsCount(CSimulatorInfo::P3D)).arg(this->getCachedModelsCount(CSimulatorInfo::FS9));
} }
QString IMultiSimulatorModelCaches::getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const
{
static const QString s("%1 models, ts: %2");
return s.arg(this->getCachedModelsCount(simulator)).arg(this->getCacheTimestamp(simulator).toString("yyyy-MM-dd HH:mm:ss"));
}
void IMultiSimulatorModelCaches::onLastSelectionChanged() void IMultiSimulatorModelCaches::onLastSelectionChanged()
{ {
this->synchronizeCurrentCache(); this->synchronizeCurrentCache();

View File

@@ -238,6 +238,9 @@ namespace BlackMisc
//! Info string without XPlane (FSX,P3D, FS9) //! Info string without XPlane (FSX,P3D, FS9)
QString getInfoStringFsFamily() const; QString getInfoStringFsFamily() const;
//! Cache count and timestamp
QString getCacheCountAndTimestamp(const CSimulatorInfo &simulator) const;
//! Descriptive text //! Descriptive text
virtual QString getDescription() const = 0; virtual QString getDescription() const = 0;