kservicegroup.cpp
00001 /* This file is part of the KDE libraries 00002 * Copyright (C) 2000 Waldo Bastian <bastian@kde.org> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License version 2 as published by the Free Software Foundation; 00007 * 00008 * This library is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Library General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Library General Public License 00014 * along with this library; see the file COPYING.LIB. If not, write to 00015 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 * Boston, MA 02110-1301, USA. 00017 **/ 00018 00019 #include <tqdir.h> 00020 00021 #include <kiconloader.h> 00022 #include <kglobal.h> 00023 #include <kstandarddirs.h> 00024 #include <klocale.h> 00025 #include <kdebug.h> 00026 #include <ksortablevaluelist.h> 00027 00028 #include "kservicefactory.h" 00029 #include "kservicegroupfactory.h" 00030 #include "kservicegroup.h" 00031 #include "kservice.h" 00032 #include "ksycoca.h" 00033 00034 class KServiceGroup::Private 00035 { 00036 public: 00037 Private() { m_bNoDisplay = false; m_bShowEmptyMenu = false;m_bShowInlineHeader=false;m_bInlineAlias=false; m_bAllowInline = false; m_inlineValue = 4; m_bShortMenu = false; m_bGeneralDescription = false;} 00038 bool m_bNoDisplay; 00039 bool m_bShortMenu; 00040 bool m_bGeneralDescription; 00041 bool m_bShowEmptyMenu; 00042 bool m_bShowInlineHeader; 00043 bool m_bInlineAlias; 00044 bool m_bAllowInline; 00045 int m_inlineValue; 00046 TQStringList suppressGenericNames; 00047 TQString directoryEntryPath; 00048 TQStringList sortOrder; 00049 }; 00050 00051 KServiceGroup::KServiceGroup( const TQString & name ) 00052 : KSycocaEntry(name), m_childCount(-1) 00053 { 00054 d = new KServiceGroup::Private; 00055 m_bDeleted = false; 00056 m_bDeep = false; 00057 } 00058 00059 KServiceGroup::KServiceGroup( const TQString &configFile, const TQString & _relpath ) 00060 : KSycocaEntry(_relpath), m_childCount(-1) 00061 { 00062 d = new KServiceGroup::Private; 00063 m_bDeleted = false; 00064 m_bDeep = false; 00065 00066 TQString cfg = configFile; 00067 if (cfg.isEmpty()) 00068 cfg = _relpath+".directory"; 00069 00070 d->directoryEntryPath = cfg; 00071 00072 KDesktopFile config( cfg, true, "apps" ); 00073 00074 m_strCaption = config.readName(); 00075 m_strIcon = config.readIcon(); 00076 m_strComment = config.readComment(); 00077 m_bDeleted = config.readBoolEntry( "Hidden", false ); 00078 d->m_bNoDisplay = config.readBoolEntry( "NoDisplay", false ); 00079 if (d->directoryEntryPath.startsWith(TQDir::homeDirPath())) 00080 d->m_bShortMenu = false; 00081 else 00082 d->m_bShortMenu = config.readBoolEntry( "X-SuSE-AutoShortMenu", false ); 00083 d->m_bGeneralDescription = config.readBoolEntry( "X-SuSE-GeneralDescription", false ); 00084 TQStringList tmpList; 00085 if (config.hasKey("OnlyShowIn")) 00086 { 00087 if ((!config.readListEntry("OnlyShowIn", ';').contains("TDE")) && (!config.readListEntry("OnlyShowIn", ';').contains("KDE"))) 00088 d->m_bNoDisplay = true; 00089 } 00090 if (config.hasKey("NotShowIn")) 00091 { 00092 if ((config.readListEntry("NotShowIn", ';').contains("TDE")) || (config.readListEntry("NotShowIn", ';').contains("KDE"))) 00093 d->m_bNoDisplay = true; 00094 } 00095 00096 m_strBaseGroupName = config.readEntry( "X-KDE-BaseGroup" ); 00097 d->suppressGenericNames = config.readListEntry( "X-KDE-SuppressGenericNames" ); 00098 d->sortOrder = config.readListEntry("SortOrder"); 00099 00100 // Fill in defaults. 00101 if (m_strCaption.isEmpty()) 00102 { 00103 m_strCaption = _relpath; 00104 if (m_strCaption.right(1) == "/") 00105 m_strCaption = m_strCaption.left(m_strCaption.length()-1); 00106 int i = m_strCaption.findRev('/'); 00107 if (i > 0) 00108 m_strCaption = m_strCaption.mid(i+1); 00109 } 00110 if (m_strIcon.isEmpty()) 00111 m_strIcon = "folder"; 00112 } 00113 00114 KServiceGroup::KServiceGroup( TQDataStream& _str, int offset, bool deep ) : 00115 KSycocaEntry( _str, offset ) 00116 { 00117 d = new KServiceGroup::Private; 00118 m_bDeep = deep; 00119 load( _str ); 00120 } 00121 00122 KServiceGroup::~KServiceGroup() 00123 { 00124 delete d; 00125 } 00126 00127 int KServiceGroup::childCount() 00128 { 00129 if (m_childCount == -1) 00130 { 00131 KConfig global("kdeglobals"); 00132 global.setGroup("KDE"); 00133 bool showUnimportant = global.readBoolEntry("showUnimportant", true); 00134 00135 m_childCount = 0; 00136 00137 for( List::ConstIterator it = m_serviceList.begin(); 00138 it != m_serviceList.end(); it++) 00139 { 00140 KSycocaEntry *p = (*it); 00141 if (p->isType(KST_KService)) 00142 { 00143 KService *service = static_cast<KService *>(p); 00144 if (!service->noDisplay()) 00145 if ( showUnimportant || !service->SuSEunimportant() ) 00146 m_childCount++; 00147 } 00148 else if (p->isType(KST_KServiceGroup)) 00149 { 00150 KServiceGroup *serviceGroup = static_cast<KServiceGroup *>(p); 00151 m_childCount += serviceGroup->childCount(); 00152 } 00153 } 00154 } 00155 return m_childCount; 00156 } 00157 00158 00159 bool KServiceGroup::showInlineHeader() const 00160 { 00161 return d->m_bShowInlineHeader; 00162 } 00163 00164 bool KServiceGroup::showEmptyMenu() const 00165 { 00166 return d->m_bShowEmptyMenu; 00167 } 00168 00169 bool KServiceGroup::inlineAlias() const 00170 { 00171 return d->m_bInlineAlias; 00172 } 00173 00174 void KServiceGroup::setInlineAlias(bool _b) 00175 { 00176 d->m_bInlineAlias = _b; 00177 } 00178 00179 void KServiceGroup::setShowEmptyMenu(bool _b) 00180 { 00181 d->m_bShowEmptyMenu=_b; 00182 } 00183 00184 void KServiceGroup::setShowInlineHeader(bool _b) 00185 { 00186 d->m_bShowInlineHeader=_b; 00187 } 00188 00189 int KServiceGroup::inlineValue() const 00190 { 00191 return d->m_inlineValue; 00192 } 00193 00194 void KServiceGroup::setInlineValue(int _val) 00195 { 00196 d->m_inlineValue = _val; 00197 } 00198 00199 bool KServiceGroup::allowInline() const 00200 { 00201 return d->m_bAllowInline; 00202 } 00203 00204 void KServiceGroup::setAllowInline(bool _b) 00205 { 00206 d->m_bAllowInline = _b; 00207 } 00208 00209 bool KServiceGroup::noDisplay() const 00210 { 00211 return d->m_bNoDisplay || m_strCaption.startsWith("."); 00212 } 00213 00214 TQStringList KServiceGroup::suppressGenericNames() const 00215 { 00216 return d->suppressGenericNames; 00217 } 00218 00219 bool KServiceGroup::SuSEgeneralDescription() const 00220 { 00221 return d->m_bGeneralDescription; 00222 } 00223 00224 bool KServiceGroup::SuSEshortMenu() const 00225 { 00226 return d->m_bShortMenu; 00227 } 00228 00229 void KServiceGroup::load( TQDataStream& s ) 00230 { 00231 TQStringList groupList; 00232 TQ_INT8 noDisplay; 00233 TQ_INT8 _showEmptyMenu; 00234 TQ_INT8 inlineHeader; 00235 TQ_INT8 _inlineAlias; 00236 TQ_INT8 _allowInline; 00237 s >> m_strCaption >> m_strIcon >> 00238 m_strComment >> groupList >> m_strBaseGroupName >> m_childCount >> 00239 noDisplay >> d->suppressGenericNames >> d->directoryEntryPath >> 00240 d->sortOrder >> _showEmptyMenu >> inlineHeader >> _inlineAlias >> 00241 _allowInline >> d->m_bShortMenu >> d->m_bGeneralDescription; 00242 00243 d->m_bNoDisplay = (noDisplay != 0); 00244 d->m_bShowEmptyMenu = ( _showEmptyMenu != 0 ); 00245 d->m_bShowInlineHeader = ( inlineHeader != 0 ); 00246 d->m_bInlineAlias = ( _inlineAlias != 0 ); 00247 d->m_bAllowInline = ( _allowInline != 0 ); 00248 00249 if (m_bDeep) 00250 { 00251 for(TQStringList::ConstIterator it = groupList.begin(); 00252 it != groupList.end(); it++) 00253 { 00254 TQString path = *it; 00255 if (path[path.length()-1] == '/') 00256 { 00257 KServiceGroup *serviceGroup; 00258 serviceGroup = KServiceGroupFactory::self()->findGroupByDesktopPath(path, false); 00259 if (serviceGroup) 00260 m_serviceList.append( SPtr(serviceGroup) ); 00261 } 00262 else 00263 { 00264 KService *service; 00265 service = KServiceFactory::self()->findServiceByDesktopPath(path); 00266 if (service) 00267 m_serviceList.append( SPtr(service) ); 00268 } 00269 } 00270 } 00271 } 00272 00273 void KServiceGroup::addEntry( KSycocaEntry *entry) 00274 { 00275 m_serviceList.append(entry); 00276 } 00277 00278 void KServiceGroup::save( TQDataStream& s ) 00279 { 00280 KSycocaEntry::save( s ); 00281 00282 TQStringList groupList; 00283 for( List::ConstIterator it = m_serviceList.begin(); 00284 it != m_serviceList.end(); it++) 00285 { 00286 KSycocaEntry *p = (*it); 00287 if (p->isType(KST_KService)) 00288 { 00289 KService *service = static_cast<KService *>(p); 00290 groupList.append( service->desktopEntryPath()); 00291 } 00292 else if (p->isType(KST_KServiceGroup)) 00293 { 00294 KServiceGroup *serviceGroup = static_cast<KServiceGroup *>(p); 00295 groupList.append( serviceGroup->relPath()); 00296 } 00297 else 00298 { 00299 //fprintf(stderr, "KServiceGroup: Unexpected object in list!\n"); 00300 } 00301 } 00302 00303 (void) childCount(); 00304 00305 TQ_INT8 noDisplay = d->m_bNoDisplay ? 1 : 0; 00306 TQ_INT8 _showEmptyMenu = d->m_bShowEmptyMenu ? 1 : 0; 00307 TQ_INT8 inlineHeader = d->m_bShowInlineHeader ? 1 : 0; 00308 TQ_INT8 _inlineAlias = d->m_bInlineAlias ? 1 : 0; 00309 TQ_INT8 _allowInline = d->m_bAllowInline ? 1 : 0; 00310 s << m_strCaption << m_strIcon << 00311 m_strComment << groupList << m_strBaseGroupName << m_childCount << 00312 noDisplay << d->suppressGenericNames << d->directoryEntryPath << 00313 d->sortOrder <<_showEmptyMenu <<inlineHeader<<_inlineAlias<<_allowInline << 00314 d->m_bShortMenu << d->m_bGeneralDescription; 00315 } 00316 00317 KServiceGroup::List 00318 KServiceGroup::entries(bool sort) 00319 { 00320 return entries(sort, true); 00321 } 00322 00323 KServiceGroup::List 00324 KServiceGroup::entries(bool sort, bool excludeNoDisplay) 00325 { 00326 return entries(sort, excludeNoDisplay, false); 00327 } 00328 00329 static void addItem(KServiceGroup::List &sorted, const KSycocaEntry::Ptr &p, bool &addSeparator) 00330 { 00331 if (addSeparator && !sorted.isEmpty()) 00332 sorted.append(new KServiceSeparator()); 00333 sorted.append(p); 00334 addSeparator = false; 00335 } 00336 00337 KServiceGroup::List 00338 KServiceGroup::entries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName) 00339 { 00340 return SuSEentries(sort, excludeNoDisplay, allowSeparators, sortByGenericName); 00341 } 00342 00343 KServiceGroup::List 00344 KServiceGroup::SuSEentries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName, bool excludeSuSEunimportant) 00345 { 00346 KServiceGroup *group = this; 00347 00348 // If the entries haven't been loaded yet, we have to reload ourselves 00349 // together with the entries. We can't only load the entries afterwards 00350 // since the offsets could have been changed if the database has changed. 00351 00352 if (!m_bDeep) { 00353 00354 group = 00355 KServiceGroupFactory::self()->findGroupByDesktopPath(relPath(), true); 00356 00357 if (0 == group) // No guarantee that we still exist! 00358 return List(); 00359 } 00360 00361 if (!sort) 00362 return group->m_serviceList; 00363 00364 // Sort the list alphabetically, according to locale. 00365 // Groups come first, then services. 00366 00367 KSortableValueList<SPtr,TQCString> slist; 00368 KSortableValueList<SPtr,TQCString> glist; 00369 for (List::ConstIterator it(group->m_serviceList.begin()); it != group->m_serviceList.end(); ++it) 00370 { 00371 KSycocaEntry *p = (*it); 00372 // if( !p->isType(KST_KServiceGroup) && !p->isType(KST_KService)) 00373 // continue; 00374 bool noDisplay = p->isType(KST_KServiceGroup) ? 00375 static_cast<KServiceGroup *>(p)->noDisplay() : 00376 static_cast<KService *>(p)->noDisplay(); 00377 if (excludeNoDisplay && noDisplay) 00378 continue; 00379 bool SuSEunimportant = p->isType(KST_KService) && 00380 static_cast<KService *>(p)->SuSEunimportant(); 00381 if (excludeSuSEunimportant && SuSEunimportant) 00382 continue; 00383 00384 // Choose the right list 00385 KSortableValueList<SPtr,TQCString> & list = p->isType(KST_KServiceGroup) ? glist : slist; 00386 TQString name; 00387 if (p->isType(KST_KServiceGroup)) 00388 name = static_cast<KServiceGroup *>(p)->caption(); 00389 else if (sortByGenericName) 00390 name = static_cast<KService *>(p)->genericName() + " " + p->name(); 00391 else 00392 name = p->name() + " " + static_cast<KService *>(p)->genericName(); 00393 00394 TQCString key( name.length() * 4 + 1 ); 00395 // strxfrm() crashes on Solaris 00396 #ifndef USE_SOLARIS 00397 // maybe it'd be better to use wcsxfrm() where available 00398 size_t ln = strxfrm( key.data(), name.local8Bit().data(), key.size()); 00399 if( ln != size_t( -1 )) 00400 { 00401 if( ln >= key.size()) 00402 { // didn't fit? 00403 key.resize( ln + 1 ); 00404 if( strxfrm( key.data(), name.local8Bit().data(), key.size()) == size_t( -1 )) 00405 key = name.local8Bit(); 00406 } 00407 } 00408 else 00409 #endif 00410 { 00411 key = name.local8Bit(); 00412 } 00413 list.insert(key,SPtr(*it)); 00414 } 00415 00416 return group->SuSEsortEntries( slist, glist, excludeNoDisplay, allowSeparators ); 00417 } 00418 00419 KServiceGroup::List 00420 KServiceGroup::SuSEsortEntries( KSortableValueList<SPtr,TQCString> slist, KSortableValueList<SPtr,TQCString> glist, bool excludeNoDisplay, bool allowSeparators ) 00421 { 00422 KServiceGroup *group = this; 00423 00424 // Now sort 00425 slist.sort(); 00426 glist.sort(); 00427 00428 if (d->sortOrder.isEmpty()) 00429 { 00430 d->sortOrder << ":M"; 00431 d->sortOrder << ":F"; 00432 d->sortOrder << ":OIH IL[4]"; //just inline header 00433 } 00434 00435 TQString rp = relPath(); 00436 if(rp == "/") rp = TQString::null; 00437 00438 // Iterate through the sort spec list. 00439 // If an entry gets mentioned explicitly, we remove it from the sorted list 00440 for (TQStringList::ConstIterator it(d->sortOrder.begin()); it != d->sortOrder.end(); ++it) 00441 { 00442 const TQString &item = *it; 00443 if (item.isEmpty()) continue; 00444 if (item[0] == '/') 00445 { 00446 TQString groupPath = rp + item.mid(1) + "/"; 00447 // Remove entry from sorted list of services. 00448 for(KSortableValueList<SPtr,TQCString>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2) 00449 { 00450 KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)((*it2).value())); 00451 if (group->relPath() == groupPath) 00452 { 00453 glist.remove(it2); 00454 break; 00455 } 00456 } 00457 } 00458 else if (item[0] != ':') 00459 { 00460 // Remove entry from sorted list of services. 00461 // TODO: Remove item from sortOrder-list if not found 00462 // TODO: This prevents duplicates 00463 for(KSortableValueList<SPtr,TQCString>::Iterator it2 = slist.begin(); it2 != slist.end(); ++it2) 00464 { 00465 if (!(*it2).value()->isType(KST_KService)) 00466 continue; 00467 KService *service = (KService *)((KSycocaEntry *)((*it2).value())); 00468 if (service->menuId() == item) 00469 { 00470 slist.remove(it2); 00471 break; 00472 } 00473 } 00474 } 00475 } 00476 00477 List sorted; 00478 00479 bool needSeparator = false; 00480 // Iterate through the sort spec list. 00481 // Add the entries to the list according to the sort spec. 00482 for (TQStringList::ConstIterator it(d->sortOrder.begin()); it != d->sortOrder.end(); ++it) 00483 { 00484 const TQString &item = *it; 00485 if (item.isEmpty()) continue; 00486 if (item[0] == ':') 00487 { 00488 // Special condition... 00489 if (item == ":S") 00490 { 00491 if (allowSeparators) 00492 needSeparator = true; 00493 } 00494 else if ( item.contains( ":O" ) ) 00495 { 00496 //todo parse attribute: 00497 TQString tmp( item ); 00498 tmp = tmp.remove(":O"); 00499 TQStringList optionAttribute = TQStringList::split(" ",tmp); 00500 if( optionAttribute.count()==0) 00501 optionAttribute.append(tmp); 00502 bool showEmptyMenu = false; 00503 bool showInline = false; 00504 bool showInlineHeader = false; 00505 bool showInlineAlias = false; 00506 int inlineValue = -1; 00507 00508 for ( TQStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 ) 00509 { 00510 parseAttribute( *it3, showEmptyMenu, showInline, showInlineHeader, showInlineAlias, inlineValue ); 00511 } 00512 for(KSortableValueList<SPtr,TQCString>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2) 00513 { 00514 KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)(*it2).value()); 00515 group->setShowEmptyMenu( showEmptyMenu ); 00516 group->setAllowInline( showInline ); 00517 group->setShowInlineHeader( showInlineHeader ); 00518 group->setInlineAlias( showInlineAlias ); 00519 group->setInlineValue( inlineValue ); 00520 } 00521 00522 } 00523 else if (item == ":M") 00524 { 00525 // Add sorted list of sub-menus 00526 for(KSortableValueList<SPtr,TQCString>::Iterator it2 = glist.begin(); it2 != glist.end(); ++it2) 00527 { 00528 addItem(sorted, (*it2).value(), needSeparator); 00529 } 00530 } 00531 else if (item == ":F") 00532 { 00533 // Add sorted list of services 00534 for(KSortableValueList<SPtr,TQCString>::Iterator it2 = slist.begin(); it2 != slist.end(); ++it2) 00535 { 00536 addItem(sorted, (*it2).value(), needSeparator); 00537 } 00538 } 00539 else if (item == ":A") 00540 { 00541 // Add sorted lists of services and submenus 00542 KSortableValueList<SPtr,TQCString>::Iterator it_s = slist.begin(); 00543 KSortableValueList<SPtr,TQCString>::Iterator it_g = glist.begin(); 00544 00545 while(true) 00546 { 00547 if (it_s == slist.end()) 00548 { 00549 if (it_g == glist.end()) 00550 break; // Done 00551 00552 // Insert remaining sub-menu 00553 addItem(sorted, (*it_g).value(), needSeparator); 00554 it_g++; 00555 } 00556 else if (it_g == glist.end()) 00557 { 00558 // Insert remaining service 00559 addItem(sorted, (*it_s).value(), needSeparator); 00560 it_s++; 00561 } 00562 else if ((*it_g).index() < (*it_s).index()) 00563 { 00564 // Insert sub-menu first 00565 addItem(sorted, (*it_g).value(), needSeparator); 00566 it_g++; 00567 } 00568 else 00569 { 00570 // Insert service first 00571 addItem(sorted, (*it_s).value(), needSeparator); 00572 it_s++; 00573 } 00574 } 00575 } 00576 } 00577 else if (item[0] == '/') 00578 { 00579 TQString groupPath = rp + item.mid(1) + "/"; 00580 00581 for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2) 00582 { 00583 if (!(*it2)->isType(KST_KServiceGroup)) 00584 continue; 00585 KServiceGroup *group = (KServiceGroup *)((KSycocaEntry *)(*it2)); 00586 if (group->relPath() == groupPath) 00587 { 00588 if (!excludeNoDisplay || !group->noDisplay()) 00589 { 00590 const TQString &nextItem = *( ++it ); 00591 if ( nextItem.startsWith( ":O" ) ) 00592 { 00593 TQString tmp( nextItem ); 00594 tmp = tmp.remove(":O"); 00595 TQStringList optionAttribute = TQStringList::split(" ",tmp); 00596 if( optionAttribute.count()==0) 00597 optionAttribute.append(tmp); 00598 bool bShowEmptyMenu = false; 00599 bool bShowInline = false; 00600 bool bShowInlineHeader = false; 00601 bool bShowInlineAlias = false; 00602 int inlineValue = -1; 00603 for ( TQStringList::Iterator it3 = optionAttribute.begin(); it3 != optionAttribute.end(); ++it3 ) 00604 { 00605 parseAttribute( *it3 , bShowEmptyMenu, bShowInline, bShowInlineHeader, bShowInlineAlias , inlineValue ); 00606 group->setShowEmptyMenu( bShowEmptyMenu ); 00607 group->setAllowInline( bShowInline ); 00608 group->setShowInlineHeader( bShowInlineHeader ); 00609 group->setInlineAlias( bShowInlineAlias ); 00610 group->setInlineValue( inlineValue ); 00611 } 00612 } 00613 else 00614 it--; 00615 00616 addItem(sorted, (group), needSeparator); 00617 } 00618 break; 00619 } 00620 } 00621 } 00622 else 00623 { 00624 for (List::ConstIterator it2(group->m_serviceList.begin()); it2 != group->m_serviceList.end(); ++it2) 00625 { 00626 if (!(*it2)->isType(KST_KService)) 00627 continue; 00628 KService *service = (KService *)((KSycocaEntry *)(*it2)); 00629 if (service->menuId() == item) 00630 { 00631 if (!excludeNoDisplay || !service->noDisplay()) 00632 addItem(sorted, (*it2), needSeparator); 00633 break; 00634 } 00635 } 00636 } 00637 } 00638 00639 return sorted; 00640 } 00641 00642 void KServiceGroup::parseAttribute( const TQString &item , bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias , int &inlineValue ) 00643 { 00644 if( item == "ME") //menu empty 00645 showEmptyMenu=true; 00646 else if ( item == "NME") //not menu empty 00647 showEmptyMenu=false; 00648 else if( item == "I") //inline menu ! 00649 showInline = true; 00650 else if ( item == "NI") //not inline menu! 00651 showInline = false; 00652 else if( item == "IH") //inline header! 00653 showInlineHeader= true; 00654 else if ( item == "NIH") //not inline header! 00655 showInlineHeader = false; 00656 else if( item == "IA") //inline alias! 00657 showInlineAlias = true; 00658 else if ( item == "NIA") //not inline alias! 00659 showInlineAlias = false; 00660 else if( ( item ).contains( "IL" )) //inline limite! 00661 { 00662 TQString tmp( item ); 00663 tmp = tmp.remove( "IL[" ); 00664 tmp = tmp.remove( "]" ); 00665 bool ok; 00666 int _inlineValue = tmp.toInt(&ok); 00667 if ( !ok ) //error 00668 _inlineValue = -1; 00669 inlineValue = _inlineValue; 00670 } 00671 else 00672 kdDebug()<<" This attribute is not supported :"<<item<<endl; 00673 } 00674 00675 void KServiceGroup::setLayoutInfo(const TQStringList &layout) 00676 { 00677 d->sortOrder = layout; 00678 } 00679 00680 TQStringList KServiceGroup::layoutInfo() const 00681 { 00682 return d->sortOrder; 00683 } 00684 00685 KServiceGroup::Ptr 00686 KServiceGroup::baseGroup( const TQString & _baseGroupName ) 00687 { 00688 return KServiceGroupFactory::self()->findBaseGroup(_baseGroupName, true); 00689 } 00690 00691 KServiceGroup::Ptr 00692 KServiceGroup::root() 00693 { 00694 return KServiceGroupFactory::self()->findGroupByDesktopPath("/", true); 00695 } 00696 00697 KServiceGroup::Ptr 00698 KServiceGroup::group(const TQString &relPath) 00699 { 00700 if (relPath.isEmpty()) return root(); 00701 return KServiceGroupFactory::self()->findGroupByDesktopPath(relPath, true); 00702 } 00703 00704 KServiceGroup::Ptr 00705 KServiceGroup::childGroup(const TQString &parent) 00706 { 00707 return KServiceGroupFactory::self()->findGroupByDesktopPath("#parent#"+parent, true); 00708 } 00709 00710 TQString 00711 KServiceGroup::directoryEntryPath() const 00712 { 00713 return d->directoryEntryPath; 00714 } 00715 00716 00717 void KServiceGroup::virtual_hook( int id, void* data ) 00718 { KSycocaEntry::virtual_hook( id, data ); } 00719 00720 00721 KServiceSeparator::KServiceSeparator( ) 00722 : KSycocaEntry("separator") 00723 { 00724 }