kio Library API Documentation

kuserprofile.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Torben Weis <weis@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 as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
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 
00040 class KServiceOffer
00041 {
00042 public:
00046   KServiceOffer();
00047 
00052   KServiceOffer( const KServiceOffer& );
00053 
00062   KServiceOffer( KService::Ptr _service,
00063          int _pref, bool _default );
00064 
00069   bool operator< ( const KServiceOffer& ) const;
00075   bool allowAsDefault() const { return m_bAllowAsDefault; }
00081   int preference() const { return m_iPreference; }
00087   KService::Ptr service() const { return m_pService; }
00093   bool isValid() const { return m_iPreference >= 0; }
00094 
00095 private:
00096   int m_iPreference;
00097   bool m_bAllowAsDefault;
00098   KService::Ptr m_pService;
00099 private:
00100   class KServiceOfferPrivate;
00101 };
00102 
00117 class KServiceTypeProfile
00118 {
00119 public:
00120   typedef QValueList<KServiceOffer> OfferList;
00121 
00122   ~KServiceTypeProfile();
00123 
00130   int preference( const QString& _service ) const;
00131 
00137   bool allowAsDefault( const QString& _service ) const;
00138 
00144   OfferList offers() const;
00145 
00155   static KService::Ptr preferredService( const QString & serviceType, const QString & genericServiceType );
00156 
00165   static KServiceTypeProfile* serviceTypeProfile( const QString& servicetype, const QString & genericServiceType = QString::null );
00166 
00186   static OfferList offers( const QString& servicetype, const QString& genericServiceType = QString::null );
00187 
00192   static const QPtrList<KServiceTypeProfile>& serviceTypeProfiles() { return *s_lstProfiles; }
00193 
00197   static void clear();
00198 
00205   static void setConfigurationMode() { s_configurationMode = true; }
00209   static bool configurationMode() { return s_configurationMode; }
00210 
00211 protected:
00220   KServiceTypeProfile( const QString& servicetype,
00221                        const QString& genericServiceType = QString::null );
00222 
00231   void addService( const QString& _service, int _preference = 1, bool _allow_as_default = true );
00232 
00233 private:
00237   struct Service
00238   {
00242     int m_iPreference;
00246     bool m_bAllowAsDefault;
00247   };
00248 
00252   QMap<QString,Service> m_mapServices;
00253 
00257   QString m_strServiceType;
00258 
00262   QString m_strGenericServiceType;
00263 
00264   static void initStatic();
00265   static QPtrList<KServiceTypeProfile>* s_lstProfiles;
00266   static bool s_configurationMode;
00267 private:
00268   class KServiceTypeProfilePrivate* d;
00269 };
00270 
00271 #endif
KDE Logo
This file is part of the documentation for kio Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:33:30 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003