french -> French
[kdepim.git] / kalarm / repetitionbutton.h
blob25e426dce5a50deaf2010cd8a120a7d732980c9f
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 <kdialog.h>
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 #ifdef USE_AKONADI
40 namespace KCalCore { class Duration; }
41 #else
42 namespace KCal { class Duration; }
43 #endif
45 class RepetitionButton : public QPushButton
47 Q_OBJECT
48 public:
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; }
58 signals:
59 void needsInitialisation(); // dialog has been created and needs set() to be called
60 void changed(); // the repetition dialog has been edited
62 private slots:
63 void slotPressed() { activate(mWaitForInit); }
65 private:
66 void activate(bool waitForInitialisation);
67 void displayDialog();
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
74 bool mReadOnly;
78 class RepetitionDlg : public KDialog
80 Q_OBJECT
81 public:
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
87 private slots:
88 void typeClicked();
89 void countChanged(int);
90 #ifdef USE_AKONADI
91 void intervalChanged(const KCalCore::Duration&);
92 void durationChanged(const KCalCore::Duration&);
93 #else
94 void intervalChanged(const KCal::Duration&);
95 void durationChanged(const KCal::Duration&);
96 #endif
97 void repetitionToggled(bool);
99 private:
100 TimeSelector* mTimeSelector;
101 QGroupBox* mButtonBox;
102 ButtonGroup* mButtonGroup;
103 RadioButton* mCountButton;
104 SpinBox* mCount;
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
114 // vim: et sw=4: