• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdeio
 

tdeio/tdeio

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

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdeio/tdeio

Skip menu "tdeio/tdeio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeio/tdeio by doxygen 1.7.1
This website is maintained by Timothy Pearson.