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)
34
bool SourceWatchList::contains(const QString& key) const
36
return m_data.contains(key);
40
QString SourceWatchList::query() const
46
void SourceWatchList::setQuery(const QString& query)
48
if (query != m_query) {
49
m_engine->disconnectSource(m_query, this);
50
dataUpdated(m_query, DataEngine::Data());
52
m_engine->connectSource(m_query, this);
57
QVariant SourceWatchList::value(const QString& id) const
59
return m_data.value(id);
63
void SourceWatchList::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
65
if (source != m_query) {
69
const QSet<QString> oldKeys = QSet<QString>::fromList(m_data.keys());
70
const QSet<QString> newKeys = QSet<QString>::fromList(data.keys());
72
emit keysRemoved(QSet<QString>(oldKeys).subtract(newKeys));
73
emit keysAdded(QSet<QString>(newKeys).subtract(oldKeys));
77
#include "sourcewatchlist.moc"