• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Plasma

appsengine.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2009 Chani Armitage <chani@kde.org>
00003  *
00004  *   This program is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU Library General Public License version 2 as
00006  *   published by the Free Software Foundation
00007  *
00008  *   This program is distributed in the hope that it will be useful,
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  *   GNU General Public License for more details
00012  *
00013  *   You should have received a copy of the GNU Library General Public
00014  *   License along with this program; if not, write to the
00015  *   Free Software Foundation, Inc.,
00016  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00017  */
00018 
00019 #include "appsengine.h"
00020 #include "appsource.h"
00021 
00022 AppsEngine::AppsEngine(QObject *parent, const QVariantList &args) :
00023     Plasma::DataEngine(parent, args)
00024 {
00025     Q_UNUSED(args);
00026 }
00027 
00028 AppsEngine::~AppsEngine()
00029 {
00030 }
00031 
00032 Plasma::Service *AppsEngine::serviceForSource(const QString &name)
00033 {
00034     AppSource *source = dynamic_cast<AppSource*>(containerForSource(name));
00035     // if source does not exist, return null service
00036     if (!source) {
00037         return Plasma::DataEngine::serviceForSource(name);
00038     }
00039     // if source represents a group or something, return null service
00040     if (!source->isApp()) {
00041         return Plasma::DataEngine::serviceForSource(name);
00042     }
00043     // if source represent a proper app, return real service
00044     Plasma::Service *service = source->createService();
00045     service->setParent(this);
00046     return service;
00047 }
00048 
00049 void AppsEngine::init()
00050 {
00051     addGroup(KServiceGroup::root());
00052     //TODO find a way to listen for changes
00053 }
00054 
00055 void AppsEngine::addGroup(KServiceGroup::Ptr group)
00056 {
00057     if (!(group && group->isValid())) {
00058         return;
00059     }
00060     AppSource *appSource = new AppSource(group, this);
00061     //TODO listen for changes
00062     addSource(appSource);
00063     //do children
00064     foreach (const KServiceGroup::Ptr subGroup, group->groupEntries(KServiceGroup::NoOptions)) {
00065         addGroup(subGroup);
00066     }
00067     foreach (const KService::Ptr app, group->serviceEntries(KServiceGroup::NoOptions)) {
00068         addApp(app);
00069     }
00070 }
00071 
00072 void AppsEngine::addApp(KService::Ptr app)
00073 {
00074     AppSource *appSource = new AppSource(app, this);
00075     //TODO listen for changes
00076     addSource(appSource);
00077 }
00078 
00079 K_EXPORT_PLASMA_DATAENGINE(apps, AppsEngine)
00080 
00081 #include "appsengine.moc"

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KStyles
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •     Animators
  •     Applets
  •     Engines
  • Solid Modules
  • System Settings
  •   SystemSettingsView
Generated for API Reference by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal