[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasma-addons/applets/opendesktop
From: Eckhart Wörner <ewoerner () kde ! org>
Date: 2009-09-07 16:05:51
Message-ID: 1252339551.070772.6129.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1020929 by ewoerner:
Only emit once when something in the source changes, this is much more efficient and \
also allows us to track the size of changes
M +10 -6 friendwatchlist.cpp
M +2 -2 friendwatchlist.h
M +12 -9 sourcewatchlist.cpp
M +4 -3 sourcewatchlist.h
--- trunk/KDE/kdeplasma-addons/applets/opendesktop/friendwatchlist.cpp \
#1020928:1020929 @@ -28,8 +28,8 @@
: QObject(parent),
m_list(engine)
{
- connect(&m_list, SIGNAL(keyAdded(QString)), SLOT(slotKeyAdded(QString)));
- connect(&m_list, SIGNAL(keyRemoved(QString)), SLOT(slotKeyRemoved(QString)));
+ connect(&m_list, SIGNAL(keysAdded(QSet<QString>)), \
SLOT(slotKeysAdded(QSet<QString>))); + connect(&m_list, \
SIGNAL(keysRemoved(QSet<QString>)), SLOT(slotKeysRemoved(QSet<QString>))); }
@@ -55,15 +55,19 @@
}
-void FriendWatchList::slotKeyAdded(const QString& key)
+void FriendWatchList::slotKeysAdded(const QSet<QString>& keys)
{
- emit friendAdded(QString(key).remove(0, 7)); // Remove the Person- prefix
+ foreach (const QString& key, keys) {
+ emit friendAdded(QString(key).remove(0, 7)); // Remove the Person- prefix
+ }
}
-void FriendWatchList::slotKeyRemoved(const QString& key)
+void FriendWatchList::slotKeysRemoved(const QSet<QString>& keys)
{
- emit friendRemoved(QString(key).remove(0, 7)); // Remove the Person- prefix
+ foreach (const QString& key, keys) {
+ emit friendRemoved(QString(key).remove(0, 7)); // Remove the Person- prefix
+ }
}
--- trunk/KDE/kdeplasma-addons/applets/opendesktop/friendwatchlist.h #1020928:1020929
@@ -40,8 +40,8 @@
void friendRemoved(const QString& id);
private Q_SLOTS:
- void slotKeyAdded(const QString& key);
- void slotKeyRemoved(const QString& key);
+ void slotKeysAdded(const QSet<QString>& keys);
+ void slotKeysRemoved(const QSet<QString>& keys);
private:
SourceWatchList m_list;
--- trunk/KDE/kdeplasma-addons/applets/opendesktop/sourcewatchlist.cpp \
#1020928:1020929 @@ -33,7 +33,7 @@
bool SourceWatchList::contains(const QString& key) const
{
- return m_keys.contains(key);
+ return m_data.contains(key);
}
@@ -53,18 +53,21 @@
}
+QVariant SourceWatchList::value(const QString& id) const
+{
+ return m_data.value(id);
+}
+
+
void SourceWatchList::dataUpdated(const QString& source, const \
Plasma::DataEngine::Data& data) {
Q_UNUSED(source)
- QSet<QString> keys = QSet<QString>::fromList(data.keys());
- foreach(const QString& key, QSet<QString>(m_keys).subtract(keys)) {
- emit keyRemoved(key);
- }
- foreach(const QString& key, QSet<QString>(keys).subtract(m_keys)) {
- emit keyAdded(key);
- }
- m_keys = keys;
+ const QSet<QString> oldKeys = QSet<QString>::fromList(m_data.keys());
+ const QSet<QString> newKeys = QSet<QString>::fromList(data.keys());
+ m_data = data;
+ emit keysRemoved(QSet<QString>(oldKeys).subtract(newKeys));
+ emit keysAdded(QSet<QString>(newKeys).subtract(oldKeys));
}
--- trunk/KDE/kdeplasma-addons/applets/opendesktop/sourcewatchlist.h #1020928:1020929
@@ -34,17 +34,18 @@
bool contains(const QString& key) const;
QString query() const;
void setQuery(const QString& query);
+ QVariant value(const QString& id) const;
Q_SIGNALS:
- void keyAdded(const QString& key);
- void keyRemoved(const QString& key);
+ void keysAdded(const QSet<QString>& keys);
+ void keysRemoved(const QSet<QString>& keys);
private Q_SLOTS:
void dataUpdated(const QString& source, const Plasma::DataEngine::Data& \
data);
private:
+ Plasma::DataEngine::Data m_data;
Plasma::DataEngine* m_engine;
- QSet<QString> m_keys;
QString m_query;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic