summaryrefslogtreecommitdiff
path: root/library/backend/event.cpp
Side-by-side diff
Diffstat (limited to 'library/backend/event.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/event.cpp539
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,5 +1,5 @@
/**********************************************************************
-** 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.
**
@@ -20,7 +20,7 @@
-#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>
@@ -73,2 +73,251 @@ 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()
@@ -85,2 +334,5 @@ Event::Event() : Record()
+/*!
+ \internal
+*/
Event::Event( const QMap<int, QString> &map )
@@ -108,2 +360,5 @@ Event::Event( const QMap<int, QString> &map )
+/*!
+ Destroys an event.
+*/
Event::~Event()
@@ -112,2 +367,5 @@ Event::~Event()
+/*!
+ \internal
+*/
int Event::week( const QDate& date )
@@ -126,2 +384,5 @@ int Event::week( const QDate& date )
+/*!
+ \internal
+*/
int Event::occurrence( const QDate& date )
@@ -133,2 +394,5 @@ int Event::occurrence( const QDate& date )
+/*!
+ \internal
+*/
int Event::dayOfWeek( char day )
@@ -144,2 +408,5 @@ int Event::dayOfWeek( char day )
+/*!
+ \internal
+*/
int Event::monthDiff( const QDate& first, const QDate& second )
@@ -150,2 +417,5 @@ int Event::monthDiff( const QDate& first, const QDate& second )
+/*!
+ \internal
+*/
QMap<int, QString> Event::toMap() const
@@ -153,7 +423,14 @@ 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() ) ) );
@@ -176,2 +453,5 @@ QMap<int, QString> Event::toMap() const
+/*!
+ \internal
+*/
void Event::setRepeat( const RepeatPattern &p )
@@ -181,2 +461,5 @@ void Event::setRepeat( const RepeatPattern &p )
+/*!
+ Sets the description of the event to \a s.
+*/
void Event::setDescription( const QString &s )
@@ -186,2 +469,5 @@ void Event::setDescription( const QString &s )
+/*!
+ Sets the location of the event to \a s.
+*/
void Event::setLocation( const QString &s )
@@ -196,2 +482,5 @@ void Event::setLocation( const QString &s )
+/*!
+ \internal
+*/
void Event::setType( Type t )
@@ -201,2 +490,6 @@ 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 )
@@ -206,2 +499,5 @@ void Event::setStart( const QDateTime &d )
+/*!
+ \internal
+*/
void Event::setStart( time_t time )
@@ -211,2 +507,6 @@ 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 )
@@ -216,2 +516,5 @@ void Event::setEnd( const QDateTime &d )
+/*!
+ \internal
+*/
void Event::setEnd( time_t time )
@@ -221,2 +524,5 @@ void Event::setEnd( time_t time )
+/*!
+ \internal
+*/
void Event::setTimeZone( const QString &z )
@@ -226,2 +532,5 @@ void Event::setTimeZone( const QString &z )
+/*!
+ \internal
+*/
void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
@@ -233,2 +542,5 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
+/*!
+ \internal
+*/
void Event::setRepeat( bool b, const RepeatPattern &p )
@@ -239,2 +551,5 @@ void Event::setRepeat( bool b, const RepeatPattern &p )
+/*!
+ Sets the notes for the event to \a n.
+*/
void Event::setNotes( const QString &n )
@@ -244,2 +559,5 @@ void Event::setNotes( const QString &n )
+/*!
+ Returns the description of the event.
+*/
const QString &Event::description() const
@@ -249,2 +567,5 @@ const QString &Event::description() const
+/*!
+ Returns the location of the event.
+*/
const QString &Event::location() const
@@ -259,2 +580,5 @@ const QString &Event::location() const
+/*!
+ \internal
+*/
Event::Type Event::type() const
@@ -264,2 +588,5 @@ Event::Type Event::type() const
+/*!
+ \internal
+*/
QDateTime Event::start( bool actual ) const
@@ -276,2 +603,5 @@ QDateTime Event::start( bool actual ) const
+/*!
+ \internal
+*/
QDateTime Event::end( bool actual ) const
@@ -288,2 +618,5 @@ QDateTime Event::end( bool actual ) const
+/*!
+ \internal
+*/
const QString &Event::timeZone() const
@@ -293,2 +626,5 @@ const QString &Event::timeZone() const
+/*!
+ \internal
+*/
bool Event::hasAlarm() const
@@ -298,2 +634,5 @@ bool Event::hasAlarm() const
+/*!
+ \internal
+*/
int Event::alarmTime() const
@@ -303,2 +642,5 @@ int Event::alarmTime() const
+/*!
+ Returns the sound type for the alarm of this event.
+*/
Event::SoundTypeChoice Event::alarmSound() const
@@ -308,2 +650,5 @@ Event::SoundTypeChoice Event::alarmSound() const
+/*!
+ \internal
+*/
bool Event::hasRepeat() const
@@ -313,2 +658,5 @@ bool Event::hasRepeat() const
+/*!
+ \internal
+*/
const Event::RepeatPattern &Event::repeatPattern() const
@@ -318,2 +666,5 @@ const Event::RepeatPattern &Event::repeatPattern() const
+/*!
+ \internal
+*/
Event::RepeatPattern &Event::repeatPattern()
@@ -323,2 +674,5 @@ Event::RepeatPattern &Event::repeatPattern()
+/*!
+ Returns the notes for the event.
+*/
const QString &Event::notes() const
@@ -328,4 +682,9 @@ const QString &Event::notes() const
+/*!
+ \internal
+*/
bool Event::operator==( const Event &e ) const
{
+ if ( uid() && e.uid() == uid() )
+ return TRUE;
return ( e.descript == descript &&
@@ -345,2 +704,6 @@ bool Event::operator==( const Event &e ) const
+/*!
+ \internal
+ Appends the contact information to \a buf.
+*/
void Event::save( QString& buf )
@@ -380,2 +743,5 @@ void Event::save( QString& buf )
+/*!
+ \internal
+*/
bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
@@ -392,2 +758,24 @@ 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
+*/
@@ -402,3 +790,5 @@ public:
-
+/*!
+ \internal
+*/
EffectiveEvent::EffectiveEvent()
@@ -410,2 +800,5 @@ EffectiveEvent::EffectiveEvent()
+/*!
+ \internal
+*/
EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos )
@@ -426,2 +819,5 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos
+/*!
+ \internal
+*/
EffectiveEvent::~EffectiveEvent()
@@ -431,2 +827,5 @@ EffectiveEvent::~EffectiveEvent()
+/*!
+ \internal
+*/
EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
@@ -463,2 +862,5 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
+/*!
+ Returns the description of the event for this effective event.
+*/
const QString &EffectiveEvent::description( ) const
@@ -468,2 +870,5 @@ const QString &EffectiveEvent::description( ) const
+/*!
+\internal
+*/
const QString &EffectiveEvent::location( ) const
@@ -473,2 +878,5 @@ const QString &EffectiveEvent::location( ) const
+/*!
+\internal
+*/
const QString &EffectiveEvent::notes() const
@@ -478,2 +886,5 @@ const QString &EffectiveEvent::notes() const
+/*!
+ Returns the event associated with this effective event.
+*/
const Event &EffectiveEvent::event() const
@@ -483,2 +894,5 @@ const Event &EffectiveEvent::event() const
+/*!
+ \internal
+*/
const QTime &EffectiveEvent::end() const
@@ -488,2 +902,5 @@ const QTime &EffectiveEvent::end() const
+/*!
+ \internal
+*/
const QTime &EffectiveEvent::start() const
@@ -493,2 +910,5 @@ const QTime &EffectiveEvent::start() const
+/*!
+ Returns the date the effective event occurs on.
+*/
const QDate &EffectiveEvent::date() const
@@ -498,2 +918,5 @@ const QDate &EffectiveEvent::date() const
+/*!
+ \internal
+*/
int EffectiveEvent::length() const
@@ -504,2 +927,5 @@ int EffectiveEvent::length() const
+/*!
+ \internal
+*/
void EffectiveEvent::setDate( const QDate &dt )
@@ -509,2 +935,5 @@ void EffectiveEvent::setDate( const QDate &dt )
+/*!
+ \internal
+*/
void EffectiveEvent::setStart( const QTime &start )
@@ -514,2 +943,5 @@ void EffectiveEvent::setStart( const QTime &start )
+/*!
+ \internal
+*/
void EffectiveEvent::setEnd( const QTime &end )
@@ -519,2 +951,5 @@ void EffectiveEvent::setEnd( const QTime &end )
+/*!
+ \internal
+*/
void EffectiveEvent::setEvent( Event e )
@@ -524,2 +959,5 @@ void EffectiveEvent::setEvent( Event e )
+/*!
+ \internal
+*/
bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
@@ -534,2 +972,5 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
+/*!
+ \internal
+*/
bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
@@ -539,2 +980,5 @@ bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
+/*!
+ \internal
+*/
bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
@@ -547,2 +991,5 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
+/*!
+ \internal
+*/
bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
@@ -552,2 +999,5 @@ bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
+/*!
+ \internal
+*/
bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
@@ -557,2 +1007,5 @@ bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
+/*!
+ \internal
+*/
bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
@@ -562,2 +1015,5 @@ bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
+/*!
+ \internal
+*/
void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
@@ -575,2 +1031,5 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
+/*!
+ \internal
+*/
QDate EffectiveEvent::startDate() const
@@ -585,2 +1044,5 @@ QDate EffectiveEvent::startDate() const
+/*!
+ \internal
+*/
QDate EffectiveEvent::endDate() const
@@ -595,2 +1057,5 @@ QDate EffectiveEvent::endDate() const
+/*!
+ \internal
+*/
int EffectiveEvent::size() const
@@ -742,10 +1207,18 @@ 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;
+
+ }
+
@@ -756,3 +1229,4 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev
cleanVObject( obj );
- }
+ }
+
@@ -761,9 +1235,18 @@ void Event::writeVCalendar( const QString &filename, const QValueList<Event> &ev
+/*!
+ 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;
+
+ }
+
@@ -776,3 +1259,5 @@ 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 )