46 cfg = _relpath + QLatin1String(
".directory");
79 m_strIcon = QString::fromLatin1(
"folder");
102 return d->m_strCaption;
114 return d->m_strComment;
120 return d->childCount();
129 for( KServiceGroup::List::ConstIterator it =
m_serviceList.begin();
153 return d->m_bShowInlineHeader;
159 return d->m_bShowEmptyMenu;
165 return d->m_bInlineAlias;
171 d->m_bInlineAlias = _b;
177 d->m_bShowEmptyMenu=_b;
183 d->m_bShowInlineHeader=_b;
189 return d->m_inlineValue;
195 d->m_inlineValue = _val;
201 return d->m_bAllowInline;
207 d->m_bAllowInline = _b;
213 return d->m_bNoDisplay || d->m_strCaption.startsWith(QLatin1Char(
'.'));
219 return d->suppressGenericNames;
226 qint8 _showEmptyMenu;
233 sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> _allowInline;
245 if ( path.endsWith( QLatin1Char(
'/' ) ) )
266 d->m_serviceList.append(entry);
279 groupList.append( service->
entryPath() );
284 groupList.append( serviceGroup->relPath() );
302 sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
309 QList<KServiceGroup::Ptr> list;
311 foreach(
const SPtr &ptr, tmp) {
326 QList<KService::Ptr> list;
328 bool foundService =
false;
329 foreach(
const SPtr &ptr, tmp) {
345 return d->entries(
this, sort,
true,
false,
false);
352 return d->entries(
this, sort, excludeNoDisplay,
false,
false);
359 return d->entries(
this, sort, excludeNoDisplay, allowSeparators, sortByGenericName);
364 if (addSeparator && !sorted.isEmpty())
367 addSeparator =
false;
389 return group->d_func()->m_serviceList;
401 if (excludeNoDisplay && noDisplay)
407 name = static_cast<KServiceGroup *>(p.
data())->
caption();
408 else if (sortByGenericName)
409 name =
static_cast<KService *
>(p.
data())->genericName() + QLatin1Char(
' ') + p->name();
411 name = p->name() + QLatin1Char(
' ') +
static_cast<KService *
>(p.
data())->genericName();
413 const QByteArray nameStr = name.toLocal8Bit();
417 #if !defined(USE_SOLARIS) && !defined(_WIN32_WCE)
419 key.resize( name.length() * 4 + 1 );
420 size_t ln = strxfrm(key.data(), nameStr.constData(), key.size());
421 if( ln !=
size_t( -1 ))
424 if( (
int)ln >= key.size())
426 ln = strxfrm( key.data(), nameStr.constData(), key.size());
427 if( ln ==
size_t( -1 ))
446 sortOrder << QString::fromLatin1(
":OIH IL[4]");
450 if(rp == QLatin1String(
"/")) rp.clear();
456 if (item.isEmpty())
continue;
457 if (item[0] == QLatin1Char(
'/'))
459 QString groupPath = rp + item.mid(1) + QLatin1Char(
'/');
464 if (group->relPath() == groupPath)
471 else if (item[0] != QLatin1Char(
':'))
479 if (service->
menuId() == item)
490 bool needSeparator =
false;
493 for (QStringList::ConstIterator it(
sortOrder.constBegin()); it !=
sortOrder.constEnd(); ++it)
496 if (item.isEmpty())
continue;
497 if (item[0] == QLatin1Char(
':'))
500 if (item == QLatin1String(
":S"))
503 needSeparator =
true;
505 else if ( item.contains( QLatin1String(
":O") ) )
509 tmp = tmp.remove(QLatin1String(
":O"));
510 QStringList optionAttribute = tmp.split(QLatin1Char(
' '), QString::SkipEmptyParts);
511 if ( optionAttribute.isEmpty() )
512 optionAttribute.append( tmp );
513 bool showEmptyMenu =
false;
514 bool showInline =
false;
515 bool showInlineHeader =
false;
516 bool showInlineAlias =
false;
517 int inlineValue = -1;
519 for ( QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 )
521 parseAttribute( *it3, showEmptyMenu, showInline, showInlineHeader, showInlineAlias, inlineValue );
526 group->setShowEmptyMenu( showEmptyMenu );
527 group->setAllowInline( showInline );
528 group->setShowInlineHeader( showInlineHeader );
529 group->setInlineAlias( showInlineAlias );
530 group->setInlineValue( inlineValue );
534 else if (item == QLatin1String(
":M"))
539 addItem(sorted, (*it2).value(), needSeparator);
542 else if (item == QLatin1String(
":F"))
547 addItem(sorted, (*it2).value(), needSeparator);
550 else if (item == QLatin1String(
":A"))
558 if (it_s == slist.end())
560 if (it_g == glist.end())
564 addItem(sorted, (*it_g).value(), needSeparator);
567 else if (it_g == glist.end())
570 addItem(sorted, (*it_s).value(), needSeparator);
573 else if ((*it_g).key() < (*it_s).key())
576 addItem(sorted, (*it_g).value(), needSeparator);
582 addItem(sorted, (*it_s).value(), needSeparator);
588 else if (item[0] == QLatin1Char(
'/'))
590 QString groupPath = rp + item.mid(1) + QLatin1Char(
'/');
592 for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.constBegin());
593 it2 != group->d_func()->m_serviceList.constEnd(); ++it2)
598 if (group->relPath() == groupPath)
600 if (!excludeNoDisplay || !group->noDisplay())
606 if ( nextItem.startsWith( QLatin1String(
":O") ) )
609 tmp = tmp.remove(QLatin1String(
":O"));
610 QStringList optionAttribute = tmp.split(QLatin1Char(
' '), QString::SkipEmptyParts);
611 if ( optionAttribute.isEmpty() )
612 optionAttribute.append( tmp );
613 bool bShowEmptyMenu =
false;
614 bool bShowInline =
false;
615 bool bShowInlineHeader =
false;
616 bool bShowInlineAlias =
false;
617 int inlineValue = -1;
618 Q_FOREACH(
const QString &opt_attr, optionAttribute )
620 parseAttribute( opt_attr, bShowEmptyMenu, bShowInline, bShowInlineHeader, bShowInlineAlias , inlineValue );
621 group->setShowEmptyMenu( bShowEmptyMenu );
622 group->setAllowInline( bShowInline );
623 group->setShowInlineHeader( bShowInlineHeader );
624 group->setInlineAlias( bShowInlineAlias );
625 group->setInlineValue( inlineValue );
639 for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.constBegin());
640 it2 != group->d_func()->m_serviceList.constEnd(); ++it2)
645 if (service->
menuId() == item)
647 if (!excludeNoDisplay || !service->
noDisplay())
648 addItem(sorted, (*it2), needSeparator);
660 if( item == QLatin1String(
"ME"))
662 else if ( item == QLatin1String(
"NME"))
664 else if( item == QLatin1String(
"I"))
666 else if ( item == QLatin1String(
"NI"))
668 else if( item == QLatin1String(
"IH"))
669 showInlineHeader=
true;
670 else if ( item == QLatin1String(
"NIH"))
671 showInlineHeader =
false;
672 else if( item == QLatin1String(
"IA"))
673 showInlineAlias =
true;
674 else if ( item == QLatin1String(
"NIA"))
675 showInlineAlias =
false;
676 else if( ( item ).contains( QLatin1String(
"IL") ))
679 tmp = tmp.remove( QLatin1String(
"IL[") );
680 tmp = tmp.remove( QLatin1Char(
']') );
682 int _inlineValue = tmp.toInt(&ok);
685 inlineValue = _inlineValue;
688 kDebug()<<
" This attribute is not supported :"<<item;
694 d->sortOrder = layout;
703 #ifndef KDE_NO_DEPRECATED
720 if (relPath.isEmpty())
return root();
732 return d_func()->m_strBaseGroupName;
739 return d->directoryEntryPath;
747 KServiceSeparatorPrivate(const
QString &name)
754 return QLatin1String(
"separator");