kalarm

repetition.h

00001 /*
00002  *  repetition.h  -  pushbutton and dialogue to specify alarm repetition
00003  *  Program:  kalarm
00004  *  Copyright (C) 2004 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef REPETITION_H
00022 #define REPETITION_H
00023 
00024 #include <qpushbutton.h>
00025 #include <kdialogbase.h>
00026 
00027 class ButtonGroup;
00028 class RadioButton;
00029 class SpinBox;
00030 class TimeSelector;
00031 class TimePeriod;
00032 class RepetitionDlg;
00033 
00034 
00035 class RepetitionButton : public QPushButton
00036 {
00037         Q_OBJECT
00038     public:
00039         RepetitionButton(const QString& caption, bool waitForInitialisation, QWidget* parent, const char* name = 0);
00040         void           set(int interval, int count)   { mInterval = interval;  mCount = count; }
00041         void           set(int interval, int count, bool dateOnly, int maxDuration = -1);
00042         void           initialise(int interval, int count, bool dateOnly, int maxDuration = -1);   // use only after needsInitialisation() signal
00043         void           activate()               { activate(false); }
00044         int            interval() const         { return mInterval; }
00045         int            count() const            { return mCount; }
00046         virtual void   setReadOnly(bool ro)     { mReadOnly = ro; }
00047         virtual bool   isReadOnly() const       { return mReadOnly; }
00048 
00049     signals:
00050         void           needsInitialisation();   // dialog has been created and needs set() to be called
00051         void           changed();               // the repetition dialog has been edited
00052 
00053     private slots:
00054         void           slotPressed()            { activate(mWaitForInit); }
00055 
00056     private:
00057         void           activate(bool waitForInitialisation);
00058         void           displayDialog();
00059 
00060         RepetitionDlg* mDialog;
00061         int            mInterval;     // interval between repetitions, in minutes
00062         int            mCount;        // total number of repetitions, including first occurrence
00063         int            mMaxDuration;  // maximum allowed duration in minutes, or -1 for infinite
00064         bool           mDateOnly;     // hours/minutes cannot be displayed
00065         bool           mWaitForInit;  // emit needsInitialisation() when button pressed, display when initialise() called
00066         bool           mReadOnly;
00067 };
00068 
00069 
00070 class RepetitionDlg : public KDialogBase
00071 {
00072         Q_OBJECT
00073     public:
00074         RepetitionDlg(const QString& caption, bool readOnly, QWidget* parent = 0, const char* name = 0);
00075         void           setReadOnly(bool);
00076         void           set(int interval, int count, bool dateOnly = false, int maxDuration = -1);
00077         int            interval() const;     // get the interval between repetitions, in minutes
00078         int            count() const;        // get the repeat count
00079 
00080     private slots:
00081         void           typeClicked();
00082         void           intervalChanged(int);
00083         void           countChanged(int);
00084         void           durationChanged(int);
00085         void           repetitionToggled(bool);
00086 
00087     private:
00088         TimeSelector*  mTimeSelector;
00089         ButtonGroup*   mButtonGroup;
00090         RadioButton*   mCountButton;
00091         SpinBox*       mCount;
00092         RadioButton*   mDurationButton;
00093         TimePeriod*    mDuration;
00094         int            mMaxDuration;     // maximum allowed duration in minutes, or -1 for infinite
00095         bool           mDateOnly;        // hours/minutes cannot be displayed
00096         bool           mReadOnly;        // the widget is read only
00097 };
00098 
00099 #endif // REPETITION_H
KDE Home | KDE Accessibility Home | Description of Access Keys