Formatting, minor tweaks

This commit is contained in:
Klaus Basan
2018-05-10 04:08:59 +02:00
parent 43cc99710a
commit 6c50c4ea72
12 changed files with 149 additions and 262 deletions

View File

@@ -601,7 +601,7 @@ namespace BlackCore
QString CSimulatorCommon::getInvalidSituationLogMessage(const CCallsign &callsign, const CInterpolationStatus &status, const QString &details) const QString CSimulatorCommon::getInvalidSituationLogMessage(const CCallsign &callsign, const CInterpolationStatus &status, const QString &details) const
{ {
static const QString msg("Cs: '%1' Interpolation: '%2'"); static const QString msg("CS: '%1' Interpolation: '%2'");
const QString m = msg.arg(callsign.asString(), status.toQString()); const QString m = msg.arg(callsign.asString(), status.toQString());
if (details.isEmpty()) { return m; } if (details.isEmpty()) { return m; }

View File

@@ -24,6 +24,7 @@
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::PhysicalQuantities;
namespace BlackGui namespace BlackGui
{ {
@@ -191,22 +192,22 @@ namespace BlackGui
if (dateTime.isNull()) return ""; if (dateTime.isNull()) return "";
if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDateTime) if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDateTime)
{ {
QDateTime dt = dateTime.value<QDateTime>(); const QDateTime dt = dateTime.value<QDateTime>();
return dt.toString(m_formatString); return dt.toString(m_formatString);
} }
else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDate) else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QDate)
{ {
QDate d = dateTime.value<QDate>(); const QDate d = dateTime.value<QDate>();
return d.toString(m_formatString); return d.toString(m_formatString);
} }
else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QTime) else if (static_cast<QMetaType::Type>(dateTime.type()) == QMetaType::QTime)
{ {
QTime t = dateTime.value<QTime>(); const QTime t = dateTime.value<QTime>();
return t.toString(m_formatString); return t.toString(m_formatString);
} }
else if (dateTime.isIntegral()) else if (dateTime.isIntegral())
{ {
QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.value<qint64>()); const QDateTime t = QDateTime::fromMSecsSinceEpoch(dateTime.value<qint64>());
return t.toString(m_formatString); return t.toString(m_formatString);
} }
else else
@@ -218,33 +219,27 @@ namespace BlackGui
CVariant CAirspaceDistanceFormatter::displayRole(const CVariant &dataCVariant) const CVariant CAirspaceDistanceFormatter::displayRole(const CVariant &dataCVariant) const
{ {
if (dataCVariant.canConvert<BlackMisc::PhysicalQuantities::CLength>()) if (dataCVariant.canConvert<CLength>())
{ {
// special treatment for some cases // special treatment for some cases
BlackMisc::PhysicalQuantities::CLength l = dataCVariant.value<BlackMisc::PhysicalQuantities::CLength>(); const CLength l = dataCVariant.value<CLength>();
if (!l.isNull() && (l.isPositiveWithEpsilonConsidered() || l.isZeroEpsilonConsidered())) const bool valid = !l.isNull() && (l.isPositiveWithEpsilonConsidered() || l.isZeroEpsilonConsidered());
{ return valid ? CPhysiqalQuantiyFormatter::displayRole(dataCVariant) : QStringLiteral("");
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);
}
else
{
return "";
}
} }
else else
{ {
Q_ASSERT_X(false, "CAirspaceDistanceFormatter::formatQVariant", "No CLength class"); Q_ASSERT_X(false, "CAirspaceDistanceFormatter::formatQVariant", "No CLength class");
return ""; return QStringLiteral("");
} }
} }
CVariant CComFrequencyFormatter::displayRole(const CVariant &dataCVariant) const CVariant CComFrequencyFormatter::displayRole(const CVariant &dataCVariant) const
{ {
if (dataCVariant.canConvert<BlackMisc::PhysicalQuantities::CFrequency>()) if (dataCVariant.canConvert<CFrequency>())
{ {
// speical treatment for some cases // speical treatment for some cases
BlackMisc::PhysicalQuantities::CFrequency f = dataCVariant.value<BlackMisc::PhysicalQuantities::CFrequency>(); const CFrequency f = dataCVariant.value<CFrequency>();
if (BlackMisc::Aviation::CComSystem::isValidComFrequency(f)) if (CComSystem::isValidComFrequency(f))
{ {
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant); return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);
} }
@@ -263,7 +258,7 @@ namespace BlackGui
CVariant CSpeedKtsFormatter::displayRole(const CVariant &dataCVariant) const CVariant CSpeedKtsFormatter::displayRole(const CVariant &dataCVariant) const
{ {
// special treatment for some cases // special treatment for some cases
BlackMisc::PhysicalQuantities::CSpeed s = dataCVariant.value<BlackMisc::PhysicalQuantities::CSpeed>(); const CSpeed s = dataCVariant.value<CSpeed>();
if (!s.isNull() && (s.isPositiveWithEpsilonConsidered() || s.isZeroEpsilonConsidered())) if (!s.isNull() && (s.isPositiveWithEpsilonConsidered() || s.isZeroEpsilonConsidered()))
{ {
return CPhysiqalQuantiyFormatter::displayRole(dataCVariant); return CPhysiqalQuantiyFormatter::displayRole(dataCVariant);

View File

@@ -83,7 +83,7 @@ namespace BlackGui
return QModelIndex(); return QModelIndex();
} }
BlackMisc::CPropertyIndex CListModelBaseNonTemplate::columnToPropertyIndex(int column) const CPropertyIndex CListModelBaseNonTemplate::columnToPropertyIndex(int column) const
{ {
return m_columns.columnToPropertyIndex(column); return m_columns.columnToPropertyIndex(column);
} }
@@ -93,7 +93,7 @@ namespace BlackGui
return m_columns.propertyIndexToColumn(propertyIndex); return m_columns.propertyIndexToColumn(propertyIndex);
} }
BlackMisc::CPropertyIndex CListModelBaseNonTemplate::modelIndexToPropertyIndex(const QModelIndex &index) const CPropertyIndex CListModelBaseNonTemplate::modelIndexToPropertyIndex(const QModelIndex &index) const
{ {
return this->columnToPropertyIndex(index.column()); return this->columnToPropertyIndex(index.column());
} }
@@ -104,7 +104,7 @@ namespace BlackGui
this->sort(column, order); this->sort(column, order);
} }
void CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const BlackMisc::CPropertyIndex &propertyIndex) void CListModelBaseNonTemplate::setSortColumnByPropertyIndex(const CPropertyIndex &propertyIndex)
{ {
m_sortColumn = m_columns.propertyIndexToColumn(propertyIndex); m_sortColumn = m_columns.propertyIndexToColumn(propertyIndex);
} }
@@ -278,7 +278,7 @@ namespace BlackGui
// index, updront checking // index, updront checking
const int row = index.row(); const int row = index.row();
const int col = index.column(); const int col = index.column();
const BlackMisc::CPropertyIndex propertyIndex = this->columnToPropertyIndex(col); const CPropertyIndex propertyIndex = this->columnToPropertyIndex(col);
if (static_cast<int>(CPropertyIndex::GlobalIndexLineNumber) == propertyIndex.frontCasted<int>()) if (static_cast<int>(CPropertyIndex::GlobalIndexLineNumber) == propertyIndex.frontCasted<int>())
{ {
return QVariant::fromValue(row + 1); return QVariant::fromValue(row + 1);
@@ -304,7 +304,7 @@ namespace BlackGui
ObjectType obj = m_container[index.row()]; ObjectType obj = m_container[index.row()];
ObjectType currentObject(obj); ObjectType currentObject(obj);
BlackMisc::CPropertyIndex propertyIndex = this->columnToPropertyIndex(index.column()); CPropertyIndex propertyIndex = this->columnToPropertyIndex(index.column());
obj.setPropertyByIndex(propertyIndex, value); obj.setPropertyByIndex(propertyIndex, value);
if (obj != currentObject) if (obj != currentObject)
@@ -393,7 +393,7 @@ namespace BlackGui
if (m_modelDestroyed) { return nullptr; } if (m_modelDestroyed) { return nullptr; }
auto sortColumn = this->getSortColumn(); auto sortColumn = this->getSortColumn();
auto sortOrder = this->getSortOrder(); auto sortOrder = this->getSortOrder();
CWorker *worker = BlackMisc::CWorker::fromTask(this, "ModelSort", [this, container, sortColumn, sortOrder]() CWorker *worker = CWorker::fromTask(this, "ModelSort", [this, container, sortColumn, sortOrder]()
{ {
return this->sortContainerByColumn(container, sortColumn, sortOrder); return this->sortContainerByColumn(container, sortColumn, sortOrder);
}); });
@@ -675,7 +675,7 @@ namespace BlackGui
} }
// this is the only part not really thread safe, but columns do not change so far // this is the only part not really thread safe, but columns do not change so far
BlackMisc::CPropertyIndex propertyIndex = m_columns.columnToSortPropertyIndex(column); const CPropertyIndex propertyIndex = m_columns.columnToSortPropertyIndex(column);
Q_ASSERT(!propertyIndex.isEmpty()); Q_ASSERT(!propertyIndex.isEmpty());
if (propertyIndex.isEmpty()) if (propertyIndex.isEmpty())
{ {

View File

@@ -323,7 +323,7 @@ namespace BlackGui
template<class ObjectType> template<class ObjectType>
bool compareForModelSort(const ObjectType &a, const ObjectType &b, Qt::SortOrder order, const BlackMisc::CPropertyIndex &index, std::true_type) bool compareForModelSort(const ObjectType &a, const ObjectType &b, Qt::SortOrder order, const BlackMisc::CPropertyIndex &index, std::true_type)
{ {
int c = a.comparePropertyByIndex(index, b); const int c = a.comparePropertyByIndex(index, b);
if (c == 0) { return false; } if (c == 0) { return false; }
return (order == Qt::AscendingOrder) ? (c < 0) : (c > 0); return (order == Qt::AscendingOrder) ? (c < 0) : (c > 0);
} }

View File

@@ -37,20 +37,20 @@ namespace BlackGui
void CStatusMessageListModel::setMode(CStatusMessageListModel::Mode mode) void CStatusMessageListModel::setMode(CStatusMessageListModel::Mode mode)
{ {
this->m_columns.clear(); m_columns.clear();
switch (mode) switch (mode)
{ {
case Detailed: case Detailed:
{ {
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms()))); m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHmsz())));
CColumn col = CColumn("severity", CStatusMessage::IndexIcon); CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString); col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
this->m_columns.addColumn(col); m_columns.addColumn(col);
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage)); m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
this->m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString)); m_columns.addColumn(CColumn::standardString("category", CStatusMessage::IndexCategoryHumanReadableOrTechnicalAsString));
this->m_sortColumn = CStatusMessage::IndexUtcTimestamp; m_sortColumn = CStatusMessage::IndexUtcTimestamp;
this->m_sortOrder = Qt::DescendingOrder; m_sortOrder = Qt::DescendingOrder;
} }
break; break;
case Simplified: case Simplified:
@@ -58,11 +58,11 @@ namespace BlackGui
this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms()))); this->m_columns.addColumn(CColumn("time", CStatusMessage::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms())));
CColumn col = CColumn("severity", CStatusMessage::IndexIcon); CColumn col = CColumn("severity", CStatusMessage::IndexIcon);
col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString); col.setSortPropertyIndex(CStatusMessage::IndexSeverityAsString);
this->m_columns.addColumn(col); m_columns.addColumn(col);
this->m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage)); m_columns.addColumn(CColumn::standardString("message", CStatusMessage::IndexMessage));
this->m_sortColumn = CStatusMessage::IndexUtcTimestamp; m_sortColumn = CStatusMessage::IndexUtcTimestamp;
this->m_sortOrder = Qt::DescendingOrder; m_sortOrder = Qt::DescendingOrder;
} }
break; break;
} }

View File

@@ -158,16 +158,11 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCallsignString: case IndexCallsignString: return CVariant(this->asString());
return CVariant(this->asString()); case IndexCallsignStringAsSet: return CVariant(this->getStringAsSet());
case IndexCallsignStringAsSet: case IndexTelephonyDesignator: return CVariant(this->getTelephonyDesignator());
return CVariant(this->getStringAsSet()); case IndexSuffix: return CVariant(this->getSuffix());
case IndexTelephonyDesignator: default: return CValueObject::propertyByIndex(index);
return CVariant(this->getTelephonyDesignator());
case IndexSuffix:
return CVariant(this->getSuffix());
default:
return CValueObject::propertyByIndex(index);
} }
} }
@@ -177,17 +172,12 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCallsignString: case IndexCallsignString: m_callsign = m_callsign = unifyCallsign(variant.toQString()); break;
m_callsign = variant.toQString(); case IndexCallsignStringAsSet: m_callsignAsSet = variant.toQString(); break;
break; case IndexTelephonyDesignator: m_telephonyDesignator = variant.toQString(); break;
case IndexCallsignStringAsSet:
m_callsignAsSet = variant.toQString();
break;
case IndexTelephonyDesignator:
m_telephonyDesignator = variant.toQString();
break;
default: default:
CValueObject::setPropertyByIndex(index, variant); CValueObject::setPropertyByIndex(index, variant);
break;
} }
} }
@@ -197,16 +187,11 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexCallsignString: case IndexCallsignString: return m_callsign.compare(compareValue.m_callsign, Qt::CaseInsensitive);
return m_callsign.compare(compareValue.m_callsign, Qt::CaseInsensitive); case IndexCallsignStringAsSet: return m_callsignAsSet.compare(compareValue.m_callsignAsSet, Qt::CaseInsensitive);
case IndexCallsignStringAsSet: case IndexTelephonyDesignator: return m_telephonyDesignator.compare(compareValue.m_telephonyDesignator, Qt::CaseInsensitive);
return m_callsignAsSet.compare(compareValue.m_callsignAsSet, Qt::CaseInsensitive); case IndexSuffix: return this->getSuffix().compare(compareValue.getSuffix(), Qt::CaseInsensitive);
case IndexTelephonyDesignator: default: break;
return m_telephonyDesignator.compare(compareValue.m_telephonyDesignator, Qt::CaseInsensitive);
case IndexSuffix:
return this->getSuffix().compare(compareValue.getSuffix(), Qt::CaseInsensitive);
default:
break;
} }
Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed"); Q_ASSERT_X(false, Q_FUNC_INFO, "Compare failed");
return 0; return 0;
@@ -216,12 +201,9 @@ namespace BlackMisc
{ {
switch (m_typeHint) switch (m_typeHint)
{ {
case Atc: case Atc: return isValidAtcCallsign(*this);
return isValidAtcCallsign(*this); case Aircraft: return isValidAircraftCallsign(*this);
case Aircraft: default: return !this->isEmpty();
return isValidAircraftCallsign(*this);
default:
return !this->isEmpty();
} }
} }

