-rw-r--r-- | library/backend/event.cpp | 539 |
1 files changed, 512 insertions, 27 deletions
diff --git a/library/backend/event.cpp b/library/backend/event.cpp index 50a663d..7110717 100644 --- a/library/backend/event.cpp +++ b/library/backend/event.cpp @@ -1,6 +1,6 @@ /********************************************************************** -** Copyright (C) 2001 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the @@ -19,9 +19,9 @@ **********************************************************************/ -#include "event.h"
+#include "event.h" #include "qfiledirect_p.h" -#include <qpe/timeconversion.h> -#include <qpe/stringutil.h> -#include <qpe/recordfields.h> +#include <qtopia/timeconversion.h> +#include <qtopia/stringutil.h> +#include <qtopia/private/recordfields.h> #include <qbuffer.h> #include <time.h> @@ -72,4 +72,253 @@ static void write( QString& buf, const Event::RepeatPattern &r ) Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); +/*! + \class Event event.h + \brief The Event class holds the data of a calendar event. + + This data includes descriptive data of the event and schedualing information. + + \ingroup qtopiaemb + \ingroup qtopiadesktop +*/ + +/*! + \class Event::RepeatPattern + \class The Event::RepeatPattern class is internal. + \internal +*/ + +/*! + \enum Event::Days + \internal +*/ + +/*! + \enum Event::Type + \internal +*/ + +/*! + \enum Event::SoundTypeChoice + + This enum type defines what kind of sound is made when an alarm occurs + for an event. The currently defined types are: + + <ul> + <li>\c Silent - No sound is produced. + <li>\c Loud - A loud sound is produced. + </ul> +*/ + +/*! + \fn bool Event::operator<( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator<=( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator!=( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator>( const Event & ) const + \internal +*/ + +/*! + \fn bool Event::operator>=( const Event & ) const + \internal +*/ + +/*! + \enum Event::RepeatType + + This enum defines how a event will repeat, if at all. + + <ul> + <li>\c NoRepeat - Event does not repeat. + <li>\c Daily - Event occurs every n days. + <li>\c Weekly - Event occurs every n weeks. + <li>\c MonthlyDay - Event occurs every n months. Event will always occur in + the same week and same day of week as the first event. + <li>\c MonthlyDate - Event occurs every n months. Event will always occur + on the same day of the month as the first event. + <li>\c Yearly - Event occurs every n years. + </ul> +*/ + +/*! + \fn bool Event::isAllDay() const + + Returns TRUE if the event is an all day event. Otherwise returns FALSE. +*/ + +/*! + \fn void Event::setAllDay(bool allday) + + If \a allday is TRUE, will set the event to be an all day event. + Otherwise sets the event to not be an all day event. + + \warning This function may affect the start and end times of the event. +*/ + +/*! + \fn QDateTime Event::start() const + + Returns the start date and time of the first occurance of the event. +*/ + +/*! + \fn QDateTime Event::end() const + + Returns the end date and time of the first occurance of the event. +*/ + +/*! + \fn time_t Event::startTime() const + \internal +*/ + +/*! + \fn time_t Event::endTime() const + \internal +*/ + +/*! + \fn void Event::setAlarm(int delay, SoundTypeChoice s) + + Sets the alarm delay of the event to \a delay and the sound type of the + alarm to \a s. +*/ + +/*! + \fn void Event::clearAlarm() + + Clears the alarm for the event. +*/ + +/*! + \fn int Event::alarmDelay() const + + Returns the delay in minutes between the alarm for an event and the + start of the event. +*/ + +/*! + \fn Event::RepeatType Event::repeatType() const + + Returns the repeat pattern type for the event. + + \sa frequency() +*/ + +/*! + \fn int Event::weekOffset() const + + Returns the number of weeks from the start of the month that this event + occurs. +*/ + +/*! + \fn QDate Event::repeatTill() const + + Returns the date that the event will continue to repeat until. If the event + repeats forever the value returned is undefined. + + \sa repeatForever() +*/ + +/*! + \fn bool Event::repeatForever() const + + Returns FALSE if there is a date set for the event to continue until. + Otherwise returns TRUE. +*/ + +/*! + \fn bool Event::doRepeat() const + \internal +*/ + +/*! + \fn bool Event::repeatOnWeekDay(int day) const + + Returns TRUE if the event has a RepeatType of Weekly and is set to occur on + \a day each week. Otherwise returns FALSE. + + \sa QDate::dayName() +*/ + +/*! + \fn void Event::setRepeatOnWeekDay(int day, bool enable) + + If \a enable is TRUE then sets the event to occur on \a day each week. + Otherwise sets the event not to occur on \a day. + + \warning this function is only relavent for a event with RepeatType of + Weekly. + + \sa QDate::dayName() +*/ + +/*! + \fn int Event::frequency() const + + Returns how often the event repeats. + + \sa repeatType() +*/ + +/*! + \fn void Event::setRepeatType(RepeatType t) + + Sets the repeat pattern type of the event to \a t. + + \sa setFrequency() +*/ + +/*! + \fn void Event::setFrequency(int n) + + Sets how often the event occurs with in its repeat pattern. + + \sa setRepeatType() +*/ + +/*! + \fn void Event::setRepeatTill(const QDate &d) + + Sets the event to repeat until \a d. +*/ + +/*! + \fn void Event::setRepeatForever(bool enable) + + If \a enable is TRUE, sets the event to repeat forever. Otherwise + sets the event to stop repeating at some date. + + \warning This function may affect the specific date the event will repeat + till. +*/ + +/*! + \fn bool Event::match(const QRegExp &r) const + + Returns TRUE if the event matches the regular expression \a r. + Otherwise returns FALSE. +*/ + +/*! + \fn char Event::day(int) + \internal +*/ + +/*! + Creates a new, empty event. +*/ Event::Event() : Record() { @@ -84,4 +333,7 @@ Event::Event() : Record() } +/*! + \internal +*/ Event::Event( const QMap<int, QString> &map ) { @@ -107,8 +359,14 @@ Event::Event( const QMap<int, QString> &map ) } +/*! + Destroys an event. +*/ Event::~Event() { } +/*! + \internal +*/ int Event::week( const QDate& date ) { @@ -125,4 +383,7 @@ int Event::week( const QDate& date ) } +/*! + \internal +*/ int Event::occurrence( const QDate& date ) { @@ -132,4 +393,7 @@ int Event::occurrence( const QDate& date ) } +/*! + \internal +*/ int Event::dayOfWeek( char day ) { @@ -143,4 +407,7 @@ int Event::dayOfWeek( char day ) } +/*! + \internal +*/ int Event::monthDiff( const QDate& first, const QDate& second ) { @@ -149,12 +416,22 @@ int Event::monthDiff( const QDate& first, const QDate& second ) } +/*! + \internal +*/ QMap<int, QString> Event::toMap() const { QMap<int, QString> m; - m.insert( DatebookDescription, description() ); - m.insert ( Location, location() ); - m.insert ( DatebookCategory, idsToString( categories() ) ); - m.insert ( TimeZone, timeZone() ); - m.insert ( Note, notes() ); + + if ( !description().isEmpty() ) + m.insert( DatebookDescription, description() ); + if ( !location().isEmpty() ) + m.insert ( Location, location() ); + if ( categories().count() ) + m.insert ( DatebookCategory, idsToString( categories() ) ); + if ( !timeZone().isEmpty() ) + m.insert ( TimeZone, timeZone() ); + if ( !notes().isEmpty() ) + m.insert ( Note, notes() ); + m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); @@ -175,4 +452,7 @@ QMap<int, QString> Event::toMap() const } +/*! + \internal +*/ void Event::setRepeat( const RepeatPattern &p ) { @@ -180,4 +460,7 @@ void Event::setRepeat( const RepeatPattern &p ) } +/*! + Sets the description of the event to \a s. +*/ void Event::setDescription( const QString &s ) { @@ -185,4 +468,7 @@ void Event::setDescription( const QString &s ) } +/*! + Sets the location of the event to \a s. +*/ void Event::setLocation( const QString &s ) { @@ -195,4 +481,7 @@ void Event::setLocation( const QString &s ) // } +/*! + \internal +*/ void Event::setType( Type t ) { @@ -200,4 +489,8 @@ void Event::setType( Type t ) } +/*! + Sets the start date and time of the first or only occurance of this event + to the date and time \a d. \a d should be in local time. +*/ void Event::setStart( const QDateTime &d ) { @@ -205,4 +498,7 @@ void Event::setStart( const QDateTime &d ) } +/*! + \internal +*/ void Event::setStart( time_t time ) { @@ -210,4 +506,8 @@ void Event::setStart( time_t time ) } +/*! + Sets the end date and time of the first or only occurance of this event + to the date and time \a d. \a d should be in local time. +*/ void Event::setEnd( const QDateTime &d ) { @@ -215,4 +515,7 @@ void Event::setEnd( const QDateTime &d ) } +/*! + \internal +*/ void Event::setEnd( time_t time ) { @@ -220,4 +523,7 @@ void Event::setEnd( time_t time ) } +/*! + \internal +*/ void Event::setTimeZone( const QString &z ) { @@ -225,4 +531,7 @@ void Event::setTimeZone( const QString &z ) } +/*! + \internal +*/ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) { @@ -232,4 +541,7 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) } +/*! + \internal +*/ void Event::setRepeat( bool b, const RepeatPattern &p ) { @@ -238,4 +550,7 @@ void Event::setRepeat( bool b, const RepeatPattern &p ) } +/*! + Sets the notes for the event to \a n. +*/ void Event::setNotes( const QString &n ) { @@ -243,4 +558,7 @@ void Event::setNotes( const QString &n ) } +/*! + Returns the description of the event. +*/ const QString &Event::description() const { @@ -248,4 +566,7 @@ const QString &Event::description() const } +/*! + Returns the location of the event. +*/ const QString &Event::location() const { @@ -258,4 +579,7 @@ const QString &Event::location() const // } +/*! + \internal +*/ Event::Type Event::type() const { @@ -263,4 +587,7 @@ Event::Type Event::type() const } +/*! + \internal +*/ QDateTime Event::start( bool actual ) const { @@ -275,4 +602,7 @@ QDateTime Event::start( bool actual ) const } +/*! + \internal +*/ QDateTime Event::end( bool actual ) const { @@ -287,4 +617,7 @@ QDateTime Event::end( bool actual ) const } +/*! + \internal +*/ const QString &Event::timeZone() const { @@ -292,4 +625,7 @@ const QString &Event::timeZone() const } +/*! + \internal +*/ bool Event::hasAlarm() const { @@ -297,4 +633,7 @@ bool Event::hasAlarm() const } +/*! + \internal +*/ int Event::alarmTime() const { @@ -302,4 +641,7 @@ int Event::alarmTime() const } +/*! + Returns the sound type for the alarm of this event. +*/ Event::SoundTypeChoice Event::alarmSound() const { @@ -307,4 +649,7 @@ Event::SoundTypeChoice Event::alarmSound() const } +/*! + \internal +*/ bool Event::hasRepeat() const { @@ -312,4 +657,7 @@ bool Event::hasRepeat() const } +/*! + \internal +*/ const Event::RepeatPattern &Event::repeatPattern() const { @@ -317,4 +665,7 @@ const Event::RepeatPattern &Event::repeatPattern() const } +/*! + \internal +*/ Event::RepeatPattern &Event::repeatPattern() { @@ -322,4 +673,7 @@ Event::RepeatPattern &Event::repeatPattern() } +/*! + Returns the notes for the event. +*/ const QString &Event::notes() const { @@ -327,6 +681,11 @@ const QString &Event::notes() const } +/*! + \internal +*/ bool Event::operator==( const Event &e ) const { + if ( uid() && e.uid() == uid() ) + return TRUE; return ( e.descript == descript && e.locat == locat && @@ -344,4 +703,8 @@ bool Event::operator==( const Event &e ) const } +/*! + \internal + Appends the contact information to \a buf. +*/ void Event::save( QString& buf ) { @@ -379,4 +742,7 @@ void Event::save( QString& buf ) } +/*! + \internal +*/ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const { @@ -391,4 +757,26 @@ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const } +/*! + \class EffectiveEvent + \brief The EffectiveEvent class the data for a single occurance of an event. + + This class describes the event for a single occurance of it. For example if + an Event occurs every week, the effective event might represent the third + occurance of this Event. + + \ingroup qtopiaemb + \ingroup qtopiadesktop + \warning This class will be phased out in Qtopia 3.x +*/ + +/*! + \enum EffectiveEvent::Position + \internal +*/ + +/*! + \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &) + \internal +*/ class EffectiveEventPrivate @@ -401,5 +789,7 @@ public: }; - +/*! + \internal +*/ EffectiveEvent::EffectiveEvent() { @@ -409,4 +799,7 @@ EffectiveEvent::EffectiveEvent() } +/*! + \internal +*/ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) { @@ -425,4 +818,7 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos } +/*! + \internal +*/ EffectiveEvent::~EffectiveEvent() { @@ -430,4 +826,7 @@ EffectiveEvent::~EffectiveEvent() } +/*! + \internal +*/ EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) { @@ -462,4 +861,7 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e ) // } +/*! + Returns the description of the event for this effective event. +*/ const QString &EffectiveEvent::description( ) const { @@ -467,4 +869,7 @@ const QString &EffectiveEvent::description( ) const } +/*! +\internal +*/ const QString &EffectiveEvent::location( ) const { @@ -472,4 +877,7 @@ const QString &EffectiveEvent::location( ) const } +/*! +\internal +*/ const QString &EffectiveEvent::notes() const { @@ -477,4 +885,7 @@ const QString &EffectiveEvent::notes() const } +/*! + Returns the event associated with this effective event. +*/ const Event &EffectiveEvent::event() const { @@ -482,4 +893,7 @@ const Event &EffectiveEvent::event() const } +/*! + \internal +*/ const QTime &EffectiveEvent::end() const { @@ -487,4 +901,7 @@ const QTime &EffectiveEvent::end() const } +/*! + \internal +*/ const QTime &EffectiveEvent::start() const { @@ -492,4 +909,7 @@ const QTime &EffectiveEvent::start() const } +/*! + Returns the date the effective event occurs on. +*/ const QDate &EffectiveEvent::date() const { @@ -497,4 +917,7 @@ const QDate &EffectiveEvent::date() const } +/*! + \internal +*/ int EffectiveEvent::length() const { @@ -503,4 +926,7 @@ int EffectiveEvent::length() const } +/*! + \internal +*/ void EffectiveEvent::setDate( const QDate &dt ) { @@ -508,4 +934,7 @@ void EffectiveEvent::setDate( const QDate &dt ) } +/*! + \internal +*/ void EffectiveEvent::setStart( const QTime &start ) { @@ -513,4 +942,7 @@ void EffectiveEvent::setStart( const QTime &start ) } +/*! + \internal +*/ void EffectiveEvent::setEnd( const QTime &end ) { @@ -518,4 +950,7 @@ void EffectiveEvent::setEnd( const QTime &end ) } +/*! + \internal +*/ void EffectiveEvent::setEvent( Event e ) { @@ -523,4 +958,7 @@ void EffectiveEvent::setEvent( Event e ) } +/*! + \internal +*/ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const { @@ -533,4 +971,7 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const } +/*! + \internal +*/ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const { @@ -538,4 +979,7 @@ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const } +/*! + \internal +*/ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const { @@ -546,4 +990,7 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const } +/*! + \internal +*/ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const { @@ -551,4 +998,7 @@ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const } +/*! + \internal +*/ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const { @@ -556,4 +1006,7 @@ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const } +/*! + \internal +*/ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const { @@ -561,4 +1014,7 @@ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const } +/*! + \internal +*/ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) { @@ -574,4 +1030,7 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) } +/*! + \internal +*/ QDate EffectiveEvent::startDate() const { @@ -584,4 +1043,7 @@ QDate EffectiveEvent::startDate() const } +/*! + \internal +*/ QDate EffectiveEvent::endDate() const { @@ -594,4 +1056,7 @@ QDate EffectiveEvent::endDate() const } +/*! + \internal +*/ int EffectiveEvent::size() const { @@ -741,12 +1206,20 @@ static Event parseVObject( VObject *obj ) - +/*! + Writes the list of \a events as a set of VCards to the file \a filename. +*/ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) -{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
+{ + + QFileDirect f( filename.utf8().data() ); + + if ( !f.open( IO_WriteOnly ) ) { + + qWarning("Unable to open vcard write"); + + return; + + } + QValueList<Event>::ConstIterator it; @@ -755,16 +1228,26 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev writeVObject( f.directHandle() , obj ); cleanVObject( obj ); - }
+ } + cleanStrTbl(); } +/*! + Writes \a event as a VCard to the file \a filename. +*/ void Event::writeVCalendar( const QString &filename, const Event &event) -{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
+{ + + QFileDirect f( filename.utf8().data() ); + + if ( !f.open( IO_WriteOnly ) ) { + + qWarning("Unable to open vcard write"); + + return; + + } + VObject *obj = createVObject( event ); @@ -775,5 +1258,7 @@ void Event::writeVCalendar( const QString &filename, const Event &event) } - +/*! + Returns the set of events read as VCards from the file \a filename. +*/ QValueList<Event> Event::readVCalendar( const QString &filename ) { |