refs #538, Formatting, minor tweaks, comments

* new slot syntax in ATC station component
* formatting, comments
* tab order
* utility function for severity in status message
* null checks in threadutils
* invalidKey function in datastore
* changed data object keys (cached objets)
* added missing value object compare cases
* renamed timer in context network
* finder function for model list
* renamed getContainer to container (as it is just a reference)
This commit is contained in:
Klaus Basan
2015-12-05 16:39:54 +01:00
parent 66ff1803cf
commit 8f85c54989
24 changed files with 90 additions and 45 deletions

View File

@@ -302,8 +302,14 @@ namespace BlackMisc
return Compare::compare(m_legacy, compareValue.isLegacyAircraft());
case IndexIsMilitary:
return Compare::compare(m_military, compareValue.isMilitary());
case IndexIsVtol:
return Compare::compare(isVtol(), compareValue.isVtol());
case IndexIsRealworld:
return Compare::compare(m_realWorld, compareValue.isRealWorld());
case IndexRank:
return Compare::compare(m_rank, compareValue.getRank());
case IndexDesignatorManufacturer:
return getDesignatorManufacturer().compare(compareValue.getDesignatorManufacturer(), Qt::CaseInsensitive);
default:
break;
}

View File

@@ -44,7 +44,7 @@ namespace BlackMisc
IndexIsLegacy,
IndexIsVtol,
IndexRank,
IndexDesignatorManufacturer
IndexDesignatorManufacturer //!< designator and manufacturer
};
//! Default constructor.

View File

@@ -166,6 +166,8 @@ namespace BlackMisc
return this->m_designator.compare(compareValue.getDesignator());
case IndexAirlineCountry:
return this->m_country.comparePropertyByIndex(compareValue.getCountry(), index.copyFrontRemoved());
case IndexDesignatorNameCountry:
return this->m_country.getName().compare(compareValue.getCountry().getName(), Qt::CaseInsensitive);
case IndexAirlineName:
return this->m_name.compare(compareValue.getName(), Qt::CaseInsensitive);
case IndexTelephonyDesignator:

View File

@@ -49,6 +49,9 @@ namespace BlackMisc
//! Has valid DB key
bool hasValidDbKey() const { return m_dbKey >= 0; }
//! Invalid key
static int invalidDbKey() { return -1; }
protected:
//! Constructor
IDatastoreObjectWithIntegerKey() {}
@@ -98,6 +101,9 @@ namespace BlackMisc
//! Has valid DB key
bool hasValidDbKey() const { return !m_dbKey.isEmpty(); }
//! Invalid key
static QString invalidDbKey() { return ""; }
protected:
//! Constructor
IDatastoreObjectWithStringKey() {}

View File

@@ -28,6 +28,16 @@ namespace BlackMisc
return false;
}
bool CAircraftModelList::containsModelStringOrId(const CAircraftModel &model, Qt::CaseSensitivity sensitivity) const
{
for (const CAircraftModel &m : (*this))
{
if (m.hasValidDbKey() && m.getDbKey() == model.getDbKey()) { return true; }
if (m.matchesModelString(model.getModelString(), sensitivity)) { return true; }
}
return false;
}
CAircraftModelList CAircraftModelList::findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity) const
{
return this->findBy([ = ](const CAircraftModel & model)

View File

@@ -40,6 +40,9 @@ namespace BlackMisc
//! Contains model string
bool containsModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
//! Contains model with model string or id
bool containsModelStringOrId(const BlackMisc::Simulation::CAircraftModel &model, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;
//! Find by model string
CAircraftModelList findByModelString(const QString &modelString, Qt::CaseSensitivity sensitivity = Qt::CaseInsensitive) const;

View File

@@ -94,15 +94,18 @@ namespace BlackMisc
//! Message severity
StatusSeverity getSeverity() const { return this->m_severity; }
//! Info or debug, no warning or error
bool isSeverityInfoOrLess() const { return this->m_severity == SeverityInfo || this->m_severity == SeverityDebug; }
//! Warning or above
bool isWarningOrAbove() const { return this->m_severity == SeverityWarning || this->m_severity == SeverityError; }
//! Message
QString getMessage() const { return this->m_message; }
//! Message empty
bool isEmpty() const { return this->m_message.isEmpty(); }
//! Info or debug, no warning or error
bool isSeverityInfoOrLess() const { return this->m_severity == SeverityInfo || this->m_severity == SeverityDebug; }
//! Returns true if this message was sent by an instance of class T.
template <class T>
bool isFromClass(const T *pointer = nullptr) const

View File

@@ -24,13 +24,15 @@ namespace BlackMisc
bool CThreadUtils::isApplicationThreadObjectThread(QObject *toBeTested)
{
Q_ASSERT_X(toBeTested, Q_FUNC_INFO, "missing QObject");
if (!toBeTested) { return false; }
if (!toBeTested->thread()) { return false; }
if (!toBeTested || !toBeTested->thread()) { return false; }
if (!QCoreApplication::instance() || !QCoreApplication::instance()->thread()) { return false; }
return (QCoreApplication::instance()->thread() == toBeTested->thread());
}
bool CThreadUtils::isCurrentThreadApplicationThread()
{
if (!QCoreApplication::instance()) { return false; }
if (!QCoreApplication::instance()->thread()) { return false; }
return (QCoreApplication::instance()->thread() == QThread::currentThread());
}