repetition.h
00001 /* 00002 * repetition.h - pushbutton and dialogue to specify alarm repetition 00003 * Program: kalarm 00004 * Copyright © 2004,2007 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 <tqpushbutton.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 TQPushButton 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 RepetitionButton(const TQString& caption, bool waitForInitialisation, TQWidget* parent, const char* name = 0); 00041 void set(int interval, int count); 00042 void set(int interval, int count, bool dateOnly, int maxDuration = -1); 00043 void initialise(int interval, int count, bool dateOnly, int maxDuration = -1); // use only after needsInitialisation() signal 00044 void activate() { activate(false); } 00045 int interval() const { return mInterval; } 00046 int count() const { return mCount; } 00047 virtual void setReadOnly(bool ro) { mReadOnly = ro; } 00048 virtual bool isReadOnly() const { return mReadOnly; } 00049 00050 signals: 00051 void needsInitialisation(); // dialog has been created and needs set() to be called 00052 void changed(); // the repetition dialog has been edited 00053 00054 private slots: 00055 void slotPressed() { activate(mWaitForInit); } 00056 00057 private: 00058 void activate(bool waitForInitialisation); 00059 void displayDialog(); 00060 00061 RepetitionDlg* mDialog; 00062 int mInterval; // interval between repetitions, in minutes 00063 int mCount; // total number of repetitions, including first occurrence 00064 int mMaxDuration; // maximum allowed duration in minutes, or -1 for infinite 00065 bool mDateOnly; // hours/minutes cannot be displayed 00066 bool mWaitForInit; // emit needsInitialisation() when button pressed, display when initialise() called 00067 bool mReadOnly; 00068 }; 00069 00070 00071 class RepetitionDlg : public KDialogBase 00072 { 00073 Q_OBJECT 00074 00075 public: 00076 RepetitionDlg(const TQString& caption, bool readOnly, TQWidget* parent = 0, const char* name = 0); 00077 void setReadOnly(bool); 00078 void set(int interval, int count, bool dateOnly = false, int maxDuration = -1); 00079 int interval() const; // get the interval between repetitions, in minutes 00080 int count() const; // get the repeat count 00081 00082 private slots: 00083 void typeClicked(); 00084 void intervalChanged(int); 00085 void countChanged(int); 00086 void durationChanged(int); 00087 void repetitionToggled(bool); 00088 00089 private: 00090 TimeSelector* mTimeSelector; 00091 ButtonGroup* mButtonGroup; 00092 RadioButton* mCountButton; 00093 SpinBox* mCount; 00094 RadioButton* mDurationButton; 00095 TimePeriod* mDuration; 00096 int mMaxDuration; // maximum allowed duration in minutes, or -1 for infinite 00097 bool mDateOnly; // hours/minutes cannot be displayed 00098 bool mReadOnly; // the widget is read only 00099 }; 00100 00101 #endif // REPETITION_H