summaryrefslogtreecommitdiffabout
path: root/libkdepim/kprefswidget.h
Unidiff
Diffstat (limited to 'libkdepim/kprefswidget.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kprefswidget.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/libkdepim/kprefswidget.h b/libkdepim/kprefswidget.h
index 8543a39..9de1be5 100644
--- a/libkdepim/kprefswidget.h
+++ b/libkdepim/kprefswidget.h
@@ -1,136 +1,138 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23// $Id$ 23// $Id$
24 24
25#ifndef _KPREFSWIDGET_H 25#ifndef _KPREFSWIDGET_H
26#define _KPREFSWIDGET_H 26#define _KPREFSWIDGET_H
27 27
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qwidget.h> 32#include <qwidget.h>
33//Added by qt3to4:
34#include <QLabel>
33 35
34class KPrefs; 36class KPrefs;
35 37
36class KColorButton; 38class KColorButton;
37class QCheckBox; 39class QCheckBox;
38class QLabel; 40class QLabel;
39class QSpinBox; 41class QSpinBox;
40class QButtonGroup; 42class Q3ButtonGroup;
41 43
42/** 44/**
43 @short Base class for widgets used by @ref KPrefsDialog. 45 @short Base class for widgets used by @ref KPrefsDialog.
44 @author Cornelius Schumacher 46 @author Cornelius Schumacher
45 @see KPrefsDialog 47 @see KPrefsDialog
46 48
47 This class provides the interface for the preferences widgets used by 49 This class provides the interface for the preferences widgets used by
48 KPrefsDialog. 50 KPrefsDialog.
49*/ 51*/
50class KPrefsWid : public QObject 52class KPrefsWid : public QObject
51{ 53{
52 Q_OBJECT 54 Q_OBJECT
53 public: 55 public:
54 /** 56 /**
55 This function is called to read value of the setting from the 57 This function is called to read value of the setting from the
56 stored configuration and display it in the widget. 58 stored configuration and display it in the widget.
57 */ 59 */
58 virtual void readConfig() = 0; 60 virtual void readConfig() = 0;
59 /** 61 /**
60 This function is called to write the current setting of the widget to the 62 This function is called to write the current setting of the widget to the
61 stored configuration. 63 stored configuration.
62 */ 64 */
63 virtual void writeConfig() = 0; 65 virtual void writeConfig() = 0;
64 66
65 //connect to this signal if you want to be notified of changes 67 //connect to this signal if you want to be notified of changes
66 signals: 68 signals:
67 void modified(); 69 void modified();
68 70
69}; 71};
70 72
71/** 73/**
72 @short Widget for bool settings in @ref KPrefsDialog. 74 @short Widget for bool settings in @ref KPrefsDialog.
73 75
74 This class provides a widget for configuring bool values. It is meant to be 76 This class provides a widget for configuring bool values. It is meant to be
75 used by KPrefsDialog. The user is responsible for the layout management. 77 used by KPrefsDialog. The user is responsible for the layout management.
76*/ 78*/
77class KPrefsWidBool : public KPrefsWid 79class KPrefsWidBool : public KPrefsWid
78{ 80{
79 public: 81 public:
80 /** 82 /**
81 Create a bool widget consisting of a QCheckbox. 83 Create a bool widget consisting of a QCheckbox.
82 84
83 @param text Text of QCheckBox. 85 @param text Text of QCheckBox.
84 @param reference Pointer to variable read and written by this widget. 86 @param reference Pointer to variable read and written by this widget.
85 @param parent Parent widget. 87 @param parent Parent widget.
86 */ 88 */
87 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent); 89 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent);
88 90
89 /** 91 /**
90 Return the QCheckbox used by this widget. 92 Return the QCheckbox used by this widget.
91 */ 93 */
92 QCheckBox *checkBox(); 94 QCheckBox *checkBox();
93 95
94 void readConfig(); 96 void readConfig();
95 void writeConfig(); 97 void writeConfig();
96 98
97 private: 99 private:
98 bool *mReference; 100 bool *mReference;
99 101
100 QCheckBox *mCheck; 102 QCheckBox *mCheck;
101}; 103};
102 104
103/** 105/**
104 @short Widget for time settings in @ref KPrefsDialog. 106 @short Widget for time settings in @ref KPrefsDialog.
105 107
106 This class provides a widget for configuring time values. It is meant to be 108 This class provides a widget for configuring time values. It is meant to be
107 used by KPrefsDialog. The user is responsible for the layout management. 109 used by KPrefsDialog. The user is responsible for the layout management.
108*/ 110*/
109class KPrefsWidTime : public KPrefsWid 111class KPrefsWidTime : public KPrefsWid
110{ 112{
111 public: 113 public:
112 /** 114 /**
113 Create a time widget consisting of a label and a spinbox. 115 Create a time widget consisting of a label and a spinbox.
114 116
115 @param text Text of Label. 117 @param text Text of Label.
116 @param reference Pointer to variable read and written by this widget. 118 @param reference Pointer to variable read and written by this widget.
117 @param parent Parent widget. 119 @param parent Parent widget.
118 */ 120 */
119 KPrefsWidTime(const QString &text,int *reference,QWidget *parent); 121 KPrefsWidTime(const QString &text,int *reference,QWidget *parent);
120 122
121 /** 123 /**
122 Return QLabel used by this widget. 124 Return QLabel used by this widget.
123 */ 125 */
124 QLabel *label(); 126 QLabel *label();
125 /** 127 /**
126 Return QSpinBox used by this widget. 128 Return QSpinBox used by this widget.
127 */ 129 */
128 QSpinBox *spinBox(); 130 QSpinBox *spinBox();
129 131
130 void readConfig(); 132 void readConfig();
131 void writeConfig(); 133 void writeConfig();
132 134
133 private: 135 private:
134 int *mReference; 136 int *mReference;
135 137
136 QLabel *mLabel; 138 QLabel *mLabel;
@@ -172,284 +174,284 @@ class KPrefsWidColor : public KPrefsWid
172 void readConfig(); 174 void readConfig();
173 void writeConfig(); 175 void writeConfig();
174 176
175 private: 177 private:
176 QColor *mReference; 178 QColor *mReference;
177 179
178 QLabel *mLabel; 180 QLabel *mLabel;
179 KColorButton *mButton; 181 KColorButton *mButton;
180}; 182};
181 183
182/** 184/**
183 @short Widget for font settings in @ref KPrefsDialog. 185 @short Widget for font settings in @ref KPrefsDialog.
184 186
185 This class provides a widget for configuring font values. It is meant to be 187 This class provides a widget for configuring font values. It is meant to be
186 used by KPrefsDialog. The user is responsible for the layout management. 188 used by KPrefsDialog. The user is responsible for the layout management.
187*/ 189*/
188class KPrefsWidFont : public KPrefsWid 190class KPrefsWidFont : public KPrefsWid
189{ 191{
190 Q_OBJECT 192 Q_OBJECT
191 public: 193 public:
192 /** 194 /**
193 Create a font widget consisting of a test field and a button for opening 195 Create a font widget consisting of a test field and a button for opening
194 a font dialog. 196 a font dialog.
195 197
196 @param label Text of label. 198 @param label Text of label.
197 @param reference Pointer to variable read and written by this widget. 199 @param reference Pointer to variable read and written by this widget.
198 @param parent Parent widget. 200 @param parent Parent widget.
199 */ 201 */
200 KPrefsWidFont(const QString &sampleText,const QString &labelText, 202 KPrefsWidFont(const QString &sampleText,const QString &labelText,
201 QFont *reference,QWidget *parent); 203 QFont *reference,QWidget *parent);
202 /** 204 /**
203 Destruct font setting widget. 205 Destruct font setting widget.
204 */ 206 */
205 ~KPrefsWidFont(); 207 ~KPrefsWidFont();
206 208
207 /** 209 /**
208 Return label. 210 Return label.
209 */ 211 */
210 QLabel *label(); 212 QLabel *label();
211 /** 213 /**
212 Return QFrame used as preview field. 214 Return QFrame used as preview field.
213 */ 215 */
214 QLabel *preview(); 216 QLabel *preview();
215 /** 217 /**
216 Return button opening the font dialog. 218 Return button opening the font dialog.
217 */ 219 */
218 QPushButton *button(); 220 QPushButton *button();
219 221
220 void readConfig(); 222 void readConfig();
221 void writeConfig(); 223 void writeConfig();
222 224
223 protected slots: 225 protected slots:
224 void selectFont(); 226 void selectFont();
225 227
226 private: 228 private:
227 QFont *mReference; 229 QFont *mReference;
228 230
229 QLabel *mLabel; 231 QLabel *mLabel;
230 QLabel *mPreview; 232 QLabel *mPreview;
231 QPushButton *mButton; 233 QPushButton *mButton;
232}; 234};
233 235
234/** 236/**
235 @short Widget for settings represented by a group of radio buttons in 237 @short Widget for settings represented by a group of radio buttons in
236 @ref KPrefsDialog. 238 @ref KPrefsDialog.
237 239
238 This class provides a widget for configuring selections. It is meant to be 240 This class provides a widget for configuring selections. It is meant to be
239 used by KPrefsDialog. The user is responsible for the layout management. The 241 used by KPrefsDialog. The user is responsible for the layout management. The
240 setting is interpreted as an int value, corresponding to the position of the 242 setting is interpreted as an int value, corresponding to the position of the
241 radio button. The position of the button is defined by the sequence of @ref 243 radio button. The position of the button is defined by the sequence of @ref
242 addRadio() calls, starting with 0. 244 addRadio() calls, starting with 0.
243*/ 245*/
244class KPrefsWidRadios : public KPrefsWid 246class KPrefsWidRadios : public KPrefsWid
245{ 247{
246 public: 248 public:
247 /** 249 /**
248 Create a widget for selection of an option. It consists of a box with 250 Create a widget for selection of an option. It consists of a box with
249 several radio buttons. 251 several radio buttons.
250 252
251 @param text Text of main box. 253 @param text Text of main box.
252 @param reference Pointer to variable read and written by this widget. 254 @param reference Pointer to variable read and written by this widget.
253 @param parent Parent widget. 255 @param parent Parent widget.
254 */ 256 */
255 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent); 257 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent);
256 virtual ~KPrefsWidRadios(); 258 virtual ~KPrefsWidRadios();
257 259
258 /** 260 /**
259 Add a radio button. 261 Add a radio button.
260 262
261 @param text Text of the button. 263 @param text Text of the button.
262 */ 264 */
263 void addRadio(const QString &text); 265 void addRadio(const QString &text);
264 266
265 /** 267 /**
266 Return the box widget used by this widget. 268 Return the box widget used by this widget.
267 */ 269 */
268 QButtonGroup *groupBox(); 270 Q3ButtonGroup *groupBox();
269 271
270 void readConfig(); 272 void readConfig();
271 void writeConfig(); 273 void writeConfig();
272 274
273 private: 275 private:
274 int *mReference; 276 int *mReference;
275 277
276 QButtonGroup *mBox; 278 Q3ButtonGroup *mBox;
277}; 279};
278 280
279 281
280/** 282/**
281 @short Widget for string settings in @ref KPrefsDialog. 283 @short Widget for string settings in @ref KPrefsDialog.
282 284
283 This class provides a widget for configuring string values. It is meant to be 285 This class provides a widget for configuring string values. It is meant to be
284 used by KPrefsDialog. The user is responsible for the layout management. 286 used by KPrefsDialog. The user is responsible for the layout management.
285*/ 287*/
286class KPrefsWidString : public KPrefsWid 288class KPrefsWidString : public KPrefsWid
287{ 289{
288 public: 290 public:
289 /** 291 /**
290 Create a string widget consisting of a test label and a line edit. 292 Create a string widget consisting of a test label and a line edit.
291 293
292 @param text Text of label. 294 @param text Text of label.
293 @param reference Pointer to variable read and written by this widget. 295 @param reference Pointer to variable read and written by this widget.
294 @param parent Parent widget. 296 @param parent Parent widget.
295 */ 297 */
296 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); 298 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
297 /** 299 /**
298 Destructor. 300 Destructor.
299 */ 301 */
300 virtual ~KPrefsWidString(); 302 virtual ~KPrefsWidString();
301 303
302 /** 304 /**
303 Return label used by this widget. 305 Return label used by this widget.
304 */ 306 */
305 QLabel *label(); 307 QLabel *label();
306 /** 308 /**
307 Return QLineEdit used by this widget. 309 Return QLineEdit used by this widget.
308 */ 310 */
309 QLineEdit *lineEdit(); 311 QLineEdit *lineEdit();
310 312
311 void readConfig(); 313 void readConfig();
312 void writeConfig(); 314 void writeConfig();
313 315
314 private: 316 private:
315 QString *mReference; 317 QString *mReference;
316 318
317 QLabel *mLabel; 319 QLabel *mLabel;
318 QLineEdit *mEdit; 320 QLineEdit *mEdit;
319}; 321};
320 322
321 323
322/** 324/**
323 @short Base class for a preferences widget. 325 @short Base class for a preferences widget.
324 326
325 This class provides the framework for a preferences widget. You have to 327 This class provides the framework for a preferences widget. You have to
326 subclass it and add the code to create the actual configuration widgets and 328 subclass it and add the code to create the actual configuration widgets and
327 do the layout management. 329 do the layout management.
328 330
329 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For 331 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For
330 these widgets the reading, writing and setting to default values is handled 332 these widgets the reading, writing and setting to default values is handled
331 automatically. Custom widgets have to be handled in the functions @ref 333 automatically. Custom widgets have to be handled in the functions @ref
332 usrReadConfig() and @ref usrWriteConfig(). 334 usrReadConfig() and @ref usrWriteConfig().
333*/ 335*/
334class KPrefsWidget : public QWidget 336class KPrefsWidget : public QWidget
335{ 337{
336 Q_OBJECT 338 Q_OBJECT
337 public: 339 public:
338 /** 340 /**
339 Create a KPrefsDialog for a KPrefs object. 341 Create a KPrefsDialog for a KPrefs object.
340 342
341 @param prefs KPrefs object used to access te configuration. 343 @param prefs KPrefs object used to access te configuration.
342 @param parent Parent widget. 344 @param parent Parent widget.
343 @param name Widget name. 345 @param name Widget name.
344 */ 346 */
345 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0); 347 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0);
346 /** 348 /**
347 Destructor. 349 Destructor.
348 */ 350 */
349 virtual ~KPrefsWidget(); 351 virtual ~KPrefsWidget();
350 352
351 /** 353 /**
352 Register a custom KPrefsWid object. 354 Register a custom KPrefsWid object.
353 */ 355 */
354 void addWid(KPrefsWid *); 356 void addWid(KPrefsWid *);
355 /** 357 /**
356 Register a @ref KPrefsWidBool object. 358 Register a @ref KPrefsWidBool object.
357 359
358 @param text Text of bool widget. 360 @param text Text of bool widget.
359 @param reference Reference to variable storing the setting. 361 @param reference Reference to variable storing the setting.
360 @param parent Parent widget. 362 @param parent Parent widget.
361 */ 363 */
362 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); 364 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
363 /** 365 /**
364 Register a @ref KPrefsWidTime object. 366 Register a @ref KPrefsWidTime object.
365 367
366 @param text Text of time widget. 368 @param text Text of time widget.
367 @param reference Reference to variable storing the setting. 369 @param reference Reference to variable storing the setting.
368 @param parent Parent widget. 370 @param parent Parent widget.
369 */ 371 */
370 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); 372 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
371 /** 373 /**
372 Register a @ref KPrefsWidColor object. 374 Register a @ref KPrefsWidColor object.
373 375
374 @param text Text of color widget. 376 @param text Text of color widget.
375 @param reference Reference to variable storing the setting. 377 @param reference Reference to variable storing the setting.
376 @param parent Parent widget. 378 @param parent Parent widget.
377 */ 379 */
378 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); 380 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
379 /** 381 /**
380 Register a @ref KPrefsWidRadios object. 382 Register a @ref KPrefsWidRadios object.
381 383
382 @param text Text of radio button box widget. 384 @param text Text of radio button box widget.
383 @param reference Reference to variable storing the setting. 385 @param reference Reference to variable storing the setting.
384 @param parent Parent widget. 386 @param parent Parent widget.
385 */ 387 */
386 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); 388 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
387 /** 389 /**
388 Register a @ref KPrefsWidString object. 390 Register a @ref KPrefsWidString object.
389 391
390 @param text Text of string widget. 392 @param text Text of string widget.
391 @param reference Reference to variable storing the setting. 393 @param reference Reference to variable storing the setting.
392 @param parent Parent widget. 394 @param parent Parent widget.
393 */ 395 */
394 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent); 396 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
395 /** 397 /**
396 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password. 398 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password.
397 399
398 @param text Text of string widget. 400 @param text Text of string widget.
399 @param reference Reference to variable storing the setting. 401 @param reference Reference to variable storing the setting.
400 @param parent Parent widget. 402 @param parent Parent widget.
401 */ 403 */
402 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); 404 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
403 /** 405 /**
404 Register a @ref KPrefsWidFont object. 406 Register a @ref KPrefsWidFont object.
405 407
406 @param sampleText Sample text of font widget. 408 @param sampleText Sample text of font widget.
407 @param buttonText Button text of font widget. 409 @param buttonText Button text of font widget.
408 @param reference Reference to variable storing the setting. 410 @param reference Reference to variable storing the setting.
409 @param parent Parent widget. 411 @param parent Parent widget.
410 */ 412 */
411 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText, 413 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
412 QFont *reference,QWidget *parent); 414 QFont *reference,QWidget *parent);
413 415
414 public slots: 416 public slots:
415 /** Set all widgets to default values. */ 417 /** Set all widgets to default values. */
416 void setDefaults(); 418 void setDefaults();
417 419
418 /** Read preferences from config file. */ 420 /** Read preferences from config file. */
419 void readConfig(); 421 void readConfig();
420 422
421 /** Write preferences to config file. */ 423 /** Write preferences to config file. */
422 void writeConfig(); 424 void writeConfig();
423 425
424 /** connect this slot to all UI elements */ 426 /** connect this slot to all UI elements */
425 void modified(); 427 void modified();
426 428
427 signals: 429 signals:
428 /** Emitted when the a changed configuration has been stored. */ 430 /** Emitted when the a changed configuration has been stored. */
429 //US void configChanged(); 431 //US void configChanged();
430 void changed( bool ); 432 void changed( bool );
431 433
432 protected slots: 434 protected slots:
433 /** Apply changes to preferences */ 435 /** Apply changes to preferences */
434 //US void slotApply(); 436 //US void slotApply();
435 437
436 //US void accept(); 438 //US void accept();
437 /** Accept changes to preferences and close dialog */ 439 /** Accept changes to preferences and close dialog */
438 //US void slotOk(); 440 //US void slotOk();
439 441
440 /** Set preferences to default values */ 442 /** Set preferences to default values */
441 //US void slotDefault(); 443 //US void slotDefault();
442 444
443 protected: 445 protected:
444 /** Implement this to read custom configuration widgets. */ 446 /** Implement this to read custom configuration widgets. */
445 virtual void usrReadConfig() {} 447 virtual void usrReadConfig() {}
446 /** Implement this to write custom configuration widgets. */ 448 /** Implement this to write custom configuration widgets. */
447 virtual void usrWriteConfig() {} 449 virtual void usrWriteConfig() {}
448 450
449 private: 451 private:
450 KPrefs *mPrefs; 452 KPrefs *mPrefs;
451 453
452 QPtrList<KPrefsWid> mPrefsWids; 454 Q3PtrList<KPrefsWid> mPrefsWids;
453}; 455};
454 456
455#endif 457#endif