• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

Plasma

abstracttoolbox.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright 2008 by Marco Martin <notmart@gmail.com>
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 as
00006  *   published by the Free Software Foundation; either version 2, or
00007  *   (at your option) any later version.
00008  *
00009  *   This program is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details
00013  *
00014  *   You should have received a copy of the GNU Library General Public
00015  *   License along with this program; if not, write to the
00016  *   Free Software Foundation, Inc.,
00017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018  */
00019 
00020 #include "abstracttoolbox.h"
00021 
00022 #include "containment.h"
00023 
00024 #include <kservicetypetrader.h>
00025 
00026 namespace Plasma
00027 {
00028 
00029 class AbstractToolBoxPrivate
00030 {
00031 public:
00032     AbstractToolBoxPrivate(Containment *c)
00033       : containment(c)
00034     {}
00035 
00036     Containment *containment;
00037 };
00038 
00039 AbstractToolBox::AbstractToolBox(Containment *parent)
00040     : QGraphicsWidget(parent),
00041       d(new AbstractToolBoxPrivate(parent))
00042 {
00043 }
00044 
00045 AbstractToolBox::AbstractToolBox(QObject *parent, const QVariantList &args)
00046    : QGraphicsWidget(dynamic_cast<QGraphicsItem *>(parent)),
00047      d(new AbstractToolBoxPrivate(qobject_cast<Containment *>(parent)))
00048 {
00049     if (!parentItem()) {
00050         setParent(parent);
00051     }
00052 }
00053 
00054 AbstractToolBox::~AbstractToolBox()
00055 {
00056     delete d;
00057 }
00058 
00059 AbstractToolBox *AbstractToolBox::load(const QString &name, const QVariantList &args, Plasma::Containment *containment)
00060 {
00061     const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
00062     KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
00063 
00064     if (!offers.isEmpty()) {
00065         KService::Ptr offer = offers.first();
00066 
00067         KPluginLoader plugin(*offer);
00068 
00069         if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
00070             return 0;
00071         }
00072 
00073         return offer->createInstance<AbstractToolBox>(containment, args);
00074     } else {
00075         return 0;
00076     }
00077 }
00078 
00079 KPluginInfo::List AbstractToolBox::listToolBoxInfo(const QString
00080  &parentApp)
00081 {
00082     KPluginInfo::List list;
00083 
00084     if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) {
00085         list = KPluginInfo::List();
00086     }
00087 
00088     QString constraint;
00089     if (parentApp.isEmpty()) {
00090         constraint.append("not exist [X-KDE-ParentApp]");
00091     } else {
00092         constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
00093     }
00094 
00095     KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
00096     return list + KPluginInfo::fromServices(offers);
00097 }
00098 
00099 Containment *AbstractToolBox::containment() const
00100 {
00101     return d->containment;
00102 }
00103 
00104 void AbstractToolBox::restore(const KConfigGroup &group)
00105 {
00106     Q_UNUSED(group)
00107 }
00108 
00109 void AbstractToolBox::save(const KConfigGroup &group)
00110 {
00111     Q_UNUSED(group)
00112 }
00113 
00114 void AbstractToolBox::reposition()
00115 {}
00116 
00117 } // plasma namespace
00118 
00119 #include "abstracttoolbox.moc"
00120 

Plasma

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
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