mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 01:05:35 +08:00
refs #368, updated aircraftcfgentries
* allow to exclude directories for read * added texture
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
@@ -43,6 +44,13 @@ namespace BlackSim
|
|||||||
/*
|
/*
|
||||||
* Aircraft model
|
* Aircraft model
|
||||||
*/
|
*/
|
||||||
|
QString CAircraftCfgEntries::getFileDirectory() const
|
||||||
|
{
|
||||||
|
if (this->m_fileName.isEmpty()) { return ""; }
|
||||||
|
QFileInfo fi(this->m_fileName);
|
||||||
|
return fi.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
QString CAircraftCfgEntries::getUiCombinedDescription() const
|
QString CAircraftCfgEntries::getUiCombinedDescription() const
|
||||||
{
|
{
|
||||||
QString d(this->m_uiManufacturer);
|
QString d(this->m_uiManufacturer);
|
||||||
@@ -64,6 +72,14 @@ namespace BlackSim
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CAircraftCfgEntries::getThumbnailFileName() const
|
||||||
|
{
|
||||||
|
if (this->m_texture.isEmpty()) { return ""; }
|
||||||
|
if (this->m_fileName.isEmpty()) { return ""; }
|
||||||
|
QString fn = QDir::cleanPath(this->getFileDirectory() + QDir::separator() + "texture." + this->m_texture + QDir::separator() + "thumbnail.jpg");
|
||||||
|
return fn;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get particular column
|
* Get particular column
|
||||||
*/
|
*/
|
||||||
@@ -85,6 +101,10 @@ namespace BlackSim
|
|||||||
return CVariant::from(this->m_atcParkingCode);
|
return CVariant::from(this->m_atcParkingCode);
|
||||||
case IndexEntryIndex:
|
case IndexEntryIndex:
|
||||||
return CVariant::from(this->m_index);
|
return CVariant::from(this->m_index);
|
||||||
|
case IndexTexture:
|
||||||
|
return CVariant::from(this->m_texture);
|
||||||
|
case IndexDescription:
|
||||||
|
return CVariant::from(this->m_description);
|
||||||
default:
|
default:
|
||||||
return CValueObject::propertyByIndex(index);
|
return CValueObject::propertyByIndex(index);
|
||||||
}
|
}
|
||||||
@@ -117,6 +137,12 @@ namespace BlackSim
|
|||||||
case IndexTitle:
|
case IndexTitle:
|
||||||
this->setTitle(variant.toQString());
|
this->setTitle(variant.toQString());
|
||||||
break;
|
break;
|
||||||
|
case IndexDescription:
|
||||||
|
this->setDescription(variant.toQString());
|
||||||
|
break;
|
||||||
|
case IndexTexture:
|
||||||
|
this->setTexture(variant.toQString());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
CValueObject::setPropertyByIndex(variant, index);
|
CValueObject::setPropertyByIndex(variant, index);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H
|
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H
|
||||||
#define BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H
|
#define BLACKSIM_FSCOMMON_AIRCRAFTCFGENTRY_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/aircraftmodel.h"
|
||||||
#include "blackmisc/propertyindex.h"
|
#include "blackmisc/propertyindex.h"
|
||||||
#include "blackmisc/nwaircraftmodel.h"
|
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
@@ -37,7 +37,8 @@ namespace BlackSim
|
|||||||
IndexAtcType,
|
IndexAtcType,
|
||||||
IndexAtcModel,
|
IndexAtcModel,
|
||||||
IndexParkingCode,
|
IndexParkingCode,
|
||||||
IndexDescription
|
IndexDescription,
|
||||||
|
IndexTexture
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
@@ -49,6 +50,9 @@ namespace BlackSim
|
|||||||
//! File name
|
//! File name
|
||||||
QString getFileName() const { return this->m_fileName; }
|
QString getFileName() const { return this->m_fileName; }
|
||||||
|
|
||||||
|
//! Directory of entry
|
||||||
|
QString getFileDirectory() const;
|
||||||
|
|
||||||
//! Title
|
//! Title
|
||||||
QString getTitle() const { return this->m_title; }
|
QString getTitle() const { return this->m_title; }
|
||||||
|
|
||||||
@@ -73,6 +77,9 @@ namespace BlackSim
|
|||||||
//! UI manufacturer (e.g. Airbus)
|
//! UI manufacturer (e.g. Airbus)
|
||||||
QString getUiManufacturer() const { return this->m_uiManufacturer; }
|
QString getUiManufacturer() const { return this->m_uiManufacturer; }
|
||||||
|
|
||||||
|
//! Texture
|
||||||
|
QString getTexture() const { return this->m_texture; }
|
||||||
|
|
||||||
//! Manufacturer + type
|
//! Manufacturer + type
|
||||||
QString getUiCombinedDescription() const;
|
QString getUiCombinedDescription() const;
|
||||||
|
|
||||||
@@ -97,6 +104,9 @@ namespace BlackSim
|
|||||||
//! Description
|
//! Description
|
||||||
void setDescription(const QString &description) { this->m_description = description.trimmed(); }
|
void setDescription(const QString &description) { this->m_description = description.trimmed(); }
|
||||||
|
|
||||||
|
//! Texture
|
||||||
|
void setTexture(const QString &texture) { this->m_texture = texture; }
|
||||||
|
|
||||||
//! UI type (e.g. A321-231 IAE)
|
//! UI type (e.g. A321-231 IAE)
|
||||||
void setUiType(const QString &type) { this->m_uiType = type.trimmed(); }
|
void setUiType(const QString &type) { this->m_uiType = type.trimmed(); }
|
||||||
|
|
||||||
@@ -104,7 +114,10 @@ namespace BlackSim
|
|||||||
void setUiManufacturer(const QString &manufacturer) { this->m_uiManufacturer = manufacturer.trimmed(); }
|
void setUiManufacturer(const QString &manufacturer) { this->m_uiManufacturer = manufacturer.trimmed(); }
|
||||||
|
|
||||||
//! To aircraft model
|
//! To aircraft model
|
||||||
BlackMisc::Network::CAircraftModel toAircraftModel() const;
|
BlackMisc::Simulation::CAircraftModel toAircraftModel() const;
|
||||||
|
|
||||||
|
//! Thumbnail.jpg path if possible
|
||||||
|
QString getThumbnailFileName() const;
|
||||||
|
|
||||||
//! \copydoc CValueObject::propertyByIndex
|
//! \copydoc CValueObject::propertyByIndex
|
||||||
virtual BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
virtual BlackMisc::CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const override;
|
||||||
@@ -127,6 +140,7 @@ namespace BlackSim
|
|||||||
QString m_description; //!< descriptive text
|
QString m_description; //!< descriptive text
|
||||||
QString m_uiType; //!< e.g. A321-231 IAE
|
QString m_uiType; //!< e.g. A321-231 IAE
|
||||||
QString m_uiManufacturer; //!< e.g. Airbus
|
QString m_uiManufacturer; //!< e.g. Airbus
|
||||||
|
QString m_texture; //!< texture, needed to identify thumbnail.jpg
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Network;
|
using namespace BlackMisc::Network;
|
||||||
|
|
||||||
namespace BlackSim
|
namespace BlackSim
|
||||||
@@ -102,10 +103,20 @@ namespace BlackSim
|
|||||||
/*
|
/*
|
||||||
* Read all entrities in given directory
|
* Read all entrities in given directory
|
||||||
*/
|
*/
|
||||||
int CAircraftCfgEntriesList::read(const QString &directory)
|
int CAircraftCfgEntriesList::read(const QString &directory, const QStringList &excludeDirectories)
|
||||||
{
|
{
|
||||||
if (m_cancelRead) { return -1; }
|
if (m_cancelRead) { return -1; }
|
||||||
|
|
||||||
|
// excluded?
|
||||||
|
for (const QString &excludeDir : excludeDirectories)
|
||||||
|
{
|
||||||
|
if (directory.contains(excludeDir, Qt::CaseInsensitive))
|
||||||
|
{
|
||||||
|
CLogMessage(this).debug() << "Skipping directory " << directory;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set directory with name filters, get aircraft.cfg and sub directories
|
// set directory with name filters, get aircraft.cfg and sub directories
|
||||||
QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs);
|
QDir dir(directory, "aircraft.cfg", QDir::Name, QDir::Files | QDir::AllDirs);
|
||||||
if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available
|
if (!dir.exists()) return 0; // can happen if there are shortcuts or linked dirs not available
|
||||||
@@ -123,8 +134,8 @@ namespace BlackSim
|
|||||||
{
|
{
|
||||||
QString nextDir = file.absoluteFilePath();
|
QString nextDir = file.absoluteFilePath();
|
||||||
if (currentDir.startsWith(nextDir, Qt::CaseInsensitive)) continue; // do not go up
|
if (currentDir.startsWith(nextDir, Qt::CaseInsensitive)) continue; // do not go up
|
||||||
if (dir == currentDir) continue; // do not recursively call same directory
|
if (dir == currentDir) { continue; } // do not recursively call same directory
|
||||||
counter += CAircraftCfgEntriesList::read(nextDir);
|
counter += CAircraftCfgEntriesList::read(nextDir, excludeDirectories);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -156,6 +167,7 @@ namespace BlackSim
|
|||||||
entry.setDescription(fixedStringContent(aircraftCfg, "description"));
|
entry.setDescription(fixedStringContent(aircraftCfg, "description"));
|
||||||
entry.setUiManufacturer(fixedStringContent(aircraftCfg, "ui_manufacturer"));
|
entry.setUiManufacturer(fixedStringContent(aircraftCfg, "ui_manufacturer"));
|
||||||
entry.setUiType(fixedStringContent(aircraftCfg, "ui_type"));
|
entry.setUiType(fixedStringContent(aircraftCfg, "ui_type"));
|
||||||
|
entry.setTexture(fixedStringContent(aircraftCfg, "texture"));
|
||||||
this->push_back(entry);
|
this->push_back(entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -12,11 +12,10 @@
|
|||||||
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H
|
#ifndef BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H
|
||||||
#define BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H
|
#define BLACKSIM_FSCOMMON_AIRCRAFTCFGLIST_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "aircraftcfgentries.h"
|
#include "aircraftcfgentries.h"
|
||||||
#include "blackmisc/sequence.h"
|
#include "blackmisc/sequence.h"
|
||||||
#include "blackmisc/collection.h"
|
#include "blackmisc/collection.h"
|
||||||
#include "blackmisc/nwaircraftmodellist.h"
|
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -27,7 +26,7 @@ namespace BlackSim
|
|||||||
namespace FsCommon
|
namespace FsCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
//! Utility, providing FSX aircraft.cfg entries
|
//! Utility, providing FS aircraft.cfg entries
|
||||||
class CAircraftCfgEntriesList : public BlackMisc::CSequence<CAircraftCfgEntries>
|
class CAircraftCfgEntriesList : public BlackMisc::CSequence<CAircraftCfgEntries>
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -44,7 +43,7 @@ namespace BlackSim
|
|||||||
// not read so far, read it
|
// not read so far, read it
|
||||||
this->clear();
|
this->clear();
|
||||||
this->m_readForDirectory = true;
|
this->m_readForDirectory = true;
|
||||||
return this->read(this->m_rootDirectory);
|
return this->read(this->m_rootDirectory, excludeDirectories());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Change the directory
|
//! Change the directory
|
||||||
@@ -80,13 +79,13 @@ namespace BlackSim
|
|||||||
QStringList getTitles(bool sorted = false) const;
|
QStringList getTitles(bool sorted = false) const;
|
||||||
|
|
||||||
//! As aircraft models
|
//! As aircraft models
|
||||||
BlackMisc::Network::CAircraftModelList toAircraftModelList() const;
|
BlackMisc::Simulation::CAircraftModelList toAircraftModelList() const;
|
||||||
|
|
||||||
//! Ambiguous titles
|
//! Ambiguous titles
|
||||||
QStringList detectAmbiguousTitles() const;
|
QStringList detectAmbiguousTitles() const;
|
||||||
|
|
||||||
//! Find by title
|
//! Find by title
|
||||||
CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity) const;
|
CAircraftCfgEntriesList findByTitle(const QString &title, Qt::CaseSensitivity caseSensitivity = Qt::CaseInsensitive) const;
|
||||||
|
|
||||||
//! \copydoc CValueObject::toQVariant
|
//! \copydoc CValueObject::toQVariant
|
||||||
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
virtual QVariant toQVariant() const override { return QVariant::fromValue(*this); }
|
||||||
@@ -94,11 +93,17 @@ namespace BlackSim
|
|||||||
//! \copydoc CValueObject::convertFromQVariant
|
//! \copydoc CValueObject::convertFromQVariant
|
||||||
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
virtual void convertFromQVariant(const QVariant &variant) override { BlackMisc::setFromQVariant(this, variant); }
|
||||||
|
|
||||||
//! Unknown entries
|
//! Do not include the following directories for FS
|
||||||
static const CAircraftCfgEntries &UnknownCfgEntries()
|
static const QStringList &excludeDirectories()
|
||||||
{
|
{
|
||||||
static CAircraftCfgEntries entries;
|
static const QStringList exclude(
|
||||||
return entries;
|
{
|
||||||
|
"SimObjects/Animals",
|
||||||
|
"SimObjects/Misc",
|
||||||
|
"SimObjects/GroundVehicles",
|
||||||
|
"SimObjects/Boats"
|
||||||
|
});
|
||||||
|
return exclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Register metadata
|
//! Register metadata
|
||||||
@@ -110,7 +115,7 @@ namespace BlackSim
|
|||||||
bool m_cancelRead = false;
|
bool m_cancelRead = false;
|
||||||
|
|
||||||
//! Read all entries in one directory
|
//! Read all entries in one directory
|
||||||
int read(const QString &directory);
|
int read(const QString &directory, const QStringList &excludeDirectories = QStringList());
|
||||||
|
|
||||||
//! Fix the content read
|
//! Fix the content read
|
||||||
static QString fixedStringContent(const QVariant &qv);
|
static QString fixedStringContent(const QVariant &qv);
|
||||||
|
|||||||
Reference in New Issue
Block a user