KDE 4.2 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KMimeTypeTrader Class Reference

from PyKDE4.kdecore import *

Detailed Description

KDE's trader for services associated to a given mimetype.

Example: say that you want to the list of all KParts components that can handle HTML. Our code would look like:

 KServiceOfferList lst = KMimeTypeTrader.self()->query("text/html",
                                                        "KParts/ReadOnlyPart");

If you want to get the preferred KParts component for text/html you could use preferredService("text/html", "KParts/ReadOnlyPart"), although if this is about loading that component you would use createPartInstanceFromQuery directly.

See also:
KServiceTypeTrader, KService


Methods

 __init__ (self)
 __init__ (self, KMimeTypeTrader other)
KService.Ptr preferredService (self, QString mimeType, QString genericServiceType=QString.fromLatin1("Application"))
KService.List query (self, QString mimeType, QString genericServiceType=QString.fromLatin1("Application"), QString constraint=QString())

Static Methods

KMimeTypeTrader self ()

Method Documentation

__init__ (   self )

Internal:

__init__ (  self,
KMimeTypeTrader  other
)
KService.Ptr preferredService (  self,
QString  mimeType,
QString  genericServiceType=QString.fromLatin1("Application")
)

Returns the preferred service for mimeType and genericServiceType

This is almost like offers().first(), except that it also checks if the service is allowed as a preferred service (see KService.allowAsDefault).

Parameters:
mimeType  the mime type (see offers())
genericServiceType  the service type (see offers())

Returns:
the preferred service, or 0 if no service is available

KService.List query (  self,
QString  mimeType,
QString  genericServiceType=QString.fromLatin1("Application"),
QString  constraint=QString()
)

This method returns a list of services which are associated with a given mimetype.

Example usage: To get list of applications that can handle a given mimetype, set genericServiceType to "Application" (which is the default). To get list of embeddable components that can handle a given mimetype, set genericServiceType to "KParts/ReadOnlyPart".

The constraint parameter is used to limit the possible choices returned based on the constraints you give it.

The constraint language is rather full. The most common keywords are AND, OR, NOT, IN, and EXIST, all used in an almost spoken-word form. An example is:

 (Type == 'Service') and (('Browser/View' in ServiceTypes) and (exist Library))

The keys used in the query (Type, ServiceTypes, Library) are all fields found in the .desktop files.

Parameters:
mimeType  A mime type like 'text/plain' or 'text/html'.
genericServiceType  a basic service type, like 'KParts/ReadOnlyPart' or 'Application'
constraint  A constraint to limit the choices returned, QString() to get all services that can handle the given mimetype

Returns:
A list of services that satisfy the query, sorted by preference (preferred service first)
See also:
http://techbase.kde.org/Development/Tutorials/Services/Traders#The_KTrader_Query_Language

KMimeTypeTrader self (   )

This is a static pointer to the KMimeTypeTrader singleton.

You will need to use this to access the KMimeTypeTrader functionality since the constructors are protected.

Returns:
Static KMimeTypeTrader instance

  • Full Index

Modules

  • akonadi
  • dnssd
  • kdecore
  • kdeui
  • khtml
  • kio
  • knewstuff
  • kparts
  • kutils
  • nepomuk
  • phonon
  • plasma
  • solid
  • soprano
This documentation is maintained by Simon Edwards.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal