diff --git a/src/blackmisc/aviation/callsignobjectlist.cpp b/src/blackmisc/aviation/callsignobjectlist.cpp index 9bc7fbef0..9c5193ad0 100644 --- a/src/blackmisc/aviation/callsignobjectlist.cpp +++ b/src/blackmisc/aviation/callsignobjectlist.cpp @@ -173,6 +173,24 @@ namespace BlackMisc return result; } + template + int ICallsignObjectList::replaceOrAddObjectsByCallsign(const CONTAINER &others) + { + if (others.isEmpty()) { return 0; } + int c = 0; + CONTAINER copy(this->container()); + for (const OBJ &obj : others) + { + const CCallsign cs(obj.getCallsign()); + if (cs.isEmpty()) continue; + copy.removeByCallsign(cs); + copy.push_back(obj); + c++; + } + *this = copy; + return c; + } + template void ICallsignObjectList::sortByCallsign() { diff --git a/src/blackmisc/aviation/callsignobjectlist.h b/src/blackmisc/aviation/callsignobjectlist.h index a64c196ac..790ba2327 100644 --- a/src/blackmisc/aviation/callsignobjectlist.h +++ b/src/blackmisc/aviation/callsignobjectlist.h @@ -87,6 +87,8 @@ namespace BlackMisc //! Split into 0..n containers as per callsign QHash splitPerCallsign() const; + //! Replace or add objects by callsign + int replaceOrAddObjectsByCallsign(const CONTAINER &others); //! Incremental update or add object int incrementalUpdateOrAdd(const OBJ &objectBeforeChanged, const BlackMisc::CPropertyIndexVariantMap &changedValues);