From bc2e0faa368b4ecc3c5ef7e2ea5c1b60c6d642c0 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Thu, 4 Feb 2016 00:57:40 +0000 Subject: [PATCH] refs #581 CValueCachePacket contains an inhibitions list that can be used to disable specific notification slots. --- src/blackmisc/valuecache.cpp | 7 +++++-- src/blackmisc/valuecache.h | 11 ++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/blackmisc/valuecache.cpp b/src/blackmisc/valuecache.cpp index 5d0265195..db3fdb498 100644 --- a/src/blackmisc/valuecache.cpp +++ b/src/blackmisc/valuecache.cpp @@ -467,7 +467,7 @@ namespace BlackMisc QList notifySlots; - forEachIntersection(m_elements, values, [changedBy, this, ¬ifySlots, &values](const QString &, const ElementPtr &element, CValueCachePacket::const_iterator it) + forEachIntersection(m_elements, values, [changedBy, this, ¬ifySlots, &values](const QString &key, const ElementPtr &element, CValueCachePacket::const_iterator it) { if (changedBy == this) // round trip { @@ -482,7 +482,10 @@ namespace BlackMisc element->m_value.uniqueWrite() = it.value(); element->m_timestamp = it.timestamp(); element->m_saved = values.isSaved(); - if (element->m_notifySlot && ! notifySlots.contains(element->m_notifySlot)) { notifySlots.push_back(element->m_notifySlot); } + if (element->m_notifySlot && ! notifySlots.contains(element->m_notifySlot) && ! values.isInhibited(parent(), key)) + { + notifySlots.push_back(element->m_notifySlot); + } } else { diff --git a/src/blackmisc/valuecache.h b/src/blackmisc/valuecache.h index 5b96e12ce..42b12ca27 100644 --- a/src/blackmisc/valuecache.h +++ b/src/blackmisc/valuecache.h @@ -25,12 +25,10 @@ namespace BlackMisc public CDictionary, QMap>, public Mixin::MetaType, public Mixin::DBusByTuple, - public Mixin::JsonByTuple, public Mixin::EqualsByTuple { public: BLACKMISC_DECLARE_USING_MIXIN_DBUS(CValueCachePacket) - BLACKMISC_DECLARE_USING_MIXIN_JSON(CValueCachePacket) //! \copydoc BlackMisc::CValueObject::base_type using base_type = CDictionary; @@ -56,6 +54,12 @@ namespace BlackMisc //! Insert values from another packet. void insert(const CValueCachePacket &other) { CDictionary::insert(other); } + //! Add a page owner and key to the list of inhibited notifications. + void inhibit(QObject *pageOwner, const QString &key) { m_inhibitions.push_back(std::make_pair(reinterpret_cast(pageOwner), key)); } + + //! Query whether a particular owner/key pair should have its notification inhibited. + bool isInhibited(QObject *pageOwner, const QString &key) const { return m_inhibitions.contains(std::make_pair(reinterpret_cast(pageOwner), key)); } + //! Discard timestamps and return as variant map. CVariantMap toVariantMap() const; @@ -89,6 +93,7 @@ namespace BlackMisc private: BLACK_ENABLE_TUPLE_CONVERSION(CValueCachePacket) bool m_saved = false; + CSequence> m_inhibitions; }; /*! @@ -347,6 +352,6 @@ namespace BlackMisc } // namespace Q_DECLARE_METATYPE(BlackMisc::CValueCachePacket) -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CValueCachePacket, (attr(o.m_saved))) +BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CValueCachePacket, (attr(o.m_saved), attr(o.m_inhibitions))) #endif