View File

@@ -143,19 +143,19 @@ namespace BlackMisc
static const QStringList &atcAlikeCallsignSuffixes(); static const QStringList &atcAlikeCallsignSuffixes();
//! Suffix to icon //! Suffix to icon
static const BlackMisc::CIcon &atcSuffixToIcon(const QString &suffix); static const CIcon &atcSuffixToIcon(const QString &suffix);
//! Representing icon //! Representing icon
static const CIcon &convertToIcon(const CCallsign &callsign); static const CIcon &convertToIcon(const CCallsign &callsign);
//! \copydoc BlackMisc::Mixin::Icon::toIcon() //! \copydoc BlackMisc::Mixin::Icon::toIcon()
BlackMisc::CIcon toIcon() const { return convertToIcon(*this); } CIcon toIcon() const { return convertToIcon(*this); }
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex //! \copydoc BlackMisc::Mixin::Index::propertyByIndex
CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; CVariant propertyByIndex(const CPropertyIndex &index) const;
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
//! Compare for index //! Compare for index
int comparePropertyByIndex(const CPropertyIndex &index, const CCallsign &compareValue) const; int comparePropertyByIndex(const CPropertyIndex &index, const CCallsign &compareValue) const;

View File

@@ -256,17 +256,13 @@ namespace BlackMisc
{ {
return myself<Derived>(); return myself<Derived>();
} }
auto i = index.frontCasted<ColumnIndex>(); const auto i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexIcon: case IndexIcon: return CVariant::from(derived()->toIcon());
return CVariant::from(derived()->toIcon()); case IndexPixmap: return CVariant::from(derived()->toPixmap());
case IndexPixmap: case IndexString: return CVariant(derived()->toQString());
return CVariant::from(derived()->toPixmap()); default: return basePropertyByIndex(static_cast<const TIndexBaseOfT<Derived> *>(derived()), index);
case IndexString:
return CVariant(derived()->toQString());
default:
return basePropertyByIndex(static_cast<const TIndexBaseOfT<Derived> *>(derived()), index);
} }
} }
template <class Derived> template <class Derived>

View File

@@ -133,42 +133,28 @@ namespace BlackMisc
switch (type) switch (type)
{ {
default: default:
case QtDebugMsg: case QtDebugMsg: m_severity = SeverityDebug; break;
this->m_severity = SeverityDebug; case QtInfoMsg: m_severity = SeverityInfo; break;
break; case QtWarningMsg: m_severity = SeverityWarning; break;
case QtInfoMsg:
this->m_severity = SeverityInfo;
break;
case QtWarningMsg:
this->m_severity = SeverityWarning;
break;
case QtCriticalMsg: case QtCriticalMsg:
case QtFatalMsg: case QtFatalMsg:
this->m_severity = SeverityError; m_severity = SeverityError;
break; break;
} }
} }
void CStatusMessage::toQtLogTriple(QtMsgType *o_type, QString *o_category, QString *o_message) const void CStatusMessage::toQtLogTriple(QtMsgType *o_type, QString *o_category, QString *o_message) const
{ {
*o_category = this->m_categories.toQString(); *o_category = m_categories.toQString();
*o_message = this->getMessage(); *o_message = this->getMessage();
switch (this->m_severity) switch (m_severity)
{ {
default: default:
case SeverityDebug: case SeverityDebug: *o_type = QtDebugMsg; break;
*o_type = QtDebugMsg; case SeverityInfo: *o_type = QtInfoMsg; break;
break; case SeverityWarning: *o_type = QtWarningMsg; break;
case SeverityInfo: case SeverityError: *o_type = QtCriticalMsg; break;
*o_type = QtInfoMsg;
break;
case SeverityWarning:
*o_type = QtWarningMsg;
break;
case SeverityError:
*o_type = QtCriticalMsg;
break;
} }
} }
@@ -187,7 +173,7 @@ namespace BlackMisc
QString CStatusMessage::getCategoriesAsString() const QString CStatusMessage::getCategoriesAsString() const
{ {
return this->m_categories.toQString(); return m_categories.toQString();
} }
QString CStatusMessage::getHumanReadablePattern() const QString CStatusMessage::getHumanReadablePattern() const
@@ -208,7 +194,7 @@ namespace BlackMisc
QString CStatusMessage::getHumanOrTechnicalCategoriesAsString() const QString CStatusMessage::getHumanOrTechnicalCategoriesAsString() const
{ {
if (this->m_categories.isEmpty()) { return ""; } if (m_categories.isEmpty()) { return ""; }
QString c(getHumanReadablePattern()); QString c(getHumanReadablePattern());
return c.isEmpty() ? this->getCategoriesAsString() : c; return c.isEmpty() ? this->getCategoriesAsString() : c;
} }
@@ -238,34 +224,34 @@ namespace BlackMisc
void CStatusMessage::prependMessage(const QString &msg) void CStatusMessage::prependMessage(const QString &msg)
{ {
if (msg.isEmpty()) { return; } if (msg.isEmpty()) { return; }
this->m_message = msg + this->m_message; m_message = msg + m_message;
} }
void CStatusMessage::appendMessage(const QString &msg) void CStatusMessage::appendMessage(const QString &msg)
{ {
if (msg.isEmpty()) { return; } if (msg.isEmpty()) { return; }
this->m_message += msg; m_message += msg;
} }
void CStatusMessage::markAsHandledBy(const QObject *object) const void CStatusMessage::markAsHandledBy(const QObject *object) const
{ {
QWriteLocker lock(&m_lock); QWriteLocker lock(&m_lock);
this->m_handledByObjects.push_back(quintptr(object)); m_handledByObjects.push_back(quintptr(object));
} }
bool CStatusMessage::wasHandledBy(const QObject *object) const bool CStatusMessage::wasHandledBy(const QObject *object) const
{ {
QReadLocker lock(&m_lock); QReadLocker lock(&m_lock);
return this->m_handledByObjects.contains(quintptr(object)); return m_handledByObjects.contains(quintptr(object));
} }
QString CStatusMessage::convertToQString(bool /** i18n */) const QString CStatusMessage::convertToQString(bool /** i18n */) const
{ {
return QLatin1String("Category: ") % return QLatin1String("Category: ") %
this->m_categories.toQString() % m_categories.toQString() %
QLatin1String(" Severity: ") % QLatin1String(" Severity: ") %
severityToString(this->m_severity) % severityToString(m_severity) %
QLatin1String(" when: ") % QLatin1String(" when: ") %
this->getFormattedUtcTimestampYmdhms() % this->getFormattedUtcTimestampYmdhms() %
@@ -335,30 +321,16 @@ namespace BlackMisc
{ {
switch (severity) switch (severity)
{ {
case SeverityDebug: case SeverityDebug: { static const QString d("debug"); return d; }
{ case SeverityInfo: { static const QString i("info"); return i; }
static QString d("debug"); case SeverityWarning: { static const QString w("warning"); return w; }
return d; case SeverityError: { static const QString e("error"); return e; }
}
case SeverityInfo:
{
static QString i("info");
return i;
}
case SeverityWarning:
{
static QString w("warning");
return w;
}
case SeverityError:
{
static QString e("error");
return e;
}
default: default:
static QString x("unknown severity"); {
qFatal("Unknown severity"); static const QString x("unknown severity");
return x; // just for compiler warning qFatal("Unknown severity");
return x; // just for compiler warning
}
} }
} }
@@ -367,18 +339,9 @@ namespace BlackMisc
auto minmax = std::minmax_element(severities.begin(), severities.end()); auto minmax = std::minmax_element(severities.begin(), severities.end());
auto min = *minmax.first; auto min = *minmax.first;
auto max = *minmax.second; auto max = *minmax.second;
if (min == SeverityDebug && max == SeverityError) if (min == SeverityDebug && max == SeverityError) { static const QString all("all severities"); return all; }
{ if (min == SeverityDebug) { QStringLiteral("at or below ") % severityToString(max); }
return "all severities"; if (max == SeverityError) { QStringLiteral("at or above ") % severityToString(min); }
}
if (min == SeverityDebug)
{
return "at or below " + severityToString(max);
}
if (max == SeverityError)
{
return "at or above " + severityToString(min);
}
auto list = severities.toList(); auto list = severities.toList();
std::sort(list.begin(), list.end()); std::sort(list.begin(), list.end());
QStringList ret; QStringList ret;
@@ -388,7 +351,7 @@ namespace BlackMisc
const QString &CStatusMessage::getSeverityAsString() const const QString &CStatusMessage::getSeverityAsString() const
{ {
return severityToString(this->m_severity); return severityToString(m_severity);
} }
const QStringList &CStatusMessage::allSeverityStrings() const QStringList &CStatusMessage::allSeverityStrings()
@@ -397,29 +360,21 @@ namespace BlackMisc
return all; return all;
} }
CVariant CStatusMessage::propertyByIndex(const BlackMisc::CPropertyIndex &index) const CVariant CStatusMessage::propertyByIndex(const CPropertyIndex &index) const
{ {
if (index.isMyself()) { return CVariant::from(*this); } if (index.isMyself()) { return CVariant::from(*this); }
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); } if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexMessage: case IndexMessage: return CVariant::from(this->getMessage());
return CVariant::from(this->getMessage()); case IndexSeverity: return CVariant::from(m_severity);
case IndexSeverity: case IndexSeverityAsString: return CVariant::from(this->getSeverityAsString());
return CVariant::from(this->m_severity); case IndexCategoriesAsString: return CVariant::from(m_categories.toQString());
case IndexSeverityAsString: case IndexCategoriesHumanReadableAsString: return CVariant::from(this->getHumanReadablePattern());
return CVariant::from(this->getSeverityAsString()); case IndexCategoryHumanReadableOrTechnicalAsString: return CVariant::from(this->getHumanOrTechnicalCategoriesAsString());
case IndexCategoriesAsString: case IndexMessageAsHtml: return CVariant::from(this->toHtml());
return CVariant::from(this->m_categories.toQString()); default: return CValueObject::propertyByIndex(index);
case IndexCategoriesHumanReadableAsString:
return CVariant::from(this->getHumanReadablePattern());
case IndexCategoryHumanReadableOrTechnicalAsString:
return CVariant::from(this->getHumanOrTechnicalCategoriesAsString());
case IndexMessageAsHtml:
return CVariant::from(this->toHtml());
default:
return CValueObject::propertyByIndex(index);
} }
} }
@@ -427,22 +382,16 @@ namespace BlackMisc
{ {
if (index.isMyself()) { (*this) = variant.to<CStatusMessage>(); return; } if (index.isMyself()) { (*this) = variant.to<CStatusMessage>(); return; }
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); return; } if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); return; }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexMessage: case IndexMessage:
this->m_message = variant.value<QString>(); m_message = variant.value<QString>();
this->m_args.clear(); m_args.clear();
break;
case IndexSeverity:
this->m_severity = variant.value<StatusSeverity>();
break;
case IndexCategoriesAsString:
this->m_categories = variant.value<CLogCategoryList>();
break;
default:
CValueObject::setPropertyByIndex(index, variant);
break; break;
case IndexSeverity: m_severity = variant.value<StatusSeverity>(); break;
case IndexCategoriesAsString: m_categories = variant.value<CLogCategoryList>(); break;
default: CValueObject::setPropertyByIndex(index, variant); break;
} }
} }
@@ -450,24 +399,18 @@ namespace BlackMisc
{ {
if (index.isMyself()) { return Compare::compare(this->getSeverity(), compareValue.getSeverity()); } if (index.isMyself()) { return Compare::compare(this->getSeverity(), compareValue.getSeverity()); }
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); } if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); }
ColumnIndex i = index.frontCasted<ColumnIndex>(); const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i) switch (i)
{ {
case IndexMessageAsHtml: case IndexMessageAsHtml:
case IndexMessage: case IndexMessage:
return this->getMessage().compare(compareValue.getMessage()); return this->getMessage().compare(compareValue.getMessage());
case IndexSeverity: case IndexSeverity: return Compare::compare(this->getSeverity(), compareValue.getSeverity());
return Compare::compare(this->getSeverity(), compareValue.getSeverity()); case IndexSeverityAsString: return this->getSeverityAsString().compare(compareValue.getSeverityAsString());
case IndexSeverityAsString: case IndexCategoriesAsString: return this->getCategoriesAsString().compare(compareValue.getCategoriesAsString());
return this->getSeverityAsString().compare(compareValue.getSeverityAsString()); case IndexCategoriesHumanReadableAsString: return this->getHumanReadablePattern().compare(compareValue.getHumanReadablePattern());
case IndexCategoriesAsString: case IndexCategoryHumanReadableOrTechnicalAsString: return this->getHumanOrTechnicalCategoriesAsString().compare(compareValue.getHumanOrTechnicalCategoriesAsString());
return this->getCategoriesAsString().compare(compareValue.getCategoriesAsString()); default: break;
case IndexCategoriesHumanReadableAsString:
return this->getHumanReadablePattern().compare(compareValue.getHumanReadablePattern());
case IndexCategoryHumanReadableOrTechnicalAsString:
return this->getHumanOrTechnicalCategoriesAsString().compare(compareValue.getHumanOrTechnicalCategoriesAsString());
default:
break;
} }
Q_ASSERT_X(false, Q_FUNC_INFO, "Comapre failed"); Q_ASSERT_X(false, Q_FUNC_INFO, "Comapre failed");
return 0; return 0;
@@ -475,26 +418,14 @@ namespace BlackMisc
QString CStatusMessage::toHtml() const QString CStatusMessage::toHtml() const
{ {
QString html; static const QString ef("</font>");
if (this->isEmpty()) return html;
switch (this->getSeverity()) switch (this->getSeverity())
{ {
case SeverityInfo: case SeverityWarning: return QStringLiteral("<font color=\"yellow\">") % this->getMessage() % ef;
break; case SeverityError: return QStringLiteral("<font color=\"red\">") % this->getMessage() % ef;
case SeverityWarning: case SeverityDebug: break;
html = "<font color=\"yellow\">"; default: break;
break;
case SeverityError:
html = "<font color=\"red\">";
break;
case SeverityDebug:
break;
default:
break;
} }
html.append(this->getMessage()); return this->getMessage();
if (this->getSeverity() == SeverityInfo) { return html; }
html.append("</font>");
return html;
} }
} // ns } // ns

