make privateHints mutable, so we can use them to cache stuff for applications even if we only acces them from a notification

This commit is contained in:
Patrick von Reth 2014-07-04 11:38:34 +02:00
parent 432fd89dd3
commit 6edbbd3df4
2 changed files with 5 additions and 5 deletions

View File

@ -55,13 +55,13 @@ bool Hint::contains(const QString &key) const
return m_data.contains(key.toLower()); return m_data.contains(key.toLower());
} }
void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value) void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value) const
{ {
QPair<quintptr,QString> pk((quintptr)owner,key.toLower()); QPair<quintptr,QString> pk((quintptr)owner,key.toLower());
m_privateData.insert(pk, value); m_privateData.insert(pk, value);
} }
void Hint::setPrivateValue(const void *owner, const QString &key, QObject *value) void Hint::setPrivateValue(const void *owner, const QString &key, QObject *value) const
{ {
QPair<quintptr,QString> pk((quintptr)owner,key.toLower()); QPair<quintptr,QString> pk((quintptr)owner,key.toLower());
m_privateData.insert(pk, qVariantFromValue(value)); m_privateData.insert(pk, qVariantFromValue(value));

View File

@ -79,7 +79,7 @@ public:
* @param key the key * @param key the key
* @param value the value * @param value the value
*/ */
void setPrivateValue(const void *owner, const QString &key, const QVariant &value); void setPrivateValue(const void *owner, const QString &key, const QVariant &value) const;
/** /**
* Sets the value for the key depending on the owner * Sets the value for the key depending on the owner
@ -87,7 +87,7 @@ public:
* @param key the key * @param key the key
* @param value the value * @param value the value
*/ */
void setPrivateValue(const void *owner, const QString &key, QObject *value); void setPrivateValue(const void *owner, const QString &key, QObject *value) const;
/** /**
* The associated value of the key if present, returns the default value otherwise. * The associated value of the key if present, returns the default value otherwise.
@ -110,7 +110,7 @@ private slots:
private: private:
QVariantHash m_data; QVariantHash m_data;
QHash<QPair<quintptr,QString>, QVariant> m_privateData; mutable QHash<QPair<quintptr,QString>, QVariant> m_privateData;
friend SNORE_EXPORT QDebug (::operator<<) ( QDebug, const Snore::Hint &); friend SNORE_EXPORT QDebug (::operator<<) ( QDebug, const Snore::Hint &);