get rid of all Class:load(..) methods, use PluginLoader directrly. --apiBloat;

This commit is contained in:
Aaron Seigo 2011-07-19 22:04:22 +02:00
parent e40bb1bcdd
commit 35898d57f1
13 changed files with 29 additions and 117 deletions

View File

@ -33,10 +33,10 @@
#include <kservicetypetrader.h>
#include <kstandarddirs.h>
#include <plasma/package.h>
#include <plasma/querymatch.h>
#include "package.h"
#include "pluginloader.h"
#include "private/abstractrunner_p.h"
#include "querymatch.h"
#include "runnercontext.h"
#include "scripting/runnerscript.h"
@ -415,7 +415,7 @@ void AbstractRunnerPrivate::prepScripting(const QString &path, const QString &ap
return;
}
package = new Package(Plasma::Package::load("Plasma/Runner", api));
package = new Package(PluginLoader::self()->loadPackage("Plasma/Runner", api));
package->setPath(path);
if (!package->isValid()) {

View File

@ -2307,20 +2307,6 @@ Applet *Applet::loadPlasmoid(const QString &path, uint appletId, const QVariantL
return 0;
}
Applet *Applet::load(const QString &appletName, uint appletId, const QVariantList &args)
{
return PluginLoader::self()->loadApplet(appletName, appletId, args);
}
Applet *Applet::load(const KPluginInfo &info, uint appletId, const QVariantList &args)
{
if (!info.isValid()) {
return 0;
}
return load(info.pluginName(), appletId, args);
}
QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
{
QVariant ret = QGraphicsWidget::itemChange(change, value);
@ -2645,7 +2631,7 @@ void AppletPrivate::init(const QString &packagePath)
}
package = new Package(Package::load("Plasma/Applet", api));
package = new Package(PluginLoader::self()->loadPackage("Plasma/Applet", api));
// find where the Package is
QString path = packagePath;

View File

@ -337,38 +337,6 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget
static Applet *loadPlasmoid(const QString &path, uint appletId = 0,
const QVariantList &args = QVariantList());
/**
* Attempts to load an applet
*
* Returns a pointer to the applet if successful.
* The caller takes responsibility for the applet, including
* deleting it when no longer needed.
*
* @param name the plugin name, as returned by KPluginInfo::pluginName()
* @param appletId unique ID to assign the applet, or zero to have one
* assigned automatically.
* @param args to send the applet extra arguments
* @return a pointer to the loaded applet, or 0 on load failure
**/
static Applet *load(const QString &name, uint appletId = 0,
const QVariantList &args = QVariantList());
/**
* Attempts to load an applet
*
* Returns a pointer to the applet if successful.
* The caller takes responsibility for the applet, including
* deleting it when no longer needed.
*
* @param info KPluginInfo object for the desired applet
* @param appletId unique ID to assign the applet, or zero to have one
* assigned automatically.
* @param args to send the applet extra arguments
* @return a pointer to the loaded applet, or 0 on load failure
**/
static Applet *load(const KPluginInfo &info, uint appletId = 0,
const QVariantList &args = QVariantList());
/**
* Get the category of the given applet
*

View File

@ -2165,7 +2165,7 @@ Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &a
v->setCursor(Qt::BusyCursor);
}
Applet *applet = Applet::load(name, id, args);
Applet *applet = PluginLoader::self()->loadApplet(name, id, args);
if (v) {
v->unsetCursor();
}

View File

@ -41,16 +41,17 @@
#include <kshortcutsdialog.h>
#include <kwindowsystem.h>
#include "animator.h"
#include "abstractdialogmanager.h"
#include "abstracttoolbox.h"
#include "animator.h"
#include "containment.h"
#include "containmentactionspluginsconfig.h"
#include "view.h"
#include "pluginloader.h"
#include "private/animator_p.h"
#include "private/applet_p.h"
#include "private/containment_p.h"
#include "tooltipmanager.h"
#include "abstractdialogmanager.h"
#include "view.h"
using namespace Plasma;
@ -910,7 +911,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
bool loadingNull = pluginName == "null";
if (!loadingNull) {
applet = Applet::load(pluginName, id, args);
applet = PluginLoader::self()->loadApplet(pluginName, id, args);
containment = dynamic_cast<Containment*>(applet);
}

View File

@ -34,6 +34,7 @@
#include "datacontainer.h"
#include "package.h"
#include "pluginloader.h"
#include "remote/authorizationmanager.h"
#include "remote/authorizationmanager_p.h"
#include "service.h"
@ -438,7 +439,7 @@ Service* DataEngine::createDefaultService(QObject *parent)
{
QVariantList args;
args << QVariant::fromValue<DataEngine*>(this);
return Service::load(d->serviceName, args, parent);
return PluginLoader::self()->loadService(d->serviceName, args, parent);
}
void DataEnginePrivate::publish(AnnouncementMethods methods, const QString &name)
@ -541,7 +542,7 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
const QString path =
KStandardDirs::locate("data",
"plasma/dataengines/" + dataEngineDescription.pluginName() + '/');
package = new Package(Package::load("Plasma/DataEngine", api));
package = new Package(PluginLoader::self()->loadPackage("Plasma/DataEngine", api));
package->setPath(path);
if (package->isValid()) {

View File

@ -35,6 +35,7 @@
#include "extenderitem.h"
#include "framesvg.h"
#include "paintutils.h"
#include "pluginloader.h"
#include "popupapplet.h"
#include "svg.h"
#include "theme.h"
@ -777,7 +778,7 @@ void ExtenderPrivate::loadExtenderItems()
//detachables.
if (!sourceApplet) {
kDebug() << "creating a temporary applet as factory";
sourceApplet = Applet::load(appletName);
sourceApplet = PluginLoader::self()->loadApplet(appletName);
temporarySourceApplet = true;
//TODO: maybe add an option to applet to indicate that it shouldn't be deleted after
//having used it as factory.

View File

@ -116,11 +116,6 @@ bool removeFolder(QString folderPath)
#endif // PLASMA_NO_KIO
Package Package::load(const QString &packageFormat, const QString &specialization)
{
return PluginLoader::self()->loadPackage(packageFormat, specialization);
}
Package::Package(PackageStructure *structure)
: d(new PackagePrivate())
{

View File

@ -76,16 +76,6 @@ class PackageStructure;
class PLASMA_EXPORT Package
{
public:
/**
* Loads a package format by name.
*
* @param format If not empty, attempts to locate the given format, either
* from built-ins or via plugins.
* @param specialization used to find script extensions for the given format, e.g. "QML" for "Plasma/Applet"
* @return a package that matches the format, if available, or an invalid package if not
*/
static Package load(const QString &format, const QString &specialization = QString());
/**
* Default constructor
*

View File

@ -36,6 +36,7 @@ class Service;
class PluginLoaderPrivate;
//TODO:
// * add loadWallpaper
// * add KPluginInfo listing support for Containments (already loaded via the applet loading code)
/**

View File

@ -19,20 +19,22 @@
#include "accessappletjob.h"
#include "service.h"
#include "servicejob.h"
#include "applet.h"
#include <qtimer.h>
#include <kdebug.h>
#include <kdesktopfile.h>
#include <kmessagebox.h>
#include <ktempdir.h>
#include <kzip.h>
#include "config-plasma.h"
#include <kzip.h>
#include <kdebug.h>
#include <kmessagebox.h>
#include <ktempdir.h>
#include <kdesktopfile.h>
#include "applet.h"
#include "package.h"
#include <qtimer.h>
#include "pluginloader.h"
#include "private/applet_p.h"
#include "service.h"
#include "servicejob.h"
namespace Plasma
{
@ -74,7 +76,7 @@ public:
QString pluginName = job->result().toString();
kDebug() << "Server responded with a pluginname, trying to load: " << pluginName;
applet = Applet::load(pluginName);
applet = PluginLoader::self()->loadApplet(pluginName);
if (applet) {
applet->d->remoteLocation = location;
} else {

View File

@ -64,17 +64,6 @@ Service::~Service()
delete d;
}
Service *Service::load(const QString &name, QObject *parent)
{
QVariantList args;
return load(name, args, parent);
}
Service *Service::load(const QString &name, const QVariantList &args, QObject *parent)
{
return PluginLoader::self()->loadService(name, args, parent);
}
Service *Service::access(const KUrl &url, QObject *parent)
{
return new RemoteService(parent, url);

View File

@ -101,28 +101,6 @@ public:
*/
~Service();
/**
* Used to load a given service from a plugin.
*
* @param name the plugin name of the service to load
* @param args a list of arguments to supply to the service plugin when loading it
* @param parent the parent object, if any, for the service
*
* @return a Service object, guaranteed to be not null.
* @since 4.5
*/
static Service *load(const QString &name, const QVariantList &args, QObject *parent = 0);
/**
* Used to load a given service from a plugin.
*
* @param name the plugin name of the service to load
* @param parent the parent object, if any, for the service
*
* @return a Service object, guaranteed to be not null.
*/
static Service *load(const QString &name, QObject *parent = 0);
/**
* Used to access a service from an url. Always check for the signal serviceReady() that fires
* when this service is actually ready for use.