korganizer Library API Documentation

koeditorrecurrence.h

00001 /*
00002     This file is part of KOrganizer.
00003     Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org>
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019     As a special exception, permission is given to link this program
00020     with any edition of Qt, and distribute the resulting executable,
00021     without including the source code for Qt in the source distribution.
00022 */
00023 #ifndef _KOEDITORRECURRENCE_H
00024 #define _KOEDITORRECURRENCE_H
00025 
00026 #include <qdatetime.h>
00027 #include <qwidget.h>
00028 #include <qbitarray.h>
00029 
00030 #include <kdialogbase.h>
00031 
00032 #include <libkcal/incidencebase.h>
00033 
00034 class QWidgetStack;
00035 class QSpinBox;
00036 class QRadioButton;
00037 class QGroupBox;
00038 class QCheckBox;
00039 
00040 class KDateEdit;
00041 namespace KCal {
00042 class Incidence;
00043 }
00044 using namespace KCal;
00045 
00046 class RecurBase : public QWidget
00047 {
00048   public:
00049     RecurBase( QWidget *parent = 0, const char *name = 0 );
00050 
00051     void setFrequency( int );
00052     int frequency();
00053     // TODO: If we want to adjust the recurrence when the start/due date change,
00054     // we need to reimplement this method in the derived classes!
00055     void setDateTimes( QDateTime /*start*/, QDateTime /*end*/ ) {}
00056 
00057     QWidget *frequencyEdit();
00058 
00059   protected:
00060     static QComboBox *createWeekCountCombo( QWidget *parent=0, const char *name=0 );
00061     static QComboBox *createWeekdayCombo( QWidget *parent=0, const char *name=0 );
00062     static QComboBox *createMonthNameCombo( QWidget *parent=0, const char *name=0 );
00063     QBoxLayout *createFrequencySpinBar( QWidget *parent, QLayout *layout,
00064     QString everyText, QString unitText );
00065 
00066   private:
00067     QSpinBox *mFrequencyEdit;
00068 };
00069 
00070 class RecurDaily : public RecurBase
00071 {
00072   public:
00073     RecurDaily( QWidget *parent = 0, const char *name = 0 );
00074 };
00075 
00076 class RecurWeekly : public RecurBase
00077 {
00078   public:
00079     RecurWeekly( QWidget *parent = 0, const char *name = 0 );
00080 
00081     void setDays( const QBitArray & );
00082     QBitArray days();
00083 
00084   private:
00085     QCheckBox *mDayBoxes[7];
00086 };
00087 
00088 class RecurMonthly : public RecurBase
00089 {
00090   public:
00091     RecurMonthly( QWidget *parent = 0, const char *name = 0 );
00092 
00093     void setByDay( int day );
00094     void setByPos( int count, int weekday );
00095 
00096     bool byDay();
00097     bool byPos();
00098 
00099     int day();
00100 
00101     int count();
00102     int weekday();
00103 
00104   private:
00105     QRadioButton *mByDayRadio;
00106     QComboBox *mByDayCombo;
00107 
00108     QRadioButton *mByPosRadio;
00109     QComboBox *mByPosCountCombo;
00110     QComboBox *mByPosWeekdayCombo;
00111 };
00112 
00113 class RecurYearly : public RecurBase
00114 {
00115   public:
00116     enum YearlyType { byDay, byPos, byMonth };
00117 
00118     RecurYearly( QWidget *parent = 0, const char *name = 0 );
00119 
00120     void setByDay( int day );
00121     void setByPos( int count, int weekday, int month );
00122     void setByMonth( int day, int month );
00123 
00124     YearlyType getType();
00125 
00126     int day();
00127     int posCount();
00128     int posWeekday();
00129     int posMonth();
00130     int monthDay();
00131     int month();
00132 
00133   private:
00134     QRadioButton *mByMonthRadio;
00135     QRadioButton *mByPosRadio;
00136     QRadioButton *mByDayRadio;
00137 
00138     QSpinBox *mByMonthSpin;
00139     QComboBox *mByMonthCombo;
00140 
00141     QComboBox *mByPosDayCombo;
00142     QComboBox *mByPosWeekdayCombo;
00143     QComboBox *mByPosMonthCombo;
00144 
00145     QSpinBox *mByDaySpin;
00146 };
00147 
00148 class RecurrenceChooser : public QWidget
00149 {
00150     Q_OBJECT
00151   public:
00152     RecurrenceChooser( QWidget *parent = 0, const char *name = 0 );
00153 
00154     enum { Daily, Weekly, Monthly, Yearly };
00155 
00156     void setType( int );
00157     int type();
00158 
00159   signals:
00160     void chosen( int );
00161 
00162   protected slots:
00163     void emitChoice();
00164 
00165   private:
00166     QComboBox *mTypeCombo;
00167 
00168     QRadioButton *mDailyButton;
00169     QRadioButton *mWeeklyButton;
00170     QRadioButton *mMonthlyButton;
00171     QRadioButton *mYearlyButton;
00172 };
00173 
00174 class ExceptionsBase
00175 {
00176   public:
00177     virtual void setDates( const DateList & ) = 0;
00178     virtual DateList dates() = 0;
00179 };
00180 
00181 class ExceptionsWidget : public QWidget, public ExceptionsBase
00182 {
00183     Q_OBJECT
00184   public:
00185     ExceptionsWidget( QWidget *parent = 0, const char *name = 0 );
00186 
00187     void setDates( const DateList & );
00188     DateList dates();
00189 
00190   protected slots:
00191     void addException();
00192     void changeException();
00193     void deleteException();
00194 
00195   private:
00196     KDateEdit *mExceptionDateEdit;
00197     QListBox *mExceptionList;
00198     DateList mExceptionDates;
00199 };
00200 
00201 class ExceptionsDialog : public KDialogBase, public ExceptionsBase
00202 {
00203   public:
00204     ExceptionsDialog( QWidget *parent, const char *name = 0 );
00205 
00206     void setDates( const DateList & );
00207     DateList dates();
00208 
00209   private:
00210     ExceptionsWidget *mExceptions;
00211 };
00212 
00213 class RecurrenceRangeBase
00214 {
00215   public:
00216     virtual void setDefaults( const QDateTime &from ) = 0;
00217 
00218     virtual void setDuration( int ) = 0;
00219     virtual int duration() = 0;
00220 
00221     virtual void setEndDate( const QDate & ) = 0;
00222     virtual QDate endDate() = 0;
00223 
00224     virtual void setDateTimes( const QDateTime &start,
00225                                const QDateTime &end = QDateTime() ) = 0;
00226 };
00227 
00228 class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase
00229 {
00230     Q_OBJECT
00231   public:
00232     RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 );
00233 
00234     void setDefaults( const QDateTime &from );
00235 
00236     void setDuration( int );
00237     int duration();
00238 
00239     void setEndDate( const QDate & );
00240     QDate endDate();
00241 
00242     void setDateTimes( const QDateTime &start,
00243                        const QDateTime &end = QDateTime() );
00244 
00245   protected slots:
00246     void showCurrentRange();
00247 
00248   private:
00249     QGroupBox *mRangeGroupBox;
00250     QLabel *mStartDateLabel;
00251     QRadioButton *mNoEndDateButton;
00252     QRadioButton *mEndDurationButton;
00253     QSpinBox *mEndDurationEdit;
00254     QRadioButton *mEndDateButton;
00255     KDateEdit *mEndDateEdit;
00256 };
00257 
00258 class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase
00259 {
00260   public:
00261     RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 );
00262 
00263     void setDefaults( const QDateTime &from );
00264 
00265     void setDuration( int );
00266     int duration();
00267 
00268     void setEndDate( const QDate & );
00269     QDate endDate();
00270 
00271     void setDateTimes( const QDateTime &start,
00272                        const QDateTime &end = QDateTime() );
00273 
00274   private:
00275     RecurrenceRangeWidget *mRecurrenceRangeWidget;
00276 };
00277 
00278 class KOEditorRecurrence : public QWidget
00279 {
00280     Q_OBJECT
00281   public:
00282     KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 );
00283     virtual ~KOEditorRecurrence();
00284 
00285     enum { Daily, Weekly, Monthly, Yearly };
00286 
00288     void setDefaults( QDateTime from, QDateTime to, bool allday );
00290     void readIncidence( Incidence * );
00292     void writeIncidence( Incidence * );
00293 
00295     bool validateInput();
00296 
00297   public slots:
00298     void setRecurrenceEnabled( bool );
00299     void setDateTimes( QDateTime start, QDateTime end );
00300     void setDateTimeStr( const QString & );
00301 
00302   signals:
00303     void dateTimesChanged( QDateTime start, QDateTime end );
00304 
00305   protected slots:
00306     void showCurrentRule( int );
00307     void showExceptionsDialog();
00308     void showRecurrenceRangeDialog();
00309 
00310   private:
00311     QCheckBox *mEnabledCheck;
00312 
00313     QGroupBox *mTimeGroupBox;
00314     QLabel *mDateTimeLabel;
00315 
00316     QGroupBox *mRuleBox;
00317     QWidgetStack *mRuleStack;
00318     RecurrenceChooser *mRecurrenceChooser;
00319 
00320     RecurDaily *mDaily;
00321     RecurWeekly *mWeekly;
00322     RecurMonthly *mMonthly;
00323     RecurYearly *mYearly;
00324 
00325     RecurrenceRangeBase *mRecurrenceRange;
00326     RecurrenceRangeWidget *mRecurrenceRangeWidget;
00327     RecurrenceRangeDialog *mRecurrenceRangeDialog;
00328     QPushButton *mRecurrenceRangeButton;
00329 
00330     ExceptionsBase *mExceptions;
00331     ExceptionsDialog *mExceptionsDialog;
00332     ExceptionsWidget *mExceptionsWidget;
00333     QPushButton *mExceptionsButton;
00334 
00335     QDateTime mEventStartDt;
00336 };
00337 
00338 #endif
KDE Logo
This file is part of the documentation for korganizer Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jan 31 15:55:49 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003