mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
refs #581 CValueCachePacket contains an inhibitions list that can be used to disable specific notification slots.
This commit is contained in:
@@ -467,7 +467,7 @@ namespace BlackMisc
|
||||
|
||||
QList<NotifySlot> 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
|
||||
{
|
||||
|
||||
@@ -25,12 +25,10 @@ namespace BlackMisc
|
||||
public CDictionary<QString, std::pair<CVariant, qint64>, QMap>,
|
||||
public Mixin::MetaType<CValueCachePacket>,
|
||||
public Mixin::DBusByTuple<CValueCachePacket>,
|
||||
public Mixin::JsonByTuple<CValueCachePacket>,
|
||||
public Mixin::EqualsByTuple<CValueCachePacket>
|
||||
{
|
||||
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<quintptr>(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<quintptr>(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<std::pair<quintptr, QString>> 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
|
||||
|
||||
Reference in New Issue
Block a user