View File

@@ -176,7 +176,7 @@ namespace BlackMisc
//! Properties by index //! Properties by index
enum ColumnIndex enum ColumnIndex
{ {
IndexCategoriesAsString = BlackMisc::CPropertyIndex::GlobalIndexCStatusMessage, IndexCategoriesAsString = CPropertyIndex::GlobalIndexCStatusMessage,
IndexCategoriesHumanReadableAsString, IndexCategoriesHumanReadableAsString,
IndexCategoryHumanReadableOrTechnicalAsString, IndexCategoryHumanReadableOrTechnicalAsString,
IndexSeverity, IndexSeverity,

View File

@@ -325,18 +325,15 @@ namespace BlackSimPlugin
m_simSimulating = true; // only place where this should be set to true m_simSimulating = true; // only place where this should be set to true
m_simConnected = true; m_simConnected = true;
HRESULT hr = SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestOwnAircraft, HRESULT hr = SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestOwnAircraft,
CSimConnectDefinitions::DataOwnAircraft, CSimConnectDefinitions::DataOwnAircraft, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME);
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_VISUAL_FRAME);
hr += SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestOwnAircraftTitle, hr += SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestOwnAircraftTitle,
CSimConnectDefinitions::DataOwnAircraftTitle, CSimConnectDefinitions::DataOwnAircraftTitle,
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
hr += SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestSimEnvironment, hr += SimConnect_RequestDataOnSimObject(m_hSimConnect, CSimConnectDefinitions::RequestSimEnvironment,
CSimConnectDefinitions::DataSimEnvironment, CSimConnectDefinitions::DataSimEnvironment,
SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_OBJECT_ID_USER, SIMCONNECT_PERIOD_SECOND, SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
SIMCONNECT_DATA_REQUEST_FLAG_CHANGED);
if (hr != S_OK) if (hr != S_OK)
{ {
@@ -428,12 +425,8 @@ namespace BlackSimPlugin
// it is duplicated in parts // it is duplicated in parts
aircraftSituation.setOnGround(simulatorOwnAircraft.simOnGround ? CAircraftSituation::OnGround : CAircraftSituation::NotOnGround, CAircraftSituation::OutOnGroundOwnAircraft); aircraftSituation.setOnGround(simulatorOwnAircraft.simOnGround ? CAircraftSituation::OnGround : CAircraftSituation::NotOnGround, CAircraftSituation::OutOnGroundOwnAircraft);
const CAircraftLights lights(simulatorOwnAircraft.lightStrobe, const CAircraftLights lights(simulatorOwnAircraft.lightStrobe, simulatorOwnAircraft.lightLanding, simulatorOwnAircraft.lightTaxi,
simulatorOwnAircraft.lightLanding, simulatorOwnAircraft.lightBeacon, simulatorOwnAircraft.lightNav, simulatorOwnAircraft.lightLogo);
simulatorOwnAircraft.lightTaxi,
simulatorOwnAircraft.lightBeacon,
simulatorOwnAircraft.lightNav,
simulatorOwnAircraft.lightLogo);
CAircraftEngineList engines; CAircraftEngineList engines;
const QList<bool> helperList const QList<bool> helperList
@@ -543,12 +536,8 @@ namespace BlackSimPlugin
void CSimulatorFsxCommon::updateOwnAircraftFromSimulator(const DataDefinitionClientAreaSb &sbDataArea) void CSimulatorFsxCommon::updateOwnAircraftFromSimulator(const DataDefinitionClientAreaSb &sbDataArea)
{ {
CTransponder::TransponderMode newMode; CTransponder::TransponderMode newMode = CTransponder::StateIdent;
if (sbDataArea.isIdent()) if (!sbDataArea.isIdent())
{
newMode = CTransponder::StateIdent;
}
else
{ {
newMode = sbDataArea.isStandby() ? CTransponder::StateStandby : CTransponder::ModeC; newMode = sbDataArea.isStandby() ? CTransponder::StateStandby : CTransponder::ModeC;
} }
@@ -636,12 +625,9 @@ namespace BlackSimPlugin
const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData(); const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData();
const DWORD objectId = simObject.getObjectId(); const DWORD objectId = simObject.getObjectId();
HRESULT hr = SimConnect_AIReleaseControl(m_hSimConnect, objectId, requestId); HRESULT hr = SimConnect_AIReleaseControl(m_hSimConnect, objectId, requestId);
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLat, 1, hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeLat, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY); hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAlt, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAlt, 1, hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAtt, 1, SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
hr += SimConnect_TransmitClientEvent(m_hSimConnect, objectId, EventFreezeAtt, 1,
SIMCONNECT_GROUP_PRIORITY_HIGHEST, SIMCONNECT_EVENT_FLAG_GROUPID_IS_PRIORITY);
if (hr != S_OK) if (hr != S_OK)
{ {
@@ -658,7 +644,7 @@ namespace BlackSimPlugin
if (updated) if (updated)
{ {
emit aircraftRenderingChanged(simObject.getAircraft()); emit aircraftRenderingChanged(simObject.getAircraft());
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' model: '%2' verified, request/object id: %3 %4").arg(callsign.toQString(), remoteAircraft.getModelString()).arg(requestId).arg(objectId)); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' model: '%2' verified, request/object id: %3 %4").arg(callsign.toQString(), remoteAircraft.getModelString()).arg(requestId).arg(objectId)); }
} }
} }
while (false); while (false);
@@ -921,8 +907,8 @@ namespace BlackSimPlugin
Q_ASSERT_X(!hasPendingAdded || m_simConnectObjects.countPendingAdded() < 2, Q_FUNC_INFO, "There must be only 0..1 pending objects"); Q_ASSERT_X(!hasPendingAdded || m_simConnectObjects.countPendingAdded() < 2, Q_FUNC_INFO, "There must be only 0..1 pending objects");
if (this->showDebugLogMessage()) if (this->showDebugLogMessage())
{ {
this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' mode: '%2' model: '%3'").arg(newRemoteAircraft.getCallsignAsString(), modeToString(addMode), newRemoteAircraft.getModelString())); this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' mode: '%2' model: '%3'").arg(newRemoteAircraft.getCallsignAsString(), modeToString(addMode), newRemoteAircraft.getModelString()));
this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' pending callsigns: '%2', pending objects: '%3'").arg(newRemoteAircraft.getCallsignAsString(), m_addPendingAircraft.getCallsignStrings().join(", "), m_simConnectObjects.getPendingAddedCallsigns().getCallsignStrings().join(", "))); this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' pending callsigns: '%2', pending objects: '%3'").arg(newRemoteAircraft.getCallsignAsString(), m_addPendingAircraft.getCallsignStrings().join(", "), m_simConnectObjects.getPendingAddedCallsigns().getCallsignStrings().join(", ")));
} }
// do we need to remove/add again because something has changed // do we need to remove/add again because something has changed
@@ -936,13 +922,13 @@ namespace BlackSimPlugin
// same model, nothing will change, otherwise add again when removed // same model, nothing will change, otherwise add again when removed
if (sameModel) if (sameModel)
{ {
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' re-added same model '%2'").arg(newRemoteAircraft.getCallsignAsString(), newModelString)); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' re-added same model '%2'").arg(newRemoteAircraft.getCallsignAsString(), newModelString)); }
return true; return true;
} }
this->physicallyRemoveRemoteAircraft(newRemoteAircraft.getCallsign()); this->physicallyRemoveRemoteAircraft(newRemoteAircraft.getCallsign());
m_addAgainAircraftWhenRemoved.replaceOrAddByCallsign(newRemoteAircraft); m_addAgainAircraftWhenRemoved.replaceOrAddByCallsign(newRemoteAircraft);
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' re-added changed model '%2', will be added again").arg(newRemoteAircraft.getCallsignAsString(), newModelString)); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' re-added changed model '%2', will be added again").arg(newRemoteAircraft.getCallsignAsString(), newModelString)); }
return false; return false;
} }
@@ -990,7 +976,7 @@ namespace BlackSimPlugin
const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData(); const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData();
const SIMCONNECT_DATA_INITPOSITION initialPosition = CSimulatorFsxCommon::aircraftSituationToFsxPosition(newRemoteAircraft.getSituation(), sendGround); const SIMCONNECT_DATA_INITPOSITION initialPosition = CSimulatorFsxCommon::aircraftSituationToFsxPosition(newRemoteAircraft.getSituation(), sendGround);
const QString modelString(newRemoteAircraft.getModelString()); const QString modelString(newRemoteAircraft.getModelString());
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' model: '%2' request: %3, init pos: %4").arg(callsign.toQString(), modelString).arg(requestId).arg(fsxPositionToString(initialPosition))); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' model: '%2' request: %3, init pos: %4").arg(callsign.toQString(), modelString).arg(requestId).arg(fsxPositionToString(initialPosition))); }
const HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, qPrintable(modelString), qPrintable(callsign.toQString().left(12)), initialPosition, requestId); const HRESULT hr = SimConnect_AICreateNonATCAircraft(m_hSimConnect, qPrintable(modelString), qPrintable(callsign.toQString().left(12)), initialPosition, requestId);
if (hr != S_OK) if (hr != S_OK)
@@ -1079,7 +1065,7 @@ namespace BlackSimPlugin
// avoid further data from simulator // avoid further data from simulator
this->stopRequestingDataForSimObject(simObject); this->stopRequestingDataForSimObject(simObject);
simObject.setPendingRemoved(true); simObject.setPendingRemoved(true);
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1' request/object id: %2/%3").arg(callsign.toQString()).arg(simObject.getRequestId()).arg(simObject.getObjectId())); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1' request/object id: %2/%3").arg(callsign.toQString()).arg(simObject.getRequestId()).arg(simObject.getObjectId())); }
// call in SIM // call in SIM
const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData(); const SIMCONNECT_DATA_REQUEST_ID requestId = this->obtainRequestIdForSimData();
@@ -1737,7 +1723,7 @@ namespace BlackSimPlugin
this->physicallyRemoveRemoteAircraft(callsign); this->physicallyRemoveRemoteAircraft(callsign);
} }
if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("Cs: '%1'").arg(toBeRemoved.toStringList().join(", "))); } if (this->showDebugLogMessage()) { this->debugLogMessage(Q_FUNC_INFO, QString("CS: '%1'").arg(toBeRemoved.toStringList().join(", "))); }
return toBeRemoved; return toBeRemoved;
} }

