mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 09:15:34 +08:00
Ref T292, Ref T285 function to set file timestamp
This commit is contained in:
@@ -449,12 +449,29 @@ namespace BlackMisc
|
||||
|
||||
void CAircraftModel::setFileTimestamp(const QDateTime ×tampUtc)
|
||||
{
|
||||
m_fileTimestamp = timestampUtc.toMSecsSinceEpoch();
|
||||
m_fileTimestamp = timestampUtc.isValid() ? timestampUtc.toMSecsSinceEpoch() : -1;
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileTimestamp(qint64 timestamp)
|
||||
{
|
||||
m_fileTimestamp = timestamp;
|
||||
m_fileTimestamp = (timestamp < 0) ? -1 : timestamp;
|
||||
}
|
||||
|
||||
void CAircraftModel::setFileDetailsAndTimestamp(const QFileInfo &fileInfo)
|
||||
{
|
||||
this->setFileName(fileInfo.absoluteFilePath());
|
||||
const QDateTime modified = fileInfo.lastModified();
|
||||
if (modified.isValid())
|
||||
{
|
||||
this->setFileTimestamp(modified);
|
||||
this->setUtcTimestamp(modified);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QDateTime created = fileInfo.lastModified();
|
||||
this->setFileTimestamp(created);
|
||||
this->setUtcTimestamp(created);
|
||||
}
|
||||
}
|
||||
|
||||
CPixmap CAircraftModel::loadIcon(CStatusMessage &success) const
|
||||
@@ -504,6 +521,7 @@ namespace BlackMisc
|
||||
this->setSimulator(otherModel.getSimulator());
|
||||
}
|
||||
|
||||
ITimestampBased::updateMissingParts(otherModel);
|
||||
m_livery.updateMissingParts(otherModel.getLivery());
|
||||
m_aircraftIcao.updateMissingParts(otherModel.getAircraftIcaoCode());
|
||||
m_distributor.updateMissingParts(otherModel.getDistributor());
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <Qt>
|
||||
#include <QFileInfo>
|
||||
#include <tuple>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -397,6 +398,9 @@ namespace BlackMisc
|
||||
//! Set file timestamp
|
||||
void setFileTimestamp(qint64 timestamp);
|
||||
|
||||
//! Set file timestamp, timestamp and file name
|
||||
void setFileDetailsAndTimestamp(const QFileInfo &fileInfo);
|
||||
|
||||
//! Load icon from disk
|
||||
CPixmap loadIcon(CStatusMessage &success) const;
|
||||
|
||||
|
||||
@@ -74,14 +74,7 @@ namespace BlackMisc
|
||||
|
||||
void ITimestampBased::setUtcTimestamp(const QDateTime ×tamp)
|
||||
{
|
||||
if (timestamp.isValid())
|
||||
{
|
||||
m_timestampMSecsSinceEpoch = timestamp.toMSecsSinceEpoch();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timestampMSecsSinceEpoch = -1; // invalid
|
||||
}
|
||||
m_timestampMSecsSinceEpoch = timestamp.isValid() ? timestamp.toMSecsSinceEpoch() : -1;
|
||||
}
|
||||
|
||||
bool ITimestampBased::isNewerThan(const ITimestampBased &otherTimestampObj) const
|
||||
@@ -266,6 +259,14 @@ namespace BlackMisc
|
||||
return Compare::compare(m_timestampMSecsSinceEpoch, compareValue.m_timestampMSecsSinceEpoch);
|
||||
}
|
||||
|
||||
void ITimestampBased::updateMissingParts(const ITimestampBased &other)
|
||||
{
|
||||
if (m_timestampMSecsSinceEpoch < 0)
|
||||
{
|
||||
m_timestampMSecsSinceEpoch = other.m_timestampMSecsSinceEpoch;
|
||||
}
|
||||
}
|
||||
|
||||
QString ITimestampWithOffsetBased::getTimestampAndOffset(bool formatted) const
|
||||
{
|
||||
static const QString ts("%1 (%2)");
|
||||
|
||||
@@ -143,6 +143,9 @@ namespace BlackMisc
|
||||
//! Compare for index
|
||||
int comparePropertyByIndex(const CPropertyIndex &index, const ITimestampBased &compareValue) const;
|
||||
|
||||
//! Update missing parts
|
||||
void updateMissingParts(const ITimestampBased &other);
|
||||
|
||||
qint64 m_timestampMSecsSinceEpoch = -1; //!< timestamp value
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user