KServiceGroup Class

Header: #include <KServiceGroup>
CMake: find_package(KF6 REQUIRED COMPONENTS Service)
target_link_libraries(mytarget PRIVATE KF6::Service)

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, 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)
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

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 ...
   }
}

@short Represents a group of services

Member Type Documentation

enum KServiceGroup::EntriesOption
flags KServiceGroup::EntriesOptions

options for groupEntries and serviceEntries @see EntriesOptions

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 @p name. @param 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 @param _fullpath full path to the config file @param _relpath relative path to the config file

bool KServiceGroup::allowInline() const

@return true if we allow to inline menu.

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. @return the base group name, or null if no base group

QString KServiceGroup::caption() const

Returns the caption of this group. @return the caption of this group

int KServiceGroup::childCount() const

Returns the total number of displayable services in this group and any of its subgroups. @return the number of child services

[static] KServiceGroup::Ptr KServiceGroup::childGroup(const QString &parent)

Returns the group of services that have X-KDE-ParentApp equal to @p parent (siblings). @param parent the name of the service's parent @return the services group

QString KServiceGroup::comment() const

Returns the comment about this service group. @return the descriptive comment for the group, if there is one, or QString() if not set

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. @param sorted true to sort items @return the list of entried

KServiceGroup::List KServiceGroup::entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName = false)

List of all Services and ServiceGroups within this ServiceGroup. @param sorted true to sort items @param excludeNoDisplay true to exclude items marked "NoDisplay" @param allowSeparators true to allow separator items to be included @param sortByGenericName true to sort GenericName+Name instead of Name+GenericName @return the list of entries

[static] KServiceGroup::Ptr KServiceGroup::group(const QString &relPath)

Returns the group with the given relative path. @param relPath the path of the service group @return the group with the given relative path name.

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. @return the name of the icon associated with the group, or QString() if not set

bool KServiceGroup::inlineAlias() const

@return true to show an inline alias item into menu

int KServiceGroup::inlineValue() const

@return inline limit value

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. @return true to hide this service group, false to display it

QString KServiceGroup::relPath() const

Returns the relative path of the service group. @return the service group's relative path

[static] KServiceGroup::Ptr KServiceGroup::root()

Returns the root service group. @return the root service group

KService::List KServiceGroup::serviceEntries(KServiceGroup::EntriesOptions options = ExcludeNoDisplay)

entries of this service group

bool KServiceGroup::showEmptyMenu() const

Return true if we want to display empty menu entry @return true to show this service group as menu entry is empty, false to hide it

bool KServiceGroup::showInlineHeader() const

@return true to show an inline header into menu

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.