mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #619, use a combined cache class
* moved caches to blackmisc * used CModelCaches in loader * applied changes in simulator specific loader classes * renamed find function to findFirstByModelStringOrDefault * made merge function static so it can be used elsewhere
This commit is contained in:
@@ -1,55 +0,0 @@
|
|||||||
/* Copyright (C) 2015
|
|
||||||
* swift project community / contributors
|
|
||||||
*
|
|
||||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
|
||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
|
||||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
|
||||||
* contained in the LICENSE file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
//! \file
|
|
||||||
|
|
||||||
#ifndef BLACKCORE_DATA_AIRCRAFTMODELS_H
|
|
||||||
#define BLACKCORE_DATA_AIRCRAFTMODELS_H
|
|
||||||
|
|
||||||
#include "blackcore/blackcoreexport.h"
|
|
||||||
#include "blackmisc/datacache.h"
|
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
|
||||||
#include "blackmisc/variant.h"
|
|
||||||
|
|
||||||
namespace BlackCore
|
|
||||||
{
|
|
||||||
namespace Data
|
|
||||||
{
|
|
||||||
//! Trait for own simulator models
|
|
||||||
struct OwnSimulatorAircraftModels : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList>
|
|
||||||
{
|
|
||||||
//! Key in data cache
|
|
||||||
static const char *key() { return "simulator/models"; }
|
|
||||||
|
|
||||||
//! Default value
|
|
||||||
static const BlackMisc::Simulation::CAircraftModelList &defaultValue()
|
|
||||||
{
|
|
||||||
static const BlackMisc::Simulation::CAircraftModelList defaultValue;
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//! Trait for vPilot derived models
|
|
||||||
struct VPilotAircraftModels : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList>
|
|
||||||
{
|
|
||||||
//! Key in data cache
|
|
||||||
static const char *key() { return "vpilot/models"; }
|
|
||||||
|
|
||||||
//! Default value
|
|
||||||
static const BlackMisc::Simulation::CAircraftModelList &defaultValue()
|
|
||||||
{
|
|
||||||
static const BlackMisc::Simulation::CAircraftModelList defaultValue;
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // ns
|
|
||||||
} // ns
|
|
||||||
|
|
||||||
#endif // guard
|
|
||||||
@@ -82,7 +82,7 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
if (modelString.isEmpty()) { return CAircraftModel(); }
|
if (modelString.isEmpty()) { return CAircraftModel(); }
|
||||||
CAircraftModelList models(getModels());
|
CAircraftModelList models(getModels());
|
||||||
return models.findFirstByModelString(modelString);
|
return models.findFirstByModelStringOrDefault(modelString);
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModelList CModelDataReader::getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode)
|
CAircraftModelList CModelDataReader::getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ SOURCES += *.cpp \
|
|||||||
$$PWD/simulation/fscommon/*.cpp \
|
$$PWD/simulation/fscommon/*.cpp \
|
||||||
$$PWD/simulation/fsx/*.cpp \
|
$$PWD/simulation/fsx/*.cpp \
|
||||||
$$PWD/simulation/xplane/*.cpp \
|
$$PWD/simulation/xplane/*.cpp \
|
||||||
# $$PWD/simulation/data/*.cpp \
|
$$PWD/simulation/data/*.cpp \
|
||||||
$$PWD/weather/*.cpp
|
$$PWD/weather/*.cpp
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
CAircraftModel CAircraftMatcher::matchByExactModelName(const CSimulatedAircraft &remoteAircraft)
|
CAircraftModel CAircraftMatcher::matchByExactModelName(const CSimulatedAircraft &remoteAircraft)
|
||||||
{
|
{
|
||||||
return this->m_installedModels.findFirstByModelString(remoteAircraft.getModelString());
|
return this->m_installedModels.findFirstByModelStringOrDefault(remoteAircraft.getModelString());
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CAircraftMatcher::matchInstalledModelsByIcaoData(const CSimulatedAircraft &remoteAircraft)
|
CAircraftModel CAircraftMatcher::matchInstalledModelsByIcaoData(const CSimulatedAircraft &remoteAircraft)
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace BlackMisc
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
CAircraftModel CAircraftModelList::findFirstByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
CAircraftModel CAircraftModelList::findFirstByModelStringOrDefault(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||||
{
|
{
|
||||||
return this->findFirstByOrDefault([ = ](const CAircraftModel & model)
|
return this->findFirstByOrDefault([ = ](const CAircraftModel & model)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace BlackMisc
|
|||||||
CAircraftModelList findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
CAircraftModelList findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
||||||
|
|
||||||
//! Find first by model string
|
//! Find first by model string
|
||||||
CAircraftModel findFirstByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
CAircraftModel findFirstByModelStringOrDefault(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
||||||
|
|
||||||
//! Find models starting with
|
//! Find models starting with
|
||||||
CAircraftModelList findModelsStartingWith(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
CAircraftModelList findModelsStartingWith(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace BlackMisc
|
|||||||
IAircraftModelLoader::IAircraftModelLoader(const CSimulatorInfo &info, const QString &rootDirectory, const QStringList &excludeDirs) :
|
IAircraftModelLoader::IAircraftModelLoader(const CSimulatorInfo &info, const QString &rootDirectory, const QStringList &excludeDirs) :
|
||||||
m_simulatorInfo(info), m_rootDirectory(rootDirectory), m_excludedDirectories(excludeDirs)
|
m_simulatorInfo(info), m_rootDirectory(rootDirectory), m_excludedDirectories(excludeDirs)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT_X(info.isSingleSimulator(), Q_FUNC_INFO, "Only one simulator per loader");
|
||||||
connect(this, &IAircraftModelLoader::loadingFinished, this, &IAircraftModelLoader::ps_loadFinished);
|
connect(this, &IAircraftModelLoader::loadingFinished, this, &IAircraftModelLoader::ps_loadFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
if (directory.isEmpty()) { return false; }
|
if (directory.isEmpty()) { return false; }
|
||||||
QDir dir(directory);
|
QDir dir(directory);
|
||||||
//! \todo not available network dir can make this hang here
|
//! \todo not available network dir can make this hang here, however there is no obvious solution to that
|
||||||
return dir.exists();
|
return dir.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ namespace BlackMisc
|
|||||||
for (CAircraftModel &simModel : modelsFromSimulator)
|
for (CAircraftModel &simModel : modelsFromSimulator)
|
||||||
{
|
{
|
||||||
if (simModel.hasValidDbKey()) { continue; } // already done
|
if (simModel.hasValidDbKey()) { continue; } // already done
|
||||||
CAircraftModel dbModel(dbModels.findFirstByModelString(simModel.getModelString()));
|
CAircraftModel dbModel(dbModels.findFirstByModelStringOrDefault(simModel.getModelString()));
|
||||||
if (!dbModel.hasValidDbKey())
|
if (!dbModel.hasValidDbKey())
|
||||||
{
|
{
|
||||||
continue; // not found
|
continue; // not found
|
||||||
@@ -70,6 +71,36 @@ namespace BlackMisc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAircraftModelList IAircraftModelLoader::getAircraftModels() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getModels(this->m_simulatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime IAircraftModelLoader::getCacheTimestamp() const
|
||||||
|
{
|
||||||
|
return this->m_caches.getCacheTimestamp(this->m_simulatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IAircraftModelLoader::syncronizeCache()
|
||||||
|
{
|
||||||
|
return this->m_caches.syncronize(this->m_simulatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IAircraftModelLoader::hasCachedData() const
|
||||||
|
{
|
||||||
|
return !this->m_caches.getModels(this->m_simulatorInfo).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessage IAircraftModelLoader::setModelsInCache(const CAircraftModelList &models)
|
||||||
|
{
|
||||||
|
return this->m_caches.setModels(models, this->m_simulatorInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessage IAircraftModelLoader::clearCache()
|
||||||
|
{
|
||||||
|
return this->setModelsInCache(CAircraftModelList());
|
||||||
|
}
|
||||||
|
|
||||||
void IAircraftModelLoader::startLoading(LoadMode mode, const CAircraftModelList &dbModels)
|
void IAircraftModelLoader::startLoading(LoadMode mode, const CAircraftModelList &dbModels)
|
||||||
{
|
{
|
||||||
if (this->m_loadingInProgress) { return; }
|
if (this->m_loadingInProgress) { return; }
|
||||||
@@ -98,19 +129,19 @@ namespace BlackMisc
|
|||||||
this->startLoadingFromDisk(mode, dbModels);
|
this->startLoadingFromDisk(mode, dbModels);
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSimulatorInfo &IAircraftModelLoader::supportedSimulators() const
|
const CSimulatorInfo &IAircraftModelLoader::getSimulator() const
|
||||||
{
|
{
|
||||||
return m_simulatorInfo;
|
return m_simulatorInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString IAircraftModelLoader::supportedSimulatorsAsString() const
|
QString IAircraftModelLoader::getSimulatorAsString() const
|
||||||
{
|
{
|
||||||
return m_simulatorInfo.toQString();
|
return m_simulatorInfo.toQString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IAircraftModelLoader::supportsSimulator(const CSimulatorInfo &info)
|
bool IAircraftModelLoader::supportsSimulator(const CSimulatorInfo &info)
|
||||||
{
|
{
|
||||||
return supportedSimulators().matchesAny(info);
|
return getSimulator().matchesAny(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IAircraftModelLoader::cancelLoading()
|
void IAircraftModelLoader::cancelLoading()
|
||||||
@@ -126,16 +157,20 @@ namespace BlackMisc
|
|||||||
|
|
||||||
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simInfo)
|
std::unique_ptr<IAircraftModelLoader> IAircraftModelLoader::createModelLoader(const CSimulatorInfo &simInfo)
|
||||||
{
|
{
|
||||||
|
std::unique_ptr<IAircraftModelLoader> loader;
|
||||||
if (simInfo.xplane())
|
if (simInfo.xplane())
|
||||||
{
|
{
|
||||||
return std::make_unique<CAircraftModelLoaderXPlane>(
|
loader = std::make_unique<CAircraftModelLoaderXPlane>(
|
||||||
CSimulatorInfo(CSimulatorInfo::XPLANE),
|
CSimulatorInfo(CSimulatorInfo::XPLANE),
|
||||||
CXPlaneUtil::xplaneRootDir());
|
CXPlaneUtil::xplaneRootDir());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return CAircraftCfgParser::createModelLoader(simInfo);
|
loader = CAircraftCfgParser::createModelLoader(simInfo);
|
||||||
}
|
}
|
||||||
|
// make sure the cache is really available
|
||||||
|
loader->syncronizeCache();
|
||||||
|
return loader;
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -65,28 +65,22 @@ namespace BlackMisc
|
|||||||
virtual bool isLoadingFinished() const = 0;
|
virtual bool isLoadingFinished() const = 0;
|
||||||
|
|
||||||
//! The loaded models
|
//! The loaded models
|
||||||
virtual const BlackMisc::Simulation::CAircraftModelList &getAircraftModels() const = 0;
|
BlackMisc::Simulation::CAircraftModelList getAircraftModels() const;
|
||||||
|
|
||||||
//! Count of loaded models
|
//! Count of loaded models
|
||||||
const int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
int getAircraftModelsCount() const { return getAircraftModels().size(); }
|
||||||
|
|
||||||
//! Cache timestamp
|
|
||||||
virtual QDateTime getCacheTimestamp() const = 0;
|
|
||||||
|
|
||||||
//! Model files updated?
|
//! Model files updated?
|
||||||
virtual bool areModelFilesUpdated() const = 0;
|
virtual bool areModelFilesUpdated() const = 0;
|
||||||
|
|
||||||
//! Any cached data
|
|
||||||
virtual bool hasCachedData() const = 0;
|
|
||||||
|
|
||||||
//! A representive pixmap for given model
|
//! A representive pixmap for given model
|
||||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const = 0;
|
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const = 0;
|
||||||
|
|
||||||
//! Which simulators are supported by that very loader
|
//! Which simulator is supported by that very loader
|
||||||
const BlackMisc::Simulation::CSimulatorInfo &supportedSimulators() const;
|
const BlackMisc::Simulation::CSimulatorInfo &getSimulator() const;
|
||||||
|
|
||||||
//! Supported simulators as string
|
//! Supported simulators as string
|
||||||
QString supportedSimulatorsAsString() const;
|
QString getSimulatorAsString() const;
|
||||||
|
|
||||||
//! Is the given simulator supported?
|
//! Is the given simulator supported?
|
||||||
bool supportsSimulator(const BlackMisc::Simulation::CSimulatorInfo &info);
|
bool supportsSimulator(const BlackMisc::Simulation::CSimulatorInfo &info);
|
||||||
@@ -100,6 +94,9 @@ namespace BlackMisc
|
|||||||
//! Create a loader
|
//! Create a loader
|
||||||
static std::unique_ptr<IAircraftModelLoader> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
static std::unique_ptr<IAircraftModelLoader> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||||
|
|
||||||
|
//! Merge with DB data if possible
|
||||||
|
static bool mergeWithDbData(BlackMisc::Simulation::CAircraftModelList &modelsFromSimulator, const BlackMisc::Simulation::CAircraftModelList &dbModels);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Parsing is finished
|
//! Parsing is finished
|
||||||
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
void loadingFinished(bool success, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
@@ -108,20 +105,33 @@ namespace BlackMisc
|
|||||||
//! Constructor
|
//! Constructor
|
||||||
IAircraftModelLoader(const CSimulatorInfo &info, const QString &rootDirectory, const QStringList &excludeDirs = {});
|
IAircraftModelLoader(const CSimulatorInfo &info, const QString &rootDirectory, const QStringList &excludeDirs = {});
|
||||||
|
|
||||||
|
//! Cache timestamp
|
||||||
|
QDateTime getCacheTimestamp() const;
|
||||||
|
|
||||||
|
//! Make sure cache is syncronized
|
||||||
|
void syncronizeCache();
|
||||||
|
|
||||||
|
//! Any cached data?
|
||||||
|
bool hasCachedData() const;
|
||||||
|
|
||||||
|
//! Set models in cache
|
||||||
|
BlackMisc::CStatusMessage setModelsInCache(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||||
|
|
||||||
|
//! Clear cache
|
||||||
|
BlackMisc::CStatusMessage clearCache();
|
||||||
|
|
||||||
//! Check if directory exists
|
//! Check if directory exists
|
||||||
bool existsDir(const QString &directory) const;
|
bool existsDir(const QString &directory) const;
|
||||||
|
|
||||||
//! Start the loading process from disk
|
//! Start the loading process from disk
|
||||||
virtual void startLoadingFromDisk(LoadMode mode, const BlackMisc::Simulation::CAircraftModelList &dbModels) = 0;
|
virtual void startLoadingFromDisk(LoadMode mode, const BlackMisc::Simulation::CAircraftModelList &dbModels) = 0;
|
||||||
|
|
||||||
//! Merge with DB data if possible
|
|
||||||
virtual bool mergeWithDbData(BlackMisc::Simulation::CAircraftModelList &modelsFromSimulator, const BlackMisc::Simulation::CAircraftModelList &dbModels);
|
|
||||||
|
|
||||||
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo; //!< Corresponding simulator
|
BlackMisc::Simulation::CSimulatorInfo m_simulatorInfo; //!< Corresponding simulator
|
||||||
std::atomic<bool> m_cancelLoading { false }; //!< flag
|
std::atomic<bool> m_cancelLoading { false }; //!< flag
|
||||||
std::atomic<bool> m_loadingInProgress { false }; //!< Loading in progress
|
std::atomic<bool> m_loadingInProgress { false }; //!< Loading in progress
|
||||||
QString m_rootDirectory; //!< root directory parsing aircraft.cfg files
|
QString m_rootDirectory; //!< root directory parsing aircraft.cfg files
|
||||||
QStringList m_excludedDirectories; //!< directories not to be parsed
|
QStringList m_excludedDirectories; //!< directories not to be parsed
|
||||||
|
BlackMisc::Simulation::Data::CModelCaches m_caches { this }; //!< caches
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
//! Loading finished
|
//! Loading finished
|
||||||
|
|||||||
144
src/blackmisc/simulation/data/modelcaches.cpp
Normal file
144
src/blackmisc/simulation/data/modelcaches.cpp
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/* Copyright (C) 2016
|
||||||
|
* swift project community / contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "modelcaches.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
namespace Data
|
||||||
|
{
|
||||||
|
CModelCaches::CModelCaches(QObject *parent) : QObject(parent)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CAircraftModelList CModelCaches::getModels(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return CAircraftModelList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessage CModelCaches::setModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.set(models);
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.set(models);
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.set(models);
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.set(models);
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return CStatusMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime CModelCaches::getCacheTimestamp(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getTimestamp();
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getTimestamp();
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getTimestamp();
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getTimestamp();
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return QDateTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelCaches::syncronize(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.synchronize(); break;
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.synchronize(); break;
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.synchronize(); break;
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.synchronize(); break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CModelSetCaches::CModelSetCaches(QObject *parent) : QObject(parent)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
CAircraftModelList CModelSetCaches::getModels(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return CAircraftModelList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CStatusMessage CModelSetCaches::setModels(const CAircraftModelList &models, const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.set(models);
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.set(models);
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.set(models);
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.set(models);
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return CStatusMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime CModelSetCaches::getCacheTimestamp(const CSimulatorInfo &simulator) const
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.getTimestamp();
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.getTimestamp();
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.getTimestamp();
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.getTimestamp();
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
return QDateTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModelSetCaches::syncronize(const CSimulatorInfo &simulator)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
switch (simulator.getSimulator())
|
||||||
|
{
|
||||||
|
case CSimulatorInfo::FS9: return this->m_modelCacheFs9.synchronize(); break;
|
||||||
|
case CSimulatorInfo::FSX: return this->m_modelCacheFsx.synchronize(); break;
|
||||||
|
case CSimulatorInfo::P3D: return this->m_modelCacheP3D.synchronize(); break;
|
||||||
|
case CSimulatorInfo::XPLANE: return this->m_modelCacheXP.synchronize(); break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "No single simulator");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
@@ -32,33 +32,137 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Trait for XP model cache
|
//! \name Caches for own models on disk, loaded by BlackMisc::Simulation::IAircraftModelLoader
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
//! XPlane
|
||||||
struct ModelCacheXP : public ModelCache
|
struct ModelCacheXP : public ModelCache
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "modelcachexp"; }
|
static const char *key() { return "modelcachexp"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Trait for FSX model cache
|
//! FSX
|
||||||
struct ModelCacheFsx : public ModelCache
|
struct ModelCacheFsx : public ModelCache
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "modelcachefsx"; }
|
static const char *key() { return "modelcachefsx"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Trait for FS9 model cache
|
//! FS9
|
||||||
struct ModelCacheFs9 : public ModelCache
|
struct ModelCacheFs9 : public ModelCache
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "modelcachefs9"; }
|
static const char *key() { return "modelcachefs9"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Trait for P3D model cache
|
//! P3D
|
||||||
struct ModelCacheP3D : public ModelCache
|
struct ModelCacheP3D : public ModelCache
|
||||||
{
|
{
|
||||||
//! Key in data cache
|
//! Key in data cache
|
||||||
static const char *key() { return "modelcachep3d"; }
|
static const char *key() { return "modelcachep3d"; }
|
||||||
};
|
};
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
|
||||||
|
//! \name Caches for choosen model sets
|
||||||
|
//! @{
|
||||||
|
|
||||||
|
//! XPlane
|
||||||
|
struct ModelSetCacheXP : public ModelCache
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "modelsetxp"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! FSX
|
||||||
|
struct ModelSetCacheFsx : public ModelCache
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "modelsetfsx"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! FS9
|
||||||
|
struct ModelSetCacheFs9 : public ModelCache
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "modelsetfs9"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! P3D
|
||||||
|
struct ModelSetCacheP3D : public ModelCache
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "modelsetp3d"; }
|
||||||
|
};
|
||||||
|
//! @}
|
||||||
|
|
||||||
|
|
||||||
|
//! Trait for vPilot derived models
|
||||||
|
struct VPilotAircraftModels : public BlackMisc::CDataTrait<BlackMisc::Simulation::CAircraftModelList>
|
||||||
|
{
|
||||||
|
//! Key in data cache
|
||||||
|
static const char *key() { return "vpilot/models"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Bundle of caches for all simulators
|
||||||
|
//! \remark Temp. workaround
|
||||||
|
class CModelCaches : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Construtor
|
||||||
|
CModelCaches(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
//! Models
|
||||||
|
CAircraftModelList getModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
|
//! Set models
|
||||||
|
BlackMisc::CStatusMessage setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
//! Cache timestamp
|
||||||
|
QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
|
//! Syncronize
|
||||||
|
void syncronize(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
private:
|
||||||
|
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::ModelCacheXP> m_modelCacheXP {this }; //!< XP cache
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Bundle of caches for model sets of all simulators
|
||||||
|
//! \remark Temp. workaround
|
||||||
|
class CModelSetCaches : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Construtor
|
||||||
|
CModelSetCaches(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
//! Models
|
||||||
|
CAircraftModelList getModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
|
//! Set models
|
||||||
|
BlackMisc::CStatusMessage setModels(const BlackMisc::Simulation::CAircraftModelList &models, const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
//! Cache timestamp
|
||||||
|
QDateTime getCacheTimestamp(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
|
||||||
|
|
||||||
|
//! Syncronize
|
||||||
|
void syncronize(const BlackMisc::Simulation::CSimulatorInfo &simulator);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFsx> m_modelCacheFsx {this }; //!< FSX cache
|
||||||
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheFs9> m_modelCacheFs9 {this }; //!< FS9 cache
|
||||||
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheP3D> m_modelCacheP3D {this }; //!< P3D cache
|
||||||
|
BlackMisc::CData<BlackMisc::Simulation::Data::ModelSetCacheXP> m_modelCacheXP {this }; //!< XP cache
|
||||||
|
};
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ namespace BlackMisc
|
|||||||
CAircraftModelList models;
|
CAircraftModelList models;
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
models = (aircraftCfgEntriesList.toAircraftModelList(this->supportedSimulators()));
|
models = (aircraftCfgEntriesList.toAircraftModelList(this->getSimulator()));
|
||||||
this->mergeWithDbData(models, dbModels);
|
this->mergeWithDbData(models, dbModels);
|
||||||
}
|
}
|
||||||
return std::make_tuple(aircraftCfgEntriesList, models, ok);
|
return std::make_tuple(aircraftCfgEntriesList, models, ok);
|
||||||
@@ -139,7 +139,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
this->m_parsedCfgEntriesList = performParsing(m_rootDirectory, m_excludedDirectories, &ok);
|
this->m_parsedCfgEntriesList = performParsing(m_rootDirectory, m_excludedDirectories, &ok);
|
||||||
CAircraftModelList models(this->m_parsedCfgEntriesList.toAircraftModelList(this->supportedSimulators()));
|
CAircraftModelList models(this->m_parsedCfgEntriesList.toAircraftModelList(this->getSimulator()));
|
||||||
this->mergeWithDbData(models, dbModels);
|
this->mergeWithDbData(models, dbModels);
|
||||||
const bool hasData = !models.isEmpty();
|
const bool hasData = !models.isEmpty();
|
||||||
if (hasData)
|
if (hasData)
|
||||||
@@ -164,24 +164,6 @@ namespace BlackMisc
|
|||||||
return !m_parserWorker || m_parserWorker->isFinished();
|
return !m_parserWorker || m_parserWorker->isFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime CAircraftCfgParser::getCacheTimestamp() const
|
|
||||||
{
|
|
||||||
if (this->m_simulatorInfo.fsx())
|
|
||||||
{
|
|
||||||
return m_modelCacheFsx.getTimestamp();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.fs9())
|
|
||||||
{
|
|
||||||
return m_modelCacheFs9.getTimestamp();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.p3d())
|
|
||||||
{
|
|
||||||
return m_modelCacheP3D.getTimestamp();
|
|
||||||
}
|
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
|
||||||
return QDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CAircraftCfgParser::areModelFilesUpdated() const
|
bool CAircraftCfgParser::areModelFilesUpdated() const
|
||||||
{
|
{
|
||||||
const QDateTime cacheTs(getCacheTimestamp());
|
const QDateTime cacheTs(getCacheTimestamp());
|
||||||
@@ -189,61 +171,6 @@ namespace BlackMisc
|
|||||||
return CFileUtils::containsFileNewerThan(cacheTs, this->getRootDirectory(), true, { fileFilter() }, this->m_excludedDirectories);
|
return CFileUtils::containsFileNewerThan(cacheTs, this->getRootDirectory(), true, { fileFilter() }, this->m_excludedDirectories);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftCfgParser::hasCachedData() const
|
|
||||||
{
|
|
||||||
if (this->m_simulatorInfo.fsx())
|
|
||||||
{
|
|
||||||
return !m_modelCacheFsx.get().isEmpty();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.fs9())
|
|
||||||
{
|
|
||||||
return !m_modelCacheFs9.get().isEmpty();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.p3d())
|
|
||||||
{
|
|
||||||
return !m_modelCacheP3D.get().isEmpty();
|
|
||||||
}
|
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CAircraftModelList &CAircraftCfgParser::getAircraftModels() const
|
|
||||||
{
|
|
||||||
static const CAircraftModelList empty;
|
|
||||||
if (this->m_simulatorInfo.fsx())
|
|
||||||
{
|
|
||||||
return m_modelCacheFsx.get();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.fs9())
|
|
||||||
{
|
|
||||||
return m_modelCacheFs9.get();
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.p3d())
|
|
||||||
{
|
|
||||||
return m_modelCacheP3D.get();
|
|
||||||
}
|
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
|
||||||
return empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
CStatusMessage CAircraftCfgParser::setModelsInCache(const CAircraftModelList &models)
|
|
||||||
{
|
|
||||||
if (this->m_simulatorInfo.fsx())
|
|
||||||
{
|
|
||||||
return m_modelCacheFsx.set(models);
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.fs9())
|
|
||||||
{
|
|
||||||
return m_modelCacheFs9.set(models);
|
|
||||||
}
|
|
||||||
else if (this->m_simulatorInfo.p3d())
|
|
||||||
{
|
|
||||||
return m_modelCacheP3D.set(models);
|
|
||||||
}
|
|
||||||
Q_ASSERT_X(false, Q_FUNC_INFO, "Illegal simulator info");
|
|
||||||
return CStatusMessage(this, CStatusMessage::SeverityError, "Wrong simulator type");
|
|
||||||
}
|
|
||||||
|
|
||||||
CAircraftCfgEntriesList CAircraftCfgParser::performParsing(const QString &directory, const QStringList &excludeDirectories, bool *ok)
|
CAircraftCfgEntriesList CAircraftCfgParser::performParsing(const QString &directory, const QStringList &excludeDirectories, bool *ok)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -48,18 +48,12 @@ namespace BlackMisc
|
|||||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const override;
|
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const override;
|
||||||
virtual bool isLoadingFinished() const override;
|
virtual bool isLoadingFinished() const override;
|
||||||
virtual bool areModelFilesUpdated() const override;
|
virtual bool areModelFilesUpdated() const override;
|
||||||
virtual bool hasCachedData() const override;
|
|
||||||
virtual QDateTime getCacheTimestamp() const override;
|
|
||||||
virtual const BlackMisc::Simulation::CAircraftModelList &getAircraftModels() const override;
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
//! Create an parser object for given simulator
|
//! Create an parser object for given simulator
|
||||||
static std::unique_ptr<CAircraftCfgParser> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
static std::unique_ptr<CAircraftCfgParser> createModelLoader(const BlackMisc::Simulation::CSimulatorInfo &simInfo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Set cached values
|
|
||||||
BlackMisc::CStatusMessage setModelsInCache(const BlackMisc::Simulation::CAircraftModelList &models);
|
|
||||||
|
|
||||||
//! \name Interface functions
|
//! \name Interface functions
|
||||||
//! @{
|
//! @{
|
||||||
virtual void startLoadingFromDisk(LoadMode mode, const BlackMisc::Simulation::CAircraftModelList &dbModels) override;
|
virtual void startLoadingFromDisk(LoadMode mode, const BlackMisc::Simulation::CAircraftModelList &dbModels) override;
|
||||||
@@ -94,11 +88,7 @@ namespace BlackMisc
|
|||||||
CAircraftCfgEntriesList m_parsedCfgEntriesList; //!< parsed entries
|
CAircraftCfgEntriesList m_parsedCfgEntriesList; //!< parsed entries
|
||||||
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
||||||
|
|
||||||
//! \todo KB/MS Is there nothing better than having 3 cache members?
|
//! Files to be used
|
||||||
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();
|
static const QString &fileFilter();
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ namespace BlackMisc
|
|||||||
|
|
||||||
void CAircraftModelLoaderXPlane::startLoadingFromDisk(LoadMode mode, const CAircraftModelList &dbModels)
|
void CAircraftModelLoaderXPlane::startLoadingFromDisk(LoadMode mode, const CAircraftModelList &dbModels)
|
||||||
{
|
{
|
||||||
m_installedModels.clear();
|
|
||||||
if (m_rootDirectory.isEmpty())
|
if (m_rootDirectory.isEmpty())
|
||||||
{
|
{
|
||||||
|
this->clearCache();
|
||||||
emit loadingFinished(false, this->m_simulatorInfo);
|
emit loadingFinished(false, this->m_simulatorInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -90,9 +90,9 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
else if (mode.testFlag(LoadDirectly))
|
else if (mode.testFlag(LoadDirectly))
|
||||||
{
|
{
|
||||||
m_installedModels = performParsing(m_rootDirectory, m_excludedDirectories);
|
CAircraftModelList models(performParsing(m_rootDirectory, m_excludedDirectories));
|
||||||
mergeWithDbData(m_installedModels, dbModels);
|
mergeWithDbData(models, dbModels);
|
||||||
emit loadingFinished(true, this->m_simulatorInfo);
|
updateInstalledModels(models);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,26 +108,10 @@ namespace BlackMisc
|
|||||||
return CFileUtils::containsFileNewerThan(cacheTs, this->getRootDirectory(), true, {fileFilterCsl(), fileFilterFlyable()}, this->m_excludedDirectories);
|
return CFileUtils::containsFileNewerThan(cacheTs, this->getRootDirectory(), true, {fileFilterCsl(), fileFilterFlyable()}, this->m_excludedDirectories);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAircraftModelLoaderXPlane::hasCachedData() const
|
|
||||||
{
|
|
||||||
//! \todo KB
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime CAircraftModelLoaderXPlane::getCacheTimestamp() const
|
|
||||||
{
|
|
||||||
//! \todo KB add cache and report back
|
|
||||||
return QDateTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
const CAircraftModelList &CAircraftModelLoaderXPlane::getAircraftModels() const
|
|
||||||
{
|
|
||||||
return m_installedModels;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CAircraftModelLoaderXPlane::updateInstalledModels(const CAircraftModelList &models)
|
void CAircraftModelLoaderXPlane::updateInstalledModels(const CAircraftModelList &models)
|
||||||
{
|
{
|
||||||
m_installedModels = models;
|
this->setModelsInCache(models);
|
||||||
emit loadingFinished(true, this->m_simulatorInfo);
|
emit loadingFinished(true, this->m_simulatorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ namespace BlackMisc
|
|||||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const override;
|
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const override;
|
||||||
virtual bool isLoadingFinished() const override;
|
virtual bool isLoadingFinished() const override;
|
||||||
virtual bool areModelFilesUpdated() const override;
|
virtual bool areModelFilesUpdated() const override;
|
||||||
virtual bool hasCachedData() const override;
|
|
||||||
virtual QDateTime getCacheTimestamp() const override;
|
|
||||||
virtual const BlackMisc::Simulation::CAircraftModelList &getAircraftModels() const override;
|
|
||||||
//! @}
|
//! @}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -113,7 +110,6 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
||||||
QVector<CSLPackage> m_cslPackages; //!< Parsed Packages. No lock required since accessed only from one thread
|
QVector<CSLPackage> m_cslPackages; //!< Parsed Packages. No lock required since accessed only from one thread
|
||||||
BlackMisc::Simulation::CAircraftModelList m_installedModels;
|
|
||||||
|
|
||||||
static const QString &fileFilterFlyable();
|
static const QString &fileFilterFlyable();
|
||||||
static const QString &fileFilterCsl();
|
static const QString &fileFilterCsl();
|
||||||
|
|||||||
Reference in New Issue
Block a user