mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
refs #614, last modifed timestamp from file set in CAircraftModel
* added to model (to display in view) * derived BlackMisc::ITimestampBased from BlackMisc::ITimestampBased
This commit is contained in:
@@ -71,6 +71,7 @@ namespace BlackGui
|
||||
// this->m_columns.addColumn(CColumn::standardString("ct", "combined type", { CAircraftModel::IndexIcao, CAircraftIcaoData::IndexCombinedAircraftType}));
|
||||
this->m_columns.addColumn(CColumn::standardString("description", CAircraftModel::IndexDescription));
|
||||
this->m_columns.addColumn(CColumn::standardString("filename", CAircraftModel::IndexFileName));
|
||||
this->m_columns.addColumn(CColumn::standardString("changed", CAircraftModel::IndexUtcTimestampFormattedYmdhms));
|
||||
|
||||
// default sort order
|
||||
this->setSortColumnByPropertyIndex(CAircraftModel::IndexModelString);
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace BlackMisc
|
||||
{
|
||||
namespace FsCommon
|
||||
{
|
||||
|
||||
CAircraftCfgEntries::CAircraftCfgEntries(const QString &fileName, int index, const QString &title, const QString &atcType, const QString &atcModel, const QString &atcParkingCode, const QString &description) :
|
||||
m_index(index), m_fileName(fileName), m_title(title.trimmed()), m_atcType(atcType.trimmed()),
|
||||
m_atcModel(atcModel.trimmed()), m_atcParkingCode(atcParkingCode.trimmed()), m_description(description.trimmed())
|
||||
@@ -120,6 +119,7 @@ namespace BlackMisc
|
||||
model.setDescription(this->getUiCombinedDescription()); // Manufacturer and type
|
||||
model.setFileName(this->getFileName());
|
||||
model.setName(this->getSimName());
|
||||
model.setUtcTimestamp(this->getUtcTimestamp()); // aircraft.cfg file last modified
|
||||
|
||||
const QString designator(CAircraftIcaoCode::normalizeDesignator(getAtcModel()));
|
||||
CAircraftIcaoCode aircraft(
|
||||
@@ -136,7 +136,7 @@ namespace BlackMisc
|
||||
livery.setAirlineIcaoCode(airline);
|
||||
model.setLivery(livery);
|
||||
|
||||
CDistributor distributor(this->getCreatedBy());
|
||||
const CDistributor distributor(this->getCreatedBy());
|
||||
model.setDistributor(distributor);
|
||||
|
||||
return model;
|
||||
@@ -153,6 +153,7 @@ namespace BlackMisc
|
||||
CVariant CAircraftCfgEntries::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -180,6 +181,7 @@ namespace BlackMisc
|
||||
void CAircraftCfgEntries::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CAircraftCfgEntries>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(variant, index); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -212,7 +214,6 @@ namespace BlackMisc
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#define BLACKMISC_SIMULATION_FSCOMMON_AIRCRAFTCFGENTRY_H
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/timestampbased.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/variant.h"
|
||||
@@ -26,7 +28,9 @@ namespace BlackMisc
|
||||
//! Set of aircraft.cfg entries representing an aircraft (FSX)
|
||||
//! \remarks an entry in the aircraft.cfg is title, atc type, ...
|
||||
//! This class already bundles relevant entries, hence the class is named Entries (plural)
|
||||
class BLACKMISC_EXPORT CAircraftCfgEntries: public BlackMisc::CValueObject<CAircraftCfgEntries>
|
||||
class BLACKMISC_EXPORT CAircraftCfgEntries:
|
||||
public BlackMisc::CValueObject<CAircraftCfgEntries>,
|
||||
public BlackMisc::ITimestampBased
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
@@ -179,7 +183,15 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(title),
|
||||
BLACK_METAMEMBER(atcType),
|
||||
BLACK_METAMEMBER(atcModel),
|
||||
BLACK_METAMEMBER(atcParkingCode)
|
||||
BLACK_METAMEMBER(atcParkingCode),
|
||||
BLACK_METAMEMBER(description),
|
||||
BLACK_METAMEMBER(uiType),
|
||||
BLACK_METAMEMBER(uiManufacturer),
|
||||
BLACK_METAMEMBER(texture),
|
||||
BLACK_METAMEMBER(simName),
|
||||
BLACK_METAMEMBER(createdBy),
|
||||
BLACK_METAMEMBER(rotorcraft),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch)
|
||||
);
|
||||
};
|
||||
} // ns
|
||||
|
||||
@@ -201,12 +201,12 @@ namespace BlackMisc
|
||||
|
||||
// Dirs last is crucial,since I will break recursion on "aircraft.cfg" level
|
||||
QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot, QDir::DirsLast);
|
||||
for (const auto &file : files)
|
||||
for (const auto &fileInfo : files)
|
||||
{
|
||||
if (m_cancelLoading) { return CAircraftCfgEntriesList(); }
|
||||
if (file.isDir())
|
||||
if (fileInfo.isDir())
|
||||
{
|
||||
const QString nextDir = file.absoluteFilePath();
|
||||
const QString nextDir = fileInfo.absoluteFilePath();
|
||||
if (currentDir.startsWith(nextDir, Qt::CaseInsensitive)) { continue; } // do not go up
|
||||
if (dir == currentDir) { continue; } // do not recursively call same directory
|
||||
|
||||
@@ -227,7 +227,7 @@ namespace BlackMisc
|
||||
// remark: in a 1st version I have used QSettings to parse to file as ini file
|
||||
// unfortunately some files are malformed which could end up in wrong data
|
||||
|
||||
const QString fileName = file.absoluteFilePath();
|
||||
const QString fileName = fileInfo.absoluteFilePath();
|
||||
QFile file(fileName);
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
@@ -344,6 +344,7 @@ namespace BlackMisc
|
||||
CAircraftCfgEntries newEntries(e);
|
||||
newEntries.setAtcModel(atcModel);
|
||||
newEntries.setAtcType(atcType);
|
||||
newEntries.setUtcTimestamp(fileInfo.lastModified());
|
||||
result.push_back(newEntries);
|
||||
}
|
||||
*ok = true;
|
||||
|
||||
Reference in New Issue
Block a user