namespace ComponentFactory


Full nameKParts::ComponentFactory
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Static Methods


Detailed Description

enum ComponentLoadingError { ErrNoServiceFound = 1, ErrServiceProvidesNoLibrary, ErrNoLibrary, ErrNoFactory, ErrNoComponent }

ComponentLoadingError

This enum type defines the possible error cases that can happen when loading a component.

template T * createInstanceFromFactory ( KLibFactory *factory, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList() )

createInstanceFromFactory

[static]

This template function allows to ask the given factory to create an instance of the given template type.

Example of usage:


     MyPlugin *plugin = KParts::ComponentFactory::createInstance<MyPlugin>( factory, parent );

Parameters:
factoryThe factory to ask for the creation of the component
parentThe parent object (see QObject constructor)
nameThe name of the object to create (see QObject constructor)
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)

Returns: A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.

template T * createPartInstanceFromFactory ( KParts::Factory *factory, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList() )

createPartInstanceFromFactory

[static]

This template function allows to ask the given kparts factory to create an instance of the given template type.

Example of usage:


     KViewPart *doc = KParts::ComponentFactory::createInstance<KViewPart>( factory, parent );

Parameters:
factoryThe factory to ask for the creation of the component
parentWidgetthe parent widget for the part
widgetNamethe name of the part's widget
parentThe parent object (see QObject constructor)
nameThe name of the object to create (see QObject constructor)
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)

Returns: A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.

template T * createInstanceFromLibrary ( const char *libraryName, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createInstanceFromLibrary

[static]

This template allows to load the specified library and ask the factory to create an instance of the given template type.

Parameters:
libraryNameThe library to open
parentThe parent object (see QObject constructor)
nameThe name of the object to create (see QObject constructor)
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)

Returns: A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.

template T * createPartInstanceFromLibrary ( const char *libraryName, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createPartInstanceFromLibrary

[static]

template T * createInstanceFromService ( const KService::Ptr &service, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createInstanceFromService

[static]

template T * createPartInstanceFromService ( const KService::Ptr &service, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createPartInstanceFromService

[static]

template T * createInstanceFromServices ( ServiceIterator begin, ServiceIterator end, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createInstanceFromServices

[static]

template T * createPartInstanceFromServices ( ServiceIterator begin, ServiceIterator end, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createPartInstanceFromServices

[static]

template T * createInstanceFromQuery ( const QString &serviceType, const QString &constraint = QString::null, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createInstanceFromQuery

[static]

template T * createPartInstanceFromQuery ( const QString &serviceType, const QString &constraint, QWidget *parentWidget = 0, const char *widgetName = 0, QObject *parent = 0, const char *name = 0, const QStringList &args = QStringList(), int *error = 0 )

createPartInstanceFromQuery

[static]

This method creates and returns a KParts part from a serviceType (e.g. a mimetype).

You can use this method to create a generic viewer - that can display any kind of file, provided that there is a ReadOnlyPart installed for it - in 5 lines:


     // Given the following: KURL url, QWidget* parentWidget and QObject* parentObject.
     QString mimetype = KMimeType::findByURL( url )->name();
     KParts::ReadOnlyPart* part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString::null, parentWidget, 0, parentObject, 0 );
     if ( part ) {
         part->openURL( url );
         part->widget()->show();  // also insert the widget into a layout, or simply use a QVBox as parentWidget
     }

Parameters:
serviceTypethe type of service for which to find a part, e.g. a mimetype
constraintan optionnal constraint to pass to the trader (see KTrader)
parentWidgetthe parent widget, will be set as the parent of the part's widget
widgetNamethe name that will be given to the part's widget
parentthe parent object for the part itself
namethe name that will be given to the part
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)
errorThe int passed here will receive an error code in case of errors. (See enum ComponentLoadingError)

Returns: A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.


Generated by: dfaure on faure on Tue Apr 16 08:50:22 2002, using kdoc 2.0a53.