• Skip to content
  • Skip to link menu
KDE 4.5 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 
00145     void setStartDt( const KDateTime &start );
00146 
00149     bool allDay() const;
00150 
00155     void setAllDay( bool allDay );
00156 
00162     KDateTime endDt( bool *result = 0 ) const;
00163 
00166     void setEndDt( const KDateTime &endDateTime );
00167 
00172     int duration() const;
00173 
00176     void setDuration( int duration );
00177 
00179     int durationTo( const KDateTime &dt ) const;
00180 
00182     int durationTo( const QDate &date ) const;
00183 
00198     void shiftTimes( const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec );
00199 
00206     bool recursOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00207 
00214     bool recursAt( const KDateTime &dt ) const;
00215 
00223     bool dateMatchesRules( const KDateTime &dt ) const;
00224 
00231     TimeList recurTimesOn( const QDate &date, const KDateTime::Spec &timeSpec ) const;
00232 
00244     DateTimeList timesInInterval( const KDateTime &start, const KDateTime &end ) const;
00245 
00251     KDateTime getNextDate( const KDateTime &preDateTime ) const;
00252 
00259     KDateTime getPreviousDate( const KDateTime &afterDateTime ) const;
00260 
00261     void setBySeconds( const QList<int> bySeconds );
00262     void setByMinutes( const QList<int> byMinutes );
00263     void setByHours( const QList<int> byHours );
00264 
00265     void setByDays( const QList<WDayPos> byDays );
00266     void setByMonthDays( const QList<int> byMonthDays );
00267     void setByYearDays( const QList<int> byYearDays );
00268     void setByWeekNumbers( const QList<int> byWeekNumbers );
00269     void setByMonths( const QList<int> byMonths );
00270     void setBySetPos( const QList<int> bySetPos );
00271     void setWeekStart( short weekStart );
00272 
00273     const QList<int> &bySeconds() const;
00274     const QList<int> &byMinutes() const;
00275     const QList<int> &byHours() const;
00276 
00277     const QList<WDayPos> &byDays() const;
00278     const QList<int> &byMonthDays() const;
00279     const QList<int> &byYearDays() const;
00280     const QList<int> &byWeekNumbers() const;
00281     const QList<int> &byMonths() const;
00282     const QList<int> &bySetPos() const;
00283     short weekStart() const;
00284 
00292     void setRRule( const QString &rrule );
00293     QString rrule() const;
00294 
00295     void setDirty();
00303     void addObserver( RuleObserver *observer );
00304 
00311     void removeObserver( RuleObserver *observer );
00312 
00316     void dump() const;
00317 
00318   private:
00319     //@cond PRIVATE
00320     class Private;
00321     Private *d;
00322     //@endcond
00323 };
00324 
00325 }
00326 
00327 #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
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.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