mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
refs #720, file name handling in models
* normalize file name before writing to DB * use local file paths for local models * display "C" for color liveries
This commit is contained in:
committed by
Mathew Sutcliffe
parent
1a4b0c5e76
commit
364914cc31
@@ -13,6 +13,7 @@
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/iconlist.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
#include "blackmisc/logcategory.h"
|
||||
#include "blackmisc/logcategorylist.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
@@ -434,12 +435,10 @@ namespace BlackMisc
|
||||
return;
|
||||
}
|
||||
|
||||
this->updateByLocalFileNames(otherModel);
|
||||
if (this->m_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); }
|
||||
if (this->m_modelString.isEmpty()) { this->setModelString(otherModel.getModelString()); }
|
||||
if (this->m_description.isEmpty()) { this->setDescription(otherModel.getDescription()); }
|
||||
if (this->m_fileName.isEmpty()) { this->setFileName(otherModel.getFileName()); }
|
||||
if (this->m_iconPath.isEmpty()) { this->setIconPath(otherModel.getIconPath()); }
|
||||
if (this->m_callsign.isEmpty()) { this->setCallsign(otherModel.getCallsign()); }
|
||||
if (this->m_modelType == TypeUnknown) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_modelMode == Undefined) { this->m_modelType = otherModel.getModelType(); }
|
||||
if (this->m_simulator.isUnspecified())
|
||||
@@ -476,11 +475,44 @@ namespace BlackMisc
|
||||
QString s(hasValidDbKey() ? "M" : "m");
|
||||
s = s.append(getDistributor().hasValidDbKey() ? 'D' : 'd');
|
||||
s = s.append(getAircraftIcaoCode().hasValidDbKey() ? 'A' : 'a');
|
||||
s = s.append(getLivery().hasValidDbKey() ? 'L' : 'l');
|
||||
s = s.append(getLivery().getAirlineIcaoCode().hasValidDbKey() ? 'A' : 'a');
|
||||
if (getLivery().isLoadedFromDb() && getLivery().isColorLivery())
|
||||
{
|
||||
s = s.append("C-");
|
||||
}
|
||||
else
|
||||
{
|
||||
s = s.append(getLivery().isLoadedFromDb() ? 'L' : 'l');
|
||||
s = s.append(getLivery().getAirlineIcaoCode().hasValidDbKey() ? 'A' : 'a');
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
void CAircraftModel::normalizeFileNameForDb()
|
||||
{
|
||||
this->m_fileName = CAircraftModel::normalizeFileNameForDb(this->m_fileName);
|
||||
}
|
||||
|
||||
void CAircraftModel::updateByLocalFileNames(const CAircraftModel &model)
|
||||
{
|
||||
if (this->getModelType() == CAircraftModel::TypeOwnSimulatorModel)
|
||||
{
|
||||
// this is local model, ignore
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.getModelType() == CAircraftModel::TypeOwnSimulatorModel)
|
||||
{
|
||||
// other local, priority
|
||||
this->setFileName(model.getFileName());
|
||||
this->setIconPath(model.getIconPath());
|
||||
return;
|
||||
}
|
||||
|
||||
// both not local, override empty values
|
||||
if (this->m_fileName.isEmpty()) { this->setFileName(model.getFileName()); }
|
||||
if (this->m_iconPath.isEmpty()) { this->setIconPath(model.getIconPath()); }
|
||||
}
|
||||
|
||||
bool CAircraftModel::matchesModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
|
||||
{
|
||||
return this->m_modelString.length() == modelString.length() &&
|
||||
@@ -519,6 +551,13 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
QString CAircraftModel::normalizeFileNameForDb(const QString &filePath)
|
||||
{
|
||||
QString n = CFileUtils::normalizeFilePathToQtStandard(filePath).toUpper();
|
||||
if (n.count('/') < 2) { return n; }
|
||||
return n.section('/', -2, -1);
|
||||
}
|
||||
|
||||
CAircraftModel::ModelMode CAircraftModel::modelModeFromString(const QString &mode)
|
||||
{
|
||||
if (mode.isEmpty() || mode.startsWith('I', Qt::CaseInsensitive)) { return Include;}
|
||||
|
||||
Reference in New Issue
Block a user