00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "kservicegroup.h"
00021 #include "kservicegroup_p.h"
00022 #include "kservicefactory.h"
00023 #include "kservicegroupfactory.h"
00024 #include "kservice.h"
00025 #include <ksycoca.h>
00026 #include <kglobal.h>
00027 #include <kstandarddirs.h>
00028 #include <klocale.h>
00029 #include <kdebug.h>
00030 #include <ksortablelist.h>
00031 #include <kdesktopfile.h>
00032 #include <kconfiggroup.h>
00033
00034
00035 KServiceGroup::KServiceGroup( const QString & name )
00036 : KSycocaEntry(*new KServiceGroupPrivate(name))
00037 {
00038 }
00039
00040 KServiceGroup::KServiceGroup( const QString &configFile, const QString & _relpath )
00041 : KSycocaEntry(*new KServiceGroupPrivate(_relpath))
00042 {
00043 Q_D(KServiceGroup);
00044
00045 QString cfg = configFile;
00046 if (cfg.isEmpty())
00047 cfg = _relpath + ".directory";
00048
00049 d->load(cfg);
00050 }
00051
00052 void KServiceGroupPrivate::load(const QString &cfg)
00053 {
00054 directoryEntryPath = cfg;
00055
00056 const KDesktopFile desktopFile( cfg );
00057
00058 const KConfigGroup config = desktopFile.desktopGroup();
00059
00060 m_strCaption = config.readEntry( "Name" );
00061 m_strIcon = config.readEntry( "Icon" );
00062 m_strComment = config.readEntry( "Comment" );
00063 deleted = config.readEntry("Hidden", false );
00064 m_bNoDisplay = desktopFile.noDisplay();
00065 m_strBaseGroupName = config.readEntry( "X-KDE-BaseGroup" );
00066 suppressGenericNames = config.readEntry( "X-KDE-SuppressGenericNames", QStringList() );
00067
00068
00069
00070 if (m_strCaption.isEmpty())
00071 {
00072 m_strCaption = path;
00073 if (m_strCaption.endsWith(QLatin1Char('/')))
00074 m_strCaption = m_strCaption.left(m_strCaption.length()-1);
00075 int i = m_strCaption.lastIndexOf('/');
00076 if (i > 0)
00077 m_strCaption = m_strCaption.mid(i+1);
00078 }
00079 if (m_strIcon.isEmpty())
00080 m_strIcon = "folder";
00081 }
00082
00083 KServiceGroup::KServiceGroup( QDataStream& _str, int offset, bool deep ) :
00084 KSycocaEntry(*new KServiceGroupPrivate(_str, offset))
00085 {
00086 Q_D(KServiceGroup);
00087 d->m_bDeep = deep;
00088 d->load( _str );
00089 }
00090
00091 KServiceGroup::~KServiceGroup()
00092 {
00093 }
00094
00095 QString KServiceGroup::relPath() const
00096 {
00097 return entryPath();
00098 }
00099
00100 QString KServiceGroup::caption() const
00101 {
00102 Q_D(const KServiceGroup);
00103 return d->m_strCaption;
00104 }
00105
00106 QString KServiceGroup::icon() const
00107 {
00108 Q_D(const KServiceGroup);
00109 return d->m_strIcon;
00110 }
00111
00112 QString KServiceGroup::comment() const
00113 {
00114 Q_D(const KServiceGroup);
00115 return d->m_strComment;
00116 }
00117
00118 int KServiceGroup::childCount() const
00119 {
00120 Q_D(const KServiceGroup);
00121 return d->childCount();
00122 }
00123
00124 int KServiceGroupPrivate::childCount() const
00125 {
00126 if (m_childCount == -1)
00127 {
00128 m_childCount = 0;
00129
00130 for( KServiceGroup::List::ConstIterator it = m_serviceList.begin();
00131 it != m_serviceList.end(); ++it)
00132 {
00133 KSycocaEntry::Ptr p = *it;
00134 if (p->isType(KST_KService))
00135 {
00136 KService::Ptr service = KService::Ptr::staticCast( p );
00137 if (!service->noDisplay())
00138 m_childCount++;
00139 }
00140 else if (p->isType(KST_KServiceGroup))
00141 {
00142 KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast( p );
00143 m_childCount += serviceGroup->childCount();
00144 }
00145 }
00146 }
00147 return m_childCount;
00148 }
00149
00150
00151 bool KServiceGroup::showInlineHeader() const
00152 {
00153 Q_D(const KServiceGroup);
00154 return d->m_bShowInlineHeader;
00155 }
00156
00157 bool KServiceGroup::showEmptyMenu() const
00158 {
00159 Q_D(const KServiceGroup);
00160 return d->m_bShowEmptyMenu;
00161 }
00162
00163 bool KServiceGroup::inlineAlias() const
00164 {
00165 Q_D(const KServiceGroup);
00166 return d->m_bInlineAlias;
00167 }
00168
00169 void KServiceGroup::setInlineAlias(bool _b)
00170 {
00171 Q_D(KServiceGroup);
00172 d->m_bInlineAlias = _b;
00173 }
00174
00175 void KServiceGroup::setShowEmptyMenu(bool _b)
00176 {
00177 Q_D(KServiceGroup);
00178 d->m_bShowEmptyMenu=_b;
00179 }
00180
00181 void KServiceGroup::setShowInlineHeader(bool _b)
00182 {
00183 Q_D(KServiceGroup);
00184 d->m_bShowInlineHeader=_b;
00185 }
00186
00187 int KServiceGroup::inlineValue() const
00188 {
00189 Q_D(const KServiceGroup);
00190 return d->m_inlineValue;
00191 }
00192
00193 void KServiceGroup::setInlineValue(int _val)
00194 {
00195 Q_D(KServiceGroup);
00196 d->m_inlineValue = _val;
00197 }
00198
00199 bool KServiceGroup::allowInline() const
00200 {
00201 Q_D(const KServiceGroup);
00202 return d->m_bAllowInline;
00203 }
00204
00205 void KServiceGroup::setAllowInline(bool _b)
00206 {
00207 Q_D(KServiceGroup);
00208 d->m_bAllowInline = _b;
00209 }
00210
00211 bool KServiceGroup::noDisplay() const
00212 {
00213 Q_D(const KServiceGroup);
00214 return d->m_bNoDisplay || d->m_strCaption.startsWith('.');
00215 }
00216
00217 QStringList KServiceGroup::suppressGenericNames() const
00218 {
00219 Q_D(const KServiceGroup);
00220 return d->suppressGenericNames;
00221 }
00222
00223 void KServiceGroupPrivate::load( QDataStream& s )
00224 {
00225 QStringList groupList;
00226 qint8 noDisplay;
00227 qint8 _showEmptyMenu;
00228 qint8 inlineHeader;
00229 qint8 _inlineAlias;
00230 qint8 _allowInline;
00231 s >> m_strCaption >> m_strIcon >>
00232 m_strComment >> groupList >> m_strBaseGroupName >> m_childCount >>
00233 noDisplay >> suppressGenericNames >> directoryEntryPath >>
00234 sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> _allowInline;
00235
00236 m_bNoDisplay = (noDisplay != 0);
00237 m_bShowEmptyMenu = ( _showEmptyMenu != 0 );
00238 m_bShowInlineHeader = ( inlineHeader != 0 );
00239 m_bInlineAlias = ( _inlineAlias != 0 );
00240 m_bAllowInline = ( _allowInline != 0 );
00241
00242 if (m_bDeep)
00243 {
00244 for(QStringList::ConstIterator it = groupList.begin();
00245 it != groupList.end(); ++it)
00246 {
00247 QString path = *it;
00248 if (path[path.length()-1] == '/')
00249 {
00250 KServiceGroup::Ptr serviceGroup;
00251 serviceGroup = KServiceGroupFactory::self()->findGroupByDesktopPath(path, false);
00252 if (serviceGroup)
00253 m_serviceList.append( KServiceGroup::SPtr::staticCast(serviceGroup) );
00254 }
00255 else
00256 {
00257 KService::Ptr service;
00258 service = KServiceFactory::self()->findServiceByDesktopPath(path);
00259 if (service)
00260 m_serviceList.append( KServiceGroup::SPtr::staticCast(service) );
00261 }
00262 }
00263 }
00264 }
00265
00266 void KServiceGroup::addEntry( const KSycocaEntry::Ptr& entry)
00267 {
00268 Q_D(KServiceGroup);
00269 d->m_serviceList.append(entry);
00270 }
00271
00272 void KServiceGroupPrivate::save( QDataStream& s )
00273 {
00274 KSycocaEntryPrivate::save( s );
00275
00276 QStringList groupList;
00277 for( KServiceGroup::List::ConstIterator it = m_serviceList.begin();
00278 it != m_serviceList.end(); ++it)
00279 {
00280 KSycocaEntry::Ptr p = *it;
00281 if (p->isType(KST_KService))
00282 {
00283 KService::Ptr service = KService::Ptr::staticCast( p );
00284 groupList.append( service->entryPath() );
00285 }
00286 else if (p->isType(KST_KServiceGroup))
00287 {
00288 KServiceGroup::Ptr serviceGroup = KServiceGroup::Ptr::staticCast( p );
00289 groupList.append( serviceGroup->relPath() );
00290 }
00291 else
00292 {
00293
00294 }
00295 }
00296
00297 (void) childCount();
00298
00299 qint8 noDisplay = m_bNoDisplay ? 1 : 0;
00300 qint8 _showEmptyMenu = m_bShowEmptyMenu ? 1 : 0;
00301 qint8 inlineHeader = m_bShowInlineHeader ? 1 : 0;
00302 qint8 _inlineAlias = m_bInlineAlias ? 1 : 0;
00303 qint8 _allowInline = m_bAllowInline ? 1 : 0;
00304 s << m_strCaption << m_strIcon <<
00305 m_strComment << groupList << m_strBaseGroupName << m_childCount <<
00306 noDisplay << suppressGenericNames << directoryEntryPath <<
00307 sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline;
00308 }
00309
00310 QList<KServiceGroup::Ptr> KServiceGroup::groupEntries(EntriesOptions options)
00311 {
00312 Q_D(KServiceGroup);
00313 bool sort = options & SortEntries || options & AllowSeparators;
00314 QList<KServiceGroup::Ptr> list;
00315 List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);
00316 foreach(const SPtr &ptr, tmp) {
00317 if (ptr->isType(KST_KServiceGroup))
00318 list.append(Ptr::staticCast(ptr));
00319 else if (ptr->isType(KST_KServiceSeparator))
00320 list.append(KServiceGroup::Ptr(static_cast<KServiceGroup *>(new KSycocaEntry())));
00321 else if (sort && ptr->isType(KST_KService))
00322 break;
00323 }
00324 return list;
00325 }
00326
00327 KService::List KServiceGroup::serviceEntries(EntriesOptions options)
00328 {
00329 Q_D(KServiceGroup);
00330 bool sort = options & SortEntries || options & AllowSeparators;
00331 QList<KService::Ptr> list;
00332 List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);
00333 bool foundService = false;
00334 foreach(const SPtr &ptr, tmp) {
00335 if (ptr->isType(KST_KService)) {
00336 list.append(KService::Ptr::staticCast(ptr));
00337 foundService = true;
00338 }
00339 else if (ptr->isType(KST_KServiceSeparator) && foundService) {
00340 list.append(KService::Ptr(static_cast<KService *>(new KSycocaEntry())));
00341 }
00342 }
00343 return list;
00344 }
00345
00346 KServiceGroup::List
00347 KServiceGroup::entries(bool sort)
00348 {
00349 Q_D(KServiceGroup);
00350 return d->entries(this, sort, true, false, false);
00351 }
00352
00353 KServiceGroup::List
00354 KServiceGroup::entries(bool sort, bool excludeNoDisplay)
00355 {
00356 Q_D(KServiceGroup);
00357 return d->entries(this, sort, excludeNoDisplay, false, false);
00358 }
00359
00360 KServiceGroup::List
00361 KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
00362 {
00363 Q_D(KServiceGroup);
00364 return d->entries(this, sort, excludeNoDisplay, allowSeparators, sortByGenericName);
00365 }
00366
00367 static void addItem(KServiceGroup::List &sorted, const KSycocaEntry::Ptr &p, bool &addSeparator)
00368 {
00369 if (addSeparator && !sorted.isEmpty())
00370 sorted.append(KSycocaEntry::Ptr(new KServiceSeparator()));
00371 sorted.append(p);
00372 addSeparator = false;
00373 }
00374
00375 KServiceGroup::List
00376 KServiceGroupPrivate::entries(KServiceGroup *group, bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName)
00377 {
00378 KServiceGroup::Ptr grp;
00379
00380
00381
00382
00383
00384 if (!m_bDeep) {
00385
00386 grp = KServiceGroupFactory::self()->findGroupByDesktopPath(path, true);
00387
00388 group = grp.data();
00389 if (0 == group)
00390 return KServiceGroup::List();
00391 }
00392
00393 if (!sort)
00394 return group->d_func()->m_serviceList;
00395
00396
00397
00398
00399 KSortableList<KServiceGroup::SPtr,QByteArray> slist;
00400 KSortableList<KServiceGroup::SPtr,QByteArray> glist;
00401 for (KServiceGroup::List::ConstIterator it(group->d_func()->m_serviceList.begin()); it != group->d_func()->m_serviceList.end(); ++it)
00402 {
00403 KSycocaEntry::Ptr p = (*it);
00404 bool noDisplay = p->isType(KST_KServiceGroup) ?
00405 static_cast<KServiceGroup *>(p.data())->noDisplay() :
00406 static_cast<KService *>(p.data())->noDisplay();
00407 if (excludeNoDisplay && noDisplay)
00408 continue;
00409
00410 KSortableList<KServiceGroup::SPtr,QByteArray> & list = p->isType(KST_KServiceGroup) ? glist : slist;
00411 QString name;
00412 if (p->isType(KST_KServiceGroup))
00413 name = static_cast<KServiceGroup *>(p.data())->caption();
00414 else if (sortByGenericName)
00415 name = static_cast<KService *>(p.data())->genericName() + ' ' + p->name();
00416 else
00417 name = p->name() + ' ' + static_cast<KService *>(p.data())->genericName();
00418
00419 QByteArray key;
00420
00421 #ifndef USE_SOLARIS
00422
00423 key.resize( name.length() * 4 + 1 );
00424 size_t ln = strxfrm( key.data(), name.toLocal8Bit().data(), key.size());
00425 if( ln != size_t( -1 ))
00426 {
00427 if( (int)ln >= key.size())
00428 {
00429 key.resize( ln + 1 );
00430 if( strxfrm( key.data(), name.toLocal8Bit().data(), key.size()) == size_t( -1 ))
00431 key = name.toLocal8Bit();
00432 }
00433 }
00434 else
00435 #endif
00436 {
00437 key = name.toLocal8Bit();
00438 }
00439 list.insert(key,KServiceGroup::SPtr(*it));
00440 }
00441
00442 slist.sort();
00443 glist.sort();
00444
00445 if (sortOrder.isEmpty())
00446 {
00447 sortOrder << ":M";
00448 sortOrder << ":F";
00449 sortOrder << ":OIH IL[4]";
00450 }
00451
00452 QString rp = path;
00453 if(rp == "/") rp.clear();
00454
00455
00456
00457 for (QStringList::ConstIterator it(sortOrder.begin()); it != sortOrder.end(); ++it)
00458 {
00459 const QString &item = *it;
00460 if (item.isEmpty()) continue;
00461 if (item[0] == '/')
00462 {
00463 QString groupPath = rp + item.mid(1) + '/';
00464
00465 for(KSortableList<KServiceGroup::SPtr,QByteArray>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2)
00466 {
00467 const KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast( (*it2).value() );
00468 if (group->relPath() == groupPath)
00469 {
00470 glist.erase(it2);
00471 break;
00472 }
00473 }
00474 }
00475 else if (item[0] != ':')
00476 {
00477
00478
00479
00480 for(KSortableList<KServiceGroup::SPtr,QByteArray>::Iterator it2 = slist.begin(); it2 != slist.end(); ++it2)
00481 {
00482 const KService::Ptr service = KService::Ptr::staticCast( (*it2).value() );
00483 if (service->menuId() == item)
00484 {
00485 slist.erase(it2);
00486 break;
00487 }
00488 }
00489 }
00490 }
00491
00492 KServiceGroup::List sorted;
00493
00494 bool needSeparator = false;
00495
00496
00497 for (QStringList::ConstIterator it(sortOrder.begin()); it != sortOrder.end(); ++it)
00498 {
00499 const QString &item = *it;
00500 if (item.isEmpty()) continue;
00501 if (item[0] == ':')
00502 {
00503
00504 if (item == ":S")
00505 {
00506 if (allowSeparators)
00507 needSeparator = true;
00508 }
00509 else if ( item.contains( ":O" ) )
00510 {
00511
00512 QString tmp( item );
00513 tmp = tmp.remove(":O");
00514 QStringList optionAttribute = tmp.split(' ', QString::SkipEmptyParts);
00515 if ( optionAttribute.isEmpty() )
00516 optionAttribute.append( tmp );
00517 bool showEmptyMenu = false;
00518 bool showInline = false;
00519 bool showInlineHeader = false;
00520 bool showInlineAlias = false;
00521 int inlineValue = -1;
00522
00523 for ( QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 )
00524 {
00525 parseAttribute( *it3, showEmptyMenu, showInline, showInlineHeader, showInlineAlias, inlineValue );
00526 }
00527 for(KSortableList<KServiceGroup::SPtr,QByteArray>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2)
00528 {
00529 KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast( (*it2).value() );
00530 group->setShowEmptyMenu( showEmptyMenu );
00531 group->setAllowInline( showInline );
00532 group->setShowInlineHeader( showInlineHeader );
00533 group->setInlineAlias( showInlineAlias );
00534 group->setInlineValue( inlineValue );
00535 }
00536
00537 }
00538 else if (item == ":M")
00539 {
00540
00541 for(KSortableList<KServiceGroup::SPtr,QByteArray>::const_iterator it2 = glist.begin(); it2 != glist.end(); ++it2)
00542 {
00543 addItem(sorted, (*it2).value(), needSeparator);
00544 }
00545 }
00546 else if (item == ":F")
00547 {
00548
00549 for(KSortableList<KServiceGroup::SPtr,QByteArray>::const_iterator it2 = slist.begin(); it2 != slist.end(); ++it2)
00550 {
00551 addItem(sorted, (*it2).value(), needSeparator);
00552 }
00553 }
00554 else if (item == ":A")
00555 {
00556
00557 KSortableList<KServiceGroup::SPtr,QByteArray>::Iterator it_s = slist.begin();
00558 KSortableList<KServiceGroup::SPtr,QByteArray>::Iterator it_g = glist.begin();
00559
00560 while(true)
00561 {
00562 if (it_s == slist.end())
00563 {
00564 if (it_g == glist.end())
00565 break;
00566
00567
00568 addItem(sorted, (*it_g).value(), needSeparator);
00569 it_g++;
00570 }
00571 else if (it_g == glist.end())
00572 {
00573
00574 addItem(sorted, (*it_s).value(), needSeparator);
00575 it_s++;
00576 }
00577 else if ((*it_g).key() < (*it_s).key())
00578 {
00579
00580 addItem(sorted, (*it_g).value(), needSeparator);
00581 it_g++;
00582 }
00583 else
00584 {
00585
00586 addItem(sorted, (*it_s).value(), needSeparator);
00587 it_s++;
00588 }
00589 }
00590 }
00591 }
00592 else if (item[0] == '/')
00593 {
00594 QString groupPath = rp + item.mid(1) + '/';
00595
00596 for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.begin()); it2 != group->d_func()->m_serviceList.end(); ++it2)
00597 {
00598 if (!(*it2)->isType(KST_KServiceGroup))
00599 continue;
00600 KServiceGroup::Ptr group = KServiceGroup::Ptr::staticCast( *it2 );
00601 if (group->relPath() == groupPath)
00602 {
00603 if (!excludeNoDisplay || !group->noDisplay())
00604 {
00605 ++it;
00606 const QString &nextItem =
00607 (it == sortOrder.end()) ? QString() : *it;
00608
00609 if ( nextItem.startsWith( ":O" ) )
00610 {
00611 QString tmp( nextItem );
00612 tmp = tmp.remove(":O");
00613 QStringList optionAttribute = tmp.split(' ', QString::SkipEmptyParts);
00614 if ( optionAttribute.isEmpty() )
00615 optionAttribute.append( tmp );
00616 bool bShowEmptyMenu = false;
00617 bool bShowInline = false;
00618 bool bShowInlineHeader = false;
00619 bool bShowInlineAlias = false;
00620 int inlineValue = -1;
00621 for ( QStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 )
00622 {
00623 parseAttribute( *it3 , bShowEmptyMenu, bShowInline, bShowInlineHeader, bShowInlineAlias , inlineValue );
00624 group->setShowEmptyMenu( bShowEmptyMenu );
00625 group->setAllowInline( bShowInline );
00626 group->setShowInlineHeader( bShowInlineHeader );
00627 group->setInlineAlias( bShowInlineAlias );
00628 group->setInlineValue( inlineValue );
00629 }
00630 }
00631 else
00632 it--;
00633
00634 addItem(sorted, KServiceGroup::SPtr::staticCast(group), needSeparator);
00635 }
00636 break;
00637 }
00638 }
00639 }
00640 else
00641 {
00642 for (KServiceGroup::List::ConstIterator it2(group->d_func()->m_serviceList.begin()); it2 != group->d_func()->m_serviceList.end(); ++it2)
00643 {
00644 if (!(*it2)->isType(KST_KService))
00645 continue;
00646 const KService::Ptr service = KService::Ptr::staticCast( *it2 );
00647 if (service->menuId() == item)
00648 {
00649 if (!excludeNoDisplay || !service->noDisplay())
00650 addItem(sorted, (*it2), needSeparator);
00651 break;
00652 }
00653 }
00654 }
00655 }
00656
00657 return sorted;
00658 }
00659
00660 void KServiceGroupPrivate::parseAttribute( const QString &item , bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias , int &inlineValue )
00661 {
00662 if( item == "ME")
00663 showEmptyMenu=true;
00664 else if ( item == "NME")
00665 showEmptyMenu=false;
00666 else if( item == "I")
00667 showInline = true;
00668 else if ( item == "NI")
00669 showInline = false;
00670 else if( item == "IH")
00671 showInlineHeader= true;
00672 else if ( item == "NIH")
00673 showInlineHeader = false;
00674 else if( item == "IA")
00675 showInlineAlias = true;
00676 else if ( item == "NIA")
00677 showInlineAlias = false;
00678 else if( ( item ).contains( "IL" ))
00679 {
00680 QString tmp( item );
00681 tmp = tmp.remove( "IL[" );
00682 tmp = tmp.remove( ']' );
00683 bool ok;
00684 int _inlineValue = tmp.toInt(&ok);
00685 if ( !ok )
00686 _inlineValue = -1;
00687 inlineValue = _inlineValue;
00688 }
00689 else
00690 kDebug()<<" This attribute is not supported :"<<item;
00691 }
00692
00693 void KServiceGroup::setLayoutInfo(const QStringList &layout)
00694 {
00695 Q_D(KServiceGroup);
00696 d->sortOrder = layout;
00697 }
00698
00699 QStringList KServiceGroup::layoutInfo() const
00700 {
00701 Q_D(const KServiceGroup);
00702 return d->sortOrder;
00703 }
00704
00705 KServiceGroup::Ptr
00706 KServiceGroup::baseGroup( const QString & _baseGroupName )
00707 {
00708 return KServiceGroupFactory::self()->findBaseGroup(_baseGroupName, true);
00709 }
00710
00711 KServiceGroup::Ptr
00712 KServiceGroup::root()
00713 {
00714 return KServiceGroupFactory::self()->findGroupByDesktopPath("/", true);
00715 }
00716
00717 KServiceGroup::Ptr
00718 KServiceGroup::group(const QString &relPath)
00719 {
00720 if (relPath.isEmpty()) return root();
00721 return KServiceGroupFactory::self()->findGroupByDesktopPath(relPath, true);
00722 }
00723
00724 KServiceGroup::Ptr
00725 KServiceGroup::childGroup(const QString &parent)
00726 {
00727 return KServiceGroupFactory::self()->findGroupByDesktopPath("#parent#"+parent, true);
00728 }
00729
00730 QString KServiceGroup::baseGroupName() const
00731 {
00732 return d_func()->m_strBaseGroupName;
00733 }
00734
00735 QString
00736 KServiceGroup::directoryEntryPath() const
00737 {
00738 Q_D(const KServiceGroup);
00739 return d->directoryEntryPath;
00740 }
00741
00742 class KServiceSeparatorPrivate : public KSycocaEntryPrivate
00743 {
00744 public:
00745 K_SYCOCATYPE( KST_KServiceSeparator, KSycocaEntryPrivate )
00746
00747 KServiceSeparatorPrivate(const QString &name)
00748 : KSycocaEntryPrivate(name)
00749 {
00750 }
00751
00752 virtual QString name() const
00753 {
00754 return QLatin1String("separator");
00755 }
00756
00757 };
00758
00759 KServiceSeparator::KServiceSeparator( )
00760 : KSycocaEntry(*new KServiceSeparatorPrivate("separator"))
00761 {
00762 }
00763
00764