diff --git a/src/blackmisc/db/datastore.h b/src/blackmisc/db/datastore.h index 8ff45826f..e85a4c865 100644 --- a/src/blackmisc/db/datastore.h +++ b/src/blackmisc/db/datastore.h @@ -73,6 +73,9 @@ namespace BlackMisc //! Has valid DB key bool hasValidDbKey() const { return m_dbKey >= 0; } + //! Same DB key and hence equal + bool isDbEqual(const IDatastoreObjectWithIntegerKey &other) const { return other.isLoadedFromDb() && this->isLoadedFromDb() && other.getDbKey() == this->getDbKey(); } + //! Loaded from DB //! \remarks here not really needed, but added to have similar signature as IDatastoreObjectWithStringKey bool isLoadedFromDb() const; @@ -143,6 +146,9 @@ namespace BlackMisc //! Has valid DB key bool hasValidDbKey() const { return !m_dbKey.isEmpty(); } + //! Same DB key and hence equal + bool isDbEqual(const IDatastoreObjectWithStringKey &other) const { return other.isLoadedFromDb() && this->isLoadedFromDb() && other.getDbKey() == this->getDbKey(); } + //! Loaded from DB bool isLoadedFromDb() const { return m_loadedFromDb; } diff --git a/src/blackmisc/simulation/simulatedaircraft.cpp b/src/blackmisc/simulation/simulatedaircraft.cpp index 1cdde71f8..9b3811be0 100644 --- a/src/blackmisc/simulation/simulatedaircraft.cpp +++ b/src/blackmisc/simulation/simulatedaircraft.cpp @@ -476,7 +476,7 @@ namespace BlackMisc { const CAircraftIcaoCode icao(this->getModel().getAircraftIcaoCode()); const CAircraftIcaoCode icaoNw(this->getNetworkModel().getAircraftIcaoCode()); - if (icao == icaoNw || icao.getDesignator() == icaoNw.getDesignator()) { return "[=] " + icao.getDesignator(); } + if (icao.isDbEqual(icaoNw) || icao == icaoNw) { return QStringLiteral("[=] ") + icao.getDesignator(); } static const QString diff("%1 -> %2"); return diff.arg(icaoNw.getDesignator(), icao.getDesignator()); } @@ -485,7 +485,7 @@ namespace BlackMisc { const CAirlineIcaoCode icao(this->getModel().getAirlineIcaoCode()); const CAirlineIcaoCode icaoNw(this->getNetworkModel().getAirlineIcaoCode()); - if (icao == icaoNw || icao.getDesignator() == icaoNw.getDesignator()) { return "[=] " + icao.getDesignator(); } + if (icao.isDbEqual(icaoNw) || icao == icaoNw) { return QStringLiteral("[=] ") + icao.getDesignator(); } static const QString diff("%1 -> %2"); return diff.arg(icaoNw.getDesignator(), icao.getDesignator()); } @@ -496,7 +496,7 @@ namespace BlackMisc const CLivery livery(this->getModel().getLivery()); const CLivery liveryNw(this->getNetworkModel().getLivery()); - if (livery == liveryNw) { return "[=] " + livery.getCombinedCodePlusInfo(); } + if (livery.isDbEqual(liveryNw) || livery == liveryNw) { return QStringLiteral("[=] ") + livery.getCombinedCodePlusInfo(); } static const QString diff("%1 -> %2"); return diff.arg(liveryNw.getCombinedCodePlusInfo(), livery.getCombinedCodePlusInfo()); }