libkdepim Library API Documentation

kprefsdialog.h

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program 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
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 #ifndef _KPREFSDIALOG_H
00024 #define _KPREFSDIALOG_H
00025 // $Id: kprefsdialog.h,v 1.3 2002/09/01 22:56:37 cumming Exp $
00026 
00027 #include <qptrlist.h>
00028 #include <qlineedit.h>
00029 
00030 #include <kdialogbase.h>
00031 
00032 class KPrefs;
00033 class KPrefsDialog;
00034 
00035 class KColorButton;
00036 class QCheckBox;
00037 class QLabel;
00038 class QSpinBox;
00039 class QButtonGroup;
00040 
00049 class KPrefsWid
00050 {
00051   public:
00056     virtual void readConfig() = 0;
00061     virtual void writeConfig() = 0;
00062 };
00063 
00070 class KPrefsWidBool : public KPrefsWid
00071 {
00072   public:
00080     KPrefsWidBool(const QString &text,bool *reference,QWidget *parent);
00081     
00085     QCheckBox *checkBox();
00086     
00087     void readConfig();
00088     void writeConfig();
00089     
00090   private:
00091     bool *mReference;
00092     
00093     QCheckBox *mCheck;
00094 };
00095 
00102 class KPrefsWidTime : public KPrefsWid
00103 {
00104   public:
00112     KPrefsWidTime(const QString &text,int *reference,QWidget *parent);
00113     
00117     QLabel *label();
00121     QSpinBox *spinBox();
00122     
00123     void readConfig();
00124     void writeConfig();
00125     
00126   private:
00127     int *mReference;
00128     
00129     QLabel *mLabel;
00130     QSpinBox *mSpin;
00131 };
00132 
00139 class KPrefsWidColor : public QObject, public KPrefsWid
00140 {
00141     Q_OBJECT
00142   public:
00151     KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent);
00155     ~KPrefsWidColor();
00156     
00160     QLabel *label();
00164     KColorButton *button();
00165     
00166     void readConfig();
00167     void writeConfig();
00168     
00169   private:
00170     QColor *mReference;
00171     
00172     QLabel *mLabel;
00173     KColorButton *mButton;
00174 };
00175 
00182 class KPrefsWidFont : public QObject, public KPrefsWid
00183 {
00184     Q_OBJECT
00185   public:
00194     KPrefsWidFont(const QString &sampleText,const QString &labelText,
00195                   QFont *reference,QWidget *parent);
00199     ~KPrefsWidFont();
00200     
00204     QLabel *label();
00208     QFrame *preview();
00212     QPushButton *button();
00213     
00214     void readConfig();
00215     void writeConfig();
00216 
00217   protected slots:
00218     void selectFont();
00219     
00220   private:
00221     QFont *mReference;
00222     
00223     QLabel *mLabel;
00224     QLabel *mPreview;
00225     QPushButton *mButton;
00226 };
00227 
00238 class KPrefsWidRadios : public KPrefsWid
00239 {
00240   public:
00249     KPrefsWidRadios(const QString &text,int *reference,QWidget *parent);
00250     virtual ~KPrefsWidRadios();
00251 
00257     void addRadio(const QString &text);
00258     
00262     QButtonGroup *groupBox();
00263     
00264     void readConfig();
00265     void writeConfig();
00266     
00267   private:
00268     int *mReference;
00269 
00270     QButtonGroup *mBox;
00271 };
00272 
00273 
00280 class KPrefsWidString : public KPrefsWid
00281 {
00282   public:
00290     KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
00294     virtual ~KPrefsWidString();
00295 
00299     QLabel *label();
00303     QLineEdit *lineEdit();
00304     
00305     void readConfig();
00306     void writeConfig();
00307     
00308   private:
00309     QString *mReference;
00310 
00311     QLabel *mLabel;
00312     QLineEdit *mEdit;
00313 };
00314 
00315 
00328 class KPrefsDialog : public KDialogBase
00329 {
00330     Q_OBJECT
00331   public:
00340     KPrefsDialog(KPrefs *prefs,QWidget *parent=0,char *name=0,bool modal=false);
00344     virtual ~KPrefsDialog();
00345 
00349     void addWid(KPrefsWid *);
00357     KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
00365     KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
00373     KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
00381     KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
00389     KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
00397     KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
00406     KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
00407                               QFont *reference,QWidget *parent);
00408 
00409   public slots:
00411     void setDefaults();
00412   
00414     void readConfig();
00415 
00417     void writeConfig();
00418 
00419   signals:
00421     void configChanged();
00422 
00423   protected slots:
00425     void slotApply();  
00426 
00428     void slotOk();
00429   
00431     void slotDefault();
00432   
00433   protected:
00435     virtual void usrReadConfig() {}
00437     virtual void usrWriteConfig() {}
00438 
00439   private:
00440     KPrefs *mPrefs;
00441 
00442     QPtrList<KPrefsWid> mPrefsWids;
00443 };
00444 
00445 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:00 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001