KService

kservicegroup.cpp
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2000 Waldo Bastian <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-only
6 */
7 
8 #include "kservicegroup.h"
9 #include "kservicegroup_p.h"
10 #include "kservicefactory_p.h"
11 #include "kservicegroupfactory_p.h"
12 #include "kservice.h"
13 #include "ksycoca_p.h"
14 #include "servicesdebug.h"
15 #include <ksycoca.h>
16 #include <KDesktopFile>
17 #include <KConfigGroup>
18 
20  : KSycocaEntry(*new KServiceGroupPrivate(name))
21 {
22 }
23 
24 KServiceGroup::KServiceGroup(const QString &configFile, const QString &_relpath)
25  : KSycocaEntry(*new KServiceGroupPrivate(_relpath))
26 {
27  Q_D(KServiceGroup);
28 
29  QString cfg = configFile;
30  if (cfg.isEmpty()) {
31  cfg = _relpath + QLatin1String(".directory");
32  }
33 
34  d->load(cfg);
35 }
36 
37 void KServiceGroupPrivate::load(const QString &cfg)
38 {
39  directoryEntryPath = cfg;
40 
41  const KDesktopFile desktopFile(cfg);
42 
43  const KConfigGroup config = desktopFile.desktopGroup();
44 
45  m_strCaption = config.readEntry("Name");
46  m_strIcon = config.readEntry("Icon");
47  m_strComment = config.readEntry("Comment");
48  deleted = config.readEntry("Hidden", false);
49  m_bNoDisplay = desktopFile.noDisplay();
50  m_strBaseGroupName = config.readEntry("X-KDE-BaseGroup");
51  suppressGenericNames = config.readEntry("X-KDE-SuppressGenericNames", QStringList());
52 
53  // Fill in defaults.
54  if (m_strCaption.isEmpty()) {
55  m_strCaption = path;
56  if (m_strCaption.endsWith(QLatin1Char('/'))) {
57  m_strCaption.chop(1);
58  }
59  int i = m_strCaption.lastIndexOf(QLatin1Char('/'));
60  if (i > 0) {
61  m_strCaption.remove(0, i + 1);
62  }
63  }
64  if (m_strIcon.isEmpty()) {
65  m_strIcon = QStringLiteral("folder");
66  }
67 }
68 
69 KServiceGroup::KServiceGroup(QDataStream &_str, int offset, bool deep) :
70  KSycocaEntry(*new KServiceGroupPrivate(_str, offset))
71 {
72  Q_D(KServiceGroup);
73  d->m_bDeep = deep;
74  d->load(_str);
75 }
76 
77 KServiceGroup::~KServiceGroup()
78 {
79 }
80 
82 {
83  return entryPath();
84 }
85 
87 {
88  Q_D(const KServiceGroup);
89  return d->m_strCaption;
90 }
91 
93 {
94  Q_D(const KServiceGroup);
95  return d->m_strIcon;
96 }
97 
99 {
100  Q_D(const KServiceGroup);
101  return d->m_strComment;
102 }
103 
105 {
106  Q_D(const KServiceGroup);
107  return d->childCount();
108 }
109 
110 int KServiceGroupPrivate::childCount() const
111 {
112  if (m_childCount == -1) {
113  m_childCount = 0;
114 
115  for (KServiceGroup::List::ConstIterator it = m_serviceList.begin();
116  it != m_serviceList.end(); ++it) {
117  KSycocaEntry::Ptr p = *it;
118  if (p->isType(KST_KService)) {
119  KService::Ptr service(static_cast<KService*>(p.data()));
120  if (!service->noDisplay()) {
121  m_childCount++;
122  }
123  } else if (p->isType(KST_KServiceGroup)) {
124  KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup*>(p.data()));
125  m_childCount += serviceGroup->childCount();
126  }
127  }
128  }
129  return m_childCount;
130 }
131 
133 {
134  Q_D(const KServiceGroup);
135  return d->m_bShowInlineHeader;
136 }
137 
139 {
140  Q_D(const KServiceGroup);
141  return d->m_bShowEmptyMenu;
142 }
143 
145 {
146  Q_D(const KServiceGroup);
147  return d->m_bInlineAlias;
148 }
149 
150 void KServiceGroup::setInlineAlias(bool _b)
151 {
152  Q_D(KServiceGroup);
153  d->m_bInlineAlias = _b;
154 }
155 
156 void KServiceGroup::setShowEmptyMenu(bool _b)
157 {
158  Q_D(KServiceGroup);
159  d->m_bShowEmptyMenu = _b;
160 }
161 
162 void KServiceGroup::setShowInlineHeader(bool _b)
163 {
164  Q_D(KServiceGroup);
165  d->m_bShowInlineHeader = _b;
166 }
167 
169 {
170  Q_D(const KServiceGroup);
171  return d->m_inlineValue;
172 }
173 
174 void KServiceGroup::setInlineValue(int _val)
175 {
176  Q_D(KServiceGroup);
177  d->m_inlineValue = _val;
178 }
179 
181 {
182  Q_D(const KServiceGroup);
183  return d->m_bAllowInline;
184 }
185 
186 void KServiceGroup::setAllowInline(bool _b)
187 {
188  Q_D(KServiceGroup);
189  d->m_bAllowInline = _b;
190 }
191 
193 {
194  Q_D(const KServiceGroup);
195  return d->m_bNoDisplay || d->m_strCaption.startsWith(QLatin1Char('.'));
196 }
197 
199 {
200  Q_D(const KServiceGroup);
201  return d->suppressGenericNames;
202 }
203 
204 void KServiceGroupPrivate::load(QDataStream &s)
205 {
206  QStringList groupList;
207  qint8 noDisplay;
208  qint8 _showEmptyMenu;
209  qint8 inlineHeader;
210  qint8 _inlineAlias;
211  qint8 _allowInline;
212  s >> m_strCaption >> m_strIcon >>
213  m_strComment >> groupList >> m_strBaseGroupName >> m_childCount >>
214  noDisplay >> suppressGenericNames >> directoryEntryPath >>
215  sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> _allowInline;
216 
217  m_bNoDisplay = (noDisplay != 0);
218  m_bShowEmptyMenu = (_showEmptyMenu != 0);
219  m_bShowInlineHeader = (inlineHeader != 0);
220  m_bInlineAlias = (_inlineAlias != 0);
221  m_bAllowInline = (_allowInline != 0);
222 
223  if (m_bDeep) {
224  for (const QString &path : qAsConst(groupList)) {
225  if (path.endsWith(QLatin1Char('/'))) {
226  KServiceGroup::Ptr serviceGroup;
227  serviceGroup = KSycocaPrivate::self()->serviceGroupFactory()->findGroupByDesktopPath(path, false);
228  if (serviceGroup) {
229  m_serviceList.append(KServiceGroup::SPtr(serviceGroup));
230  }
231  } else {
232  KService::Ptr service;
233  service = KSycocaPrivate::self()->serviceFactory()->findServiceByDesktopPath(path);
234  if (service) {
235  m_serviceList.append(KServiceGroup::SPtr(service));
236  }
237  }
238  }
239  }
240 }
241 
243 {
244  Q_D(KServiceGroup);
245  d->m_serviceList.append(entry);
246 }
247 
248 void KServiceGroupPrivate::save(QDataStream &s)
249 {
250  KSycocaEntryPrivate::save(s);
251 
252  QStringList groupList;
253  for (const KSycocaEntry::Ptr &p : qAsConst(m_serviceList)) {
254  if (p->isType(KST_KService)) {
255  KService::Ptr service(static_cast<KService*>(p.data()));
256  groupList.append(service->entryPath());
257  } else if (p->isType(KST_KServiceGroup)) {
258  KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup*>(p.data()));
259  groupList.append(serviceGroup->relPath());
260  } else {
261  //fprintf(stderr, "KServiceGroup: Unexpected object in list!\n");
262  }
263  }
264 
265  (void) childCount();
266 
267  qint8 noDisplay = m_bNoDisplay ? 1 : 0;
268  qint8 _showEmptyMenu = m_bShowEmptyMenu ? 1 : 0;
269  qint8 inlineHeader = m_bShowInlineHeader ? 1 : 0;
270  qint8 _inlineAlias = m_bInlineAlias ? 1 : 0;
271  qint8 _allowInline = m_bAllowInline ? 1 : 0;
272  s << m_strCaption << m_strIcon <<
273  m_strComment << groupList << m_strBaseGroupName << m_childCount <<
274  noDisplay << suppressGenericNames << directoryEntryPath <<
275  sortOrder << _showEmptyMenu << inlineHeader << _inlineAlias << _allowInline;
276 }
277 
279 {
280  Q_D(KServiceGroup);
281  bool sort = options & SortEntries || options & AllowSeparators;
283  const List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);
284  for (const SPtr &ptr : tmp) {
285  if (ptr->isType(KST_KServiceGroup)) {
286  KServiceGroup::Ptr serviceGroup(static_cast<KServiceGroup*>(ptr.data()));
287  list.append(serviceGroup);
288  } else if (ptr->isType(KST_KServiceSeparator)) {
289  list.append(KServiceGroup::Ptr(static_cast<KServiceGroup *>(new KSycocaEntry())));
290  } else if (sort && ptr->isType(KST_KService)) {
291  break;
292  }
293  }
294  return list;
295 }
296 
298 {
299  Q_D(KServiceGroup);
300  bool sort = options & SortEntries || options & AllowSeparators;
302  const List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);
303  bool foundService = false;
304  for (const SPtr &ptr : tmp) {
305  if (ptr->isType(KST_KService)) {
306  list.append(KService::Ptr(static_cast<KService*>(ptr.data())));
307  foundService = true;
308  } else if (ptr->isType(KST_KServiceSeparator) && foundService) {
309  list.append(KService::Ptr(static_cast<KService *>(new KSycocaEntry())));
310  }
311  }
312  return list;
313 }
314 
317 {
318  Q_D(KServiceGroup);
319  return d->entries(this, sort, true, false, false);
320 }
321 
323 KServiceGroup::entries(bool sort, bool excludeNoDisplay)
324 {
325  Q_D(KServiceGroup);
326  return d->entries(this, sort, excludeNoDisplay, false, false);
327 }
328 
330 KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
331 {
332  Q_D(KServiceGroup);
333  return d->entries(this, sort, excludeNoDisplay, allowSeparators, sortByGenericName);
334 }
335 
336 static void addItem(KServiceGroup::List &sorted, const KSycocaEntry::Ptr &p, bool &addSeparator)
337 {
338  if (addSeparator && !sorted.isEmpty()) {
339  sorted.append(KSycocaEntry::Ptr(new KServiceSeparator()));
340  }
341  sorted.append(p);
342  addSeparator = false;
343 }
344 
346 KServiceGroupPrivate::entries(KServiceGroup *group, bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
347 {
349 
350  // If the entries haven't been loaded yet, we have to reload ourselves
351  // together with the entries. We can't only load the entries afterwards
352  // since the offsets could have been changed if the database has changed.
353 
354  KServiceGroup::Ptr grp;
355  if (!m_bDeep) {
356  grp = KSycocaPrivate::self()->serviceGroupFactory()->findGroupByDesktopPath(path, true);
357 
358  group = grp.data();
359  if (nullptr == group) { // No guarantee that we still exist!
360  return KServiceGroup::List();
361  }
362  }
363 
364  if (!sort) {
365  return group->d_func()->m_serviceList;
366  }
367 
368  // Sort the list alphabetically, according to locale.
369  // Groups come first, then services.
370 
371  // We use a QMap, for sorting using a stored temporary key.
372  typedef QMap<QByteArray, KServiceGroup::SPtr> SortedContainer;
373  SortedContainer slist;
374  SortedContainer glist;
375  const auto listService = group->d_func()->m_serviceList;
376  for (const KSycocaEntry::Ptr &p : listService) {
377  bool noDisplay = p->isType(KST_KServiceGroup) ?
378  static_cast<KServiceGroup *>(p.data())->noDisplay() :
379  static_cast<KService *>(p.data())->noDisplay();
380  if (excludeNoDisplay && noDisplay) {
381  continue;
382  }
383  // Choose the right list
384  SortedContainer &list = p->isType(KST_KServiceGroup) ? glist : slist;
385  QString name;
386  if (p->isType(KST_KServiceGroup)) {
387  name = static_cast<KServiceGroup *>(p.data())->caption();
388  } else if (sortByGenericName) {
389  name = static_cast<KService *>(p.data())->genericName() + QLatin1Char(' ') + p->name();
390  } else {
391  name = p->name() + QLatin1Char(' ') + static_cast<KService *>(p.data())->genericName();
392  }
393 
394  const QByteArray nameStr = name.toLocal8Bit();
395 
396  QByteArray key;
397  // strxfrm() crashes on Solaris and strxfrm is not defined under wince
398 #if !defined(USE_SOLARIS) && !defined(_WIN32_WCE)
399  // maybe it'd be better to use wcsxfrm() where available
400  key.resize(name.length() * 4 + 1);
401  size_t ln = strxfrm(key.data(), nameStr.constData(), key.size());
402  if (ln != size_t(-1)) {
403  key.resize(ln);
404  if (int(ln) >= key.size()) {
405  // didn't fit?
406  ln = strxfrm(key.data(), nameStr.constData(), key.size());
407  if (ln == size_t(-1)) {
408  key = nameStr;
409  }
410  }
411  } else
412 #endif
413  {
414  key = nameStr;
415  }
416  list.insert(key, KServiceGroup::SPtr(p));
417  }
418 
419  if (sortOrder.isEmpty()) {
420  sortOrder << QStringLiteral(":M");
421  sortOrder << QStringLiteral(":F");
422  sortOrder << QStringLiteral(":OIH IL[4]"); //just inline header
423  }
424 
425  QString rp = path;
426  if (rp == QLatin1String("/")) {
427  rp.clear();
428  }
429 
430  // Iterate through the sort spec list.
431  // If an entry gets mentioned explicitly, we remove it from the sorted list
432  for (const QString &item : qAsConst(sortOrder)) {
433  if (item.isEmpty()) {
434  continue;
435  }
436  if (item[0] == QLatin1Char('/')) {
437  QString groupPath = rp + item.midRef(1) + QLatin1Char('/');
438  // Remove entry from sorted list of services.
439  for (SortedContainer::iterator it2 = glist.begin(); it2 != glist.end(); ++it2) {
440  const KServiceGroup::Ptr group(static_cast<KServiceGroup*>(it2.value().data()));
441  if (group->relPath() == groupPath) {
442  glist.erase(it2);
443  break;
444  }
445  }
446  } else if (item[0] != QLatin1Char(':')) {
447  // Remove entry from sorted list of services.
448  // TODO: Remove item from sortOrder-list if not found
449  // TODO: This prevents duplicates
450  for (SortedContainer::iterator it2 = slist.begin(); it2 != slist.end(); ++it2) {
451  const KService::Ptr service(static_cast<KService*>(it2.value().data()));
452  if (service->menuId() == item) {
453  slist.erase(it2);
454  break;
455  }
456  }
457  }
458  }
459 
460  KServiceGroup::List sorted;
461 
462  bool needSeparator = false;
463  // Iterate through the sort spec list.
464  // Add the entries to the list according to the sort spec.
465  for (QStringList::ConstIterator it(sortOrder.constBegin()); it != sortOrder.constEnd(); ++it) {
466  const QString &item = *it;
467  if (item.isEmpty()) {
468  continue;
469  }
470  if (item[0] == QLatin1Char(':')) {
471  // Special condition...
472  if (item == QLatin1String(":S")) {
473  if (allowSeparators) {
474  needSeparator = true;
475  }
476  } else if (item.contains(QLatin1String(":O"))) {
477  //todo parse attribute:
478  QString tmp(item);
479  tmp.remove(QStringLiteral(":O"));
480 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
481  QStringList optionAttribute = tmp.split(QLatin1Char(' '), QString::SkipEmptyParts);
482 #else
483  QStringList optionAttribute = tmp.split(QLatin1Char(' '), Qt::SkipEmptyParts);
484 #endif
485  if (optionAttribute.isEmpty()) {
486  optionAttribute.append(tmp);
487  }
488  bool showEmptyMenu = false;
489  bool showInline = false;
490  bool showInlineHeader = false;
491  bool showInlineAlias = false;
492  int inlineValue = -1;
493 
494  for (QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3) {
495  parseAttribute(*it3, showEmptyMenu, showInline, showInlineHeader, showInlineAlias, inlineValue);
496  }
497  for (SortedContainer::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2) {
498  KServiceGroup::Ptr group(static_cast<KServiceGroup*>(it2.value().data()));
499  group->setShowEmptyMenu(showEmptyMenu);
500  group->setAllowInline(showInline);
501  group->setShowInlineHeader(showInlineHeader);
502  group->setInlineAlias(showInlineAlias);
503  group->setInlineValue(inlineValue);
504  }
505 
506  } else if (item == QLatin1String(":M")) {
507  // Add sorted list of sub-menus
508  for (SortedContainer::const_iterator it2 = glist.constBegin(); it2 != glist.constEnd(); ++it2) {
509  addItem(sorted, it2.value(), needSeparator);
510  }
511  } else if (item == QLatin1String(":F")) {
512  // Add sorted list of services
513  for (SortedContainer::const_iterator it2 = slist.constBegin(); it2 != slist.constEnd(); ++it2) {
514  addItem(sorted, it2.value(), needSeparator);
515  }
516  } else if (item == QLatin1String(":A")) {
517  // Add sorted lists of services and submenus
518  SortedContainer::Iterator it_s = slist.begin();
519  SortedContainer::Iterator it_g = glist.begin();
520 
521  while (true) {
522  if (it_s == slist.end()) {
523  if (it_g == glist.end()) {
524  break; // Done
525  }
526 
527  // Insert remaining sub-menu
528  addItem(sorted, it_g.value(), needSeparator);
529  it_g++;
530  } else if (it_g == glist.end()) {
531  // Insert remaining service
532  addItem(sorted, it_s.value(), needSeparator);
533  it_s++;
534  } else if (it_g.key() < it_s.key()) {
535  // Insert sub-menu first
536  addItem(sorted, it_g.value(), needSeparator);
537  it_g++;
538  } else {
539  // Insert service first
540  addItem(sorted, it_s.value(), needSeparator);
541  it_s++;
542  }
543  }
544  }
545  } else if (item[0] == QLatin1Char('/')) {
546  QString groupPath = rp + item.midRef(1) + QLatin1Char('/');
547 
548  for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.constBegin());
549  it2 != group->d_func()->m_serviceList.constEnd(); ++it2) {
550  if (!(*it2)->isType(KST_KServiceGroup)) {
551  continue;
552  }
553  KServiceGroup::Ptr group(static_cast<KServiceGroup*>((*it2).data()));
554  if (group->relPath() == groupPath) {
555  if (!excludeNoDisplay || !group->noDisplay()) {
556  ++it;
557  const QString &nextItem =
558  (it == sortOrder.constEnd()) ? QString() : *it;
559 
560  if (nextItem.startsWith(QLatin1String(":O"))) {
561  QString tmp(nextItem);
562  tmp.remove(QStringLiteral(":O"));
563 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
564  QStringList optionAttribute = tmp.split(QLatin1Char(' '), QString::SkipEmptyParts);
565 #else
566  QStringList optionAttribute = tmp.split(QLatin1Char(' '), Qt::SkipEmptyParts);
567 #endif
568  if (optionAttribute.isEmpty()) {
569  optionAttribute.append(tmp);
570  }
571  bool bShowEmptyMenu = false;
572  bool bShowInline = false;
573  bool bShowInlineHeader = false;
574  bool bShowInlineAlias = false;
575  int inlineValue = -1;
576  for (const QString &opt_attr : qAsConst(optionAttribute)) {
577  parseAttribute(opt_attr, bShowEmptyMenu, bShowInline, bShowInlineHeader, bShowInlineAlias, inlineValue);
578  group->setShowEmptyMenu(bShowEmptyMenu);
579  group->setAllowInline(bShowInline);
580  group->setShowInlineHeader(bShowInlineHeader);
581  group->setInlineAlias(bShowInlineAlias);
582  group->setInlineValue(inlineValue);
583  }
584  } else {
585  it--;
586  }
587 
588  addItem(sorted, KServiceGroup::SPtr(group), needSeparator);
589  }
590  break;
591  }
592  }
593  } else {
594  for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.constBegin());
595  it2 != group->d_func()->m_serviceList.constEnd(); ++it2) {
596  if (!(*it2)->isType(KST_KService)) {
597  continue;
598  }
599  const KService::Ptr service(static_cast<KService*>((*it2).data()));
600  if (service->menuId() == item) {
601  if (!excludeNoDisplay || !service->noDisplay()) {
602  addItem(sorted, (*it2), needSeparator);
603  }
604  break;
605  }
606  }
607  }
608  }
609 
610  return sorted;
611 }
612 
613 void KServiceGroupPrivate::parseAttribute(const QString &item, bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool &showInlineAlias, int &inlineValue)
614 {
615  if (item == QLatin1String("ME")) { //menu empty
616  showEmptyMenu = true;
617  } else if (item == QLatin1String("NME")) { //not menu empty
618  showEmptyMenu = false;
619  } else if (item == QLatin1String("I")) { //inline menu !
620  showInline = true;
621  } else if (item == QLatin1String("NI")) { //not inline menu!
622  showInline = false;
623  } else if (item == QLatin1String("IH")) { //inline header!
624  showInlineHeader = true;
625  } else if (item == QLatin1String("NIH")) { //not inline header!
626  showInlineHeader = false;
627  } else if (item == QLatin1String("IA")) { //inline alias!
628  showInlineAlias = true;
629  } else if (item == QLatin1String("NIA")) { //not inline alias!
630  showInlineAlias = false;
631  } else if ((item).contains(QLatin1String("IL"))) { //inline limite!
632  QString tmp(item);
633  tmp.remove(QStringLiteral("IL["));
634  tmp.remove(QLatin1Char(']'));
635  bool ok;
636  int _inlineValue = tmp.toInt(&ok);
637  if (!ok) { //error
638  _inlineValue = -1;
639  }
640  inlineValue = _inlineValue;
641  } else {
642  qCDebug(SERVICES) << "This attribute is not supported:" << item;
643  }
644 }
645 
647 {
648  Q_D(KServiceGroup);
649  d->sortOrder = layout;
650 }
651 
653 {
654  Q_D(const KServiceGroup);
655  return d->sortOrder;
656 }
657 
660 {
662  return KSycocaPrivate::self()->serviceGroupFactory()->findGroupByDesktopPath(QStringLiteral("/"), true);
663 }
664 
667 {
668  if (relPath.isEmpty()) {
669  return root();
670  }
672  return KSycocaPrivate::self()->serviceGroupFactory()->findGroupByDesktopPath(relPath, true);
673 }
674 
677 {
679  return KSycocaPrivate::self()->serviceGroupFactory()->findGroupByDesktopPath(QLatin1String("#parent#") + parent, true);
680 }
681 
683 {
684  return d_func()->m_strBaseGroupName;
685 }
686 
687 QString
689 {
690  Q_D(const KServiceGroup);
691  return d->directoryEntryPath;
692 }
693 
694 class KServiceSeparatorPrivate : public KSycocaEntryPrivate
695 {
696 public:
697  K_SYCOCATYPE(KST_KServiceSeparator, KSycocaEntryPrivate)
698 
699  KServiceSeparatorPrivate(const QString &name)
700  : KSycocaEntryPrivate(name)
701  {
702  }
703 
704  QString name() const override;
705 };
706 
707 QString KServiceSeparatorPrivate::name() const
708 {
709  return QStringLiteral("separator");
710 }
711 
712 
713 KServiceSeparator::KServiceSeparator()
714  : KSycocaEntry(*new KServiceSeparatorPrivate(QStringLiteral("separator")))
715 {
716 }
717 
718 KServiceSeparator::~KServiceSeparator()
719 {
720 }
721 
bool noDisplay() const
Returns true if the NoDisplay flag was set, i.e.
QString directoryEntryPath() const
Returns a path to the .directory file describing this service group.
KServiceGroup represents a group of service, for example screensavers.
Definition: kservicegroup.h:52
bool showInlineHeader() const
QString relPath() const
Returns the relative path of the service group.
KServiceGroup(const QString &name)
Construct a dummy servicegroup indexed with name.
Represent a service, like an application or plugin bound to one or several mimetypes (or servicetypes...
Definition: kservice.h:45
bool allowInline() const
QString icon() const
Returns the name of the icon associated with the group.
KService::List serviceEntries(EntriesOptions options=ExcludeNoDisplay)
entries of this service group
QString genericName() const
Returns the generic name for the service, if there is one (e.g.
Definition: kservice.cpp:944
QByteArray & insert(int i, char ch)
QString caption() const
Returns the caption of this group.
QList< Ptr > groupEntries(EntriesOptions options=ExcludeNoDisplay)
subgroups for this service group
QString & remove(int position, int n)
void chop(int n)
exclude items marked "NoDisplay"
bool noDisplay() const
T value(int i) const const
QString path() const
Definition: kservice.cpp:925
void clear()
void resize(int size)
QString baseGroupName() const
Returns a non-empty string if the group is a special base group.
sort by GenericName+Name instead of Name+GenericName
void append(const T &value)
QString entryPath() const
void addEntry(const KSycocaEntry::Ptr &entry)
int childCount() const
Returns the total number of displayable services in this group and any of its subgroups.
Base class for all Sycoca entries.
Definition: ksycocaentry.h:30
int toInt(bool *ok, int base) const const
bool isEmpty() const const
bool isEmpty() const const
List entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName=false)
List of all Services and ServiceGroups within this ServiceGroup.
const char * constData() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
QStringList split(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool inlineAlias() const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
typedef Iterator
int inlineValue() const
QList::iterator end()
QByteArray toLocal8Bit() const const
void setLayoutInfo(const QStringList &layout)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
SkipEmptyParts
QStringRef midRef(int position, int n) const const
static Ptr childGroup(const QString &parent)
Returns the group of services that have X-KDE-ParentApp equal to parent (siblings).
QList< SPtr > List
A list of shared data pointers for KSycocaEntry.
Definition: kservicegroup.h:67
QStringList suppressGenericNames() const
Returns a list of untranslated generic names that should be be suppressed when showing this group...
QStringList layoutInfo() const
bool showEmptyMenu() const
Return true if we want to display empty menu entry.
static Ptr root()
Returns the root service group.
typedef ConstIterator
int length() const const
char * data()
QString comment() const
Returns the comment about this service group.
static Ptr group(const QString &relPath)
Returns the group with the given relative path.
int size() const const
T readEntry(const QString &key, const T &aDefault) const
QString name() const
static KSycoca * self()
Get or create the only instance of KSycoca (read-only)
Definition: ksycoca.cpp:349
QList::iterator begin()
allow separator items to be included
void ensureCacheValid()
Ensures the ksycoca database is up to date.
Definition: ksycoca.cpp:759
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 11 2020 22:49:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.