kio Library API Documentation

KServiceTypeProfile Class Reference

KServiceTypeProfile represents the user's preferences for services of a service type. Represents the user's preferences for services of a service type. More...

#include <kuserprofile.h>

Collaboration diagram for KServiceTypeProfile:

Collaboration graph
[legend]
List of all members.

Public Types

typedef QValueList< KServiceOfferOfferList

Public Member Functions

int preference (const QString &_service) const
bool allowAsDefault (const QString &_service) const
OfferList offers () const

Static Public Member Functions

KService::Ptr preferredService (const QString &serviceType, const QString &genericServiceType)
KServiceTypeProfileserviceTypeProfile (const QString &servicetype, const QString &genericServiceType=QString::null)
OfferList offers (const QString &servicetype, const QString &genericServiceType=QString::null)
const QPtrList< KServiceTypeProfile > & serviceTypeProfiles ()
void clear ()
void setConfigurationMode ()
bool configurationMode ()

Protected Member Functions

 KServiceTypeProfile (const QString &servicetype, const QString &genericServiceType=QString::null)
void addService (const QString &_service, int _preference=1, bool _allow_as_default=true)

Detailed Description

KServiceTypeProfile represents the user's preferences for services of a service type. Represents the user's preferences for services of a service type.

It consists of a list of services (service offers) for the service type that is sorted by the user's preference. KTrader uses KServiceTypeProfile to sort its results, so usually you can just use KTrader to find the user's preferred service.

See also:
KService

KServiceType

KServiceOffer

KTrader

Definition at line 117 of file kuserprofile.h.


Constructor & Destructor Documentation

KServiceTypeProfile::KServiceTypeProfile const QString servicetype,
const QString genericServiceType = QString::null
[protected]
 

Constructor is called when the user profile is read for the first time.

Parameters:
serviceType the service type (e.g. a MIME type)
genericServiceType the generic service type (e.g. "Application" or "KParts/ReadOnlyPart"). Can be QString::null, then the "Application" generic type will be used

Definition at line 181 of file kuserprofile.cpp.

References QPtrList< KServiceTypeProfile >::append().


Member Function Documentation

int KServiceTypeProfile::preference const QString _service  )  const
 

Returns the users preference of the given service.

Parameters:
_service the name of the service to check
Returns:
the user's preference number of the given _service, or 0 the service is unknown.

Definition at line 205 of file kuserprofile.cpp.

References QMap< QString, Service >::end(), and QMap< QString, Service >::find().

bool KServiceTypeProfile::allowAsDefault const QString _service  )  const
 

Checks whether the given _service can be used as default.

Parameters:
_service the name of the service to check
Returns:
true if allowed as default

Definition at line 214 of file kuserprofile.cpp.

References QMap< QString, Service >::end(), QMap< QString, Service >::find(), and KService::serviceByName().

KServiceTypeProfile::OfferList KServiceTypeProfile::offers  )  const
 

Returns the list of all service offers for the service types that are represented by this profile.

Returns:
the list of KServiceOffer instances

Definition at line 246 of file kuserprofile.cpp.

References QValueList::append(), QValueList::begin(), QMap< QString, Service >::end(), QValueList::end(), endl(), QMap< QString, Service >::find(), QString::isEmpty(), kdDebug(), KServiceType::offers(), and offers().

Referenced by offers(), and preferredService().

KService::Ptr KServiceTypeProfile::preferredService const QString serviceType,
const QString genericServiceType
[static]
 

Returns the preferred service for _serviceType and _genericServiceType ("Application", type of component, or null).

Parameters:
serviceType the service type (e.g. a MIME type)
genericServiceType the generic service type (e.g. "Application" or "KParts/ReadOnlyPart")
Returns:
the preferred service, or 0 if no service is available

Definition at line 288 of file kuserprofile.cpp.

References QValueList::begin(), QValueList::end(), endl(), kdDebug(), and offers().

Referenced by KRun::runURL().

KServiceTypeProfile * KServiceTypeProfile::serviceTypeProfile const QString servicetype,
const QString genericServiceType = QString::null
[static]
 

Returns the profile for the requested service type.

Parameters:
servicetype the service type (e.g. a MIME type)
genericServiceType the generic service type (e.g. "Application" or "KParts/ReadOnlyPart"). Can be QString::null, then the "Application" generic type will be used
Returns:
the KServiceTypeProfile with the given arguments, or 0 if not found

Definition at line 229 of file kuserprofile.cpp.

References QPtrListIterator::current(), QString::isEmpty(), and KGlobal::staticQString().

Referenced by offers().

KServiceTypeProfile::OfferList KServiceTypeProfile::offers const QString servicetype,
const QString genericServiceType = QString::null
[static]
 

Returns the offers associated with a given servicetype, sorted by preference.

This is what KTrader uses to get the list of offers, before applying the constraints and preferences.

If genericServiceType is specified, a list is returned with the offers associated with the combination of the two service types. This is almost like an "foo in ServiceTypes" constraint in the KTrader, but the difference is that to order the offers, we will look at entries specifically for those two service types. Typically, this is used for getting the list of embeddable components that can handle a given mimetype. In that case, servicetype is the mimetype and genericServiceType is "KParts/ReadOnlyPart".

Parameters:
servicetype the service type (e.g. a MIME type)
genericServiceType the generic service type (e.g. "Application" or "KParts/ReadOnlyPart"). Can be QString::null, then all generic types will be included
Returns:
the list of offers witht he given parameters

Definition at line 97 of file kuserprofile.cpp.

References QValueList::append(), QValueList::begin(), QValueList::count(), QPtrListIterator::current(), QValueList::end(), endl(), QString::isEmpty(), kdDebug(), KServiceType::offers(), offers(), and serviceTypeProfile().

const QPtrList<KServiceTypeProfile>& KServiceTypeProfile::serviceTypeProfiles  )  [inline, static]
 

Returns a list of all KServiceTypeProfiles.

Returns:
a list of all KServiceTypeProfiles

Definition at line 192 of file kuserprofile.h.

void KServiceTypeProfile::clear  )  [inline, static]
 

Clear all cached information.

Definition at line 197 of file kuserprofile.h.

void KServiceTypeProfile::setConfigurationMode  )  [inline, static]
 

This method activates a special mode of KServiceTypeProfile, in which all/all and all/allfiles are excluded from the results of the queries.

It is meant for the configuration module _only_.

Definition at line 205 of file kuserprofile.h.

void KServiceTypeProfile::addService const QString _service,
int  _preference = 1,
bool  _allow_as_default = true
[protected]
 

Add a service to this profile.

Parameters:
_service the name of the service
_pref the user's preference value, must be positive, bigger is better
_default true if the service should be used as default

Definition at line 198 of file kuserprofile.cpp.


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kio Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 12 09:07:01 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003