libkdepim Library API Documentation

kprefs.h

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@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., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 #ifndef _KPREFS_H
00021 #define _KPREFS_H
00022 // $Id: kprefs.h,v 1.2 2002/08/05 10:59:54 janpascal Exp $
00023 
00024 #include <qptrlist.h>
00025 #include <qcolor.h>
00026 #include <qfont.h>
00027 #include <qstringlist.h>
00028 
00029 class KConfig;
00030 
00042 class KPrefsItem {
00043   public:
00050     KPrefsItem(const QString &group,const QString &name) :
00051       mGroup(group),mName(name) {}
00055     virtual ~KPrefsItem() {}
00056     
00061     virtual void setDefault() = 0;
00067     virtual void readConfig(KConfig *) = 0;
00072     virtual void writeConfig(KConfig *) = 0;
00073 
00074   protected:
00075     QString mGroup;
00076     QString mName;
00077 };
00078 
00130 class KPrefs {
00131   public:
00138     KPrefs(const QString &configname=QString::null);
00142     virtual ~KPrefs();
00143   
00148     void setDefaults();
00149   
00154     void readConfig();
00155 
00160     void writeConfig();
00161 
00167     static void setCurrentGroup(const QString &group);
00168 
00172     void addItem(KPrefsItem *);
00173 
00184     void addItemBool(const QString &key,bool *reference,
00185                      bool defaultValue=false);
00196     void addItemInt(const QString &key,int *reference,
00197                     int defaultValue=0);
00208     void addItemColor(const QString &key,QColor *reference,
00209                       const QColor &defaultValue=QColor(128,128,128));
00220     void addItemFont(const QString &key,QFont *reference,
00221                      const QFont &defaultValue=QFont("helvetica",12));
00232     void addItemString(const QString &key,QString *reference,
00233                        const QString &defaultValue="");
00246     void addItemPassword(const QString &key,QString *reference,
00247                          const QString &defaultValue="");
00258     void addItemStringList(const QString &key,QStringList *reference,
00259                            const QStringList &defaultValue=QStringList());
00260 
00271     void addItemIntList(const QString &key,QValueList<int> *reference,
00272                         const QValueList<int> &defaultValue=QValueList<int>());
00273 
00274   protected:
00278     virtual void usrSetDefaults() {};
00282     virtual void usrReadConfig() {};
00286     virtual void usrWriteConfig() {};
00287 
00291     KConfig *config() const;
00292 
00293   private:
00294     static QString *mCurrentGroup;
00295 
00296     KConfig *mConfig;  // pointer to KConfig object
00297 
00298     QPtrList<KPrefsItem> mItems;
00299 };
00300 
00301 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:22 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001