2
This file is part of KDE.
4
Copyright (c) 2009 Eckhart Wörner <ewoerner@kde.org>
6
This program is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2 of the License, or
9
(at your option) any later version.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22
#include "sourcewatchlist.h"
25
using namespace Plasma;
27
SourceWatchList::SourceWatchList(DataEngine* engine, QObject* parent)
35
bool SourceWatchList::contains(const QString& key) const
37
return m_data.contains(key);
41
QString SourceWatchList::query() const
47
void SourceWatchList::setQuery(const QString& query)
49
if (query != m_query) {
50
if (!m_query.isEmpty()) {
51
m_engine->disconnectSource(m_query, this);
53
dataUpdated(m_query, DataEngine::Data());
55
if (!m_query.isEmpty()) {
56
m_engine->connectSource(m_query, this, m_updateInterval);
62
void SourceWatchList::setUpdateInterval(uint updateInterval)
64
m_updateInterval = updateInterval;
65
if (!m_query.isEmpty()) {
66
m_engine->connectSource(m_query, this, m_updateInterval);
71
QVariant SourceWatchList::value(const QString& id) const
73
return m_data.value(id);
77
void SourceWatchList::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
81
const QSet<QString> oldKeys = QSet<QString>::fromList(m_data.keys());
82
const QSet<QString> newKeys = QSet<QString>::fromList(data.keys());
84
QSet<QString> addedKeys = QSet<QString>(newKeys).subtract(oldKeys);
85
QSet<QString> removedKeys = QSet<QString>(oldKeys).subtract(newKeys);
86
if (!removedKeys.isEmpty()) {
87
emit keysRemoved(removedKeys);
89
if (!addedKeys.isEmpty()) {
90
emit keysAdded(addedKeys);
95
#include "sourcewatchlist.moc"