kparts/componentfactory.h (was: plugin loading (was: kcmoduleinfo / Plugin linking problem))

David Faure faure at kde.org
Wed Aug 15 22:58:27 BST 2007


On Wednesday 15 August 2007, Matthias Kretz wrote:
> I started going through the plugin factory code in kdelibs and got stuck at  
> kdelibs/kparts/factory.h and kdelibs/kparts/componentfactory.h. The 
> KParts::ComponentFactory namespace provides the following methods:
> 
> createPartInstanceFromFactory(KParts::Factory *factory, QWidget *parentWidget,
>     QObject *parent, const QStringList &args)
> LXR: 0 uses
Well it's used by createPartInstanceFromLibrary.
 
> createPartInstanceFromLibrary(const char *libraryName, QWidget *parentWidget,
>     QObject *parent, const QStringList &args, int *error)
> LXR: 5 uses
> 
> createPartInstanceFromService(const KService::Ptr &service, QWidget
>     *parentWidget, QObject *parent, const QStringList &args, int *error)
> LXR: 5 uses
> 
> createPartInstanceFromServices(ServiceIterator begin, ServiceIterator end,
>     QWidget *parentWidget, QObject *parent, const QStringList &args, int
>     *error)
> LXR: 0 uses
Well it's used by createPartInstanceFromQuery :)

> createPartInstanceFromQuery(const QString &mimeType, const QString
>     &constraint, QWidget *parentWidget, QObject *parent, const QStringList
>     &args, int *error)
> LXR: 16 uses
>
> KParts::Factory changes the KLibFactory interface a bit by adding the 
> partComponentData and createPartObject functions. The latter function differs 
> from the KLibFactory create function only in that it adds a parentWidget 
> argument. The partComponentData() function could be moved up to 
> KLibFactory/KPluginFactory and renamed to pluginComponentData() or simply 
> componentData().
> 
> IMHO we should try to remove both KParts::Factory and 
> KParts::ComponentFactory. Opinions?

I disagree. KParts needs two parents (one for the widget and one for the part),
this is the reason for the kparts factory stuff.
And we definitely need those helper methods which are currently in ComponentFactory.
See the comment in createPartInstanceFromQuery: it makes "show me a viewer for this url" a 5-liner.
I'm surprised that there are only 16 uses, but even that should be enough to keep it IMHO.

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list