2 * repetitionbutton.h - pushbutton and dialog to specify alarm repetition
4 * Copyright © 2004-2007,2009-2011 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef REPETITIONBUTTON_H
22 #define REPETITIONBUTTON_H
24 #include <kalarmcal/repetition.h>
27 #include <QPushButton>
29 using namespace KAlarmCal
;
40 namespace KCalCore
{ class Duration
; }
42 namespace KCal
{ class Duration
; }
45 class RepetitionButton
: public QPushButton
49 RepetitionButton(const QString
& caption
, bool waitForInitialisation
, QWidget
* parent
);
50 void set(const Repetition
&);
51 void set(const Repetition
&, bool dateOnly
, int maxDuration
= -1);
52 void initialise(const Repetition
&, bool dateOnly
, int maxDuration
= -1); // use only after needsInitialisation() signal
53 void activate() { activate(false); }
54 Repetition
repetition() const { return mRepetition
; }
55 virtual void setReadOnly(bool ro
) { mReadOnly
= ro
; }
56 virtual bool isReadOnly() const { return mReadOnly
; }
59 void needsInitialisation(); // dialog has been created and needs set() to be called
60 void changed(); // the repetition dialog has been edited
63 void slotPressed() { activate(mWaitForInit
); }
66 void activate(bool waitForInitialisation
);
69 RepetitionDlg
* mDialog
;
70 Repetition mRepetition
; // repetition interval and count
71 int mMaxDuration
; // maximum allowed duration in minutes, or -1 for infinite
72 bool mDateOnly
; // hours/minutes cannot be displayed
73 bool mWaitForInit
; // emit needsInitialisation() when button pressed, display when initialise() called
78 class RepetitionDlg
: public KDialog
82 RepetitionDlg(const QString
& caption
, bool readOnly
, QWidget
* parent
= 0);
83 void setReadOnly(bool);
84 void set(const Repetition
&, bool dateOnly
= false, int maxDuration
= -1);
85 Repetition
repetition() const; // get the repetition interval and count
89 void countChanged(int);
91 void intervalChanged(const KCalCore::Duration
&);
92 void durationChanged(const KCalCore::Duration
&);
94 void intervalChanged(const KCal::Duration
&);
95 void durationChanged(const KCal::Duration
&);
97 void repetitionToggled(bool);
100 TimeSelector
* mTimeSelector
;
101 QGroupBox
* mButtonBox
;
102 ButtonGroup
* mButtonGroup
;
103 RadioButton
* mCountButton
;
105 RadioButton
* mDurationButton
;
106 TimePeriod
* mDuration
;
107 int mMaxDuration
; // maximum allowed duration in minutes, or -1 for infinite
108 bool mDateOnly
; // hours/minutes cannot be displayed
109 bool mReadOnly
; // the widget is read only
112 #endif // REPETITIONBUTTON_H