kio
kservicetype.h
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00003 1999 Waldo Bastian <bastian@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef __kservicetype_h__ 00022 #define __kservicetype_h__ 00023 00024 #include "ksycocaentry.h" 00025 #include "kservice.h" 00026 00027 #include <qstring.h> 00028 #include <qstringlist.h> 00029 #include <qptrlist.h> 00030 #include <qmap.h> 00031 #include <qshared.h> 00032 #include <qdatastream.h> 00033 #include <qvariant.h> 00034 00035 #include <ksimpleconfig.h> 00036 00045 class KIO_EXPORT KServiceType : public KSycocaEntry 00046 { 00047 K_SYCOCATYPE( KST_KServiceType, KSycocaEntry ) 00048 00049 public: 00050 typedef KSharedPtr<KServiceType> Ptr; 00051 typedef QValueList<Ptr> List; 00052 public: 00053 00062 KServiceType( const QString & _fullpath, const QString& _name, 00063 const QString& _icon, const QString& _comment); 00064 00070 KServiceType( const QString & _fullpath ); 00071 00076 KServiceType( KDesktopFile *config); 00077 00082 KServiceType( QDataStream& _str, int offset ); 00083 00084 virtual ~KServiceType(); 00085 00094 QString icon() const { return m_strIcon; } 00095 00100 QString comment() const { return m_strComment; } 00101 00106 QString name() const { return m_strName; } 00107 00114 QString desktopEntryPath() const { return entryPath(); } 00115 00121 bool isDerived() const { return m_bDerived; } 00122 00129 QString parentServiceType() const; 00130 00136 bool inherits( const QString& servTypeName ) const; 00137 00146 virtual QVariant property( const QString& _name ) const; 00147 00152 virtual QStringList propertyNames() const; 00153 00158 bool isValid() const { return m_bValid; } 00159 00166 virtual QVariant::Type propertyDef( const QString& _name ) const; 00167 00168 virtual QStringList propertyDefNames() const; 00169 virtual const QMap<QString,QVariant::Type>& propertyDefs() const { return m_mapPropDefs; } 00170 00175 virtual void save( QDataStream& ); 00176 00181 virtual void load( QDataStream& ); 00182 00187 // gcc 2.95.x doesn't understand KServiceType::Ptr here 00188 /* KServiceType:: */ Ptr parentType(); 00193 void addService(KService::Ptr service); 00198 KService::List services(); 00199 00207 static Ptr serviceType( const QString& _name ); 00208 00217 static KService::List offers( const QString& _servicetype ); 00218 00227 static List allServiceTypes(); 00228 00229 protected: 00230 void init( KDesktopFile *config ); 00231 00232 protected: 00233 QString m_strName; 00234 QString m_strIcon; 00235 QString m_strComment; 00236 QMap<QString,QVariant> m_mapProps; 00237 QMap<QString,QVariant::Type> m_mapPropDefs; 00238 00239 bool m_bValid:1; 00240 bool m_bDerived:1; 00241 protected: 00242 virtual void virtual_hook( int id, void* data ); 00243 private: 00244 class KServiceTypePrivate; 00245 KServiceTypePrivate* d; 00246 }; 00247 00248 //QDataStream& operator>>( QDataStream& _str, KServiceType& s ); 00249 //QDataStream& operator<<( QDataStream& _str, KServiceType& s ); 00250 00251 #endif