View File

@@ -8,11 +8,8 @@
*/ */
//! \cond PRIVATE_TESTS //! \cond PRIVATE_TESTS
//! \file
/*! //! \ingroup testblackmisc
* \file
* \ingroup testblackmisc
*/
#include "testflightplan.h" #include "testflightplan.h"
#include "blackmisc/aviation/flightplan.h" #include "blackmisc/aviation/flightplan.h"
@@ -34,26 +31,26 @@ namespace BlackMiscTest
remarks = QStringLiteral("RT/KESTREL OPR/MYTRAVEL REG/G-DAJC SEL/FP-ES PER/C NAV/RNP10"); remarks = QStringLiteral("RT/KESTREL OPR/MYTRAVEL REG/G-DAJC SEL/FP-ES PER/C NAV/RNP10");
fpRemarks = CFlightPlanRemarks(remarks); fpRemarks = CFlightPlanRemarks(remarks);
QVERIFY2(fpRemarks.getSelcalCode().getCode() == "FPES" , "Wrong SELCAL code"); QVERIFY2(fpRemarks.getSelcalCode().getCode() == "FPES", "Wrong SELCAL code");
QVERIFY2(fpRemarks.getFlightOperator() == "MYTRAVEL" , "Wrong flight operator"); QVERIFY2(fpRemarks.getFlightOperator() == "MYTRAVEL", "Wrong flight operator");
QVERIFY2(fpRemarks.getRegistration().asString() == "GDAJC" , "Wrong registration"); QVERIFY2(fpRemarks.getRegistration().asString() == "GDAJC", "Wrong registration");
remarks = QStringLiteral("OPR/UAL CALLSIGN/UNITED"); remarks = QStringLiteral("OPR/UAL CALLSIGN/UNITED");
fpRemarks = CFlightPlanRemarks(remarks); fpRemarks = CFlightPlanRemarks(remarks);
QVERIFY2(fpRemarks.getAirlineIcao().getDesignator() == "UAL" , "Wrong airline, expect UAL"); QVERIFY2(fpRemarks.getAirlineIcao().getDesignator() == "UAL", "Wrong airline, expect UAL");
QVERIFY2(fpRemarks.getFlightOperator().isEmpty() , "Expect to operator, should be in airline"); QVERIFY2(fpRemarks.getFlightOperator().isEmpty(), "Expect to operator, should be in airline");
QVERIFY2(fpRemarks.getRegistration().isEmpty(), "Expect no registration"); QVERIFY2(fpRemarks.getRegistration().isEmpty(), "Expect no registration");
QVERIFY2(fpRemarks.getRadioTelephony() == "UNITED" , "Expect telephony"); QVERIFY2(fpRemarks.getRadioTelephony() == "UNITED", "Expect telephony");
remarks = QStringLiteral("/v/FPL-VIR9-IS-A346/DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200 OPR/VIRGIN AIRLINES"); remarks = QStringLiteral("/v/FPL-VIR9-IS-A346/DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200 OPR/VIRGIN AIRLINES");
fpRemarks = CFlightPlanRemarks(remarks); fpRemarks = CFlightPlanRemarks(remarks);
QVERIFY2(fpRemarks.getRegistration().asString() == "GVGAS" , "Wrong registration"); QVERIFY2(fpRemarks.getRegistration().asString() == "GVGAS", "Wrong registration");
QVERIFY2(fpRemarks.getFlightOperator() == "VIRGIN AIRLINES", "Wrong operator"); QVERIFY2(fpRemarks.getFlightOperator() == "VIRGIN AIRLINES", "Wrong operator");
QVERIFY2(fpRemarks.getVoiceCapabilities().getCapabilities() == CVoiceCapabilities::Voice, "Wrong airline, expect UAL"); QVERIFY2(fpRemarks.getVoiceCapabilities().getCapabilities() == CVoiceCapabilities::Voice, "Wrong airline, expect UAL");
remarks = QStringLiteral("/v/FPL-VIR9-IS-A346/ OPR/VIRGIN AIRLINES DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200"); remarks = QStringLiteral("/v/FPL-VIR9-IS-A346/ OPR/VIRGIN AIRLINES DEP/S-EGLL/ARR/KJFK/REG/G-VGAS/TCAS RVR/200");
fpRemarks = CFlightPlanRemarks(remarks); fpRemarks = CFlightPlanRemarks(remarks);
QVERIFY2(fpRemarks.getRegistration().asString() == "GVGAS" , "Wrong registration"); QVERIFY2(fpRemarks.getRegistration().asString() == "GVGAS", "Wrong registration");
QVERIFY2(fpRemarks.getFlightOperator() == "VIRGIN AIRLINES", "Wrong operator"); QVERIFY2(fpRemarks.getFlightOperator() == "VIRGIN AIRLINES", "Wrong operator");
QVERIFY2(fpRemarks.getVoiceCapabilities().getCapabilities() == CVoiceCapabilities::Voice, "Wrong airline, expect UAL"); QVERIFY2(fpRemarks.getVoiceCapabilities().getCapabilities() == CVoiceCapabilities::Voice, "Wrong airline, expect UAL");
} }