00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __kuserprofile_h__
00021 #define __kuserprofile_h__
00022
00023 #include <qmap.h>
00024 #include <qstring.h>
00025 #include <qptrlist.h>
00026 #include <qvaluelist.h>
00027
00028 #include <kservice.h>
00029
00037 class KServiceOffer
00038 {
00039 public:
00040 KServiceOffer();
00041 KServiceOffer( const KServiceOffer& );
00042 KServiceOffer( KService::Ptr _service,
00043 int _pref, bool _default );
00044
00045 bool operator< ( const KServiceOffer& ) const;
00050 bool allowAsDefault() const { return m_bAllowAsDefault; }
00054 int preference() const { return m_iPreference; }
00058 KService::Ptr service() const { return m_pService; }
00062 bool isValid() const { return m_iPreference >= 0; }
00063
00064 private:
00065 int m_iPreference;
00066 bool m_bAllowAsDefault;
00067 KService::Ptr m_pService;
00068 private:
00069 class KServiceOfferPrivate;
00070 };
00071
00076 class KServiceTypeProfile
00077 {
00078 public:
00079 typedef QValueList<KServiceOffer> OfferList;
00080
00081 ~KServiceTypeProfile();
00082
00087 int preference( const QString& _service ) const;
00088 bool allowAsDefault( const QString& _service ) const;
00089
00090 OfferList offers() const;
00091
00100 static KService::Ptr preferredService( const QString & serviceType, const QString & genericServiceType );
00101
00105 static KServiceTypeProfile* serviceTypeProfile( const QString& servicetype, const QString & genericServiceType = QString::null );
00106
00120 static OfferList offers( const QString& servicetype, const QString& genericServiceType = QString::null );
00121
00122 static const QPtrList<KServiceTypeProfile>& serviceTypeProfiles() { return *s_lstProfiles; }
00123
00127 static void clear() { delete s_lstProfiles; s_lstProfiles = 0L; }
00128
00134 static void setConfigurationMode() { s_configurationMode = true; }
00138 static bool configurationMode() { return s_configurationMode; }
00139
00140 protected:
00145 KServiceTypeProfile( const QString& _servicetype, const QString& _genericServiceType = QString::null );
00146
00150 void addService( const QString& _service, int _preference = 1, bool _allow_as_default = TRUE );
00151
00152 private:
00156 struct Service
00157 {
00161 int m_iPreference;
00165 bool m_bAllowAsDefault;
00166 };
00167
00171 QMap<QString,Service> m_mapServices;
00172
00176 QString m_strServiceType;
00177
00181 QString m_strGenericServiceType;
00182
00183 static void initStatic();
00184 static QPtrList<KServiceTypeProfile>* s_lstProfiles;
00185 static bool s_configurationMode;
00186 private:
00187 class KServiceTypeProfilePrivate* d;
00188 };
00189
00190 #endif