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