KServiceGroup Class Reference
from PyKDE4.kdecore import *
Inherits: KSycocaEntry
Detailed Description
KServiceGroup represents a group of service, for example screensavers. This class is typically used like this:
// Start from root group KServiceGroup.Ptr group = KServiceGroup.root(); if (!group || !group->isValid()) return; KServiceGroup.List list = group->entries(); // Iterate over all entries in the group for( KServiceGroup.List.ConstIterator it = list.begin(); it != list.end(); it++) { KSycocaEntry *p = (*it); if (p->isType(KST_KService)) { KService *s = static_cast<KService *>(p); printf("Name = %s\n", s->name().toLatin1()); } else if (p->isType(KST_KServiceGroup)) { KServiceGroup *g = static_cast<KServiceGroup *>(p); // Sub group ... } }
Represents a group of services
Enumerations | |
EntriesOption | { NoOptions, SortEntries, ExcludeNoDisplay, AllowSeparators, SortByGenericName } Typesafe wrapper: EntriesOptions |
Methods | |
__init__ (self, QString name) | |
__init__ (self, QString _fullpath, QString _relpath) | |
__init__ (self, QDataStream _str, int offset, bool deep) | |
addEntry (self, KSycocaEntry.Ptr entry) | |
bool | allowInline (self) |
QString | baseGroupName (self) |
QString | caption (self) |
int | childCount (self) |
QString | comment (self) |
QString | directoryEntryPath (self) |
KSycocaEntry.List | entries (self, bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName=0) |
KSycocaEntry.List | entries (self, bool sorted, bool excludeNoDisplay) |
KSycocaEntry.List | entries (self, bool sorted=0) |
[KServiceGroup::Ptr] | groupEntries (self, KServiceGroup.EntriesOptions options=KServiceGroup.ExcludeNoDisplay) |
QString | icon (self) |
bool | inlineAlias (self) |
int | inlineValue (self) |
QStringList | layoutInfo (self) |
bool | noDisplay (self) |
QString | relPath (self) |
KService.List | serviceEntries (self, KServiceGroup.EntriesOptions options=KServiceGroup.ExcludeNoDisplay) |
setAllowInline (self, bool _b) | |
setInlineAlias (self, bool _b) | |
setInlineValue (self, int _val) | |
setLayoutInfo (self, QStringList layout) | |
setShowEmptyMenu (self, bool b) | |
setShowInlineHeader (self, bool _b) | |
bool | showEmptyMenu (self) |
bool | showInlineHeader (self) |
QStringList | suppressGenericNames (self) |
Static Methods | |
KServiceGroup.Ptr | baseGroup (QString baseGroupName) |
KServiceGroup.Ptr | childGroup (QString parent) |
KServiceGroup.Ptr | group (QString relPath) |
KServiceGroup.Ptr | root () |
Method Documentation
__init__ | ( | self, | ||
QString | name | |||
) |
Construct a dummy servicegroup indexed with name.
- Parameters:
-
name the name of the service group
Construct a service and take all information from a config file
- Parameters:
-
_fullpath full path to the config file _relpath relative path to the config file
__init__ | ( | self, | ||
QDataStream | _str, | |||
int | offset, | |||
bool | deep | |||
) |
- Internal:
- construct a service from a stream. The stream must already be positionned at the correct offset
addEntry | ( | self, | ||
KSycocaEntry.Ptr | entry | |||
) |
- Internal:
- Add a service to this group
bool allowInline | ( | self ) |
- Returns:
- true if we allow to inline menu.
KServiceGroup.Ptr baseGroup | ( | QString | baseGroupName | |
) |
Returns the group for the given baseGroupName. Can return 0 if the directory (or the .directory file) was deleted.
- Returns:
- the base group with the given name, or 0 if not available.
This mechanism was fragile and isn't used in kde4 anymore.
- Deprecated:
- Use a servicetype and a proper trader query instead, for a better way of finding related services.
QString baseGroupName | ( | self ) |
Returns a non-empty string if the group is a special base group. By default, "Settings/" is the kcontrol base group ("settings") and "System/Screensavers/" is the screensavers base group ("screensavers"). This allows moving the groups without breaking those apps.
The base group is defined by the X-KDE-BaseGroup key in the .directory file.
- Returns:
- the base group name, or null if no base group
QString caption | ( | self ) |
Returns the caption of this group.
- Returns:
- the caption of this group
int childCount | ( | self ) |
Returns the total number of displayable services in this group and any of its subgroups.
- Returns:
- the number of child services
KServiceGroup.Ptr childGroup | ( | QString | parent | |
) |
Returns the group of services that have X-KDE-ParentApp equal to parent (siblings).
- Parameters:
-
parent the name of the service's parent
- Returns:
- the services group
QString comment | ( | self ) |
Returns the comment about this service group.
- Returns:
- the descriptive comment for the group, if there is one, or QString() if not set
QString directoryEntryPath | ( | self ) |
Returns a path to the .directory file describing this service group. The path is either absolute or relative to the "apps" resource.
KSycocaEntry.List entries | ( | self, | ||
bool | sorted, | |||
bool | excludeNoDisplay, | |||
bool | allowSeparators, | |||
bool | sortByGenericName=0 | |||
) |
List of all Services and ServiceGroups within this ServiceGroup.
- Parameters:
-
sorted true to sort items excludeNoDisplay true to exclude items marked "NoDisplay" allowSeparators true to allow separator items to be included sortByGenericName true to sort GenericName+Name instead of Name+GenericName
- Returns:
- the list of entries
KSycocaEntry.List entries | ( | self, | ||
bool | sorted, | |||
bool | excludeNoDisplay | |||
) |
KSycocaEntry.List entries | ( | self, | ||
bool | sorted=0 | |||
) |
List of all Services and ServiceGroups within this ServiceGroup.
- Parameters:
-
sorted true to sort items
- Returns:
- the list of entried
KServiceGroup.Ptr group | ( | QString | relPath | |
) |
Returns the group with the given relative path.
- Parameters:
-
relPath the path of the service group
- Returns:
- the group with the given relative path name.
[KServiceGroup::Ptr] groupEntries | ( | self, | ||
KServiceGroup.EntriesOptions | options=KServiceGroup.ExcludeNoDisplay | |||
) |
subgroups for this service group
QString icon | ( | self ) |
Returns the name of the icon associated with the group.
- Returns:
- the name of the icon associated with the group, or QString() if not set
bool inlineAlias | ( | self ) |
- Returns:
- true to show an inline alias item into menu
int inlineValue | ( | self ) |
- Returns:
- inline limite value
QStringList layoutInfo | ( | self ) |
- Internal:
- Returns information related to the layout of services in this group.
bool noDisplay | ( | self ) |
Returns true if the NoDisplay flag was set, i.e. if this group should be hidden from menus, while still being in ksycoca.
- Returns:
- true to hide this service group, false to display it
QString relPath | ( | self ) |
Returns the relative path of the service group.
- Returns:
- the service group's relative path
KServiceGroup.Ptr root | ( | ) |
Returns the root service group.
- Returns:
- the root service group
KService.List serviceEntries | ( | self, | ||
KServiceGroup.EntriesOptions | options=KServiceGroup.ExcludeNoDisplay | |||
) |
entries of this service group
setAllowInline | ( | self, | ||
bool | _b | |||
) |
setInlineAlias | ( | self, | ||
bool | _b | |||
) |
setInlineValue | ( | self, | ||
int | _val | |||
) |
setLayoutInfo | ( | self, | ||
QStringList | layout | |||
) |
- Internal:
- Sets information related to the layout of services in this group.
setShowEmptyMenu | ( | self, | ||
bool | b | |||
) |
setShowInlineHeader | ( | self, | ||
bool | _b | |||
) |
bool showEmptyMenu | ( | self ) |
Return true if we want to display empty menu entry
- Returns:
- true to show this service group as menu entry is empty, false to hide it
bool showInlineHeader | ( | self ) |
- Returns:
- true to show an inline header into menu
QStringList suppressGenericNames | ( | self ) |
Returns a list of untranslated generic names that should be be suppressed when showing this group. E.g. The group "Games/Arcade" might want to suppress the generic name "Arcade Game" since it's redundant in this particular context.
Enumeration Documentation
EntriesOption |
options for groupEntries and serviceEntries
- Note:
- It is necessary to wrap members of this enumeration in a
EntriesOptions
instance when passing them to a method as group of flags. For example:EntriesOptions( NoOptions | SortEntries)
- Enumerator:
-
NoOptions = 0x0 SortEntries = 0x1 ExcludeNoDisplay = 0x2 AllowSeparators = 0x4 SortByGenericName = 0x8