# class KMimeTypeTrader

###

Module | kdecore
Namespace |
Class | KMimeTypeTrader
Inherits |

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

- KMimeTypeTrader ( )

  returns ctor
  Not implemented

  Internal

- preferredService (mimeType, genericServiceType)

  returns KService.Ptr

  Argument | Type | Default
  --- | --- | ---
  mimeType | QString |
  genericServiceType | QString | 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).

  mimeType - the mime type (see offers())

  genericServiceType - the service type (see offers()) Returns the preferred service, or 0 if no service is available

- query (mimeType, genericServiceType, constraint)

  returns KService.List

  Argument | Type | Default
  --- | --- | ---
  mimeType | QString |
  genericServiceType | QString | QString.fromLatin1("Application")
  constraint | QString | 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.

  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

- self ( )

  returns KMimeTypeTrader
  static

  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