Formatting, minor tweaks

This commit is contained in:
Klaus Basan
2018-02-07 02:03:27 +01:00
parent b78d057c59
commit 10f942e702
13 changed files with 87 additions and 79 deletions

View File

@@ -705,21 +705,23 @@ namespace BlackCore
// some checks for special conditions, e.g. logout -> empty list, but still signals pending
if (this->isConnected() && remoteAircraft.hasValidCallsign())
{
const QString msg = QString("Ready for matching '%1' with model type '%2'").arg(callsign.toQString(), remoteAircraft.getModel().getModelTypeAsString());
const CStatusMessage m = CMatchingUtils::logMessage(callsign, msg, getLogCategories());
const QString readyMsg = QString("Ready for matching '%1' with model type '%2'").arg(callsign.toQString(), remoteAircraft.getModel().getModelTypeAsString());
const CStatusMessage m = CMatchingUtils::logMessage(callsign, readyMsg, getLogCategories());
this->addReverseLookupMessage(callsign, m);
emit this->readyForModelMatching(remoteAircraft);
}
else
{
const CStatusMessage m = CMatchingUtils::logMessage(callsign, "Ignoring this aircraft, not found in range list", getLogCategories());
const CStatusMessage m = CMatchingUtils::logMessage(callsign, "Ignoring this aircraft, not found in range list, disconnected, or no callsign", getLogCategories());
this->addReverseLookupMessage(callsign, m);
}
}
void CAirspaceMonitor::onAtcPositionUpdate(const CCallsign &callsign, const BlackMisc::PhysicalQuantities::CFrequency &frequency, const CCoordinateGeodetic &position, const BlackMisc::PhysicalQuantities::CLength &range)
{
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(this), Q_FUNC_INFO, "wrong thread");
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Need sApp");
if (!this->isConnected()) { return; }
const CAtcStationList stationsWithCallsign = m_atcStationsOnline.findByCallsign(callsign);
if (stationsWithCallsign.isEmpty())
@@ -959,7 +961,7 @@ namespace BlackCore
{
const QString resolvedTelephony = CAircraftMatcher::reverseLookupTelephonyDesignator(telephony);
airlineIcao.setTelephonyDesignator(resolvedTelephony);
CMatchingUtils::addLogDetailsToList(log, callsign, QString("Setting resolved telephoy designator '%1' from '%2'").arg(resolvedTelephony, telephony), getLogCategories());
CMatchingUtils::addLogDetailsToList(log, callsign, QString("Setting resolved telephony designator '%1' from '%2'").arg(resolvedTelephony, telephony), getLogCategories());
}
}

View File

@@ -104,14 +104,19 @@ namespace BlackCore
virtual bool updateAircraftRendered(const BlackMisc::Aviation::CCallsign &callsign, bool rendered) override;
virtual bool updateAircraftGroundElevation(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Geo::CElevationPlane &elevation) override;
virtual void updateMarkAllAsNotRendered() override;
virtual void enableReverseLookupMessages(bool enabled) override;
virtual bool isReverseLookupMessagesEnabled() const override;
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual BlackMisc::CStatusMessageList getAircraftPartsHistory(const BlackMisc::Aviation::CCallsign &callsign) const override;
virtual bool isAircraftPartsHistoryEnabled() const override;
virtual void enableAircraftPartsHistory(bool enabled) override;
//! @}
//! \ingroup remoteaircraftprovider
//! \ingroup reverselookup
//! @{
virtual void enableReverseLookupMessages(bool enabled) override;
virtual bool isReverseLookupMessagesEnabled() const override;
virtual BlackMisc::CStatusMessageList getReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
//! @}
//! Returns the list of users we know about
BlackMisc::Network::CUserList getUsers() const;
@@ -289,6 +294,9 @@ namespace BlackCore
//! Connected with network?
bool isConnected() const;
//! Get the currently connected server
const BlackMisc::Network::CServer getConnectedServer() const;
//! Supports VATSIM data file
bool supportsVatsimDataFile() const;
@@ -342,23 +350,23 @@ namespace BlackCore
//! Send the information if aircraft and(!) client are available
//! \note it can take some time to obtain all data for model matching, so function recursively calls itself if something is still missing (trial)
//! \sa reverseLookupModelWithFlightplanData
void sendReadyForModelMatching(const BlackMisc::Aviation::CCallsign &callsign, int trial = 1);
//! Reverse lookup messages
//! \threadsafe
//! \ingroup reverselookup
//! @{
void addReverseLookupMessages(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CStatusMessageList &messages);
//! Reverse lookup messages
//! \threadsafe
void addReverseLookupMessage(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::CStatusMessage &message);
//! Reverse lookup messages
//! \threadsafe
void addReverseLookupMessage(
const BlackMisc::Aviation::CCallsign &callsign, const QString &message,
BlackMisc::CStatusMessage::StatusSeverity severity = BlackMisc::CStatusMessage::SeverityInfo);
//! @}
//! Reverse lookup, if available flight plan data are considered
//! \remark this is where a model is created based on network data
//! \ingroup reverselookup
BlackMisc::Simulation::CAircraftModel reverseLookupModelWithFlightplanData(
const BlackMisc::Aviation::CCallsign &callsign, const QString &aircraftIcao,
const QString &airlineIcao, const QString &livery, const QString &modelString,

View File

@@ -415,6 +415,9 @@ namespace BlackCore
BLACK_VERIFY_X(!callsign.isEmpty(), Q_FUNC_INFO, "Remote aircraft with empty callsign");
if (callsign.isEmpty()) { return; }
// here we find the best simulator model for a resolved model
// in the first step we already tried to find accurate ICAO codes etc.
// coming from CAirspaceMonitor::sendReadyForModelMatching
CStatusMessageList matchingMessages;
CStatusMessageList *pMatchingMessages = m_enableMatchingMessages ? &matchingMessages : nullptr;
const CAircraftModel aircraftModel = m_aircraftMatcher.getClosestMatch(remoteAircraft, pMatchingMessages);
@@ -423,8 +426,8 @@ namespace BlackCore
const CSimulatedAircraft aircraftAfterModelApplied = getAircraftInRangeForCallsign(remoteAircraft.getCallsign());
m_simulatorPlugin.second->logicallyAddRemoteAircraft(aircraftAfterModelApplied);
CMatchingUtils::addLogDetailsToList(pMatchingMessages, callsign, QString("Logically added remote aircraft: %1").arg(aircraftAfterModelApplied.toQString()));
addMatchingMessages(callsign, matchingMessages);
emit modelMatchingCompleted(remoteAircraft);
this->addMatchingMessages(callsign, matchingMessages);
emit this->modelMatchingCompleted(remoteAircraft);
}
void CContextSimulator::xCtxRemovedRemoteAircraft(const CCallsign &callsign)

View File

@@ -15,9 +15,7 @@
#include "blackcore/blackcoreexport.h"
#include "blackcore/db/databasereader.h"
#include "blackcore/data/dbcaches.h"
#include "blackmisc/aviation/aircrafticaocode.h"
#include "blackmisc/aviation/aircrafticaocodelist.h"
#include "blackmisc/aviation/airlineicaocode.h"
#include "blackmisc/aviation/airlineicaocodelist.h"
#include "blackmisc/network/entityflags.h"
#include "blackmisc/network/url.h"

View File

@@ -101,21 +101,21 @@ namespace BlackCore
CAircraftModel CModelDataReader::getModelForModelString(const QString &modelString) const
{
if (modelString.isEmpty()) { return CAircraftModel(); }
const CAircraftModelList models(getModels());
const CAircraftModelList models(this->getModels());
return models.findFirstByModelStringOrDefault(modelString);
}
CAircraftModel CModelDataReader::getModelForDbKey(int dbKey) const
{
if (dbKey < 0) { return CAircraftModel(); }
const CAircraftModelList models(getModels());
const CAircraftModelList models(this->getModels());
return models.findByKey(dbKey);
}
CAircraftModelList CModelDataReader::getModelsForAircraftDesignatorAndLiveryCombinedCode(const QString &aircraftDesignator, const QString &combinedCode)
{
if (aircraftDesignator.isEmpty()) { return CAircraftModelList(); }
const CAircraftModelList models(getModels());
const CAircraftModelList models(this->getModels());
return models.findByAircraftDesignatorAndLiveryCombinedCode(aircraftDesignator, combinedCode);
}

View File

