• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

KCal Library

recurrencerule.h

00001 /*
00002   This file is part of the kcal library.
00003 
00004   Copyright (c) 1998 Preston Brown <pbrown@kde.org>
00005   Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
00006   Copyright (c) 2002,2006,2007 David Jarvie <software@astrojar.org.uk>
00007   Copyright (c) 2005, Reinhold Kainhofer <reinhold@kainhofer.com>
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Library General Public
00011   License as published by the Free Software Foundation; either
00012   version 2 of the License, or (at your option) any later version.
00013 
00014   This library 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 GNU
00017   Library General Public License for more details.
00018 
00019   You should have received a copy of the GNU Library General Public License
00020   along with this library; see the file COPYING.LIB.  If not, write to
00021   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00022   Boston, MA 02110-1301, USA.
00023 */
00024 #ifndef KCAL_RECURRENCERULE_H
00025 #define KCAL_RECURRENCERULE_H
00026 
00027 #include "kcal_export.h"
00028 #include "kcal/listbase.h"
00029 #include "kcal/sortablelist.h"
00030 
00031 #include <kdatetime.h>
00032 
00033 #include <QtCore/QList>
00034 
00035 namespace KCal {
00036 
00037 // These two are duplicates wrt. incidencebase.h
00038 typedef SortableList<KDateTime> DateTimeList;
00039 typedef SortableList<QDate> DateList;
00040 /* List of times */
00041 typedef SortableList<QTime> TimeList;
00042 
00046 class KCAL_EXPORT RecurrenceRule
00047 {
00048   public:
00049     class RuleObserver
00050     {
00051       public:
00052         virtual ~RuleObserver() {}
00054         virtual void recurrenceChanged( RecurrenceRule * ) = 0;
00055     };
00056     typedef ListBase<RecurrenceRule> List;
00057 
00059     enum PeriodType {
00060       rNone = 0,
00061       rSecondly,
00062       rMinutely,
00063       rHourly,
00064       rDaily,
00065       rWeekly,
00066       rMonthly,
00067       rYearly
00068     };
00069 
00071     class WDayPos
00072     {
00073       public:
00074         explicit WDayPos( int ps = 0, short dy = 0 ) : mDay( dy ), mPos( ps ) {}
00075         short day() const { return mDay; }
00076         int pos() const { return mPos; }
00077         void setDay( short dy ) { mDay = dy; }
00078         void setPos( int ps ) { mPos = ps; }
00079 
00080         bool operator==( const RecurrenceRule::WDayPos &pos2 ) const {
00081           return mDay == pos2.mDay && mPos == pos2.mPos;
00082       }
00083 
00084       protected:
00085         short mDay; // Weekday, 1=monday, 7=sunday
00086         int mPos;   // week of the day (-1 for last, 1 for first, 0 for all weeks)
00087                     // Bounded by -366 and +366, 0 means all weeks in that period
00088     };
00089 
00090     RecurrenceRule();
00091     RecurrenceRule( const RecurrenceRule &r );
00092     ~RecurrenceRule();
00093 
00094     bool operator==( const RecurrenceRule &r ) const;
00095     bool operator!=( const RecurrenceRule &r ) const  { return !operator==(r); }
00096     RecurrenceRule &operator=( const RecurrenceRule &r );
00097 
00099     void setReadOnly( bool readOnly );
00100 
00104     bool isReadOnly() const;
00105 
00110     bool recurs() const;
00111     void setRecurrenceType( PeriodType period );
00112     PeriodType recurrenceType() const;
00113 
00115     void clear();
00116 
00120     uint frequency() const;
00121 
00125     void setFrequency( int freq );
00126 
00132     KDateTime startDt() const;
00133 
00142     void setStartDt( const KDateTime &start );
00143 
00146     bool allDay() const;
00147 
00152     void setAllDay( bool allDay );
00153 
00159     KDateTime endDt( bool *result = 0 ) const;
00160 
00163     void setEndDt( const KDateTime &endDateTime );
00164 
00169     int duration() const;
00170 
00173     void setDuration( int duration );
00174 
00176     int durationTo( const KDateTime &dt ) const;
00177 
00179     int durationTo( const QDate &date ) const;
00180 
00195     void shiftTimes( const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec );
00196 
00203     bool recursOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00204 
00211     bool recursAt( const KDateTime &dt ) const;
00212 
00220     bool dateMatchesRules( const KDateTime &dt ) const;
00221 
00228     TimeList recurTimesOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00229 
00241     DateTimeList timesInInterval( const KDateTime &start, const KDateTime &end ) const;
00242 
00248     KDateTime getNextDate( const KDateTime &preDateTime ) const;
00249 
00256     KDateTime getPreviousDate( const KDateTime &afterDateTime ) const;
00257 
00258     void setBySeconds( const QList<int> bySeconds );
00259     void setByMinutes( const QList<int> byMinutes );
00260     void setByHours( const QList<int> byHours );
00261 
00262     void setByDays( const QList<WDayPos> byDays );
00263     void setByMonthDays( const QList<int> byMonthDays );
00264     void setByYearDays( const QList<int> byYearDays );
00265     void setByWeekNumbers( const QList<int> byWeekNumbers );
00266     void setByMonths( const QList<int> byMonths );
00267     void setBySetPos( const QList<int> bySetPos );
00268     void setWeekStart( short weekStart );
00269 
00270     const QList<int> &bySeconds() const;
00271     const QList<int> &byMinutes() const;
00272     const QList<int> &byHours() const;
00273 
00274     const QList<WDayPos> &byDays() const;
00275     const QList<int> &byMonthDays() const;
00276     const QList<int> &byYearDays() const;
00277     const QList<int> &byWeekNumbers() const;
00278     const QList<int> &byMonths() const;
00279     const QList<int> &bySetPos() const;
00280     short weekStart() const;
00281 
00289     void setRRule( const QString &rrule );
00290     QString rrule() const;
00291 
00292     void setDirty();
00300     void addObserver( RuleObserver *observer );
00301 
00308     void removeObserver( RuleObserver *observer );
00309 
00313     void dump() const;
00314 
00315   private:
00316     //@cond PRIVATE
00317     class Private;
00318     Private *d;
00319     //@endcond
00320 };
00321 
00322 }
00323 
00324 #endif

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  • kabc
  • kblog
  • kcal
  • kimap
  • kioslave
  •   imap4
  •   mbox
  • kldap
  • kmime
  • kpimidentities
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.5.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal