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 <tqptrlist.h> 00023 #include <tqstring.h> 00024 #include <tqshared.h> 00025 #include <tqdatastream.h> 00026 #include <tqvariant.h> 00027 00028 #include <kdesktopfile.h> 00029 #include <ksortablevaluelist.h> 00030 00031 #include "tdesycocaentry.h" 00032 #include "tdesycocatype.h" 00033 #include "kservice.h" 00034 00035 class KBuildServiceGroupFactory; 00036 00068 class TDEIO_EXPORT KServiceGroup : public KSycocaEntry 00069 { 00070 friend class KBuildServiceGroupFactory; 00071 K_SYCOCATYPE( KST_KServiceGroup, KSycocaEntry ) 00072 00073 public: 00074 typedef TDESharedPtr<KServiceGroup> Ptr; 00075 typedef TDESharedPtr<KSycocaEntry> SPtr; 00076 typedef TQValueList<SPtr> List; 00077 public: 00083 KServiceGroup( const TQString & name ); 00084 00090 KServiceGroup( const TQString & _fullpath, const TQString & _relpath ); 00091 00096 KServiceGroup( TQDataStream& _str, int offset, bool deep ); 00097 00098 virtual ~KServiceGroup(); 00099 00104 bool isValid() const { return true; } 00105 00110 virtual TQString name() const { return entryPath(); } 00111 00116 virtual TQString relPath() const { return entryPath(); } 00117 00122 TQString caption() const { return m_strCaption; } 00123 00129 TQString icon() const { return m_strIcon; } 00130 00136 TQString 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 TQStringList suppressGenericNames() const; 00197 00202 void setLayoutInfo(const TQStringList &layout); 00203 00207 bool SuSEshortMenu() const; 00208 bool SuSEgeneralDescription() const; 00209 00214 TQStringList layoutInfo() const; 00215 00220 virtual void load( TQDataStream& ); 00225 virtual void save( TQDataStream& ); 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 * Original API and feature kindly provided by SuSE 00250 */ 00251 virtual List SuSEentries(bool sort, bool excludeNoDisplay, bool allowSeparators, bool sortByGenericName, bool excludeSuSEunimportant = false); 00252 virtual List SuSEsortEntries( KSortableValueList<SPtr,TQCString> slist, KSortableValueList<SPtr,TQCString> glist, bool excludeNoDisplay, bool allowSeparators ); 00253 00264 TQString baseGroupName() const { return m_strBaseGroupName; } 00265 00271 TQString directoryEntryPath() const; 00272 00278 static Ptr baseGroup( const TQString &baseGroupName ); 00279 00284 static Ptr root(); 00285 00291 static Ptr group(const TQString &relPath); 00292 00300 static Ptr childGroup(const TQString &parent); 00301 00306 void parseAttribute( const TQString &item , bool &showEmptyMenu, bool &showInline, bool &showInlineHeader, bool & showInlineAlias ,int &inlineValue ); 00307 00308 protected: 00313 void addEntry( KSycocaEntry *entry); 00314 00315 TQString m_strCaption; 00316 TQString m_strIcon; 00317 TQString m_strComment; 00318 00319 List m_serviceList; 00320 bool m_bDeep; 00321 TQString 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 TDEIO_EXPORT KServiceSeparator : public KSycocaEntry 00331 { 00332 K_SYCOCATYPE( KST_KServiceSeparator, KSycocaEntry ) 00333 00334 public: 00335 typedef TDESharedPtr<KServiceSeparator> Ptr; 00336 public: 00341 KServiceSeparator(); 00342 00343 bool isValid() const { return true; } 00344 00345 // Dummy 00346 virtual TQString name() const { return "separator"; } 00347 // Dummy 00348 virtual void load( TQDataStream& ) { }; 00349 // Dummy 00350 virtual void save( TQDataStream& ) { }; 00351 }; 00352 00353 #endif