@@ -83,7 +83,7 @@ namespace BlackGui
void CModelMatcherComponent::tabIndexChanged(int index)
{
if (index < 0) { return; }
QTabWidget *tw = CGuiUtility::parentTabWidget(this);
const QTabWidget *tw = CGuiUtility::parentTabWidget(this);
Q_ASSERT_X(tw, Q_FUNC_INFO, "Cannot find parent tab widget");
const QWidget *tabWidget = tw->currentWidget();
const QWidget *myselfTabWidget = this->parentWidget();
@@ -140,8 +140,7 @@ namespace BlackGui
{
if (number > 0 && entity.testFlag(CEntityFlags::ModelEntity) && state == CEntityFlags::ReadFinished)
{
QStringList modelStrings(sGui->getWebDataServices()->getModelStrings());
modelStrings.sort();
const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings(true));
ui->le_ModelString->setCompleter(new QCompleter(modelStrings, this));
}
}

View File

@@ -66,6 +66,9 @@
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Enable">
<property name="toolTip">
<string>Enables / disables future message logging</string>
</property>
<property name="text">
<string>Enable:</string>
</property>

View File

@@ -72,14 +72,9 @@ namespace BlackMisc
QString CAircraftIcaoCode::getDesignatorDbKey() const
{
if (this->isLoadedFromDb())
{
return this->getDesignator() + " " + this->getDbKeyAsStringInParentheses();
}
else
{
return this->getDesignator();
}
return (this->isLoadedFromDb()) ?
this->getDesignator() % QStringLiteral(" ") % this->getDbKeyAsStringInParentheses() :
this->getDesignator();
}
QString CAircraftIcaoCode::convertToQString(bool i18n) const

View File

@@ -80,8 +80,11 @@ namespace BlackMisc
//! Designator and DB key
QString getDesignatorDbKey() const;
//! Designator + Manufacturer
QString getDesignatorManufacturer() const;
//! Set ICAO designator, e.g. "B737"
void setDesignator(const QString &icaoDesignator) { this->m_designator = icaoDesignator.trimmed().toUpper(); }
void setDesignator(const QString &icaoDesignator) { m_designator = icaoDesignator.trimmed().toUpper(); }
//! Aircraft designator?
bool hasDesignator() const;
@@ -99,10 +102,10 @@ namespace BlackMisc
const QString &getIataCode() const { return m_iataCode; }
//! Set IATA code
void setIataCode(const QString &iata) { this->m_iataCode = iata.toUpper().trimmed(); }
void setIataCode(const QString &iata) { m_iataCode = iata.toUpper().trimmed(); }
//! Has IATA code?
bool hasIataCode() const { return !this->m_iataCode.isEmpty(); }
bool hasIataCode() const { return !m_iataCode.isEmpty(); }
//! IATA code same as designator?
bool isIataSameAsDesignator() const;
@@ -111,16 +114,16 @@ namespace BlackMisc
const QString &getFamily() const { return m_family; }
//! Set family
void setFamily(const QString &family) { this->m_family = family.toUpper().trimmed(); }
void setFamily(const QString &family) { m_family = family.toUpper().trimmed(); }
//! Has family?
bool hasFamily() const { return !this->m_family.isEmpty(); }
bool hasFamily() const { return !m_family.isEmpty(); }
//! Family same as designator?
bool isFamilySameAsDesignator() const;
//! Get type, e.g. "L2J"
const QString &getCombinedType() const { return this->m_combinedType; }
const QString &getCombinedType() const { return m_combinedType; }
//! Combined type available?
bool hasValidCombinedType() const;
@@ -138,7 +141,7 @@ namespace BlackMisc
QString getAircraftType() const;
//! Set type
void setCombinedType(const QString &type) { this->m_combinedType = type.trimmed().toUpper(); }
void setCombinedType(const QString &type) { m_combinedType = type.trimmed().toUpper(); }
//! Get IACO model description, e.g. "A-330-200"
const QString &getModelDescription() const { return m_modelDescription; }
@@ -159,9 +162,6 @@ namespace BlackMisc
//! \remark * can be used as wildcard, e.g. L*J, L**
bool matchesCombinedType(const QString &combinedType) const;
//! Designator + Manufacturer
QString getDesignatorManufacturer() const;
//! Set the model description (ICAO description)
void setModelDescription(const QString &modelDescription) { m_modelDescription = modelDescription.trimmed(); }
@@ -172,13 +172,13 @@ namespace BlackMisc
void setModelSwiftDescription(const QString &modelDescription) { m_modelSwiftDescription = modelDescription.trimmed(); }
//! Has model description?
bool hasModelDescription() const { return !this->m_modelDescription.isEmpty(); }
bool hasModelDescription() const { return !m_modelDescription.isEmpty(); }
//! Has IATA model description?
bool hasModelIataDescription() const { return !this->m_modelIataDescription.isEmpty(); }
bool hasModelIataDescription() const { return !m_modelIataDescription.isEmpty(); }
//! Has swift model description?
bool hasModelSwiftDescription() const { return !this->m_modelSwiftDescription.isEmpty(); }
bool hasModelSwiftDescription() const { return !m_modelSwiftDescription.isEmpty(); }
//! Get manufacturer, e.g. "Airbus"
const QString &getManufacturer() const { return m_manufacturer; }

