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 = name.isEmpty() ? QString() : 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 if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) { 00069 return offer->createInstance<AbstractToolBox>(containment, args); 00070 } 00071 } 00072 00073 return 0; 00074 } 00075 00076 KPluginInfo::List AbstractToolBox::listToolBoxInfo(const QString 00077 &parentApp) 00078 { 00079 KPluginInfo::List list; 00080 00081 if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) { 00082 list = KPluginInfo::List(); 00083 } 00084 00085 QString constraint; 00086 if (parentApp.isEmpty()) { 00087 constraint.append("not exist [X-KDE-ParentApp]"); 00088 } else { 00089 constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'"); 00090 } 00091 00092 KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint); 00093 return list + KPluginInfo::fromServices(offers); 00094 } 00095 00096 Containment *AbstractToolBox::containment() const 00097 { 00098 return d->containment; 00099 } 00100 00101 void AbstractToolBox::restore(const KConfigGroup &group) 00102 { 00103 Q_UNUSED(group) 00104 } 00105 00106 void AbstractToolBox::save(const KConfigGroup &group) 00107 { 00108 Q_UNUSED(group) 00109 } 00110 00111 void AbstractToolBox::reposition() 00112 {} 00113 00114 } // plasma namespace 00115 00116 #include "abstracttoolbox.moc" 00117
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 17:35:52 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Wed May 2 2012 17:35:52 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.