kalarm

recurrenceedit.h

00001 /*
00002  *  recurrenceedit.h  -  widget to edit the event's recurrence definition
00003  *  Program:  kalarm
00004  *  Copyright © 2002-2005 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  Based originally on KOrganizer module koeditorrecurrence.h,
00007  *  Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
00008  *
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License along
00020  *  with this program; if not, write to the Free Software Foundation, Inc.,
00021  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00022  */
00023 
00024 #ifndef RECURRENCEEDIT_H
00025 #define RECURRENCEEDIT_H
00026 
00027 #include <qframe.h>
00028 #include <qdatetime.h>
00029 #include <qvaluelist.h>
00030 
00031 #include "datetime.h"
00032 class QWidgetStack;
00033 class QGroupBox;
00034 class QLabel;
00035 class QListBox;
00036 class QButton;
00037 class QPushButton;
00038 class QBoxLayout;
00039 class SpinBox;
00040 class CheckBox;
00041 class RadioButton;
00042 class DateEdit;
00043 class TimeEdit;
00044 class ButtonGroup;
00045 class KAEvent;
00046 class Rule;
00047 class NoRule;
00048 class SubDailyRule;
00049 class DailyRule;
00050 class WeeklyRule;
00051 class MonthlyRule;
00052 class YearlyRule;
00053 
00054 
00055 class RecurrenceEdit : public QFrame
00056 {
00057         Q_OBJECT
00058     public:
00059         // Don't alter the order of these recurrence types
00060         enum RepeatType { INVALID_RECUR = -1, NO_RECUR, AT_LOGIN, SUBDAILY, DAILY, WEEKLY, MONTHLY, ANNUAL };
00061 
00062         RecurrenceEdit(bool readOnly, QWidget* parent, const char* name = 0);
00063         virtual ~RecurrenceEdit()  { }
00064 
00066         void          setDefaults(const QDateTime& from);
00068         void          set(const KAEvent&);
00070         void          updateEvent(KAEvent&, bool adjustStart);
00071         QWidget*      checkData(const QDateTime& startDateTime, QString& errorMessage) const;
00072         RepeatType    repeatType() const                    { return mRuleButtonType; }
00073         bool          isTimedRepeatType() const             { return mRuleButtonType >= SUBDAILY; }
00074         void          setStartDate(const QDate&, const QDate& today);
00075         void          setDefaultEndDate(const QDate&);
00076         void          setEndDateTime(const DateTime&);
00077         DateTime      endDateTime() const;
00078         bool          stateChanged() const;
00079 
00080         static QString i18n_Norecur();           // text of 'No recurrence' selection, lower case
00081         static QString i18n_NoRecur();           // text of 'No Recurrence' selection, initial capitals
00082         static QString i18n_AtLogin();           // text of 'At Login' selection
00083         static QString i18n_l_Atlogin();         // text of 'At &login' selection, with 'L' shortcut
00084         static QString i18n_HourlyMinutely();    // text of 'Hourly/Minutely'
00085         static QString i18n_u_HourlyMinutely();  // text of 'Ho&urly/Minutely' selection, with 'U' shortcut
00086         static QString i18n_Daily();             // text of 'Daily' selection
00087         static QString i18n_d_Daily();           // text of '&Daily' selection, with 'D' shortcut
00088         static QString i18n_Weekly();            // text of 'Weekly' selection
00089         static QString i18n_w_Weekly();          // text of '&Weekly' selection, with 'W' shortcut
00090         static QString i18n_Monthly();           // text of 'Monthly' selection
00091         static QString i18n_m_Monthly();         // text of '&Monthly' selection, with 'M' shortcut
00092         static QString i18n_Yearly();            // text of 'Yearly' selection
00093         static QString i18n_y_Yearly();          // text of '&Yearly' selection, with 'Y' shortcut
00094 
00095     public slots:
00096         void          setDateTime(const QDateTime& start)   { mCurrStartDateTime = start; }
00097 
00098     signals:
00099         void          shown();
00100         void          typeChanged(int recurType);   // returns a RepeatType value
00101         void          frequencyChanged();
00102 
00103     protected:
00104         virtual void  showEvent(QShowEvent*);
00105 
00106     private slots:
00107         void          periodClicked(int);
00108         void          rangeTypeClicked();
00109         void          repeatCountChanged(int value);
00110         void          slotAnyTimeToggled(bool);
00111         void          addException();
00112         void          changeException();
00113         void          deleteException();
00114         void          enableExceptionButtons();
00115 
00116     private:
00117         void          setRuleDefaults(const QDate& start);
00118         void          saveState();
00119 
00120         // Main rule box and choices
00121         QWidgetStack*     mRuleStack;
00122         Rule*             mRule;         // current rule widget, or 0 if NoRule
00123         NoRule*           mNoRule;
00124         SubDailyRule*     mSubDailyRule;
00125         DailyRule*        mDailyRule;
00126         WeeklyRule*       mWeeklyRule;
00127         MonthlyRule*      mMonthlyRule;
00128         YearlyRule*       mYearlyRule;
00129 
00130         ButtonGroup*      mRuleButtonGroup;
00131         RadioButton*      mNoneButton;
00132         RadioButton*      mAtLoginButton;
00133         RadioButton*      mSubDailyButton;
00134         RadioButton*      mDailyButton;
00135         RadioButton*      mWeeklyButton;
00136         RadioButton*      mMonthlyButton;
00137         RadioButton*      mYearlyButton;
00138         int               mNoneButtonId;
00139         int               mAtLoginButtonId;
00140         int               mSubDailyButtonId;
00141         int               mDailyButtonId;
00142         int               mWeeklyButtonId;
00143         int               mMonthlyButtonId;
00144         int               mYearlyButtonId;
00145         RepeatType        mRuleButtonType;
00146         bool              mDailyShown;       // daily rule has been displayed at some time or other
00147         bool              mWeeklyShown;      // weekly rule has been displayed at some time or other
00148         bool              mMonthlyShown;     // monthly rule has been displayed at some time or other
00149         bool              mYearlyShown;      // yearly rule has been displayed at some time or other
00150 
00151         // Range
00152         ButtonGroup*      mRangeButtonGroup;
00153         RadioButton*      mNoEndDateButton;
00154         RadioButton*      mRepeatCountButton;
00155         SpinBox*          mRepeatCountEntry;
00156         QLabel*           mRepeatCountLabel;
00157         RadioButton*      mEndDateButton;
00158         DateEdit*         mEndDateEdit;
00159         TimeEdit*         mEndTimeEdit;
00160         CheckBox*         mEndAnyTimeCheckBox;
00161 
00162         // Exceptions
00163         QGroupBox*        mExceptionGroup;
00164         QListBox*         mExceptionDateList;
00165         DateEdit*         mExceptionDateEdit;
00166         QPushButton*      mChangeExceptionButton;
00167         QPushButton*      mDeleteExceptionButton;
00168         QValueList<QDate> mExceptionDates;
00169 
00170         // Current start date and time
00171         QDateTime         mCurrStartDateTime;
00172         bool              mNoEmitTypeChanged;        // suppress typeChanged() signal
00173         bool              mReadOnly;
00174 
00175         // Initial state of non-rule controls
00176         QButton*          mSavedRuleButton;          // which rule button was selected
00177         QButton*          mSavedRangeButton;         // which range button was selected
00178         int               mSavedRepeatCount;         // repeat count
00179         DateTime          mSavedEndDateTime;         // end date/time
00180         QValueList<QDate> mSavedExceptionDates;      // exception dates
00181 };
00182 
00183 #endif // RECURRENCEEDIT_H
KDE Home | KDE Accessibility Home | Description of Access Keys