File indexing completed on 2024-05-12 05:14:56
0001 /* 0002 * repetitionbutton.h - pushbutton and dialog to specify alarm repetition 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2004-2022 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "kalarmcalendar/repetition.h" 0012 0013 #include <QDialog> 0014 #include <QPushButton> 0015 0016 using namespace KAlarmCal; 0017 0018 class QGroupBox; 0019 class ButtonGroup; 0020 class RadioButton; 0021 class SpinBox; 0022 class TimeSelector; 0023 class TimePeriod; 0024 class RepetitionDlg; 0025 0026 namespace KCalendarCore { class Duration; } 0027 0028 class RepetitionButton : public QPushButton 0029 { 0030 Q_OBJECT 0031 public: 0032 RepetitionButton(const QString& caption, bool waitForInitialisation, QWidget* parent); 0033 void set(const Repetition&); 0034 void set(const Repetition&, bool dateOnly, int maxDuration = -1); 0035 void initialise(const Repetition&, bool dateOnly, int maxDuration = -1); // use only after needsInitialisation() signal 0036 void activate() { activate(false); } 0037 Repetition repetition() const { return mRepetition; } 0038 virtual void setReadOnly(bool ro) { mReadOnly = ro; } 0039 virtual bool isReadOnly() const { return mReadOnly; } 0040 0041 Q_SIGNALS: 0042 void needsInitialisation(); // dialog has been created and needs set() to be called 0043 void changed(); // the repetition dialog has been edited 0044 0045 private Q_SLOTS: 0046 void slotPressed() { activate(mWaitForInit); } 0047 0048 private: 0049 void activate(bool waitForInitialisation); 0050 void displayDialog(); 0051 0052 RepetitionDlg* mDialog {nullptr}; 0053 Repetition mRepetition; // repetition interval and count 0054 int mMaxDuration {-1}; // maximum allowed duration in minutes, or -1 for infinite 0055 bool mDateOnly {false}; // hours/minutes cannot be displayed 0056 bool mWaitForInit; // Q_EMIT needsInitialisation() when button pressed, display when initialise() called 0057 bool mReadOnly {false}; 0058 }; 0059 0060 0061 class RepetitionDlg : public QDialog 0062 { 0063 Q_OBJECT 0064 public: 0065 RepetitionDlg(const QString& caption, bool readOnly, QWidget* parent = nullptr); 0066 void setReadOnly(bool); 0067 void set(const Repetition&, bool dateOnly = false, int maxDuration = -1); 0068 Repetition repetition() const; // get the repetition interval and count 0069 0070 private Q_SLOTS: 0071 void typeClicked(); 0072 void countChanged(int); 0073 void intervalChanged(const KCalendarCore::Duration&); 0074 void durationChanged(const KCalendarCore::Duration&); 0075 void repetitionToggled(bool); 0076 0077 private: 0078 TimeSelector* mTimeSelector; 0079 QGroupBox* mButtonBox; 0080 ButtonGroup* mButtonGroup; 0081 RadioButton* mCountButton; 0082 SpinBox* mCount; 0083 RadioButton* mDurationButton; 0084 TimePeriod* mDuration; 0085 int mMaxDuration; // maximum allowed duration in minutes, or -1 for infinite 0086 bool mDateOnly; // hours/minutes cannot be displayed 0087 bool mReadOnly; // the widget is read only 0088 }; 0089 0090 // vim: et sw=4: