kdecore: format and indent

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-04-19 04:34:16 +03:00
parent d3ca6d35c5
commit 4600904f5b
2 changed files with 349 additions and 350 deletions

View file

@ -21,70 +21,72 @@
#include "kservicefactory.h"
#include "kservicegroupfactory.h"
#include "kservice.h"
#include <ksycoca.h>
#include <kglobal.h>
#include <kstandarddirs.h>
#include <klocale.h>
#include <kdebug.h>
#include <ksortablelist.h>
#include <kdesktopfile.h>
#include <kconfiggroup.h>
#include "ksycoca.h"
#include "kglobal.h"
#include "kstandarddirs.h"
#include "klocale.h"
#include "kdebug.h"
#include "ksortablelist.h"
#include "kdesktopfile.h"
#include "kconfiggroup.h"
KServiceGroup::KServiceGroup( const QString & name )
: KSycocaEntry(*new KServiceGroupPrivate(name))
KServiceGroup::KServiceGroup(const QString &name)
: KSycocaEntry(*new KServiceGroupPrivate(name))
{
}
KServiceGroup::KServiceGroup( const QString &configFile, const QString & _relpath )
: KSycocaEntry(*new KServiceGroupPrivate(_relpath))
KServiceGroup::KServiceGroup(const QString &fullpath, const QString &relpath)
: KSycocaEntry(*new KServiceGroupPrivate(relpath))
{
Q_D(KServiceGroup);
QString cfg = configFile;
QString cfg = fullpath;
if (cfg.isEmpty())
cfg = _relpath + QLatin1String(".directory");
cfg = relpath + QLatin1String(".directory");
d->load(cfg);
}
void KServiceGroupPrivate::load(const QString &cfg)
{
directoryEntryPath = cfg;
directoryEntryPath = cfg;
const KDesktopFile desktopFile( cfg );
const KDesktopFile desktopFile( cfg );
const KConfigGroup config = desktopFile.desktopGroup();
const KConfigGroup config = desktopFile.desktopGroup();
m_strCaption = config.readEntry( "Name" );
m_strIcon = config.readEntry( "Icon" );
m_strComment = config.readEntry( "Comment" );
deleted = config.readEntry("Hidden", false );
m_bNoDisplay = desktopFile.noDisplay();
m_strBaseGroupName = config.readEntry( "X-KDE-BaseGroup" );
suppressGenericNames = config.readEntry( "X-KDE-SuppressGenericNames", QStringList() );
// d->sortOrder = config.readEntry("SortOrder", QStringList());
m_strCaption = config.readEntry("Name");
m_strIcon = config.readEntry("Icon");
m_strComment = config.readEntry("Comment");
deleted = config.readEntry("Hidden", false);
m_bNoDisplay = desktopFile.noDisplay();
m_strBaseGroupName = config.readEntry("X-KDE-BaseGroup");
suppressGenericNames = config.readEntry("X-KDE-SuppressGenericNames", QStringList());
// d->sortOrder = config.readEntry("SortOrder", QStringList());
// Fill in defaults.
if (m_strCaption.isEmpty())
{
m_strCaption = path;
if (m_strCaption.endsWith(QLatin1Char('/')))
m_strCaption = m_strCaption.left(m_strCaption.length()-1);
int i = m_strCaption.lastIndexOf(QLatin1Char('/'));
if (i > 0)
m_strCaption = m_strCaption.mid(i+1);
}
if (m_strIcon.isEmpty())
m_strIcon = QString::fromLatin1("folder");
// Fill in defaults.
if (m_strCaption.isEmpty()) {
m_strCaption = path;
if (m_strCaption.endsWith(QLatin1Char('/'))) {
m_strCaption = m_strCaption.left(m_strCaption.length() - 1);
}
int i = m_strCaption.lastIndexOf(QLatin1Char('/'));
if (i > 0) {
m_strCaption = m_strCaption.mid(i + 1);
}
}
if (m_strIcon.isEmpty()) {
m_strIcon = QString::fromLatin1("folder");
}
}
KServiceGroup::KServiceGroup( QDataStream& _str, int offset, bool deep ) :
KSycocaEntry(*new KServiceGroupPrivate(_str, offset))
KServiceGroup::KServiceGroup(QDataStream &str, int offset, bool deep)
: KSycocaEntry(*new KServiceGroupPrivate(str, offset))
{
Q_D(KServiceGroup);
d->m_bDeep = deep;
d->load( _str );
Q_D(KServiceGroup);
d->m_bDeep = deep;
d->load(str);
}
KServiceGroup::~KServiceGroup()
@ -122,28 +124,23 @@ int KServiceGroup::childCount() const
int KServiceGroupPrivate::childCount() const
{
if (m_childCount == -1)
{
m_childCount = 0;
if (m_childCount == -1) {
m_childCount = 0;
for( KServiceGroup::List::ConstIterator it = m_serviceList.begin();
it != m_serviceList.end(); ++it)
{
KSycocaEntry::Ptr p = *it;
if (p->isType(KST_KService))
{
KService::Ptr service = KService::Ptr::staticCast( p );
if (!service->noDisplay())
m_childCount++;
for( KServiceGroup::List::ConstIterator it = m_serviceList.begin(); it != m_serviceList.end(); ++it) {
KSycocaEntry::Ptr p = *it;
if (p->isType(KST_KService)) {
KService::Ptr service = KService::Ptr::staticCast( p );
if (!service->noDisplay()) {
m_childCount++;
}
} else if (p->isType(KST_KServiceGroup)) {
KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast( p );
m_childCount += serviceGroup->childCount();
}
}
else if (p->isType(KST_KServiceGroup))
{
KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast( p );
m_childCount += serviceGroup->childCount();
}
}
}
return m_childCount;
}
return m_childCount;
}
@ -165,22 +162,22 @@ bool KServiceGroup::inlineAlias() const
return d->m_bInlineAlias;
}
void KServiceGroup::setInlineAlias(bool _b)
void KServiceGroup::setInlineAlias(bool b)
{
Q_D(KServiceGroup);
d->m_bInlineAlias = _b;
d->m_bInlineAlias = b;
}
void KServiceGroup::setShowEmptyMenu(bool _b)
void KServiceGroup::setShowEmptyMenu(bool b)
{
Q_D(KServiceGroup);
d->m_bShowEmptyMenu=_b;
d->m_bShowEmptyMenu = b;
}
void KServiceGroup::setShowInlineHeader(bool _b)
void KServiceGroup::setShowInlineHeader(bool b)
{
Q_D(KServiceGroup);
d->m_bShowInlineHeader=_b;
d->m_bShowInlineHeader = b;
}
int KServiceGroup::inlineValue() const
@ -189,10 +186,10 @@ int KServiceGroup::inlineValue() const
return d->m_inlineValue;
}
void KServiceGroup::setInlineValue(int _val)
void KServiceGroup::setInlineValue(int val)
{
Q_D(KServiceGroup);
d->m_inlineValue = _val;
d->m_inlineValue = val;
}
bool KServiceGroup::allowInline() const
@ -201,22 +198,22 @@ bool KServiceGroup::allowInline() const
return d->m_bAllowInline;
}
void KServiceGroup::setAllowInline(bool _b)
void KServiceGroup::setAllowInline(bool b)
{
Q_D(KServiceGroup);
d->m_bAllowInline = _b;
d->m_bAllowInline = b;
}
bool KServiceGroup::noDisplay() const
{
Q_D(const KServiceGroup);
return d->m_bNoDisplay || d->m_strCaption.startsWith(QLatin1Char('.'));
return d->m_bNoDisplay || d->m_strCaption.startsWith(QLatin1Char('.'));
}
QStringList KServiceGroup::suppressGenericNames() const
{
Q_D(const KServiceGroup);
return d->suppressGenericNames;
return d->suppressGenericNames;
}
void KServiceGroupPrivate::load( QDataStream& s )
@ -238,68 +235,59 @@ void KServiceGroupPrivate::load( QDataStream& s )
m_bInlineAlias = ( _inlineAlias != 0 );
m_bAllowInline = ( _allowInline != 0 );
if (m_bDeep)
{
Q_FOREACH(const QString &path, groupList)
{
if ( path.endsWith( QLatin1Char( '/' ) ) )
{
KServiceGroup::Ptr serviceGroup;
serviceGroup = KServiceGroupFactory::self()->findGroupByDesktopPath(path, false);
if (serviceGroup)
m_serviceList.append( KServiceGroup::SPtr::staticCast(serviceGroup) );
if (m_bDeep) {
Q_FOREACH(const QString &path, groupList) {
if (path.endsWith( QLatin1Char('/'))) {
KServiceGroup::Ptr serviceGroup;
serviceGroup = KServiceGroupFactory::self()->findGroupByDesktopPath(path, false);
if (serviceGroup) {
m_serviceList.append(KServiceGroup::SPtr::staticCast(serviceGroup));
}
} else {
KService::Ptr service;
service = KServiceFactory::self()->findServiceByDesktopPath(path);
if (service) {
m_serviceList.append(KServiceGroup::SPtr::staticCast(service));
}
}
}
else
{
KService::Ptr service;
service = KServiceFactory::self()->findServiceByDesktopPath(path);
if (service)
m_serviceList.append( KServiceGroup::SPtr::staticCast(service) );
}
}
}
}
}
void KServiceGroup::addEntry( const KSycocaEntry::Ptr& entry)
void KServiceGroup::addEntry(const KSycocaEntry::Ptr &entry)
{
Q_D(KServiceGroup);
d->m_serviceList.append(entry);
d->m_serviceList.append(entry);
}
void KServiceGroupPrivate::save( QDataStream& s )
void KServiceGroupPrivate::save(QDataStream &s)
{
KSycocaEntryPrivate::save( s );
KSycocaEntryPrivate::save(s);
QStringList groupList;
Q_FOREACH(KSycocaEntry::Ptr p, m_serviceList)
{
if (p->isType(KST_KService))
{
KService::Ptr service = KService::Ptr::staticCast( p );
groupList.append( service->entryPath() );
}
else if (p->isType(KST_KServiceGroup))
{
KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast( p );
groupList.append( serviceGroup->relPath() );
}
else
{
//fprintf(stderr, "KServiceGroup: Unexpected object in list!\n");
}
}
QStringList groupList;
Q_FOREACH(KSycocaEntry::Ptr p, m_serviceList) {
if (p->isType(KST_KService)) {
KService::Ptr service = KService::Ptr::staticCast( p );
groupList.append( service->entryPath() );
} else if (p->isType(KST_KServiceGroup)) {
KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast(p);
groupList.append(serviceGroup->relPath());
} else {
// fprintf(stderr, "KServiceGroup: Unexpected object in list!\n");
}
}
(void) childCount();
(void) childCount();
qint8 noDisplay = m_bNoDisplay ? 1 : 0;
qint8 _showEmptyMenu = m_bShowEmptyMenu ? 1 : 0;
qint8 inlineHeader = m_bShowInlineHeader ? 1 : 0;
qint8 _inlineAlias = m_bInlineAlias ? 1 : 0;
qint8 _allowInline = m_bAllowInline ? 1 : 0;
s << m_strCaption << m_strIcon <<
m_strComment << groupList << m_strBaseGroupName << m_childCount <<
noDisplay << suppressGenericNames << directoryEntryPath <<
sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
qint8 noDisplay = m_bNoDisplay ? 1 : 0;
qint8 _showEmptyMenu = m_bShowEmptyMenu ? 1 : 0;
qint8 inlineHeader = m_bShowInlineHeader ? 1 : 0;
qint8 _inlineAlias = m_bInlineAlias ? 1 : 0;
qint8 _allowInline = m_bAllowInline ? 1 : 0;
s << m_strCaption << m_strIcon <<
m_strComment << groupList << m_strBaseGroupName << m_childCount <<
noDisplay << suppressGenericNames << directoryEntryPath <<
sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
}
QList<KServiceGroup::Ptr> KServiceGroup::groupEntries(EntriesOptions options)
@ -309,12 +297,13 @@ QList<KServiceGroup::Ptr> KServiceGroup::groupEntries(EntriesOptions options)
QList<KServiceGroup::Ptr> list;
List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);
foreach(const SPtr &ptr, tmp) {
if (ptr->isType(KST_KServiceGroup))
if (ptr->isType(KST_KServiceGroup)) {
list.append(Ptr::staticCast(ptr));
else if (ptr->isType(KST_KServiceSeparator))
} else if (ptr->isType(KST_KServiceSeparator)) {
list.append(KServiceGroup::Ptr(static_cast<KServiceGroup *>(new KSycocaEntry())));
else if (sort && ptr->isType(KST_KService))
} else if (sort && ptr->isType(KST_KService)) {
break;
}
}
return list;
}
@ -330,30 +319,27 @@ KService::List KServiceGroup::serviceEntries(EntriesOptions options)
if (ptr->isType(KST_KService)) {
list.append(KService::Ptr::staticCast(ptr));
foundService = true;
}
else if (ptr->isType(KST_KServiceSeparator) && foundService) {
} else if (ptr->isType(KST_KServiceSeparator) && foundService) {
list.append(KService::Ptr(static_cast<KService *>(new KSycocaEntry())));
}
}
return list;
}
KServiceGroup::List
KServiceGroup::entries(bool sort)
KServiceGroup::List KServiceGroup::entries(bool sort)
{
Q_D(KServiceGroup);
return d->entries(this, sort, true, false, false);
}
KServiceGroup::List
KServiceGroup::entries(bool sort, bool excludeNoDisplay)
KServiceGroup::List KServiceGroup::entries(bool sort, bool excludeNoDisplay)
{
Q_D(KServiceGroup);
return d->entries(this, sort, excludeNoDisplay, false, false);
}
KServiceGroup::List
KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
KServiceGroup::List KServiceGroup::entries(bool sort, bool excludeNoDisplay,
bool allowSeparators, bool sortByGenericName)
{
Q_D(KServiceGroup);
return d->entries(this, sort, excludeNoDisplay, allowSeparators, sortByGenericName);
@ -361,14 +347,16 @@ KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, b
static void addItem(KServiceGroup::List &sorted, const KSycocaEntry::Ptr &p, bool &addSeparator)
{
if (addSeparator && !sorted.isEmpty())
sorted.append(KSycocaEntry::Ptr(new KServiceSeparator()));
sorted.append(p);
addSeparator = false;
if (addSeparator && !sorted.isEmpty()) {
sorted.append(KSycocaEntry::Ptr(new KServiceSeparator()));
}
sorted.append(p);
addSeparator = false;
}
KServiceGroup::List
KServiceGroupPrivate::entries(KServiceGroup *group, bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
KServiceGroup::List KServiceGroupPrivate::entries(KServiceGroup *group,
bool sort, bool excludeNoDisplay,
bool allowSeparators, bool sortByGenericName)
{
KServiceGroup::Ptr grp;
@ -377,38 +365,41 @@ KServiceGroupPrivate::entries(KServiceGroup *group, bool sort, bool excludeNoDis
// since the offsets could have been changed if the database has changed.
if (!m_bDeep) {
grp = KServiceGroupFactory::self()->findGroupByDesktopPath(path, true);
group = grp.data();
if (0 == group) // No guarantee that we still exist!
if (!group) {
// No guarantee that we still exist!
return KServiceGroup::List();
}
}
if (!sort)
if (!sort) {
return group->d_func()->m_serviceList;
}
// Sort the list alphabetically, according to locale.
// Groups come first, then services.
KSortableList<KServiceGroup::SPtr,QByteArray> slist;
KSortableList<KServiceGroup::SPtr,QByteArray> glist;
Q_FOREACH (KSycocaEntry::Ptr p, group->d_func()->m_serviceList)
{
Q_FOREACH (KSycocaEntry::Ptr p, group->d_func()->m_serviceList) {
bool noDisplay = p->isType(KST_KServiceGroup) ?
static_cast<KServiceGroup *>(p.data())->noDisplay() :
static_cast<KService *>(p.data())->noDisplay();
if (excludeNoDisplay && noDisplay)
continue;
if (excludeNoDisplay && noDisplay) {
continue;
}
// Choose the right list
KSortableList<KServiceGroup::SPtr,QByteArray> & list = p->isType(KST_KServiceGroup) ? glist : slist;
QString name;
if (p->isType(KST_KServiceGroup))
name = static_cast<KServiceGroup *>(p.data())->caption();
else if (sortByGenericName)
name = static_cast<KService *>(p.data())->genericName() + QLatin1Char(' ') + p->name();
else
name = p->name() + QLatin1Char(' ') + static_cast<KService *>(p.data())->genericName();
if (p->isType(KST_KServiceGroup)) {
name = static_cast<KServiceGroup *>(p.data())->caption();
} else if (sortByGenericName) {
name = static_cast<KService *>(p.data())->genericName() + QLatin1Char(' ') + p->name();
} else {
name = p->name() + QLatin1Char(' ') + static_cast<KService *>(p.data())->genericName();
}
const QByteArray nameStr = name.toLocal8Bit();
@ -655,37 +646,49 @@ KServiceGroupPrivate::entries(KServiceGroup *group, bool sort, bool excludeNoDis
return sorted;
}
void KServiceGroupPrivate::parseAttribute( const QString &item , bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias , int &inlineValue )
void KServiceGroupPrivate::parseAttribute(const QString &item , bool &showEmptyMenu,
bool &showInline, bool &showInlineHeader,
bool &showInlineAlias , int &inlineValue)
{
if( item == QLatin1String("ME")) //menu empty
if (item == QLatin1String("ME")) {
// menu empty
showEmptyMenu=true;
else if ( item == QLatin1String("NME")) //not menu empty
} else if (item == QLatin1String("NME")) {
// not menu empty
showEmptyMenu=false;
else if( item == QLatin1String("I")) //inline menu !
} else if (item == QLatin1String("I")) {
//inline menu !
showInline = true;
else if ( item == QLatin1String("NI")) //not inline menu!
} else if (item == QLatin1String("NI")) {
// not inline menu!
showInline = false;
else if( item == QLatin1String("IH")) //inline header!
} else if(item == QLatin1String("IH")) {
// inline header!
showInlineHeader= true;
else if ( item == QLatin1String("NIH")) //not inline header!
} else if (item == QLatin1String("NIH")) {
// not inline header!
showInlineHeader = false;
else if( item == QLatin1String("IA")) //inline alias!
} else if(item == QLatin1String("IA")) {
// inline alias!
showInlineAlias = true;
else if ( item == QLatin1String("NIA")) //not inline alias!
} else if (item == QLatin1String("NIA")) {
// not inline alias!
showInlineAlias = false;
else if( ( item ).contains( QLatin1String("IL") )) //inline limite!
{
QString tmp( item );
tmp = tmp.remove( QLatin1String("IL[") );
tmp = tmp.remove( QLatin1Char(']') );
bool ok;
} else if (item.contains(QLatin1String("IL"))) {
//inline limit!
QString tmp(item);
tmp = tmp.remove(QLatin1String("IL["));
tmp = tmp.remove(QLatin1Char(']'));
bool ok = false;
int _inlineValue = tmp.toInt(&ok);
if ( !ok ) //error
if (!ok) {
//error
_inlineValue = -1;
inlineValue = _inlineValue;
}
inlineValue = _inlineValue;
} else {
kDebug()<< "This attribute is not supported:" << item;
}
else
kDebug()<<" This attribute is not supported :"<<item;
}
void KServiceGroup::setLayoutInfo(const QStringList &layout)
@ -700,22 +703,20 @@ QStringList KServiceGroup::layoutInfo() const
return d->sortOrder;
}
KServiceGroup::Ptr
KServiceGroup::root()
KServiceGroup::Ptr KServiceGroup::root()
{
return KServiceGroupFactory::self()->findGroupByDesktopPath(QString::fromLatin1("/"), true);
return KServiceGroupFactory::self()->findGroupByDesktopPath(QString::fromLatin1("/"), true);
}
KServiceGroup::Ptr
KServiceGroup::group(const QString &relPath)
KServiceGroup::Ptr KServiceGroup::group(const QString &relPath)
{
if (relPath.isEmpty()) return root();
return KServiceGroupFactory::self()->findGroupByDesktopPath(relPath, true);
if (relPath.isEmpty()) {
return root();
}
return KServiceGroupFactory::self()->findGroupByDesktopPath(relPath, true);
}
KServiceGroup::Ptr
KServiceGroup::childGroup(const QString &parent)
KServiceGroup::Ptr KServiceGroup::childGroup(const QString &parent)
{
return KServiceGroupFactory::self()->findGroupByDesktopPath(QString::fromLatin1("#parent#")+parent, true);
}
@ -725,8 +726,7 @@ QString KServiceGroup::baseGroupName() const
return d_func()->m_strBaseGroupName;
}
QString
KServiceGroup::directoryEntryPath() const
QString KServiceGroup::directoryEntryPath() const
{
Q_D(const KServiceGroup);
return d->directoryEntryPath;

View file

@ -61,152 +61,151 @@ class KDECORE_EXPORT KServiceGroup : public KSycocaEntry
{
friend class KBuildServiceGroupFactory;
public:
typedef KSharedPtr<KServiceGroup> Ptr;
typedef KSharedPtr<KSycocaEntry> SPtr;
typedef QList<SPtr> List;
typedef KSharedPtr<KServiceGroup> Ptr;
typedef KSharedPtr<KSycocaEntry> SPtr;
typedef QList<SPtr> List;
public:
/**
* Construct a dummy servicegroup indexed with @p name.
* @param name the name of the service group
*/
KServiceGroup( const QString & name );
/**
* Construct a dummy servicegroup indexed with @p name.
* @param name the name of the service group
*/
KServiceGroup(const QString &name);
/**
* 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
*/
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
*/
KServiceGroup(const QString &fullpath, const QString &relpath);
/**
* @internal construct a service from a stream.
* The stream must already be positionned at the correct offset
*/
KServiceGroup( QDataStream& _str, int offset, bool deep );
/**
* @internal construct a service from a stream.
* The stream must already be positionned at the correct offset
*/
KServiceGroup(QDataStream &str, int offset, bool deep);
virtual ~KServiceGroup();
virtual ~KServiceGroup();
/**
* Returns the relative path of the service group.
* @return the service group's relative path
*/
QString relPath() const;
/**
* Returns the relative path of the service group.
* @return the service group's relative path
*/
QString relPath() const;
/**
* Returns the caption of this group.
* @return the caption of this group
*/
QString caption() const;
/**
* Returns the caption of this group.
* @return the caption of this group
*/
QString caption() 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
*/
QString 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
*/
QString icon() 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 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 comment() const;
/**
* Returns the total number of displayable services in this group and
* any of its subgroups.
* @return the number of child services
*/
int childCount() const;
/**
* Returns the total number of displayable services in this group and
* any of its subgroups.
* @return the number of child services
*/
int childCount() 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
*/
bool 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
*/
bool noDisplay() 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 showEmptyMenu() const;
void setShowEmptyMenu( bool b);
/**
* 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 showEmptyMenu() const;
void setShowEmptyMenu( bool b);
/**
* @return true to show an inline header into menu
*/
bool showInlineHeader() const;
void setShowInlineHeader(bool _b);
/**
* @return true to show an inline header into menu
*/
bool showInlineHeader() const;
void setShowInlineHeader(bool b);
/**
* @return true to show an inline alias item into menu
*/
bool inlineAlias() const;
void setInlineAlias(bool _b);
/**
* @return true if we allow to inline menu.
*/
bool allowInline() const;
void setAllowInline(bool _b);
/**
* @return true to show an inline alias item into menu
*/
bool inlineAlias() const;
void setInlineAlias(bool b);
/**
* @return true if we allow to inline menu.
*/
bool allowInline() const;
void setAllowInline(bool b);
/**
* @return inline limite value
*/
int inlineValue() const;
void setInlineValue(int _val);
/**
* @return inline limite value
*/
int inlineValue() const;
void setInlineValue(int val);
/**
* 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.
*/
QStringList 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.
*/
QStringList suppressGenericNames() const;
/**
* @internal
* Sets information related to the layout of services in this group.
*/
void setLayoutInfo(const QStringList &layout);
/**
* @internal
* Sets information related to the layout of services in this group.
*/
void setLayoutInfo(const QStringList &layout);
/**
* @internal
* Returns information related to the layout of services in this group.
*/
QStringList layoutInfo() const;
/**
* @internal
* Returns information related to the layout of services in this group.
*/
QStringList layoutInfo() const;
/**
* 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
*/
List entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName=false);
List entries(bool sorted, bool excludeNoDisplay);
/**
* 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
*/
List entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName = false);
List entries(bool sorted, bool excludeNoDisplay);
/**
* List of all Services and ServiceGroups within this
* ServiceGroup.
* @param sorted true to sort items
* @return the list of entried
*/
List entries(bool sorted = false);
/**
* List of all Services and ServiceGroups within this
* ServiceGroup.
* @param sorted true to sort items
* @return the list of entried
*/
List entries(bool sorted = false);
/**
* options for groupEntries and serviceEntries
*/
enum EntriesOption
{
NoOptions = 0x0,
SortEntries = 0x1, /*< sort items */
ExcludeNoDisplay = 0x2, /*< exclude items marked "NoDisplay" */
AllowSeparators = 0x4, /*< allow separator items to be included */
SortByGenericName = 0x8 /*< sort by GenericName+Name instead of Name+GenericName */
/**
* options for groupEntries and serviceEntries
*/
enum EntriesOption {
NoOptions = 0x0,
SortEntries = 0x1, /*< sort items */
ExcludeNoDisplay = 0x2, /*< exclude items marked "NoDisplay" */
AllowSeparators = 0x4, /*< allow separator items to be included */
SortByGenericName = 0x8 /*< sort by GenericName+Name instead of Name+GenericName */
};
Q_DECLARE_FLAGS(EntriesOptions, EntriesOption)
@ -220,51 +219,51 @@ public:
*/
KService::List serviceEntries(EntriesOptions options = ExcludeNoDisplay);
/**
* 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 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 baseGroupName() const;
/**
* Returns a path to the .directory file describing this service group.
* The path is either absolute or relative to the "apps" resource.
*/
QString directoryEntryPath() const;
/**
* Returns a path to the .directory file describing this service group.
* The path is either absolute or relative to the "apps" resource.
*/
QString directoryEntryPath() const;
/**
* Returns the root service group.
* @return the root service group
*/
static Ptr root();
/**
* Returns the root service group.
* @return the root service group
*/
static Ptr root();
/**
* 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.
*/
static Ptr 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.
*/
static Ptr group(const QString &relPath);
/**
* 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
*/
static Ptr 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
*/
static Ptr childGroup(const QString &parent);
protected:
/**
* @internal
* Add a service to this group
*/
void addEntry( const KSycocaEntry::Ptr& entry);
/**
* @internal
* Add a service to this group
*/
void addEntry(const KSycocaEntry::Ptr &entry);
private:
Q_DECLARE_PRIVATE(KServiceGroup)
};