summaryrefslogtreecommitdiff
path: root/library/backend/event.cpp
authorzecke <zecke>2002-09-10 12:09:49 (UTC)
committer zecke <zecke>2002-09-10 12:09:49 (UTC)
commit6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff)
tree6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/backend/event.cpp
parentd10cddb3c9ce75bc90b14add14bc133737fe35aa (diff)
downloadopie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz
opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2
Qtopia1-6 merge
still to test bic changes to be resolved more changes to be made?
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,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
@@ -18,11 +18,11 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "event.h" 21#include "event.h"
22#include "qfiledirect_p.h" 22#include "qfiledirect_p.h"
23#include <qpe/timeconversion.h> 23#include <qtopia/timeconversion.h>
24#include <qpe/stringutil.h> 24#include <qtopia/stringutil.h>
25#include <qpe/recordfields.h> 25#include <qtopia/private/recordfields.h>
26#include <qbuffer.h> 26#include <qbuffer.h>
27#include <time.h> 27#include <time.h>
28#include "vobject_p.h" 28#include "vobject_p.h"
@@ -71,6 +71,255 @@ static void write( QString& buf, const Event::RepeatPattern &r )
71 71
72Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia ); 72Qtopia::UidGen Event::sUidGen( Qtopia::UidGen::Qtopia );
73 73
74/*!
75 \class Event event.h
76 \brief The Event class holds the data of a calendar event.
77
78 This data includes descriptive data of the event and schedualing information.
79
80 \ingroup qtopiaemb
81 \ingroup qtopiadesktop
82*/
83
84/*!
85 \class Event::RepeatPattern
86 \class The Event::RepeatPattern class is internal.
87 \internal
88*/
89
90/*!
91 \enum Event::Days
92 \internal
93*/
94
95/*!
96 \enum Event::Type
97 \internal
98*/
99
100/*!
101 \enum Event::SoundTypeChoice
102
103 This enum type defines what kind of sound is made when an alarm occurs
104 for an event. The currently defined types are:
105
106 <ul>
107 <li>\c Silent - No sound is produced.
108 <li>\c Loud - A loud sound is produced.
109 </ul>
110*/
111
112/*!
113 \fn bool Event::operator<( const Event & ) const
114 \internal
115*/
116
117/*!
118 \fn bool Event::operator<=( const Event & ) const
119 \internal
120*/
121
122/*!
123 \fn bool Event::operator!=( const Event & ) const
124 \internal
125*/
126
127/*!
128 \fn bool Event::operator>( const Event & ) const
129 \internal
130*/
131
132/*!
133 \fn bool Event::operator>=( const Event & ) const
134 \internal
135*/
136
137/*!
138 \enum Event::RepeatType
139
140 This enum defines how a event will repeat, if at all.
141
142 <ul>
143 <li>\c NoRepeat - Event does not repeat.
144 <li>\c Daily - Event occurs every n days.
145 <li>\c Weekly - Event occurs every n weeks.
146 <li>\c MonthlyDay - Event occurs every n months. Event will always occur in
147 the same week and same day of week as the first event.
148 <li>\c MonthlyDate - Event occurs every n months. Event will always occur
149 on the same day of the month as the first event.
150 <li>\c Yearly - Event occurs every n years.
151 </ul>
152*/
153
154/*!
155 \fn bool Event::isAllDay() const
156
157 Returns TRUE if the event is an all day event. Otherwise returns FALSE.
158*/
159
160/*!
161 \fn void Event::setAllDay(bool allday)
162
163 If \a allday is TRUE, will set the event to be an all day event.
164 Otherwise sets the event to not be an all day event.
165
166 \warning This function may affect the start and end times of the event.
167*/
168
169/*!
170 \fn QDateTime Event::start() const
171
172 Returns the start date and time of the first occurance of the event.
173*/
174
175/*!
176 \fn QDateTime Event::end() const
177
178 Returns the end date and time of the first occurance of the event.
179*/
180
181/*!
182 \fn time_t Event::startTime() const
183 \internal
184*/
185
186/*!
187 \fn time_t Event::endTime() const
188 \internal
189*/
190
191/*!
192 \fn void Event::setAlarm(int delay, SoundTypeChoice s)
193
194 Sets the alarm delay of the event to \a delay and the sound type of the
195 alarm to \a s.
196*/
197
198/*!
199 \fn void Event::clearAlarm()
200
201 Clears the alarm for the event.
202*/
203
204/*!
205 \fn int Event::alarmDelay() const
206
207 Returns the delay in minutes between the alarm for an event and the
208 start of the event.
209*/
210
211/*!
212 \fn Event::RepeatType Event::repeatType() const
213
214 Returns the repeat pattern type for the event.
215
216 \sa frequency()
217*/
218
219/*!
220 \fn int Event::weekOffset() const
221
222 Returns the number of weeks from the start of the month that this event
223 occurs.
224*/
225
226/*!
227 \fn QDate Event::repeatTill() const
228
229 Returns the date that the event will continue to repeat until. If the event
230 repeats forever the value returned is undefined.
231
232 \sa repeatForever()
233*/
234
235/*!
236 \fn bool Event::repeatForever() const
237
238 Returns FALSE if there is a date set for the event to continue until.
239 Otherwise returns TRUE.
240*/
241
242/*!
243 \fn bool Event::doRepeat() const
244 \internal
245*/
246
247/*!
248 \fn bool Event::repeatOnWeekDay(int day) const
249
250 Returns TRUE if the event has a RepeatType of Weekly and is set to occur on
251 \a day each week. Otherwise returns FALSE.
252
253 \sa QDate::dayName()
254*/
255
256/*!
257 \fn void Event::setRepeatOnWeekDay(int day, bool enable)
258
259 If \a enable is TRUE then sets the event to occur on \a day each week.
260 Otherwise sets the event not to occur on \a day.
261
262 \warning this function is only relavent for a event with RepeatType of
263 Weekly.
264
265 \sa QDate::dayName()
266*/
267
268/*!
269 \fn int Event::frequency() const
270
271 Returns how often the event repeats.
272
273 \sa repeatType()
274*/
275
276/*!
277 \fn void Event::setRepeatType(RepeatType t)
278
279 Sets the repeat pattern type of the event to \a t.
280
281 \sa setFrequency()
282*/
283
284/*!
285 \fn void Event::setFrequency(int n)
286
287 Sets how often the event occurs with in its repeat pattern.
288
289 \sa setRepeatType()
290*/
291
292/*!
293 \fn void Event::setRepeatTill(const QDate &d)
294
295 Sets the event to repeat until \a d.
296*/
297
298/*!
299 \fn void Event::setRepeatForever(bool enable)
300
301 If \a enable is TRUE, sets the event to repeat forever. Otherwise
302 sets the event to stop repeating at some date.
303
304 \warning This function may affect the specific date the event will repeat
305 till.
306*/
307
308/*!
309 \fn bool Event::match(const QRegExp &r) const
310
311 Returns TRUE if the event matches the regular expression \a r.
312 Otherwise returns FALSE.
313*/
314
315/*!
316 \fn char Event::day(int)
317 \internal
318*/
319
320/*!
321 Creates a new, empty event.
322*/
74Event::Event() : Record() 323Event::Event() : Record()
75{ 324{
76 startUTC = endUTC = time( 0 ); 325 startUTC = endUTC = time( 0 );
@@ -83,6 +332,9 @@ Event::Event() : Record()
83 pattern.frequency = -1; 332 pattern.frequency = -1;
84} 333}
85 334
335/*!
336 \internal
337*/
86Event::Event( const QMap<int, QString> &map ) 338Event::Event( const QMap<int, QString> &map )
87{ 339{
88 setDescription( map[DatebookDescription] ); 340 setDescription( map[DatebookDescription] );
@@ -106,10 +358,16 @@ Event::Event( const QMap<int, QString> &map )
106 setUid( map[ DatebookUid ].toInt() ); 358 setUid( map[ DatebookUid ].toInt() );
107} 359}
108 360
361/*!
362 Destroys an event.
363*/
109Event::~Event() 364Event::~Event()
110{ 365{
111} 366}
112 367
368/*!
369 \internal
370*/
113int Event::week( const QDate& date ) 371int Event::week( const QDate& date )
114{ 372{
115 // Calculates the week this date is in within that 373 // Calculates the week this date is in within that
@@ -124,6 +382,9 @@ int Event::week( const QDate& date )
124 return week; 382 return week;
125} 383}
126 384
385/*!
386 \internal
387*/
127int Event::occurrence( const QDate& date ) 388int Event::occurrence( const QDate& date )
128{ 389{
129 // calculates the number of occurrances of this day of the 390 // calculates the number of occurrances of this day of the
@@ -131,6 +392,9 @@ int Event::occurrence( const QDate& date )
131 return ( date.day() - 1 ) / 7 + 1; 392 return ( date.day() - 1 ) / 7 + 1;
132} 393}
133 394
395/*!
396 \internal
397*/
134int Event::dayOfWeek( char day ) 398int Event::dayOfWeek( char day )
135{ 399{
136 int dayOfWeek = 1; 400 int dayOfWeek = 1;
@@ -142,20 +406,33 @@ int Event::dayOfWeek( char day )
142 return dayOfWeek; 406 return dayOfWeek;
143} 407}
144 408
409/*!
410 \internal
411*/
145int Event::monthDiff( const QDate& first, const QDate& second ) 412int Event::monthDiff( const QDate& first, const QDate& second )
146{ 413{
147 return ( second.year() - first.year() ) * 12 + 414 return ( second.year() - first.year() ) * 12 +
148 second.month() - first.month(); 415 second.month() - first.month();
149} 416}
150 417
418/*!
419 \internal
420*/
151QMap<int, QString> Event::toMap() const 421QMap<int, QString> Event::toMap() const
152{ 422{
153 QMap<int, QString> m; 423 QMap<int, QString> m;
154 m.insert( DatebookDescription, description() ); 424
155 m.insert ( Location, location() ); 425 if ( !description().isEmpty() )
156 m.insert ( DatebookCategory, idsToString( categories() ) ); 426 m.insert( DatebookDescription, description() );
157 m.insert ( TimeZone, timeZone() ); 427 if ( !location().isEmpty() )
158 m.insert ( Note, notes() ); 428 m.insert ( Location, location() );
429 if ( categories().count() )
430 m.insert ( DatebookCategory, idsToString( categories() ) );
431 if ( !timeZone().isEmpty() )
432 m.insert ( TimeZone, timeZone() );
433 if ( !notes().isEmpty() )
434 m.insert ( Note, notes() );
435
159 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) ); 436 m.insert ( StartDateTime, QString::number( TimeConversion::toUTC( start() ) ) );
160 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) ); 437 m.insert ( EndDateTime, QString::number( TimeConversion::toUTC( end() ) ) );
161 m.insert ( DatebookType, QString::number( (int)type() ) ); 438 m.insert ( DatebookType, QString::number( (int)type() ) );
@@ -174,16 +451,25 @@ QMap<int, QString> Event::toMap() const
174 return m; 451 return m;
175} 452}
176 453
454/*!
455 \internal
456*/
177void Event::setRepeat( const RepeatPattern &p ) 457void Event::setRepeat( const RepeatPattern &p )
178{ 458{
179 setRepeat( p.type != NoRepeat, p ); 459 setRepeat( p.type != NoRepeat, p );
180} 460}
181 461
462/*!
463 Sets the description of the event to \a s.
464*/
182void Event::setDescription( const QString &s ) 465void Event::setDescription( const QString &s )
183{ 466{
184 descript = s; 467 descript = s;
185} 468}
186 469
470/*!
471 Sets the location of the event to \a s.
472*/
187void Event::setLocation( const QString &s ) 473void Event::setLocation( const QString &s )
188{ 474{
189 locat = s; 475 locat = s;
@@ -194,36 +480,59 @@ void Event::setLocation( const QString &s )
194// categ = s; 480// categ = s;
195// } 481// }
196 482
483/*!
484 \internal
485*/
197void Event::setType( Type t ) 486void Event::setType( Type t )
198{ 487{
199 typ = t; 488 typ = t;
200} 489}
201 490
491/*!
492 Sets the start date and time of the first or only occurance of this event
493 to the date and time \a d. \a d should be in local time.
494*/
202void Event::setStart( const QDateTime &d ) 495void Event::setStart( const QDateTime &d )
203{ 496{
204 startUTC = TimeConversion::toUTC( d ); 497 startUTC = TimeConversion::toUTC( d );
205} 498}
206 499
500/*!
501 \internal
502*/
207void Event::setStart( time_t time ) 503void Event::setStart( time_t time )
208{ 504{
209 startUTC = time; 505 startUTC = time;
210} 506}
211 507
508/*!
509 Sets the end date and time of the first or only occurance of this event
510 to the date and time \a d. \a d should be in local time.
511*/
212void Event::setEnd( const QDateTime &d ) 512void Event::setEnd( const QDateTime &d )
213{ 513{
214 endUTC = TimeConversion::toUTC( d ); 514 endUTC = TimeConversion::toUTC( d );
215} 515}
216 516
517/*!
518 \internal
519*/
217void Event::setEnd( time_t time ) 520void Event::setEnd( time_t time )
218{ 521{
219 endUTC = time; 522 endUTC = time;
220} 523}
221 524
525/*!
526 \internal
527*/
222void Event::setTimeZone( const QString &z ) 528void Event::setTimeZone( const QString &z )
223{ 529{
224 tz = z; 530 tz = z;
225} 531}
226 532
533/*!
534 \internal
535*/
227void Event::setAlarm( bool b, int minutes, SoundTypeChoice s ) 536void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
228{ 537{
229 hAlarm = b; 538 hAlarm = b;
@@ -231,22 +540,34 @@ void Event::setAlarm( bool b, int minutes, SoundTypeChoice s )
231 aSound = s; 540 aSound = s;
232} 541}
233 542
543/*!
544 \internal
545*/
234void Event::setRepeat( bool b, const RepeatPattern &p ) 546void Event::setRepeat( bool b, const RepeatPattern &p )
235{ 547{
236 hRepeat = b; 548 hRepeat = b;
237 pattern = p; 549 pattern = p;
238} 550}
239 551
552/*!
553 Sets the notes for the event to \a n.
554*/
240void Event::setNotes( const QString &n ) 555void Event::setNotes( const QString &n )
241{ 556{
242 note = n; 557 note = n;
243} 558}
244 559
560/*!
561 Returns the description of the event.
562*/
245const QString &Event::description() const 563const QString &Event::description() const
246{ 564{
247 return descript; 565 return descript;
248} 566}
249 567
568/*!
569 Returns the location of the event.
570*/
250const QString &Event::location() const 571const QString &Event::location() const
251{ 572{
252 return locat; 573 return locat;
@@ -257,11 +578,17 @@ const QString &Event::location() const
257// return categ; 578// return categ;
258// } 579// }
259 580
581/*!
582 \internal
583*/
260Event::Type Event::type() const 584Event::Type Event::type() const
261{ 585{
262 return typ; 586 return typ;
263} 587}
264 588
589/*!
590 \internal
591*/
265QDateTime Event::start( bool actual ) const 592QDateTime Event::start( bool actual ) const
266{ 593{
267 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime(); 594 QDateTime dt = (startUTC > 0) ? TimeConversion::fromUTC( startUTC ) : QDateTime::currentDateTime();
@@ -274,6 +601,9 @@ QDateTime Event::start( bool actual ) const
274 return dt; 601 return dt;
275} 602}
276 603
604/*!
605 \internal
606*/
277QDateTime Event::end( bool actual ) const 607QDateTime Event::end( bool actual ) const
278{ 608{
279 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime(); 609 QDateTime dt = (endUTC > 0) ? TimeConversion::fromUTC( endUTC ) : QDateTime::currentDateTime();
@@ -286,48 +616,77 @@ QDateTime Event::end( bool actual ) const
286 return dt; 616 return dt;
287} 617}
288 618
619/*!
620 \internal
621*/
289const QString &Event::timeZone() const 622const QString &Event::timeZone() const
290{ 623{
291 return tz; 624 return tz;
292} 625}
293 626
627/*!
628 \internal
629*/
294bool Event::hasAlarm() const 630bool Event::hasAlarm() const
295{ 631{
296 return hAlarm; 632 return hAlarm;
297} 633}
298 634
635/*!
636 \internal
637*/
299int Event::alarmTime() const 638int Event::alarmTime() const
300{ 639{
301 return aMinutes; 640 return aMinutes;
302} 641}
303 642
643/*!
644 Returns the sound type for the alarm of this event.
645*/
304Event::SoundTypeChoice Event::alarmSound() const 646Event::SoundTypeChoice Event::alarmSound() const
305{ 647{
306 return aSound; 648 return aSound;
307} 649}
308 650
651/*!
652 \internal
653*/
309bool Event::hasRepeat() const 654bool Event::hasRepeat() const
310{ 655{
311 return doRepeat(); 656 return doRepeat();
312} 657}
313 658
659/*!
660 \internal
661*/
314const Event::RepeatPattern &Event::repeatPattern() const 662const Event::RepeatPattern &Event::repeatPattern() const
315{ 663{
316 return pattern; 664 return pattern;
317} 665}
318 666
667/*!
668 \internal
669*/
319Event::RepeatPattern &Event::repeatPattern() 670Event::RepeatPattern &Event::repeatPattern()
320{ 671{
321 return pattern; 672 return pattern;
322} 673}
323 674
675/*!
676 Returns the notes for the event.
677*/
324const QString &Event::notes() const 678const QString &Event::notes() const
325{ 679{
326 return note; 680 return note;
327} 681}
328 682
683/*!
684 \internal
685*/
329bool Event::operator==( const Event &e ) const 686bool Event::operator==( const Event &e ) const
330{ 687{
688 if ( uid() && e.uid() == uid() )
689 return TRUE;
331 return ( e.descript == descript && 690 return ( e.descript == descript &&
332 e.locat == locat && 691 e.locat == locat &&
333 e.categ == categ && 692 e.categ == categ &&
@@ -343,6 +702,10 @@ bool Event::operator==( const Event &e ) const
343 e.note == note ); 702 e.note == note );
344} 703}
345 704
705/*!
706 \internal
707 Appends the contact information to \a buf.
708*/
346void Event::save( QString& buf ) 709void Event::save( QString& buf )
347{ 710{
348 buf += " description=\"" + Qtopia::escapeString(descript) + "\""; 711 buf += " description=\"" + Qtopia::escapeString(descript) + "\"";
@@ -378,6 +741,9 @@ void Event::save( QString& buf )
378 buf += customToXml(); 741 buf += customToXml();
379} 742}
380 743
744/*!
745 \internal
746*/
381bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const 747bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
382{ 748{
383 // *sigh* 749 // *sigh*
@@ -390,6 +756,28 @@ bool Event::RepeatPattern::operator==( const Event::RepeatPattern &right ) const
390 && createTime == right.createTime ); 756 && createTime == right.createTime );
391} 757}
392 758
759/*!
760 \class EffectiveEvent
761 \brief The EffectiveEvent class the data for a single occurance of an event.
762
763 This class describes the event for a single occurance of it. For example if
764 an Event occurs every week, the effective event might represent the third
765 occurance of this Event.
766
767 \ingroup qtopiaemb
768 \ingroup qtopiadesktop
769 \warning This class will be phased out in Qtopia 3.x
770*/
771
772/*!
773 \enum EffectiveEvent::Position
774 \internal
775*/
776
777/*!
778 \fn EffectiveEvent &EffectiveEvent::operator=(const EffectiveEvent &)
779 \internal
780*/
393 781
394class EffectiveEventPrivate 782class EffectiveEventPrivate
395{ 783{
@@ -400,7 +788,9 @@ public:
400 QDate endDate; 788 QDate endDate;
401}; 789};
402 790
403 791/*!
792 \internal
793*/
404EffectiveEvent::EffectiveEvent() 794EffectiveEvent::EffectiveEvent()
405{ 795{
406 mDate = QDate::currentDate(); 796 mDate = QDate::currentDate();
@@ -408,6 +798,9 @@ EffectiveEvent::EffectiveEvent()
408 d = 0; 798 d = 0;
409} 799}
410 800
801/*!
802 \internal
803*/
411EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos ) 804EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos )
412{ 805{
413 mEvent = e; 806 mEvent = e;
@@ -424,11 +817,17 @@ EffectiveEvent::EffectiveEvent( const Event &e, const QDate &date, Position pos
424 d = 0; 817 d = 0;
425} 818}
426 819
820/*!
821 \internal
822*/
427EffectiveEvent::~EffectiveEvent() 823EffectiveEvent::~EffectiveEvent()
428{ 824{
429 delete d; 825 delete d;
430} 826}
431 827
828/*!
829 \internal
830*/
432EffectiveEvent::EffectiveEvent( const EffectiveEvent &e ) 831EffectiveEvent::EffectiveEvent( const EffectiveEvent &e )
433{ 832{
434 d = 0; 833 d = 0;
@@ -461,67 +860,106 @@ EffectiveEvent& EffectiveEvent::operator=( const EffectiveEvent & e )
461// return mEvent.category(); 860// return mEvent.category();
462// } 861// }
463 862
863/*!
864 Returns the description of the event for this effective event.
865*/
464const QString &EffectiveEvent::description( ) const 866const QString &EffectiveEvent::description( ) const
465{ 867{
466 return mEvent.description(); 868 return mEvent.description();
467} 869}
468 870
871/*!
872\internal
873*/
469const QString &EffectiveEvent::location( ) const 874const QString &EffectiveEvent::location( ) const
470{ 875{
471 return mEvent.location(); 876 return mEvent.location();
472} 877}
473 878
879/*!
880\internal
881*/
474const QString &EffectiveEvent::notes() const 882const QString &EffectiveEvent::notes() const
475{ 883{
476 return mEvent.notes(); 884 return mEvent.notes();
477} 885}
478 886
887/*!
888 Returns the event associated with this effective event.
889*/
479const Event &EffectiveEvent::event() const 890const Event &EffectiveEvent::event() const
480{ 891{
481 return mEvent; 892 return mEvent;
482} 893}
483 894
895/*!
896 \internal
897*/
484const QTime &EffectiveEvent::end() const 898const QTime &EffectiveEvent::end() const
485{ 899{
486 return mEnd; 900 return mEnd;
487} 901}
488 902
903/*!
904 \internal
905*/
489const QTime &EffectiveEvent::start() const 906const QTime &EffectiveEvent::start() const
490{ 907{
491 return mStart; 908 return mStart;
492} 909}
493 910
911/*!
912 Returns the date the effective event occurs on.
913*/
494const QDate &EffectiveEvent::date() const 914const QDate &EffectiveEvent::date() const
495{ 915{
496 return mDate; 916 return mDate;
497} 917}
498 918
919/*!
920 \internal
921*/
499int EffectiveEvent::length() const 922int EffectiveEvent::length() const
500{ 923{
501 return (mEnd.hour() * 60 - mStart.hour() * 60) 924 return (mEnd.hour() * 60 - mStart.hour() * 60)
502 + QABS(mStart.minute() - mEnd.minute() ); 925 + QABS(mStart.minute() - mEnd.minute() );
503} 926}
504 927
928/*!
929 \internal
930*/
505void EffectiveEvent::setDate( const QDate &dt ) 931void EffectiveEvent::setDate( const QDate &dt )
506{ 932{
507 mDate = dt; 933 mDate = dt;
508} 934}
509 935
936/*!
937 \internal
938*/
510void EffectiveEvent::setStart( const QTime &start ) 939void EffectiveEvent::setStart( const QTime &start )
511{ 940{
512 mStart = start; 941 mStart = start;
513} 942}
514 943
944/*!
945 \internal
946*/
515void EffectiveEvent::setEnd( const QTime &end ) 947void EffectiveEvent::setEnd( const QTime &end )
516{ 948{
517 mEnd = end; 949 mEnd = end;
518} 950}
519 951
952/*!
953 \internal
954*/
520void EffectiveEvent::setEvent( Event e ) 955void EffectiveEvent::setEvent( Event e )
521{ 956{
522 mEvent = e; 957 mEvent = e;
523} 958}
524 959
960/*!
961 \internal
962*/
525bool EffectiveEvent::operator<( const EffectiveEvent &e ) const 963bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
526{ 964{
527 if ( mDate < e.date() ) 965 if ( mDate < e.date() )
@@ -532,11 +970,17 @@ bool EffectiveEvent::operator<( const EffectiveEvent &e ) const
532 return FALSE; 970 return FALSE;
533} 971}
534 972
973/*!
974 \internal
975*/
535bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const 976bool EffectiveEvent::operator<=( const EffectiveEvent &e ) const
536{ 977{
537 return (mDate <= e.date() ); 978 return (mDate <= e.date() );
538} 979}
539 980
981/*!
982 \internal
983*/
540bool EffectiveEvent::operator==( const EffectiveEvent &e ) const 984bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
541{ 985{
542 return ( mDate == e.date() 986 return ( mDate == e.date()
@@ -545,21 +989,33 @@ bool EffectiveEvent::operator==( const EffectiveEvent &e ) const
545 && mEvent == e.event() ); 989 && mEvent == e.event() );
546} 990}
547 991
992/*!
993 \internal
994*/
548bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const 995bool EffectiveEvent::operator!=( const EffectiveEvent &e ) const
549{ 996{
550 return !(*this == e); 997 return !(*this == e);
551} 998}
552 999
1000/*!
1001 \internal
1002*/
553bool EffectiveEvent::operator>( const EffectiveEvent &e ) const 1003bool EffectiveEvent::operator>( const EffectiveEvent &e ) const
554{ 1004{
555 return !(*this <= e ); 1005 return !(*this <= e );
556} 1006}
557 1007
1008/*!
1009 \internal
1010*/
558bool EffectiveEvent::operator>=(const EffectiveEvent &e) const 1011bool EffectiveEvent::operator>=(const EffectiveEvent &e) const
559{ 1012{
560 return !(*this < e); 1013 return !(*this < e);
561} 1014}
562 1015
1016/*!
1017 \internal
1018*/
563void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to ) 1019void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
564{ 1020{
565 if ( !from.isValid() ) { 1021 if ( !from.isValid() ) {
@@ -573,6 +1029,9 @@ void EffectiveEvent::setEffectiveDates( const QDate &from, const QDate &to )
573 d->endDate = to; 1029 d->endDate = to;
574} 1030}
575 1031
1032/*!
1033 \internal
1034*/
576QDate EffectiveEvent::startDate() const 1035QDate EffectiveEvent::startDate() const
577{ 1036{
578 if ( d ) 1037 if ( d )
@@ -583,6 +1042,9 @@ QDate EffectiveEvent::startDate() const
583 return mEvent.start().date(); 1042 return mEvent.start().date();
584} 1043}
585 1044
1045/*!
1046 \internal
1047*/
586QDate EffectiveEvent::endDate() const 1048QDate EffectiveEvent::endDate() const
587{ 1049{
588 if ( d ) 1050 if ( d )
@@ -593,6 +1055,9 @@ QDate EffectiveEvent::endDate() const
593 return mEvent.end().date(); 1055 return mEvent.end().date();
594} 1056}
595 1057
1058/*!
1059 \internal
1060*/
596int EffectiveEvent::size() const 1061int EffectiveEvent::size() const
597{ 1062{
598 return ( mEnd.hour() - mStart.hour() ) * 3600 1063 return ( mEnd.hour() - mStart.hour() ) * 3600
@@ -740,32 +1205,50 @@ static Event parseVObject( VObject *obj )
740} 1205}
741 1206
742 1207
743 1208/*!
1209 Writes the list of \a events as a set of VCards to the file \a filename.
1210*/
744void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events) 1211void Event::writeVCalendar( const QString &filename, const QValueList<Event> &events)
745{ 1212{
746 QFileDirect f( filename.utf8().data() ); 1213
747 if ( !f.open( IO_WriteOnly ) ) { 1214 QFileDirect f( filename.utf8().data() );
748 qWarning("Unable to open vcard write"); 1215
749 return; 1216 if ( !f.open( IO_WriteOnly ) ) {
750 } 1217
1218 qWarning("Unable to open vcard write");
1219
1220 return;
1221
1222 }
1223
751 1224
752 QValueList<Event>::ConstIterator it; 1225 QValueList<Event>::ConstIterator it;
753 for( it = events.begin(); it != events.end(); ++it ) { 1226 for( it = events.begin(); it != events.end(); ++it ) {
754 VObject *obj = createVObject( *it ); 1227 VObject *obj = createVObject( *it );
755 writeVObject( f.directHandle() , obj ); 1228 writeVObject( f.directHandle() , obj );
756 cleanVObject( obj ); 1229 cleanVObject( obj );
757 } 1230 }
1231
758 1232
759 cleanStrTbl(); 1233 cleanStrTbl();
760} 1234}
761 1235
1236/*!
1237 Writes \a event as a VCard to the file \a filename.
1238*/
762void Event::writeVCalendar( const QString &filename, const Event &event) 1239void Event::writeVCalendar( const QString &filename, const Event &event)
763{ 1240{
764 QFileDirect f( filename.utf8().data() ); 1241
765 if ( !f.open( IO_WriteOnly ) ) { 1242 QFileDirect f( filename.utf8().data() );
766 qWarning("Unable to open vcard write"); 1243
767 return; 1244 if ( !f.open( IO_WriteOnly ) ) {
768 } 1245
1246 qWarning("Unable to open vcard write");
1247
1248 return;
1249
1250 }
1251
769 1252
770 VObject *obj = createVObject( event ); 1253 VObject *obj = createVObject( event );
771 writeVObject( f.directHandle() , obj ); 1254 writeVObject( f.directHandle() , obj );
@@ -774,7 +1257,9 @@ void Event::writeVCalendar( const QString &filename, const Event &event)
774 cleanStrTbl(); 1257 cleanStrTbl();
775} 1258}
776 1259
777 1260/*!
1261 Returns the set of events read as VCards from the file \a filename.
1262*/
778QValueList<Event> Event::readVCalendar( const QString &filename ) 1263QValueList<Event> Event::readVCalendar( const QString &filename )
779{ 1264{
780 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); 1265 VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() );