2
* Copyright 2009 Chani Armitage <chani@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
#include "appsengine.h"
20
#include "appsource.h"
24
AppsEngine::AppsEngine(QObject *parent, const QVariantList &args) :
25
Plasma::DataEngine(parent, args)
30
AppsEngine::~AppsEngine()
34
void AppsEngine::init()
36
addGroup(KServiceGroup::root());
37
connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(sycocaChanged(QStringList)));
40
void AppsEngine::sycocaChanged(const QStringList &changes)
42
if (changes.contains("apps") || changes.contains("xdgdata-apps")) {
44
addGroup(KServiceGroup::root());
48
Plasma::Service *AppsEngine::serviceForSource(const QString &name)
50
AppSource *source = dynamic_cast<AppSource*>(containerForSource(name));
51
// if source does not exist, return null service
53
return Plasma::DataEngine::serviceForSource(name);
56
// if source represents a group or something, return null service
57
if (!source->isApp()) {
58
return Plasma::DataEngine::serviceForSource(name);
60
// if source represent a proper app, return real service
61
Plasma::Service *service = source->createService();
62
service->setParent(this);
66
void AppsEngine::addGroup(KServiceGroup::Ptr group)
68
if (!(group && group->isValid())) {
71
AppSource *appSource = new AppSource(group, this);
72
//TODO listen for changes
75
foreach (const KServiceGroup::Ptr subGroup, group->groupEntries(KServiceGroup::NoOptions)) {
78
foreach (const KService::Ptr app, group->serviceEntries(KServiceGroup::NoOptions)) {
83
void AppsEngine::addApp(KService::Ptr app)
85
AppSource *appSource = new AppSource(app, this);
86
//TODO listen for changes
90
K_EXPORT_PLASMA_DATAENGINE(apps, AppsEngine)
92
#include "appsengine.moc"