mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
refs #619, adjusted model loader / implementing classes
* init data based on last setup * init changed some signatures
This commit is contained in:
@@ -96,12 +96,12 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex()
|
||||
int comparePropertyByIndex(const CAircraftModel &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Can be initialized from FSD
|
||||
bool canInitializeFromFsd() const;
|
||||
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CAircraftModel &compareValue, const CPropertyIndex &index) const;
|
||||
|
||||
//! Corresponding callsign if applicable
|
||||
const BlackMisc::Aviation::CCallsign &getCallsign() const { return this->m_callsign; }
|
||||
|
||||
|
||||
@@ -58,23 +58,23 @@ namespace BlackMisc
|
||||
if (this->m_loadingInProgress) { return; }
|
||||
this->m_loadingInProgress = true;
|
||||
const bool useCachedData = !mode.testFlag(CacheSkipped) && this->hasCachedData();
|
||||
if (useCachedData && mode.testFlag(CacheFirst))
|
||||
if (useCachedData && (mode.testFlag(CacheFirst) || mode.testFlag(CacheOnly)))
|
||||
{
|
||||
emit loadingFinished(true);
|
||||
emit loadingFinished(true, this->m_simulatorInfo);
|
||||
return;
|
||||
}
|
||||
else if (useCachedData && mode.testFlag(CacheUntilNewer))
|
||||
{
|
||||
if (!this->areModelFilesUpdated())
|
||||
{
|
||||
emit loadingFinished(true);
|
||||
emit loadingFinished(true, this->m_simulatorInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (mode.testFlag(CacheOnly))
|
||||
{
|
||||
// only cache, but we did not find any data
|
||||
emit loadingFinished(false);
|
||||
emit loadingFinished(false, this->m_simulatorInfo);
|
||||
return;
|
||||
}
|
||||
this->startLoadingFromDisk(mode);
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace BlackMisc
|
||||
CacheUntilNewer = 1 << 2, //!< use cache until newer data re available
|
||||
CacheFirst = 1 << 3, //!< always use cache (if it has data)
|
||||
CacheSkipped = 1 << 4, //!< ignore cache
|
||||
CacheOnly = 1 << 5, //!< force ignoring the cache
|
||||
CacheOnly = 1 << 5, //!< only read cache, never load from disk
|
||||
Default = LoadInBackground | CacheFirst //!< default mode
|
||||
};
|
||||
Q_DECLARE_FLAGS(LoadMode, LoadModeFlag)
|
||||
@@ -97,7 +97,7 @@ namespace BlackMisc
|
||||
|
||||
signals:
|
||||
//! Parsing is finished
|
||||
void loadingFinished(bool success);
|
||||
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
|
||||
@@ -107,8 +107,9 @@ namespace BlackMisc
|
||||
{
|
||||
if (pair.second)
|
||||
{
|
||||
this->updateCfgEntriesList(pair.first);
|
||||
this->m_parsedCfgEntriesList = pair.first;
|
||||
this->setModelsInCache(pair.first.toAircraftModelList());
|
||||
emit loadingFinished(true, this->m_simulatorInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -117,7 +118,15 @@ namespace BlackMisc
|
||||
bool ok;
|
||||
this->m_parsedCfgEntriesList = performParsing(m_rootDirectory, m_excludedDirectories, &ok);
|
||||
this->setModelsInCache(this->m_parsedCfgEntriesList.toAircraftModelList());
|
||||
emit loadingFinished(ok);
|
||||
emit loadingFinished(ok, this->m_simulatorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftCfgParser::ps_cacheChanged()
|
||||
{
|
||||
if (this->hasCachedData())
|
||||
{
|
||||
emit this->loadingFinished(true, this->m_simulatorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,12 +197,6 @@ namespace BlackMisc
|
||||
return empty;
|
||||
}
|
||||
|
||||
void CAircraftCfgParser::updateCfgEntriesList(const CAircraftCfgEntriesList &cfgEntriesList)
|
||||
{
|
||||
m_parsedCfgEntriesList = cfgEntriesList;
|
||||
emit loadingFinished(true);
|
||||
}
|
||||
|
||||
CStatusMessage CAircraftCfgParser::setModelsInCache(const CAircraftModelList &models)
|
||||
{
|
||||
if (this->m_simulatorInfo.fsx())
|
||||
|
||||
@@ -56,10 +56,6 @@ namespace BlackMisc
|
||||
//! Create an parser object for given simulator
|
||||
static std::unique_ptr<CAircraftCfgParser> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||
|
||||
public slots:
|
||||
//! Parsed or injected entires
|
||||
void updateCfgEntriesList(const BlackMisc::Simulation::FsCommon::CAircraftCfgEntriesList &cfgEntriesList);
|
||||
|
||||
protected:
|
||||
//! Set cached values
|
||||
BlackMisc::CStatusMessage setModelsInCache(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
@@ -69,6 +65,10 @@ namespace BlackMisc
|
||||
virtual void startLoadingFromDisk(LoadMode mode) override;
|
||||
//! @}
|
||||
|
||||
private slots:
|
||||
//! Cache changed
|
||||
void ps_cacheChanged();
|
||||
|
||||
private:
|
||||
//! Section within file
|
||||
enum FileSection
|
||||
@@ -95,9 +95,9 @@ namespace BlackMisc
|
||||
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
||||
|
||||
//! \todo KB/MS Is there nothing better than having 3 cache members?
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFsx> m_modelCacheFsx {this}; //!< FSX cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFs9> m_modelCacheFs9 {this}; //!< Fs9 cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheP3D> m_modelCacheP3D {this}; //!< P3D cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFsx> m_modelCacheFsx {this, &CAircraftCfgParser::ps_cacheChanged}; //!< FSX cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheFs9> m_modelCacheFs9 {this, &CAircraftCfgParser::ps_cacheChanged}; //!< FS9 cache
|
||||
BlackMisc::CData<BlackMisc::Simulation::Data::ModelCacheP3D> m_modelCacheP3D {this, &CAircraftCfgParser::ps_cacheChanged}; //!< P3D cache
|
||||
|
||||
static const QString &fileFilter();
|
||||
};
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace BlackMisc
|
||||
m_installedModels.clear();
|
||||
if (m_rootDirectory.isEmpty())
|
||||
{
|
||||
emit loadingFinished(false);
|
||||
emit loadingFinished(false, this->m_simulatorInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace BlackMisc
|
||||
else if (mode.testFlag(LoadDirectly))
|
||||
{
|
||||
m_installedModels = performParsing(m_rootDirectory, m_excludedDirectories);
|
||||
emit loadingFinished(true);
|
||||
emit loadingFinished(true, this->m_simulatorInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace BlackMisc
|
||||
void CAircraftModelLoaderXPlane::updateInstalledModels(const CAircraftModelList &models)
|
||||
{
|
||||
m_installedModels = models;
|
||||
emit loadingFinished(true);
|
||||
emit loadingFinished(true, this->m_simulatorInfo);
|
||||
}
|
||||
|
||||
QString CAircraftModelLoaderXPlane::CSLPlane::getModelName() const
|
||||
|
||||
Reference in New Issue
Block a user