From 4cc1c7e0a9af2ff6fdc2eb55e30a8716f0ab246b Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Thu, 29 Oct 2020 22:41:00 +0000 Subject: [PATCH] Issue #77 Move definition of Mixin::Index::apply --- src/blackmisc/mixin/mixinindex.h | 24 +---------------------- src/blackmisc/propertyindexvariantmap.h | 26 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/blackmisc/mixin/mixinindex.h b/src/blackmisc/mixin/mixinindex.h index 9c1fa2930..0af286968 100644 --- a/src/blackmisc/mixin/mixinindex.h +++ b/src/blackmisc/mixin/mixinindex.h @@ -53,7 +53,7 @@ namespace BlackMisc //! Update by variant map //! \return number of values changed, with skipEqualValues equal values will not be changed - CPropertyIndexList apply(const CPropertyIndexVariantMap &indexMap, bool skipEqualValues = false); + CPropertyIndexList apply(const CPropertyIndexVariantMap &indexMap, bool skipEqualValues = false); // impl in propertyindexvariantmap.h //! Set property by index void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant); @@ -114,28 +114,6 @@ namespace BlackMisc using ::BlackMisc::Mixin::Index::equalsPropertyByIndex; // *INDENT-ON* - template - CPropertyIndexList Index::apply(const BlackMisc::CPropertyIndexVariantMap &indexMap, bool skipEqualValues) - { - if (indexMap.isEmpty()) return {}; - - CPropertyIndexList changed; - const auto &map = indexMap.map(); - for (auto it = map.begin(); it != map.end(); ++it) - { - const CVariant value = it.value(); - const CPropertyIndex index = it.key(); - if (skipEqualValues) - { - const bool equal = derived()->equalsPropertyByIndex(value, index); - if (equal) { continue; } - } - derived()->setPropertyByIndex(index, value); - changed.push_back(index); - } - return changed; - } - template void Index::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) { diff --git a/src/blackmisc/propertyindexvariantmap.h b/src/blackmisc/propertyindexvariantmap.h index 8166f8d79..687d2f58e 100644 --- a/src/blackmisc/propertyindexvariantmap.h +++ b/src/blackmisc/propertyindexvariantmap.h @@ -14,6 +14,7 @@ #include "blackmisc/blackmiscexport.h" #include "blackmisc/mixin/mixincompare.h" #include "blackmisc/mixin/mixindbus.h" +#include "blackmisc/mixin/mixinindex.h" #include "blackmisc/inheritancetraits.h" #include "blackmisc/predicates.h" #include "blackmisc/propertyindex.h" @@ -139,6 +140,31 @@ namespace BlackMisc //! \copydoc BlackMisc::Mixin::DataStreamByMetaClass::unmarshalFromDataStream void unmarshalFromDataStream(QDataStream &stream); }; + + namespace Mixin + { + template + CPropertyIndexList Index::apply(const BlackMisc::CPropertyIndexVariantMap &indexMap, bool skipEqualValues) + { + if (indexMap.isEmpty()) return {}; + + CPropertyIndexList changed; + const auto &map = indexMap.map(); + for (auto it = map.begin(); it != map.end(); ++it) + { + const CVariant value = it.value(); + const CPropertyIndex index = it.key(); + if (skipEqualValues) + { + const bool equal = derived()->equalsPropertyByIndex(value, index); + if (equal) { continue; } + } + derived()->setPropertyByIndex(index, value); + changed.push_back(index); + } + return changed; + } + } } // ns Q_DECLARE_METATYPE(BlackMisc::CPropertyIndexVariantMap)