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
;
39 namespace KCalCore
{ class Duration
; }
41 class RepetitionButton
: public QPushButton
45 RepetitionButton(const QString
& caption
, bool waitForInitialisation
, QWidget
* parent
);
46 void set(const Repetition
&);
47 void set(const Repetition
&, bool dateOnly
, int maxDuration
= -1);
48 void initialise(const Repetition
&, bool dateOnly
, int maxDuration
= -1); // use only after needsInitialisation() signal
49 void activate() { activate(false); }
50 Repetition
repetition() const { return mRepetition
; }
51 virtual void setReadOnly(bool ro
) { mReadOnly
= ro
; }
52 virtual bool isReadOnly() const { return mReadOnly
; }
55 void needsInitialisation(); // dialog has been created and needs set() to be called
56 void changed(); // the repetition dialog has been edited
59 void slotPressed() { activate(mWaitForInit
); }
62 void activate(bool waitForInitialisation
);
65 RepetitionDlg
* mDialog
;
66 Repetition mRepetition
; // repetition interval and count
67 int mMaxDuration
; // maximum allowed duration in minutes, or -1 for infinite
68 bool mDateOnly
; // hours/minutes cannot be displayed
69 bool mWaitForInit
; // Q_EMIT needsInitialisation() when button pressed, display when initialise() called
74 class RepetitionDlg
: public QDialog
78 RepetitionDlg(const QString
& caption
, bool readOnly
, QWidget
* parent
= Q_NULLPTR
);
79 void setReadOnly(bool);
80 void set(const Repetition
&, bool dateOnly
= false, int maxDuration
= -1);
81 Repetition
repetition() const; // get the repetition interval and count
85 void countChanged(int);
86 void intervalChanged(const KCalCore::Duration
&);
87 void durationChanged(const KCalCore::Duration
&);
88 void repetitionToggled(bool);
91 TimeSelector
* mTimeSelector
;
92 QGroupBox
* mButtonBox
;
93 ButtonGroup
* mButtonGroup
;
94 RadioButton
* mCountButton
;
96 RadioButton
* mDurationButton
;
97 TimePeriod
* mDuration
;
98 int mMaxDuration
; // maximum allowed duration in minutes, or -1 for infinite
99 bool mDateOnly
; // hours/minutes cannot be displayed
100 bool mReadOnly
; // the widget is read only
103 #endif // REPETITIONBUTTON_H