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

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
abstracttoolbox.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 by Marco Martin <notmart@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "abstracttoolbox.h"
21 
22 #include "containment.h"
23 
24 #include <kservicetypetrader.h>
25 
26 namespace Plasma
27 {
28 
29 class AbstractToolBoxPrivate
30 {
31 public:
32  AbstractToolBoxPrivate(Containment *c)
33  : containment(c)
34  {}
35 
36  Containment *containment;
37 };
38 
39 AbstractToolBox::AbstractToolBox(Containment *parent)
40  : QGraphicsWidget(parent),
41  d(new AbstractToolBoxPrivate(parent))
42 {
43 }
44 
45 AbstractToolBox::AbstractToolBox(QObject *parent, const QVariantList & /*args*/)
46  : QGraphicsWidget(dynamic_cast<QGraphicsItem *>(parent)),
47  d(new AbstractToolBoxPrivate(qobject_cast<Containment *>(parent)))
48 {
49  if (!parentItem()) {
50  setParent(parent);
51  }
52 }
53 
54 AbstractToolBox::~AbstractToolBox()
55 {
56  delete d;
57 }
58 
59 AbstractToolBox *AbstractToolBox::load(const QString &name, const QVariantList &args, Plasma::Containment *containment)
60 {
61  const QString constraint = name.isEmpty() ? QString() : QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
62  KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
63 
64  if (!offers.isEmpty()) {
65  KService::Ptr offer = offers.first();
66 
67  KPluginLoader plugin(*offer);
68  if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
69  return offer->createInstance<AbstractToolBox>(containment, args);
70  }
71  }
72 
73  return 0;
74 }
75 
76 KPluginInfo::List AbstractToolBox::listToolBoxInfo(const QString
77  &parentApp)
78 {
79  KPluginInfo::List list;
80 
81  if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) {
82  list = KPluginInfo::List();
83  }
84 
85  QString constraint;
86  if (parentApp.isEmpty()) {
87  constraint.append("not exist [X-KDE-ParentApp]");
88  } else {
89  constraint.append("[X-KDE-ParentApp] == '").append(parentApp).append("'");
90  }
91 
92  KService::List offers = KServiceTypeTrader::self()->query("Plasma/ToolBox", constraint);
93  return list + KPluginInfo::fromServices(offers);
94 }
95 
96 Containment *AbstractToolBox::containment() const
97 {
98  return d->containment;
99 }
100 
101 void AbstractToolBox::restore(const KConfigGroup &group)
102 {
103  Q_UNUSED(group)
104 }
105 
106 void AbstractToolBox::save(const KConfigGroup &group)
107 {
108  Q_UNUSED(group)
109 }
110 
111 void AbstractToolBox::reposition()
112 {}
113 
114 } // plasma namespace
115 
116 #include "abstracttoolbox.moc"
117 
Plasma::AbstractToolBox::AbstractToolBox
AbstractToolBox(Containment *parent)
Definition: abstracttoolbox.cpp:39
abstracttoolbox.h
containment.h
QObject
Plasma::AbstractToolBox::load
static AbstractToolBox * load(const QString &name, const QVariantList &args=QVariantList(), Plasma::Containment *containment=0)
Create a new AbstractToolBox, loading the proper plugin.
Definition: abstracttoolbox.cpp:59
Plasma::isPluginVersionCompatible
bool isPluginVersionCompatible(unsigned int version)
Verifies that a plugin is compatible with plasma.
Definition: version.cpp:51
Plasma::AbstractToolBox::reposition
void reposition()
Inform the ToolBox it has to reposition itlself It has to be reimplemented in toolboxes that need it...
Definition: abstracttoolbox.cpp:111
Plasma::AbstractToolBox::restore
void restore(const KConfigGroup &group)
Restore the ToolBox settings It has to be reimplemented in toolboxes that need it.
Definition: abstracttoolbox.cpp:101
Plasma::AbstractToolBox::containment
Containment * containment() const
Definition: abstracttoolbox.cpp:96
Plasma::AbstractToolBox
Definition: abstracttoolbox.h:40
Plasma::AbstractToolBox::~AbstractToolBox
~AbstractToolBox()
Definition: abstracttoolbox.cpp:54
Plasma::AbstractToolBox::listToolBoxInfo
static KPluginInfo::List listToolBoxInfo(const QString &parentApp=QString())
Returns a list of all installed ToolBox plugins.
Definition: abstracttoolbox.cpp:76
Plasma::AbstractToolBox::save
void save(const KConfigGroup &group)
Save the ToolBox settings It has to be reimplemented in toolboxes that need it.
Definition: abstracttoolbox.cpp:106
Plasma::Containment
The base class for plugins that provide backgrounds and applet grouping containers.
Definition: containment.h:72
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:32 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal