kservicegroup.h

00001 /* This file is part of the KDE project
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 #ifndef __kservicegroup_h__
00020 #define __kservicegroup_h__
00021 
00022 #include <qptrlist.h>
00023 #include <qstring.h>
00024 #include <qshared.h>
00025 #include <qdatastream.h>
00026 #include <qvariant.h>
00027 
00028 #include <kdesktopfile.h>
00029 #include <ksortablevaluelist.h>
00030 
00031 #include "ksycocaentry.h"
00032 #include "ksycocatype.h"
00033 #include "kservice.h"
00034 
00035 class KBuildServiceGroupFactory;
00036 
00068 class KIO_EXPORT KServiceGroup : public KSycocaEntry
00069 {
00070   friend class KBuildServiceGroupFactory;
00071   K_SYCOCATYPE( KST_KServiceGroup, KSycocaEntry )
00072 
00073 public:
00074   typedef KSharedPtr<KServiceGroup> Ptr;
00075   typedef KSharedPtr<KSycocaEntry> SPtr;
00076   typedef QValueList<SPtr> List;
00077 public:
00083   KServiceGroup( const QString & name );
00084 
00090   KServiceGroup( const QString & _fullpath, const QString & _relpath );
00091 
00096   KServiceGroup( QDataStream& _str, int offset, bool deep );
00097 
00098   virtual ~KServiceGroup();
00099 
00104   bool isValid() const { return true; }
00105 
00110   virtual QString name() const { return entryPath(); }
00111 
00116   virtual QString relPath() const { return entryPath(); }
00117 
00122   QString caption() const { return m_strCaption; }
00123 
00129   QString icon() const { return m_strIcon; }
00130 
00136   QString comment() const { return m_strComment; }
00137 
00143   int childCount();
00144 
00151   bool noDisplay() const;
00152 
00158   bool showEmptyMenu() const;
00159   void setShowEmptyMenu( bool b);
00160 
00165   bool showInlineHeader() const;
00166   void setShowInlineHeader(bool _b);
00167 
00172   bool inlineAlias() const;
00173   void setInlineAlias(bool _b);
00178   bool allowInline() const;
00179   void setAllowInline(bool _b);
00180 
00185   int inlineValue() const;
00186   void setInlineValue(int _val);
00187 
00188 
00196   QStringList suppressGenericNames() const;
00197 
00202   void setLayoutInfo(const QStringList &layout);
00203 
00207   bool SuSEshortMenu() const;
00208   bool SuSEgeneralDescription() const;
00209 
00214   QStringList layoutInfo() const;
00215 
00220   virtual void load( QDataStream& );
00225   virtual void save( QDataStream& );
00226 
00237   List entries(bool sorted, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName=false);
00238   virtual List entries(bool sorted, bool excludeNoDisplay);
00239 
00246   virtual List entries(bool sorted = false);
00247 
00248   /*
00249    * UNOFFICIAL SuSE special
00250    */
00251   virtual List SuSEentries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName, bool excludeSuSEunimportant = true);
00252   virtual List SuSEsortEntries( KSortableValueList<SPtr,QCString> slist, KSortableValueList<SPtr,QCString> glist, bool excludeNoDisplay, bool allowSeparators );
00253 
00264   QString baseGroupName() const { return m_strBaseGroupName; }
00265 
00271   QString directoryEntryPath() const;
00272 
00278   static Ptr baseGroup( const QString &baseGroupName );
00279 
00284   static Ptr root();
00285 
00291   static Ptr group(const QString &relPath);
00292 
00300   static Ptr childGroup(const QString &parent);
00301 
00306     void parseAttribute( const QString &item ,  bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias ,int &inlineValue );
00307 
00308 protected:
00313   void addEntry( KSycocaEntry *entry);
00314 
00315   QString m_strCaption;
00316   QString m_strIcon;
00317   QString m_strComment;
00318 
00319   List m_serviceList;
00320   bool m_bDeep;
00321   QString m_strBaseGroupName;
00322   int m_childCount;
00323 protected:
00324   virtual void virtual_hook( int id, void* data );
00325 private:
00326   class Private;
00327   Private* d;
00328 };
00329 
00330 class KIO_EXPORT KServiceSeparator : public KSycocaEntry
00331 {
00332   K_SYCOCATYPE( KST_KServiceSeparator, KSycocaEntry )
00333 
00334 public:
00335   typedef KSharedPtr<KServiceSeparator> Ptr;
00336 public:
00341   KServiceSeparator();
00342 
00343   bool isValid() const { return true; }
00344 
00345   // Dummy
00346   virtual QString name() const { return "separator"; }
00347   // Dummy
00348   virtual void load( QDataStream& ) { };
00349   // Dummy
00350   virtual void save( QDataStream& ) { };
00351 };
00352 
00353 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys