• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeparts
 

tdeparts

  • KParts
  • ComponentFactory
Enumerations | Functions
KParts::ComponentFactory Namespace Reference

Enumerations

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

Functions

template<class T >
static T * createInstanceFromFactory (KLibFactory *factory, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList())
 
template<class T >
static T * createPartInstanceFromFactory (KParts::Factory *factory, TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList())
 
template<class T >
static T * createInstanceFromLibrary (const char *libraryName, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T >
static T * createPartInstanceFromLibrary (const char *libraryName, TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T >
static T * createInstanceFromService (const KService::Ptr &service, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T >
static T * createPartInstanceFromService (const KService::Ptr &service, TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T , class ServiceIterator >
static T * createInstanceFromServices (ServiceIterator begin, ServiceIterator end, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T , class ServiceIterator >
static T * createPartInstanceFromServices (ServiceIterator begin, ServiceIterator end, TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T >
static T * createInstanceFromQuery (const TQString &serviceType, const TQString &constraint=TQString::null, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 
template<class T >
static T * createPartInstanceFromQuery (const TQString &serviceType, const TQString &constraint, TQWidget *parentWidget=0, const char *widgetName=0, TQObject *parent=0, const char *name=0, const TQStringList &args=TQStringList(), int *error=0)
 

Detailed Description

Namespace for KParts components.

Enumeration Type Documentation

◆ ComponentLoadingError

enum KParts::ComponentFactory::ComponentLoadingError

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

  • ErrNoServiceFound - no service implementing the given mimetype and fullfilling the given constraint expression can be found.
  • ErrServiceProvidesNoLibrary - the specified service provides no shared library
  • ErrNoLibrary - the specified library could not be loaded. Use KLibLoader::lastErrorMessage for details.
  • ErrNoFactory - the library does not export a factory for creating components
  • ErrNoComponent - the factory does not support creating components of the specified type

Definition at line 37 of file componentfactory.h.

Function Documentation

◆ createInstanceFromFactory()

template<class T >
static T * KParts::ComponentFactory::createInstanceFromFactory ( KLibFactory *  factory,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList() 
)
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::createInstanceFromFactory<MyPlugin>( factory, parent );
Parameters
factoryThe factory to ask for the creation of the component
parentThe parent object (see TQObject constructor)
nameThe name of the object to create (see TQObject 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.

Definition at line 61 of file componentfactory.h.

◆ createInstanceFromLibrary()

template<class T >
static T * KParts::ComponentFactory::createInstanceFromLibrary ( const char *  libraryName,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
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 TQObject constructor)
nameThe name of the object to create (see TQObject constructor)
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)
error
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.

Definition at line 127 of file componentfactory.h.

◆ createInstanceFromQuery()

template<class T >
static T * KParts::ComponentFactory::createInstanceFromQuery ( const TQString &  serviceType,
const TQString &  constraint = TQString::null,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

This method creates and returns a plugin, from the trader query for a given serviceType.

Example:

KMyAppPlugin* plugin = KParts::ComponentFactory::createInstanceFromQuery<KMyAppPlugin>( serviceType, TQString::null, parentObject );
if ( plugin ) {
....
}
Parameters
serviceTypethe type of service for which to find a plugin
constraintan optional constraint to pass to the trader (see TDEIO::TDETrader)
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.

Definition at line 321 of file componentfactory.h.

◆ createInstanceFromService()

template<class T >
static T * KParts::ComponentFactory::createInstanceFromService ( const KService::Ptr &  service,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

Definition at line 201 of file componentfactory.h.

◆ createInstanceFromServices()

template<class T , class ServiceIterator >
static T * KParts::ComponentFactory::createInstanceFromServices ( ServiceIterator  begin,
ServiceIterator  end,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

Definition at line 241 of file componentfactory.h.

◆ createPartInstanceFromFactory()

template<class T >
static T * KParts::ComponentFactory::createPartInstanceFromFactory ( KParts::Factory *  factory,
TQWidget *  parentWidget = 0,
const char *  widgetName = 0,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList() 
)
static

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

Example of usage:

KViewPart *doc = KParts::ComponentFactory::createPartInstanceFromFactory<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 TQObject constructor)
nameThe name of the object to create (see TQObject 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.

Definition at line 95 of file componentfactory.h.

◆ createPartInstanceFromLibrary()

template<class T >
static T * KParts::ComponentFactory::createPartInstanceFromLibrary ( const char *  libraryName,
TQWidget *  parentWidget = 0,
const char *  widgetName = 0,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

Definition at line 158 of file componentfactory.h.

◆ createPartInstanceFromQuery()

template<class T >
static T * KParts::ComponentFactory::createPartInstanceFromQuery ( const TQString &  serviceType,
const TQString &  constraint,
TQWidget *  parentWidget = 0,
const char *  widgetName = 0,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
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, TQWidget* parentWidget and TQObject* parentObject.
TQString mimetype = KMimeType::findByURL( url )->name();
KParts::ReadOnlyPart* part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, TQString::null, parentWidget, 0, parentObject, 0 );
if ( part ) {
part->openURL( url );
part->widget()->show(); // also insert the widget into a layout, or simply use a TQVBox as parentWidget
}
KParts::Part::widget
virtual TQWidget * widget()
Definition: part.cpp:171
KParts::ReadOnlyPart
Base class for any "viewer" part.
Definition: part.h:339
KParts::ReadOnlyPart::openURL
virtual bool openURL(const KURL &url)
Only reimplement openURL if you don't want the network transparency support to download from the url ...
Definition: part.cpp:333
Parameters
serviceTypethe type of service for which to find a part, e.g. a mimetype
constraintan optional constraint to pass to the trader (see TDETrader)
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.

Definition at line 370 of file componentfactory.h.

◆ createPartInstanceFromService()

template<class T >
static T * KParts::ComponentFactory::createPartInstanceFromService ( const KService::Ptr &  service,
TQWidget *  parentWidget = 0,
const char *  widgetName = 0,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

Definition at line 220 of file componentfactory.h.

◆ createPartInstanceFromServices()

template<class T , class ServiceIterator >
static T * KParts::ComponentFactory::createPartInstanceFromServices ( ServiceIterator  begin,
ServiceIterator  end,
TQWidget *  parentWidget = 0,
const char *  widgetName = 0,
TQObject *  parent = 0,
const char *  name = 0,
const TQStringList &  args = TQStringList(),
int *  error = 0 
)
static

Definition at line 268 of file componentfactory.h.

tdeparts

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

tdeparts

Skip menu "tdeparts"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeparts by doxygen 1.9.4
This website is maintained by Timothy Pearson.