SVN_SILENT made messages (after extraction)
[kdepim.git] / kalarm / repetitionbutton.h
blob1f6d711569ffec9ef80a4109ca62af7799225140
1 /*
2 * repetitionbutton.h - pushbutton and dialog to specify alarm repetition
3 * Program: kalarm
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>
26 #include <QDialog>
27 #include <QPushButton>
29 using namespace KAlarmCal;
31 class QGroupBox;
32 class ButtonGroup;
33 class RadioButton;
34 class SpinBox;
35 class TimeSelector;
36 class TimePeriod;
37 class RepetitionDlg;
39 namespace KCalCore { class Duration; }
41 class RepetitionButton : public QPushButton
43 Q_OBJECT
44 public:
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; }
54 Q_SIGNALS:
55 void needsInitialisation(); // dialog has been created and needs set() to be called
56 void changed(); // the repetition dialog has been edited
58 private Q_SLOTS:
59 void slotPressed() { activate(mWaitForInit); }
61 private:
62 void activate(bool waitForInitialisation);
63 void displayDialog();
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
70 bool mReadOnly;
74 class RepetitionDlg : public QDialog
76 Q_OBJECT
77 public:
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
83 private Q_SLOTS:
84 void typeClicked();
85 void countChanged(int);
86 void intervalChanged(const KCalCore::Duration&);
87 void durationChanged(const KCalCore::Duration&);
88 void repetitionToggled(bool);
90 private:
91 TimeSelector* mTimeSelector;
92 QGroupBox* mButtonBox;
93 ButtonGroup* mButtonGroup;
94 RadioButton* mCountButton;
95 SpinBox* mCount;
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
105 // vim: et sw=4: