KServiceGroup Class
KServiceGroup represents a group of service, for example screensavers. More...
Header: | #include <KServiceGroup> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Service) target_link_libraries(mytarget PRIVATE KF6::Service) |
Inherits: | KSycocaEntry |
Public Types
enum | EntriesOption { NoOptions, SortEntries, ExcludeNoDisplay, AllowSeparators, SortByGenericName } |
flags | EntriesOptions |
List | |
Ptr | |
SPtr |
Public Functions
KServiceGroup(const QString &name) | |
KServiceGroup(const QString &_fullpath, const QString &_relpath) | |
bool | allowInline() const |
QString | baseGroupName() const |
QString | caption() const |
int | childCount() const |
QString | comment() const |
QString | directoryEntryPath() const |
KServiceGroup::List | entries(bool sorted = false) |
KServiceGroup::List | entries(bool sorted, bool excludeNoDisplay) |
KServiceGroup::List | entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName = false) |
QList<KServiceGroup::Ptr> | groupEntries(KServiceGroup::EntriesOptions options = ExcludeNoDisplay) |
QString | icon() const |
bool | inlineAlias() const |
int | inlineValue() const |
bool | noDisplay() const |
QString | relPath() const |
KService::List | serviceEntries(KServiceGroup::EntriesOptions options = ExcludeNoDisplay) |
void | setAllowInline(bool _b) |
void | setInlineAlias(bool _b) |
void | setInlineValue(int _val) |
void | setShowEmptyMenu(bool b) |
void | setShowInlineHeader(bool _b) |
bool | showEmptyMenu() const |
bool | showInlineHeader() const |
QStringList | suppressGenericNames() const |
Static Public Members
KServiceGroup::Ptr | childGroup(const QString &parent) |
KServiceGroup::Ptr | group(const QString &relPath) |
KServiceGroup::Ptr | root() |
Detailed Description
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 ... } }
Member Type Documentation
enum KServiceGroup::EntriesOption
flags KServiceGroup::EntriesOptions
Options for groupEntries and serviceEntries
Constant | Value | Description |
---|---|---|
KServiceGroup::NoOptions | 0x0 | no options set |
KServiceGroup::SortEntries | 0x1 | sort items |
KServiceGroup::ExcludeNoDisplay | 0x2 | exclude items marked "NoDisplay" |
KServiceGroup::AllowSeparators | 0x4 | allow separator items to be included |
KServiceGroup::SortByGenericName | 0x8 | sort by GenericName+Name instead of Name+GenericName |
The EntriesOptions type is a typedef for QFlags<EntriesOption>. It stores an OR combination of EntriesOption values.
KServiceGroup::List
A list of shared data pointers for KSycocaEntry.
KServiceGroup::Ptr
A shared data pointer for KServiceGroup.
KServiceGroup::SPtr
A shared data pointer for KSycocaEntry.
Member Function Documentation
KServiceGroup::KServiceGroup(const QString &name)
Construct a dummy servicegroup indexed with name.
name the name of the service group
KServiceGroup::KServiceGroup(const QString &_fullpath, const QString &_relpath)
Construct a service and take all information from a config file
_fullpath full path to the config file
_relpath relative path to the config file
bool KServiceGroup::allowInline() const
Return true
if we allow to inline menu.
See also setAllowInline().
QString KServiceGroup::baseGroupName() const
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.
QString KServiceGroup::caption() const
Returns the caption of this group.
int KServiceGroup::childCount() const
Returns the total number of displayable services in this group and any of its subgroups.
[static]
KServiceGroup::Ptr KServiceGroup::childGroup(const QString &parent)
Returns the group of services that have X-KDE-ParentApp equal to parent (siblings).
parent the name of the service's parent
QString KServiceGroup::comment() const
Returns the comment about this service group.
QString KServiceGroup::directoryEntryPath() const
Returns a path to the .directory file describing this service group. The path is either absolute or relative to the "apps" resource.
KServiceGroup::List KServiceGroup::entries(bool sorted = false)
List of all Services and ServiceGroups within this ServiceGroup.
sorted true to sort items
Returns the list of entried
KServiceGroup::List KServiceGroup::entries(bool sorted, bool excludeNoDisplay)
KServiceGroup::List KServiceGroup::entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName = false)
List of all Services and ServiceGroups within this ServiceGroup.
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
[static]
KServiceGroup::Ptr KServiceGroup::group(const QString &relPath)
Returns the group with the given relative path.
relPath the path of the service group
QList<KServiceGroup::Ptr> KServiceGroup::groupEntries(KServiceGroup::EntriesOptions options = ExcludeNoDisplay)
subgroups for this service group
QString KServiceGroup::icon() const
Returns the name of the icon associated with the group.
bool KServiceGroup::inlineAlias() const
Returns true
to show an inline alias item into menu
See also setInlineAlias().
int KServiceGroup::inlineValue() const
Returns inline limit value
See also setInlineValue().
bool KServiceGroup::noDisplay() const
Returns true
if the NoDisplay flag was set, i.e. if this group should be hidden from menus, while still being in ksycoca.
QString KServiceGroup::relPath() const
Returns the relative path of the service group.
[static]
KServiceGroup::Ptr KServiceGroup::root()
Returns the root service group.
KService::List KServiceGroup::serviceEntries(KServiceGroup::EntriesOptions options = ExcludeNoDisplay)
entries of this service group
void KServiceGroup::setAllowInline(bool _b)
See also allowInline().
void KServiceGroup::setInlineAlias(bool _b)
See also inlineAlias().
void KServiceGroup::setInlineValue(int _val)
See also inlineValue().
void KServiceGroup::setShowEmptyMenu(bool b)
See also showEmptyMenu().
void KServiceGroup::setShowInlineHeader(bool _b)
See also showInlineHeader().
bool KServiceGroup::showEmptyMenu() const
Return true if we want to display empty menu entry
See also setShowEmptyMenu().
bool KServiceGroup::showInlineHeader() const
Returns true
to show an inline header into menu
See also setShowInlineHeader().
QStringList KServiceGroup::suppressGenericNames() const
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.