Plasma
appsource.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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"