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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user