mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
refs #822, add file timestamp
This commit is contained in:
@@ -200,6 +200,10 @@ namespace BlackMisc
|
||||
return CVariant(this->m_name);
|
||||
case IndexFileName:
|
||||
return CVariant(this->m_fileName);
|
||||
case IndexFileTimestamp:
|
||||
return CVariant::fromValue(this->getFileTimestamp());
|
||||
case IndexFileTimestampFormattedYmdhms:
|
||||
return CVariant::fromValue(this->getFormattedFileTimestampYmdhms());
|
||||
case IndexIconPath:
|
||||
return CVariant(this->m_iconPath);
|
||||
case IndexAircraftIcaoCode:
|
||||
@@ -251,6 +255,16 @@ namespace BlackMisc
|
||||
case IndexFileName:
|
||||
this->m_fileName = variant.toQString();
|
||||
break;
|
||||
case IndexFileTimestamp:
|
||||
if (variant.canConvert<QDateTime>())
|
||||
{
|
||||
this->setFileTimestamp(variant.value<QDateTime>());
|
||||
}
|
||||
else if (variant.canConvert<qint64>())
|
||||
{
|
||||
this->m_fileTimestamp = variant.value<qint64>();
|
||||
}
|
||||
break;
|
||||
case IndexIconPath:
|
||||
this->m_iconPath = variant.toQString();
|
||||
break;
|
||||
@@ -300,6 +314,9 @@ namespace BlackMisc
|
||||
return this->m_callsign.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getCallsign());
|
||||
case IndexFileName:
|
||||
return this->m_fileName.compare(compareValue.getFileName(), Qt::CaseInsensitive);
|
||||
case IndexFileTimestamp:
|
||||
case IndexFileTimestampFormattedYmdhms:
|
||||
return Compare::compare(this->m_fileTimestamp, compareValue.m_fileTimestamp);
|
||||
case IndexIconPath:
|
||||
return this->m_iconPath.compare(compareValue.getIconPath(), Qt::CaseInsensitive);
|
||||
case IndexModelType:
|
||||
@@ -461,6 +478,33 @@ namespace BlackMisc
|
||||
return (static_cast<int>(simulator) & static_cast<int>(this->getSimulator().getSimulator())) > 0;
|
||||
}
|
||||
|
||||
QDateTime CAircraftModel::getFileTimestamp() const
|
||||
{
|
||||
return this->hasValidFileTimestamp() ? QDateTime::fromMSecsSinceEpoch(this->m_fileTimestamp, Qt::UTC) : QDateTime();
|
||||
}
|
||||
|
||||
QString CAircraftModel::getFormattedFileTimestampYmdhms() const
|
||||
{
|
||||
return this->hasValidFileTimestamp() ?
|
||||
this->getFileTimestamp().toString("yyyy-MM-dd HH:mm:ss") :
|
||||
"";
|
||||
}
|
||||
|
||||
bool CAircraftModel::hasValidFileTimestamp() const
|
||||
{
|
||||
return this->m_fileTimestamp >= 0;
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileTimestamp(const QDateTime ×tampUtc)
|
||||
{
|
||||
this->m_fileTimestamp = timestampUtc.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileTimestamp(qint64 timestamp)
|
||||
{
|
||||
this->m_fileTimestamp = timestamp;
|
||||
}
|
||||
|
||||
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
||||
{
|
||||
static const CStatusMessage noIcon(this, CStatusMessage::SeverityInfo, "no icon");
|
||||
@@ -498,6 +542,7 @@ namespace BlackMisc
|
||||
if (this->m_name.isEmpty()) { this->setName(otherModel.getName()); }
|
||||
if (this->m_modelType == TypeUnknown) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_modelMode == Undefined) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_fileTimestamp < 0) { this->setFileTimestamp(otherModel.getFileTimestamp()); }
|
||||
if (this->m_description.isEmpty() || this->m_description.startsWith(CAircraftModel::autoGenerated(), Qt::CaseInsensitive)) { this->setDescription(otherModel.getDescription()); }
|
||||
if (this->m_simulator.isUnspecified())
|
||||
{
|
||||
|
||||
@@ -96,6 +96,8 @@ namespace BlackMisc
|
||||
IndexLivery,
|
||||
IndexDistributor,
|
||||
IndexFileName,
|
||||
IndexFileTimestamp,
|
||||
IndexFileTimestampFormattedYmdhms,
|
||||
IndexIconPath,
|
||||
IndexModelType,
|
||||
IndexModelTypeAsString,
|
||||
@@ -301,6 +303,21 @@ namespace BlackMisc
|
||||
//! File representing model
|
||||
void setIconPath(const QString &iconFile) { m_iconPath = iconFile; }
|
||||
|
||||
//! Get timestamp
|
||||
QDateTime getFileTimestamp() const;
|
||||
|
||||
//! File timestamp
|
||||
QString getFormattedFileTimestampYmdhms() const;
|
||||
|
||||
//! Valid file timestamp?
|
||||
bool hasValidFileTimestamp() const;
|
||||
|
||||
//! Set file timestamp
|
||||
void setFileTimestamp(const QDateTime ×tampUtc);
|
||||
|
||||
//! Set file timestamp
|
||||
void setFileTimestamp(qint64 timestamp);
|
||||
|
||||
//! Load icon from disk
|
||||
CPixmap loadIcon(CStatusMessage &success) const;
|
||||
|
||||
@@ -332,7 +349,7 @@ namespace BlackMisc
|
||||
//! File path for DB (absolute paths make no sense in DB)
|
||||
void normalizeFileNameForDb();
|
||||
|
||||
//! If we have local file names, we use those
|
||||
//! If we have local file names, we use those namesx
|
||||
void updateLocalFileNames(const CAircraftModel &model);
|
||||
|
||||
//! Matches model string?
|
||||
@@ -360,7 +377,7 @@ namespace BlackMisc
|
||||
QString toDatabaseJsonString(QJsonDocument::JsonFormat format = QJsonDocument::Compact) const;
|
||||
|
||||
//! As a brief HTML summary (e.g. used in tooltips)
|
||||
QString asHtmlSummary () const;
|
||||
QString asHtmlSummary() const;
|
||||
|
||||
//! Model type
|
||||
static QString modelTypeToString(ModelType type);
|
||||
@@ -396,6 +413,7 @@ namespace BlackMisc
|
||||
QString m_description; //!< descriptive text
|
||||
QString m_fileName; //!< file name
|
||||
QString m_iconPath; //!< a file representing the aircraft as icon
|
||||
qint64 m_fileTimestamp = -1; //!< file timestamp of originating file (if applicable)
|
||||
ModelType m_modelType = TypeUnknown; //!< model string is coming representing ...?
|
||||
ModelMode m_modelMode = Include; //!< model mode (include / exclude)
|
||||
|
||||
@@ -414,6 +432,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(description, 0, DisabledForComparison),
|
||||
BLACK_METAMEMBER(fileName, 0, DisabledForComparison),
|
||||
BLACK_METAMEMBER(iconPath, 0, DisabledForComparison),
|
||||
BLACK_METAMEMBER(fileTimestamp, 0, DisabledForComparison),
|
||||
BLACK_METAMEMBER(modelType),
|
||||
BLACK_METAMEMBER(modelMode)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user