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

Plasma

appsource.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 "appsource.h"
00020 #include "appsengine.h"
00021 #include "appservice.h"
00022 
00023 AppSource::AppSource(KServiceGroup::Ptr group, QObject *parent) :
00024     Plasma::DataContainer(parent),
00025     m_group(group),
00026     m_app(),
00027     m_isApp(false)
00028 {
00029     setObjectName(m_group->entryPath());
00030     setData("isApp", false);
00031     updateGroup();
00032 }
00033 
00034 AppSource::AppSource(KService::Ptr app, QObject *parent) :
00035     Plasma::DataContainer(parent),
00036     m_group(),
00037     m_app(app),
00038     m_isApp(true)
00039 {
00040     setObjectName(m_app->storageId());
00041     setData("isApp", true);
00042     updateApp();
00043 }
00044 
00045 AppSource::~AppSource()
00046 {
00047 }
00048 
00049 Plasma::Service *AppSource::createService()
00050 {
00051     return new AppService(this);
00052 }
00053 
00054 KService::Ptr AppSource::getApp()
00055 {
00056     return m_app;
00057 }
00058 
00059 bool AppSource::isApp() const
00060 {
00061     return m_isApp;
00062 }
00063 
00064 void AppSource::updateGroup()
00065 {
00066     setData("iconName", m_group->icon());
00067     setData("name", m_group->caption());
00068     setData("comment", m_group->comment());
00069     setData("display", !m_group->noDisplay());
00070 
00071     QStringList entries;
00072     foreach (KSycocaEntry::Ptr p, m_group->entries(false, false, true)) {
00073         if (p->isType(KST_KService)) {
00074             const KService::Ptr service = KService::Ptr::staticCast(p);
00075             entries << service->storageId();
00076         } else if (p->isType(KST_KServiceGroup)) {
00077             const KServiceGroup::Ptr service = KServiceGroup::Ptr::staticCast(p);
00078             entries << service->entryPath();
00079         } else if (p->isType(KST_KServiceSeparator)) {
00080             entries << "---";
00081         } else {
00082             kDebug() << "unexpected object in entry list";
00083         }
00084     }
00085     setData("entries", entries);
00086 
00087     checkForUpdate();
00088 }
00089 
00090 void AppSource::updateApp()
00091 {
00092     setData("iconName", m_app->icon());
00093     setData("name", m_app->name());
00094     setData("genericName", m_app->genericName());
00095     setData("menuId", m_app->menuId());
00096     setData("entryPath", m_app->entryPath());
00097     setData("comment", m_app->comment());
00098     setData("keywords", m_app->keywords());
00099     setData("categories", m_app->categories());
00100     setData("display", !m_app->noDisplay());
00101     checkForUpdate();
00102 }
00103 
00104 #include "appsource.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"
  • 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