korganizer
koeditorrecurrence.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef KOEDITORRECURRENCE_H
00025 #define KOEDITORRECURRENCE_H
00026
00027 #include <kcal/incidencebase.h>
00028
00029 #include <KDialog>
00030
00031 #include <QDateTime>
00032 #include <QWidget>
00033 #include <QBitArray>
00034
00035 class KComboBox;
00036 class QBoxLayout;
00037 class QCheckBox;
00038 class QLabel;
00039 class QListWidget;
00040 class QGroupBox;
00041 class QRadioButton;
00042 class QSpinBox;
00043 class QStackedWidget;
00044
00045 namespace KPIM {
00046 class KDateEdit;
00047 }
00048 namespace KCal {
00049 class Incidence;
00050 }
00051 using namespace KCal;
00052
00053 class RecurBase : public QWidget
00054 {
00055 public:
00056 explicit RecurBase( QWidget *parent = 0 );
00057
00058 void setFrequency( int );
00059 int frequency();
00060
00061
00062 void setDateTimes( const QDateTime &, const QDateTime & ) {}
00063
00064 QWidget *frequencyEdit();
00065
00066 protected:
00067 static KComboBox *createWeekCountCombo( QWidget *parent=0 );
00068 static KComboBox *createWeekdayCombo( QWidget *parent=0 );
00069 static KComboBox *createMonthNameCombo( QWidget *parent=0 );
00070 QBoxLayout *createFrequencySpinBar( QWidget *parent, QLayout *layout,
00071 const QString &everyText, const QString &unitText );
00072
00073 private:
00074 QSpinBox *mFrequencyEdit;
00075 };
00076
00077 class RecurDaily : public RecurBase
00078 {
00079 public:
00080 explicit RecurDaily( QWidget *parent = 0 );
00081 };
00082
00083 class RecurWeekly : public RecurBase
00084 {
00085 public:
00086 explicit RecurWeekly( QWidget *parent = 0 );
00087
00088 void setDays( const QBitArray & );
00089 QBitArray days();
00090
00091 private:
00092 QCheckBox *mDayBoxes[7];
00093 };
00094
00095 class RecurMonthly : public RecurBase
00096 {
00097 public:
00098 explicit RecurMonthly( QWidget *parent = 0 );
00099
00100 void setByDay( int day );
00101 void setByPos( int count, int weekday );
00102
00103 bool byDay();
00104 bool byPos();
00105
00106 int day();
00107
00108 int count();
00109 int weekday();
00110
00111 private:
00112 QRadioButton *mByDayRadio;
00113 KComboBox *mByDayCombo;
00114
00115 QRadioButton *mByPosRadio;
00116 KComboBox *mByPosCountCombo;
00117 KComboBox *mByPosWeekdayCombo;
00118 };
00119
00120 class RecurYearly : public RecurBase
00121 {
00122 public:
00123 enum YearlyType {
00124 byDay,
00125 byPos,
00126 byMonth
00127 };
00128
00129 explicit RecurYearly( QWidget *parent = 0 );
00130
00131 void setByDay( int day );
00132 void setByPos( int count, int weekday, int month );
00133 void setByMonth( int day, int month );
00134
00135 YearlyType getType();
00136
00137 int day();
00138 int posCount();
00139 int posWeekday();
00140 int posMonth();
00141 int monthDay();
00142 int month();
00143
00144 private:
00145 QRadioButton *mByMonthRadio;
00146 QRadioButton *mByPosRadio;
00147 QRadioButton *mByDayRadio;
00148
00149 QSpinBox *mByMonthSpin;
00150 KComboBox *mByMonthCombo;
00151
00152 KComboBox *mByPosDayCombo;
00153 KComboBox *mByPosWeekdayCombo;
00154 KComboBox *mByPosMonthCombo;
00155
00156 QSpinBox *mByDaySpin;
00157 };
00158
00159 class RecurrenceChooser : public QWidget
00160 {
00161 Q_OBJECT
00162 public:
00163 explicit RecurrenceChooser( QWidget *parent = 0 );
00164
00165 enum {
00166 Daily,
00167 Weekly,
00168 Monthly,
00169 Yearly
00170 };
00171
00172 void setType( int );
00173 int type();
00174
00175 signals:
00176 void chosen( int );
00177
00178 protected slots:
00179 void emitChoice();
00180
00181 private:
00182 KComboBox *mTypeCombo;
00183
00184 QRadioButton *mDailyButton;
00185 QRadioButton *mWeeklyButton;
00186 QRadioButton *mMonthlyButton;
00187 QRadioButton *mYearlyButton;
00188 };
00189
00190 class ExceptionsBase
00191 {
00192 public:
00193 virtual ~ExceptionsBase(){}
00194 virtual void setDates( const DateList & ) = 0;
00195 virtual DateList dates() = 0;
00196 };
00197
00198 class ExceptionsWidget : public QWidget, public ExceptionsBase
00199 {
00200 Q_OBJECT
00201 public:
00202 explicit ExceptionsWidget( QWidget *parent = 0 );
00203
00204 void setDates( const DateList & );
00205 DateList dates();
00206
00207 protected slots:
00208 void addException();
00209 void changeException();
00210 void deleteException();
00211
00212 private:
00213 KPIM::KDateEdit *mExceptionDateEdit;
00214 QListWidget *mExceptionList;
00215 DateList mExceptionDates;
00216 };
00217
00218 class ExceptionsDialog : public KDialog, public ExceptionsBase
00219 {
00220 public:
00221 explicit ExceptionsDialog( QWidget *parent );
00222
00223 void setDates( const DateList & );
00224 DateList dates();
00225
00226 private:
00227 ExceptionsWidget *mExceptions;
00228 };
00229
00230 class RecurrenceRangeBase
00231 {
00232 public:
00233 virtual ~RecurrenceRangeBase() {}
00234 virtual void setDefaults( const QDateTime &from ) = 0;
00235
00236 virtual void setDuration( int ) = 0;
00237 virtual int duration() = 0;
00238
00239 virtual void setEndDate( const QDate & ) = 0;
00240 virtual QDate endDate() = 0;
00241
00242 virtual void setDateTimes( const QDateTime &start,
00243 const QDateTime &end = QDateTime() ) = 0;
00244 };
00245
00246 class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
00247 {
00248 Q_OBJECT
00249 public:
00250 explicit RecurrenceRangeWidget( QWidget *parent = 0 );
00251
00252 void setDefaults( const QDateTime &from );
00253
00254 void setDuration( int );
00255 int duration();
00256
00257 void setEndDate( const QDate & );
00258 QDate endDate();
00259
00260 void setDateTimes( const QDateTime &start,
00261 const QDateTime &end = QDateTime() );
00262
00263 protected slots:
00264 void showCurrentRange();
00265
00266 private:
00267 QGroupBox *mRangeGroupBox;
00268 QLabel *mStartDateLabel;
00269 QRadioButton *mNoEndDateButton;
00270 QRadioButton *mEndDurationButton;
00271 QSpinBox *mEndDurationEdit;
00272 QRadioButton *mEndDateButton;
00273 KPIM::KDateEdit *mEndDateEdit;
00274 };
00275
00276 class RecurrenceRangeDialog : public KDialog, public RecurrenceRangeBase
00277 {
00278 public:
00279 explicit RecurrenceRangeDialog( QWidget *parent = 0 );
00280
00281 void setDefaults( const QDateTime &from );
00282
00283 void setDuration( int );
00284 int duration();
00285
00286 void setEndDate( const QDate & );
00287 QDate endDate();
00288
00289 void setDateTimes( const QDateTime &start,
00290 const QDateTime &end = QDateTime() );
00291
00292 private:
00293 RecurrenceRangeWidget *mRecurrenceRangeWidget;
00294 };
00295
00296 class KOEditorRecurrence : public QWidget
00297 {
00298 Q_OBJECT
00299 public:
00300 explicit KOEditorRecurrence ( QWidget *parent = 0 );
00301 virtual ~KOEditorRecurrence();
00302
00303 enum {
00304 Daily,
00305 Weekly,
00306 Monthly,
00307 Yearly
00308 };
00309
00311 void setDefaults( const QDateTime &from, const QDateTime &to, bool allday );
00312
00314 void readIncidence( Incidence * );
00315
00317 void writeIncidence( Incidence * );
00318
00320 bool validateInput();
00321
00322 bool recurs();
00323
00324 public slots:
00325 void setRecurrenceEnabled( bool );
00326 void setDateTimes( const QDateTime &start, const QDateTime &end );
00327 void setDateTimeStr( const QString & );
00328
00329 signals:
00330 void dateTimesChanged( const QDateTime &start, const QDateTime &end );
00331
00332 protected slots:
00333 void showCurrentRule( int );
00334 void showExceptionsDialog();
00335 void showRecurrenceRangeDialog();
00336
00337 private:
00338 QCheckBox *mEnabledCheck;
00339
00340 QGroupBox *mTimeGroupBox;
00341 QLabel *mDateTimeLabel;
00342
00343 QGroupBox *mRuleBox;
00344 QStackedWidget *mRuleStack;
00345 RecurrenceChooser *mRecurrenceChooser;
00346
00347 RecurDaily *mDaily;
00348 RecurWeekly *mWeekly;
00349 RecurMonthly *mMonthly;
00350 RecurYearly *mYearly;
00351
00352 RecurrenceRangeBase *mRecurrenceRange;
00353 RecurrenceRangeWidget *mRecurrenceRangeWidget;
00354 RecurrenceRangeDialog *mRecurrenceRangeDialog;
00355 QPushButton *mRecurrenceRangeButton;
00356
00357 ExceptionsBase *mExceptions;
00358 ExceptionsDialog *mExceptionsDialog;
00359 ExceptionsWidget *mExceptionsWidget;
00360 QPushButton *mExceptionsButton;
00361
00362 QDateTime mEventStartDt;
00363 };
00364
00365 class KOEditorRecurrenceDialog : public KDialog
00366 {
00367 Q_OBJECT
00368 public:
00369 KOEditorRecurrenceDialog( QWidget *parent );
00370 KOEditorRecurrence *editor() const { return mRecurrence; }
00371
00372 private:
00373 KOEditorRecurrence *mRecurrence;
00374 };
00375
00376 #endif