mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Ref T247, utility functions to validate model set
This commit is contained in:
@@ -50,8 +50,8 @@ namespace BlackMisc
|
||||
//! \remarks Simulator independent class, supposed to be common denominator
|
||||
class BLACKMISC_EXPORT CAircraftModel :
|
||||
public CValueObject<CAircraftModel>,
|
||||
public BlackMisc::Db::IDatastoreObjectWithIntegerKey,
|
||||
public BlackMisc::IOrderable
|
||||
public Db::IDatastoreObjectWithIntegerKey, // also ITimestampBased
|
||||
public IOrderable
|
||||
{
|
||||
public:
|
||||
//! Model type
|
||||
@@ -295,6 +295,63 @@ namespace BlackMisc
|
||||
//! Matches given simulator?
|
||||
bool matchesSimulatorFlag(CSimulatorInfo::Simulator simulator) const;
|
||||
|
||||
//! swift livery string (to be sent via network), "liveryCode [modelString]";
|
||||
//! \sa splitNetworkLiveryString
|
||||
QString getSwiftLiveryString() const;
|
||||
|
||||
//! Update missing parts from another model
|
||||
void updateMissingParts(const CAircraftModel &otherModel, bool dbModelPriority = true);
|
||||
|
||||
//! Queried model string?
|
||||
bool hasQueriedModelString() const;
|
||||
|
||||
//! Model string which was manually set
|
||||
bool hasManuallySetString() const;
|
||||
|
||||
//! Non empty model string
|
||||
bool hasModelString() const { return !m_modelString.isEmpty(); }
|
||||
|
||||
//! Description
|
||||
bool hasDescription(bool ignoreAutoGenerated = false) const;
|
||||
|
||||
//! Valid simulator
|
||||
bool hasValidSimulator() const;
|
||||
|
||||
//! Info, which members (Livery, Aircraft ICAO, ...) are already based on DB data
|
||||
QString getMembersDbStatus() const;
|
||||
|
||||
//! Matches model string?
|
||||
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||
|
||||
//! Calculate score
|
||||
int calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries, CStatusMessageList *log = nullptr) const;
|
||||
|
||||
//! Validate
|
||||
CStatusMessageList validate(bool withNestedObjects) const;
|
||||
|
||||
//! Considered equal for publishing, compares if livery etc. are the same DB values
|
||||
bool isEqualForPublishing(const CAircraftModel &dbModel, CStatusMessageList *details = nullptr) const;
|
||||
|
||||
//! Helper class used by implementation.
|
||||
using MemoHelper = CMemoHelper<Aviation::CAircraftIcaoCode, Aviation::CLivery, CDistributor>;
|
||||
|
||||
//! To JSON with memoized members (used by CAircraftModelList)
|
||||
QJsonObject toMemoizedJson(MemoHelper::CMemoizer &) const;
|
||||
|
||||
//! From JSON with memoized members (used by CAircraftModelList)
|
||||
void convertFromMemoizedJson(const QJsonObject &json, const MemoHelper::CUnmemoizer &);
|
||||
|
||||
//! To database JSON
|
||||
QJsonObject toDatabaseJson() const;
|
||||
|
||||
//! To database JSON
|
||||
QString toDatabaseJsonString(QJsonDocument::JsonFormat format = QJsonDocument::Compact) const;
|
||||
|
||||
//! As a brief HTML summary (e.g. used in tooltips)
|
||||
QString asHtmlSummary(const QString &separator = "<br>") const;
|
||||
|
||||
// ---------------- simulator file related functions -------------------
|
||||
|
||||
//! File name (corresponding data for simulator, only available if representing simulator model
|
||||
QString getFileName() const { return m_fileName; }
|
||||
|
||||
@@ -328,66 +385,20 @@ namespace BlackMisc
|
||||
//! Load icon from disk
|
||||
CPixmap loadIcon(CStatusMessage &success) const;
|
||||
|
||||
//! swift livery string (to be sent via network), "liveryCode [modelString]";
|
||||
//! \sa splitNetworkLiveryString
|
||||
QString getSwiftLiveryString() const;
|
||||
|
||||
//! Update missing parts from another model
|
||||
void updateMissingParts(const CAircraftModel &otherModel, bool dbModelPriority = true);
|
||||
|
||||
//! Queried model string?
|
||||
bool hasQueriedModelString() const;
|
||||
|
||||
//! Model string which was manually set
|
||||
bool hasManuallySetString() const;
|
||||
|
||||
//! Non empty model string
|
||||
bool hasModelString() const { return !m_modelString.isEmpty(); }
|
||||
|
||||
//! Description
|
||||
bool hasDescription(bool ignoreAutoGenerated = false) const;
|
||||
|
||||
//! Valid simulator
|
||||
bool hasValidSimulator() const;
|
||||
|
||||
//! Info, which members (Livery, Aircraft ICAO, ...) are already based on DB data
|
||||
QString getMembersDbStatus() const;
|
||||
|
||||
//! File path for DB (absolute paths make no sense in DB)
|
||||
void normalizeFileNameForDb();
|
||||
|
||||
//! If we have local file names, we use those namesx
|
||||
//! Update file names from local model
|
||||
//! \remark if we have local file names, we use those names
|
||||
void updateLocalFileNames(const CAircraftModel &model);
|
||||
|
||||
//! Matches model string?
|
||||
bool matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const;
|
||||
//! Adjust file names to a new directory
|
||||
bool adjustLocalFileNames(const QString &newModelDir, const QString &stripModelDirIndicator = {});
|
||||
|
||||
//! Calculate score
|
||||
int calculateScore(const CAircraftModel &compareModel, bool preferColorLiveries, CStatusMessageList *log = nullptr) const;
|
||||
//! Does the corresponding file exist?
|
||||
bool existsCorrespondingFile() const;
|
||||
|
||||
//! Validate
|
||||
CStatusMessageList validate(bool withNestedObjects) const;
|
||||
|
||||
//! Considered equal for publishing, compares if livery etc. are the same DB values
|
||||
bool isEqualForPublishing(const CAircraftModel &dbModel, CStatusMessageList *details = nullptr) const;
|
||||
|
||||
//! Helper class used by implementation.
|
||||
using MemoHelper = CMemoHelper<Aviation::CAircraftIcaoCode, Aviation::CLivery, CDistributor>;
|
||||
|
||||
//! To JSON with memoized members (used by CAircraftModelList)
|
||||
QJsonObject toMemoizedJson(MemoHelper::CMemoizer &) const;
|
||||
|
||||
//! From JSON with memoized members (used by CAircraftModelList)
|
||||
void convertFromMemoizedJson(const QJsonObject &json, const MemoHelper::CUnmemoizer &);
|
||||
|
||||
//! To database JSON
|
||||
QJsonObject toDatabaseJson() const;
|
||||
|
||||
//! To database JSON
|
||||
QString toDatabaseJsonString(QJsonDocument::JsonFormat format = QJsonDocument::Compact) const;
|
||||
|
||||
//! As a brief HTML summary (e.g. used in tooltips)
|
||||
QString asHtmlSummary(const QString &separator = "<br>") const;
|
||||
// ---------------- end file related functions --------------
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
|
||||
Reference in New Issue
Block a user