mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 02:35:33 +08:00
refs #643, moved aircraft model icon loading to model class
* removed iconForModel from interface and aircraft config parser * CPixmap support for loading pixmap from file * Access to model of model set loader by model string * icon path as member of CAircraftModel
This commit is contained in:
@@ -120,6 +120,7 @@ namespace BlackMisc
|
||||
model.setFileName(this->getFileName());
|
||||
model.setName(this->getSimName());
|
||||
model.setUtcTimestamp(this->getUtcTimestamp()); // aircraft.cfg file last modified
|
||||
model.setIconPath(this->getThumbnailFileName());
|
||||
|
||||
const QString designator(CAircraftIcaoCode::normalizeDesignator(getAtcModel()));
|
||||
CAircraftIcaoCode aircraft(
|
||||
|
||||
@@ -67,34 +67,6 @@ namespace BlackMisc
|
||||
if (this->m_parserWorker) { this->m_parserWorker->waitForFinished(); }
|
||||
}
|
||||
|
||||
CPixmap CAircraftCfgParser::iconForModel(const QString &modelString, CStatusMessage &statusMessage) const
|
||||
{
|
||||
static const CPixmap empty {};
|
||||
if (modelString.isEmpty()) { return empty; }
|
||||
CAircraftCfgEntriesList cfgEntries = this->getAircraftCfgEntriesList().findByTitle(modelString);
|
||||
if (cfgEntries.isEmpty())
|
||||
{
|
||||
statusMessage = CStatusMessage(CStatusMessage::SeverityWarning, QString("No .cfg entry for '%1'").arg(modelString));
|
||||
return empty;
|
||||
}
|
||||
|
||||
// normally we should have only one entry
|
||||
if (cfgEntries.size() > 1)
|
||||
{
|
||||
statusMessage = CStatusMessage(CStatusMessage::SeverityWarning, QString("Multiple FSX .cfg entries for '%1'").arg(modelString));
|
||||
}
|
||||
|
||||
// use first with icon
|
||||
for (const CAircraftCfgEntries &entry : cfgEntries)
|
||||
{
|
||||
const QString thumbnail = entry.getThumbnailFileName();
|
||||
if (thumbnail.isEmpty()) { continue; }
|
||||
QPixmap pm;
|
||||
if (pm.load(thumbnail)) { return CPixmap(pm); }
|
||||
}
|
||||
return empty;
|
||||
}
|
||||
|
||||
void CAircraftCfgParser::startLoadingFromDisk(LoadMode mode, const CAircraftModelList &dbModels)
|
||||
{
|
||||
if (mode.testFlag(LoadInBackground))
|
||||
|
||||
@@ -45,7 +45,6 @@ namespace BlackMisc
|
||||
|
||||
//! \name Interface functions
|
||||
//! @{
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelName, BlackMisc::CStatusMessage &statusMessage) const override;
|
||||
virtual bool isLoadingFinished() const override;
|
||||
virtual bool areModelFilesUpdated() const override;
|
||||
//! @}
|
||||
@@ -85,8 +84,8 @@ namespace BlackMisc
|
||||
//! Content after "="
|
||||
static QString getFixedIniLineContent(const QString &line);
|
||||
|
||||
CAircraftCfgEntriesList m_parsedCfgEntriesList; //!< parsed entries
|
||||
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
||||
CAircraftCfgEntriesList m_parsedCfgEntriesList; //!< parsed entries
|
||||
QPointer<BlackMisc::CWorker> m_parserWorker; //!< worker will destroy itself, so weak pointer
|
||||
|
||||
//! Files to be used
|
||||
static const QString &fileFilter();
|
||||
|
||||
Reference in New Issue
Block a user