View File

@@ -411,23 +411,23 @@ namespace BlackMisc
return CAirlineIcaoCode();
}
QString designator(json.value(prefix % QLatin1String("designator")).toString());
QString designator(json.value(prefix % QStringLiteral("designator")).toString());
if (!CAirlineIcaoCode::isValidAirlineDesignator(designator))
{
designator = CAirlineIcaoCode::normalizeDesignator(designator);
}
const QString iata(json.value(prefix % QLatin1String("iata")).toString());
const QString telephony(json.value(prefix % QLatin1String("callsign")).toString());
const QString name(json.value(prefix % QLatin1String("name")).toString());
const QString countryIso(json.value(prefix % QLatin1String("country")).toString());
const QString countryName(json.value(prefix % QLatin1String("countryname")).toString());
const QString groupName(json.value(prefix % QLatin1String("groupname")).toString());
const QString groupDesignator(json.value(prefix % QLatin1String("groupdesignator")).toString());
const int groupId(json.value(prefix % QLatin1String("groupid")).toInt(-1));
const bool va = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QLatin1String("va")).toString());
const bool operating = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QLatin1String("operating")).toString());
const bool military = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QLatin1String("military")).toString());
const QString iata(json.value(prefix % QStringLiteral("iata")).toString());
const QString telephony(json.value(prefix % QStringLiteral("callsign")).toString());
const QString name(json.value(prefix % QStringLiteral("name")).toString());
const QString countryIso(json.value(prefix % QStringLiteral("country")).toString());
const QString countryName(json.value(prefix % QStringLiteral("countryname")).toString());
const QString groupName(json.value(prefix % QStringLiteral("groupname")).toString());
const QString groupDesignator(json.value(prefix % QStringLiteral("groupdesignator")).toString());
const int groupId(json.value(prefix % QStringLiteral("groupid")).toInt(-1));
const bool va = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QStringLiteral("va")).toString());
const bool operating = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QStringLiteral("operating")).toString());
const bool military = CDatastoreUtility::dbBoolStringToBool(json.value(prefix % QStringLiteral("military")).toString());
CAirlineIcaoCode code(
designator, name,

View File

@@ -21,14 +21,14 @@ namespace BlackMisc
{
QString IDatastoreObjectWithIntegerKey::getDbKeyAsString() const
{
if (this->m_dbKey < 0) { return ""; }
return QString::number(this->m_dbKey);
if (m_dbKey < 0) { return ""; }
return QString::number(m_dbKey);
}
QString IDatastoreObjectWithIntegerKey::getDbKeyAsStringInParentheses(const QString &prefix) const
{
if (this->m_dbKey < 0) { return ""; }
return prefix + "(" + QString::number(this->m_dbKey) + ")";
if (m_dbKey < 0) { return ""; }
return prefix + "(" + QString::number(m_dbKey) + ")";
}
void IDatastoreObjectWithIntegerKey::setDbKey(const QString &key)
@@ -36,7 +36,7 @@ namespace BlackMisc
bool ok;
int k = key.toInt(&ok);
if (!ok) { k = -1; }
this->m_dbKey = k;
m_dbKey = k;
}
bool IDatastoreObjectWithIntegerKey::isLoadedFromDb() const
@@ -68,7 +68,7 @@ namespace BlackMisc
QJsonValue IDatastoreObjectWithIntegerKey::getDbKeyAsJsonValue() const
{
if (this->hasValidDbKey()) { return QJsonValue(this->m_dbKey); }
if (this->hasValidDbKey()) { return QJsonValue(m_dbKey); }
return QJsonValue();
}
@@ -96,7 +96,7 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexDbIntegerKey: return CVariant::from(this->m_dbKey);
case IndexDbIntegerKey: return CVariant::from(m_dbKey);
case IndexDbKeyAsString: return CVariant::from(this->getDbKeyAsString());
case IndexIsLoadedFromDb: return CVariant::from(this->hasValidDbKey());
case IndexDatabaseIcon: return CVariant::from(this->toDatabaseIcon());
@@ -112,10 +112,10 @@ namespace BlackMisc
switch (i)
{
case IndexDbIntegerKey:
this->m_dbKey = variant.toInt();
m_dbKey = variant.toInt();
break;
case IndexDbKeyAsString:
this->m_dbKey = stringToDbKey(variant.toQString());
m_dbKey = stringToDbKey(variant.toQString());
default:
break;
}
@@ -128,7 +128,7 @@ namespace BlackMisc
switch (i)
{
case IndexDbKeyAsString: // fall thru
case IndexDbIntegerKey: return Compare::compare(this->m_dbKey, compareValue.getDbKey());
case IndexDbIntegerKey: return Compare::compare(m_dbKey, compareValue.getDbKey());
case IndexDatabaseIcon: return Compare::compare(this->hasValidDbKey(), compareValue.hasValidDbKey());
default: break;
}
@@ -145,14 +145,14 @@ namespace BlackMisc
QJsonValue IDatastoreObjectWithStringKey::getDbKeyAsJsonValue() const
{
if (this->hasValidDbKey()) { return QJsonValue(this->m_dbKey); }
if (this->hasValidDbKey()) { return QJsonValue(m_dbKey); }
static const QJsonValue null;
return null;
}
QString IDatastoreObjectWithStringKey::getDbKeyAsStringInParentheses(const QString &prefix) const
{
if (this->m_dbKey.isEmpty()) { return ""; }
if (m_dbKey.isEmpty()) { return ""; }
return prefix + "(" + m_dbKey + ")";
}
@@ -190,9 +190,9 @@ namespace BlackMisc
switch (i)
{
case IndexDbKeyAsString: // fall thru
case IndexDbStringKey: return CVariant::from(this->m_dbKey);
case IndexDbStringKey: return CVariant::from(m_dbKey);
case IndexDatabaseIcon: return CVariant::from(this->toDatabaseIcon());
case IndexIsLoadedFromDb: return CVariant::from(this->m_loadedFromDb);
case IndexIsLoadedFromDb: return CVariant::from(m_loadedFromDb);
default:
break;
}
@@ -207,10 +207,10 @@ namespace BlackMisc
{
case IndexDbStringKey:
case IndexDbKeyAsString:
this->m_dbKey = variant.value<QString>();
m_dbKey = variant.value<QString>();
break;
case IndexIsLoadedFromDb:
this->m_loadedFromDb = variant.toBool();
m_loadedFromDb = variant.toBool();
break;
default:
break;
@@ -224,7 +224,7 @@ namespace BlackMisc
switch (i)
{
case IndexDbKeyAsString: // fall thru
case IndexDbStringKey: return this->m_dbKey.compare(compareValue.getDbKey());
case IndexDbStringKey: return m_dbKey.compare(compareValue.getDbKey());
case IndexDatabaseIcon: return Compare::compare(this->hasValidDbKey(), compareValue.hasValidDbKey());
default:
break;

View File

@@ -35,7 +35,7 @@ namespace BlackMisc
IndexSystemString
};
//! Known system
//! Known systems
enum System
{
Unspecified, //!< unspecified

View File

@@ -452,17 +452,17 @@ namespace BlackMisc
int CAircraftModelList::keepModelsWithString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity)
{
int cs = this->size();
const int cs = this->size();
(*this) = (findByModelStrings(modelStrings, sensitivity));
int d = cs - this->size();
const int d = cs - this->size();
return d;
}
int CAircraftModelList::removeModelsWithString(const QStringList &modelStrings, Qt::CaseSensitivity sensitivity)
{
int cs = this->size();
const int cs = this->size();
(*this) = (this->findByNotInModelStrings(modelStrings, sensitivity));
int d = cs - this->size();
const int d = cs - this->size();
return d;
}