aboutsummaryrefslogtreecommitdiff
path: root/libcontextsubscriber
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2009-09-16 15:13:59 +0200
committerMichael Dominic K <mdk@codethink.co.uk>2009-09-16 15:13:59 +0200
commitfa037e4187b0c9ada1d9d72a772efa88c373aa2b (patch)
treeb9ff1b2fc3abb8ea8947fd45e5c0ec8a7c990570 /libcontextsubscriber
parentd0743f7a89525cf3f30b606e0349149124172362 (diff)
Proper implementation of ContextPropertyInfo exists stuff.
Diffstat (limited to 'libcontextsubscriber')
-rw-r--r--libcontextsubscriber/src/contextpropertyinfo.cpp21
-rw-r--r--libcontextsubscriber/src/contextpropertyinfo.h1
2 files changed, 9 insertions, 13 deletions
diff --git a/libcontextsubscriber/src/contextpropertyinfo.cpp b/libcontextsubscriber/src/contextpropertyinfo.cpp
index 30cfd8b7..9a19baad 100644
--- a/libcontextsubscriber/src/contextpropertyinfo.cpp
+++ b/libcontextsubscriber/src/contextpropertyinfo.cpp
@@ -211,6 +211,7 @@ ContextPropertyInfo::ContextPropertyInfo(const QString &key, QObject *parent)
cachedDoc = infoBackend->docForKey(keyName);
cachedPlugin = infoBackend->pluginForKey(keyName);
cachedConstructionString = infoBackend->constructionStringForKey(keyName);
+ cachedExists = infoBackend->keyExists(keyName);
}
}
@@ -239,11 +240,7 @@ QString ContextPropertyInfo::type() const
bool ContextPropertyInfo::exists() const
{
QMutexLocker lock(&cacheLock);
- // A key is assumed to exist if it's type != "".
- if (cachedType != "")
- return true;
- else
- return false;
+ return cachedExists;
}
/// Returns the name of the plugin supplying this property
@@ -312,10 +309,13 @@ void ContextPropertyInfo::onKeyDataChanged(const QString& key)
QString oldPlugin = cachedPlugin;
QString oldConstructionString = cachedConstructionString;
+ bool oldExists = cachedExists;
+
QString newPlugin = InfoBackend::instance()->pluginForKey(keyName);
QString newConstructionString = InfoBackend::instance()->constructionStringForKey(keyName);
cachedPlugin = newPlugin;
cachedConstructionString = newConstructionString;
+ cachedExists = InfoBackend::instance()->keyExists(keyName);
// Release the lock before emitting the signals; otherwise
// listeners trying to access cached values would create a
@@ -323,15 +323,10 @@ void ContextPropertyInfo::onKeyDataChanged(const QString& key)
lock.unlock();
// Emit the needed signals
- if (oldType != newType) {
-
- if (oldType == "")
- emit existsChanged(true);
- if (newType == "")
- emit existsChanged(false);
-
+ if (oldType != newType)
emit typeChanged(cachedType);
- }
+ if (oldExists != cachedExists)
+ emit existsChanged(cachedExists);
// TBD: obsolete the providerChanged & providerDBusTypeChanged signals?
if (oldPlugin != newPlugin || oldConstructionString != newConstructionString) {
diff --git a/libcontextsubscriber/src/contextpropertyinfo.h b/libcontextsubscriber/src/contextpropertyinfo.h
index e83aebb9..15bf6ddb 100644
--- a/libcontextsubscriber/src/contextpropertyinfo.h
+++ b/libcontextsubscriber/src/contextpropertyinfo.h
@@ -55,6 +55,7 @@ private:
QString cachedType; ///< Cached (stored) type of the key.
QString cachedPlugin; ///< Cached name of the plugin providing the key
QString cachedConstructionString; ///< Cached construction string for the Provider
+ bool cachedExists; ///< Cached state of the key (existance).
mutable QMutex cacheLock; ///< Lock for the cache.
private slots: