summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/oevent.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/oevent.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/oevent.cpp534
1 files changed, 405 insertions, 129 deletions
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp
index de5e30b..d9cee2b 100644
--- a/libopie2/opiepim/oevent.cpp
+++ b/libopie2/opiepim/oevent.cpp
@@ -2,3 +2,3 @@
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
@@ -28,9 +28,6 @@
28*/ 28*/
29#include <qshared.h>
30#include <qarray.h>
31 29
32#include <qpe/palmtopuidgen.h> 30#include "oevent.h"
33#include <qpe/categories.h>
34#include <qpe/stringutil.h>
35 31
32/* OPIE */
36#include <opie2/orecur.h> 33#include <opie2/orecur.h>
@@ -38,8 +35,15 @@
38#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <qpe/categories.h>
37#include <qpe/palmtopuidgen.h>
38#include <qpe/stringutil.h>
39 39
40#include <opie2/oevent.h> 40/* QT */
41#include <qshared.h>
42#include <qarray.h>
41 43
42namespace Opie { 44namespace Opie
45{
43 46
44int OCalendarHelper::week( const QDate& date) { 47int OCalendarHelper::week( const QDate& date )
48{
45 // Calculates the week this date is in within that 49 // Calculates the week this date is in within that
@@ -55,3 +59,6 @@ int OCalendarHelper::week( const QDate& date) {
55} 59}
56int OCalendarHelper::ocurrence( const QDate& date) { 60
61
62int OCalendarHelper::ocurrence( const QDate& date )
63{
57 // calculates the number of occurrances of this day of the 64 // calculates the number of occurrances of this day of the
@@ -60,6 +67,10 @@ int OCalendarHelper::ocurrence( const QDate& date) {
60} 67}
61int OCalendarHelper::dayOfWeek( char day ) { 68
69
70int OCalendarHelper::dayOfWeek( char day )
71{
62 int dayOfWeek = 1; 72 int dayOfWeek = 1;
63 char i = ORecur::MON; 73 char i = ORecur::MON;
64 while ( !( i & day ) && i <= ORecur::SUN ) { 74 while ( !( i & day ) && i <= ORecur::SUN )
75 {
65 i <<= 1; 76 i <<= 1;
@@ -69,3 +80,6 @@ int OCalendarHelper::dayOfWeek( char day ) {
69} 80}
70int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { 81
82
83int OCalendarHelper::monthDiff( const QDate& first, const QDate& second )
84{
71 return ( second.year() - first.year() ) * 12 + 85 return ( second.year() - first.year() ) * 12 +
@@ -74,4 +88,7 @@ int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) {
74 88
75struct OEvent::Data : public QShared { 89
76 Data() : QShared() { 90struct OEvent::Data : public QShared
91{
92 Data() : QShared()
93 {
77 child = 0; 94 child = 0;
@@ -82,3 +99,4 @@ struct OEvent::Data : public QShared {
82 } 99 }
83 ~Data() { 100 ~Data()
101 {
84 delete manager; 102 delete manager;
@@ -100,6 +118,10 @@ struct OEvent::Data : public QShared {
100 118
119
101OEvent::OEvent( int uid ) 120OEvent::OEvent( int uid )
102 : OPimRecord( uid ) { 121 : OPimRecord( uid )
122{
103 data = new Data; 123 data = new Data;
104} 124}
125
126
105OEvent::OEvent( const OEvent& ev) 127OEvent::OEvent( const OEvent& ev)
@@ -110,2 +132,3 @@ OEvent::OEvent( const OEvent& ev)
110 132
133
111OEvent::OEvent( const QMap<int, QString> map ) 134OEvent::OEvent( const QMap<int, QString> map )
@@ -118,4 +141,7 @@ OEvent::OEvent( const QMap<int, QString> map )
118 141
119OEvent::~OEvent() { 142
120 if ( data->deref() ) { 143OEvent::~OEvent()
144{
145 if ( data->deref() )
146 {
121 delete data; 147 delete data;
@@ -124,3 +150,6 @@ OEvent::~OEvent() {
124} 150}
125OEvent& OEvent::operator=( const OEvent& ev) { 151
152
153OEvent& OEvent::operator=( const OEvent& ev )
154{
126 if ( this == &ev ) return *this; 155 if ( this == &ev ) return *this;
@@ -135,6 +164,12 @@ OEvent& OEvent::operator=( const OEvent& ev) {
135} 164}
136QString OEvent::description()const { 165
166
167QString OEvent::description() const
168{
137 return data->description; 169 return data->description;
138} 170}
139void OEvent::setDescription( const QString& description ) { 171
172
173void OEvent::setDescription( const QString& description )
174{
140 changeOrModify(); 175 changeOrModify();
@@ -142,3 +177,6 @@ void OEvent::setDescription( const QString& description ) {
142} 177}
143void OEvent::setLocation( const QString& loc ) { 178
179
180void OEvent::setLocation( const QString& loc )
181{
144 changeOrModify(); 182 changeOrModify();
@@ -146,6 +184,12 @@ void OEvent::setLocation( const QString& loc ) {
146} 184}
147QString OEvent::location()const { 185
186
187QString OEvent::location() const
188{
148 return data->location; 189 return data->location;
149} 190}
150OPimNotifyManager &OEvent::notifiers()const { 191
192
193OPimNotifyManager &OEvent::notifiers() const
194{
151 // I hope we can skip the changeOrModify here 195 // I hope we can skip the changeOrModify here
@@ -158,3 +202,6 @@ OPimNotifyManager &OEvent::notifiers()const {
158} 202}
159bool OEvent::hasNotifiers()const { 203
204
205bool OEvent::hasNotifiers() const
206{
160 if (!data->manager ) 207 if (!data->manager )
@@ -167,3 +214,6 @@ bool OEvent::hasNotifiers()const {
167} 214}
168ORecur OEvent::recurrence()const { 215
216
217ORecur OEvent::recurrence() const
218{
169 if (!data->recur) 219 if (!data->recur)
@@ -173,3 +223,6 @@ ORecur OEvent::recurrence()const {
173} 223}
174void OEvent::setRecurrence( const ORecur& rec) { 224
225
226void OEvent::setRecurrence( const ORecur& rec )
227{
175 changeOrModify(); 228 changeOrModify();
@@ -180,3 +233,6 @@ void OEvent::setRecurrence( const ORecur& rec) {
180} 233}
181bool OEvent::hasRecurrence()const { 234
235
236bool OEvent::hasRecurrence() const
237{
182 if (!data->recur ) return false; 238 if (!data->recur ) return false;
@@ -184,6 +240,12 @@ bool OEvent::hasRecurrence()const {
184} 240}
185QString OEvent::note()const { 241
242
243QString OEvent::note() const
244{
186 return data->note; 245 return data->note;
187} 246}
188void OEvent::setNote( const QString& note ) { 247
248
249void OEvent::setNote( const QString& note )
250{
189 changeOrModify(); 251 changeOrModify();
@@ -191,6 +253,12 @@ void OEvent::setNote( const QString& note ) {
191} 253}
192QDateTime OEvent::createdDateTime()const { 254
255
256QDateTime OEvent::createdDateTime() const
257{
193 return data->created; 258 return data->created;
194} 259}
195void OEvent::setCreatedDateTime( const QDateTime& time ) { 260
261
262void OEvent::setCreatedDateTime( const QDateTime& time )
263{
196 changeOrModify(); 264 changeOrModify();
@@ -198,3 +266,6 @@ void OEvent::setCreatedDateTime( const QDateTime& time ) {
198} 266}
199QDateTime OEvent::startDateTime()const { 267
268
269QDateTime OEvent::startDateTime() const
270{
200 if ( data->isAllDay ) 271 if ( data->isAllDay )
@@ -203,3 +274,6 @@ QDateTime OEvent::startDateTime()const {
203} 274}
204QDateTime OEvent::startDateTimeInZone()const { 275
276
277QDateTime OEvent::startDateTimeInZone() const
278{
205 /* if no timezone, or all day event or if the current and this timeZone match... */ 279 /* if no timezone, or all day event or if the current and this timeZone match... */
@@ -210,3 +284,6 @@ QDateTime OEvent::startDateTimeInZone()const {
210} 284}
211void OEvent::setStartDateTime( const QDateTime& dt ) { 285
286
287void OEvent::setStartDateTime( const QDateTime& dt )
288{
212 changeOrModify(); 289 changeOrModify();
@@ -214,3 +291,6 @@ void OEvent::setStartDateTime( const QDateTime& dt ) {
214} 291}
215QDateTime OEvent::endDateTime()const { 292
293
294QDateTime OEvent::endDateTime() const
295{
216 /* 296 /*
@@ -223,3 +303,6 @@ QDateTime OEvent::endDateTime()const {
223} 303}
224QDateTime OEvent::endDateTimeInZone()const { 304
305
306QDateTime OEvent::endDateTimeInZone() const
307{
225 /* if no timezone, or all day event or if the current and this timeZone match... */ 308 /* if no timezone, or all day event or if the current and this timeZone match... */
@@ -230,3 +313,6 @@ QDateTime OEvent::endDateTimeInZone()const {
230} 313}
231void OEvent::setEndDateTime( const QDateTime& dt ) { 314
315
316void OEvent::setEndDateTime( const QDateTime& dt )
317{
232 changeOrModify(); 318 changeOrModify();
@@ -234,9 +320,18 @@ void OEvent::setEndDateTime( const QDateTime& dt ) {
234} 320}
235bool OEvent::isMultipleDay()const { 321
322
323bool OEvent::isMultipleDay() const
324{
236 return data->end.date().day() - data->start.date().day(); 325 return data->end.date().day() - data->start.date().day();
237} 326}
238bool OEvent::isAllDay()const { 327
328
329bool OEvent::isAllDay() const
330{
239 return data->isAllDay; 331 return data->isAllDay;
240} 332}
241void OEvent::setAllDay( bool allDay ) { 333
334
335void OEvent::setAllDay( bool allDay )
336{
242 changeOrModify(); 337 changeOrModify();
@@ -245,3 +340,6 @@ void OEvent::setAllDay( bool allDay ) {
245} 340}
246void OEvent::setTimeZone( const QString& tz ) { 341
342
343void OEvent::setTimeZone( const QString& tz )
344{
247 changeOrModify(); 345 changeOrModify();
@@ -249,3 +347,6 @@ void OEvent::setTimeZone( const QString& tz ) {
249} 347}
250QString OEvent::timeZone()const { 348
349
350QString OEvent::timeZone() const
351{
251 if (data->isAllDay ) return QString::fromLatin1("UTC"); 352 if (data->isAllDay ) return QString::fromLatin1("UTC");
@@ -253,4 +354,8 @@ QString OEvent::timeZone()const {
253} 354}
254bool OEvent::match( const QRegExp& re )const { 355
255 if ( re.match( data->description ) != -1 ){ 356
357bool OEvent::match( const QRegExp& re ) const
358{
359 if ( re.match( data->description ) != -1 )
360 {
256 setLastHitField( Qtopia::DatebookDescription ); 361 setLastHitField( Qtopia::DatebookDescription );
@@ -258,3 +363,4 @@ bool OEvent::match( const QRegExp& re )const {
258 } 363 }
259 if ( re.match( data->note ) != -1 ){ 364 if ( re.match( data->note ) != -1 )
365 {
260 setLastHitField( Qtopia::Note ); 366 setLastHitField( Qtopia::Note );
@@ -262,3 +368,4 @@ bool OEvent::match( const QRegExp& re )const {
262 } 368 }
263 if ( re.match( data->location ) != -1 ){ 369 if ( re.match( data->location ) != -1 )
370 {
264 setLastHitField( Qtopia::Location ); 371 setLastHitField( Qtopia::Location );
@@ -266,3 +373,4 @@ bool OEvent::match( const QRegExp& re )const {
266 } 373 }
267 if ( re.match( data->start.toString() ) != -1 ){ 374 if ( re.match( data->start.toString() ) != -1 )
375 {
268 setLastHitField( Qtopia::StartDateTime ); 376 setLastHitField( Qtopia::StartDateTime );
@@ -270,3 +378,4 @@ bool OEvent::match( const QRegExp& re )const {
270 } 378 }
271 if ( re.match( data->end.toString() ) != -1 ){ 379 if ( re.match( data->end.toString() ) != -1 )
380 {
272 setLastHitField( Qtopia::EndDateTime ); 381 setLastHitField( Qtopia::EndDateTime );
@@ -276,3 +385,6 @@ bool OEvent::match( const QRegExp& re )const {
276} 385}
277QString OEvent::toRichText()const { 386
387
388QString OEvent::toRichText() const
389{
278 QString text, value; 390 QString text, value;
@@ -281,3 +393,4 @@ QString OEvent::toRichText()const {
281 text += "<b><h3><img src=\"datebook/DateBook\">"; 393 text += "<b><h3><img src=\"datebook/DateBook\">";
282 if ( !description().isEmpty() ) { 394 if ( !description().isEmpty() )
395 {
283 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); 396 text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" );
@@ -287,3 +400,4 @@ QString OEvent::toRichText()const {
287 // location 400 // location
288 if ( !(value = location()).isEmpty() ) { 401 if ( !( value = location() ).isEmpty() )
402 {
289 text += "<b>" + QObject::tr( "Location:" ) + "</b> "; 403 text += "<b>" + QObject::tr( "Location:" ) + "</b> ";
@@ -293,3 +407,4 @@ QString OEvent::toRichText()const {
293 // all day event 407 // all day event
294 if ( isAllDay() ) { 408 if ( isAllDay() )
409 {
295 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; 410 text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>";
@@ -297,3 +412,4 @@ QString OEvent::toRichText()const {
297 // multiple day event 412 // multiple day event
298 else if ( isMultipleDay () ) { 413 else if ( isMultipleDay () )
414 {
299 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; 415 text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>";
@@ -301,5 +417,7 @@ QString OEvent::toRichText()const {
301 // start & end times 417 // start & end times
302 else { 418 else
419 {
303 // start time 420 // start time
304 if ( startDateTime().isValid() ) { 421 if ( startDateTime().isValid() )
422 {
305 text += "<b>" + QObject::tr( "Start:") + "</b> "; 423 text += "<b>" + QObject::tr( "Start:") + "</b> ";
@@ -310,3 +428,4 @@ QString OEvent::toRichText()const {
310 // end time 428 // end time
311 if ( endDateTime().isValid() ) { 429 if ( endDateTime().isValid() )
430 {
312 text += "<b>" + QObject::tr( "End:") + "</b> "; 431 text += "<b>" + QObject::tr( "End:") + "</b> ";
@@ -318,3 +437,4 @@ QString OEvent::toRichText()const {
318 // categories 437 // categories
319 if ( categoryNames("Calendar").count() ){ 438 if ( categoryNames( "Calendar" ).count() )
439 {
320 text += "<b>" + QObject::tr( "Category:") + "</b> "; 440 text += "<b>" + QObject::tr( "Category:") + "</b> ";
@@ -325,3 +445,4 @@ QString OEvent::toRichText()const {
325 //notes 445 //notes
326 if ( !note().isEmpty() ) { 446 if ( !note().isEmpty() )
447 {
327 text += "<b>" + QObject::tr( "Note:") + "</b><br>"; 448 text += "<b>" + QObject::tr( "Note:") + "</b><br>";
@@ -333,3 +454,6 @@ QString OEvent::toRichText()const {
333} 454}
334QString OEvent::toShortText()const { 455
456
457QString OEvent::toShortText() const
458{
335 QString text; 459 QString text;
@@ -348,19 +472,38 @@ QString OEvent::toShortText()const {
348} 472}
349QString OEvent::type()const { 473
474
475QString OEvent::type() const
476{
350 return QString::fromLatin1("OEvent"); 477 return QString::fromLatin1("OEvent");
351} 478}
352QString OEvent::recordField( int /*id */ )const { 479
480
481QString OEvent::recordField( int /*id */ ) const
482{
353 return QString::null; 483 return QString::null;
354} 484}
355int OEvent::rtti() { 485
486
487int OEvent::rtti()
488{
356 return OPimResolver::DateBook; 489 return OPimResolver::DateBook;
357} 490}
358bool OEvent::loadFromStream( QDataStream& ) { 491
492
493bool OEvent::loadFromStream( QDataStream& )
494{
359 return true; 495 return true;
360} 496}
361bool OEvent::saveToStream( QDataStream& )const { 497
498
499bool OEvent::saveToStream( QDataStream& ) const
500{
362 return true; 501 return true;
363} 502}
364void OEvent::changeOrModify() { 503
365 if ( data->count != 1 ) { 504
505void OEvent::changeOrModify()
506{
507 if ( data->count != 1 )
508 {
366 data->deref(); 509 data->deref();
@@ -384,3 +527,4 @@ void OEvent::changeOrModify() {
384 527
385 if ( data->child ) { 528 if ( data->child )
529 {
386 d2->child = new QArray<int>( *data->child ); 530 d2->child = new QArray<int>( *data->child );
@@ -392,4 +536,8 @@ void OEvent::changeOrModify() {
392} 536}
393void OEvent::deref() { 537
394 if ( data->deref() ) { 538
539void OEvent::deref()
540{
541 if ( data->deref() )
542 {
395 delete data; 543 delete data;
@@ -403,3 +551,4 @@ void OEvent::deref() {
403// Encoding should happen at one place, only ! (eilers) 551// Encoding should happen at one place, only ! (eilers)
404QMap<int, QString> OEvent::toMap()const { 552QMap<int, QString> OEvent::toMap() const
553{
405 QMap<int, QString> retMap; 554 QMap<int, QString> retMap;
@@ -422,6 +571,8 @@ QMap<int, QString> OEvent::toMap()const {
422 retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); 571 retMap.insert( OEvent::FRecParent, QString::number( parent() ) );
423 if( children().count() ){ 572 if ( children().count() )
573 {
424 QArray<int> childr = children(); 574 QArray<int> childr = children();
425 QString buf; 575 QString buf;
426 for ( uint i = 0; i < childr.count(); i++ ) { 576 for ( uint i = 0; i < childr.count(); i++ )
577 {
427 if ( i != 0 ) buf += " "; 578 if ( i != 0 ) buf += " ";
@@ -433,3 +584,4 @@ QMap<int, QString> OEvent::toMap()const {
433 // Add recurrence stuff 584 // Add recurrence stuff
434 if( hasRecurrence() ){ 585 if ( hasRecurrence() )
586 {
435 ORecur recur = recurrence(); 587 ORecur recur = recurrence();
@@ -444,3 +596,5 @@ QMap<int, QString> OEvent::toMap()const {
444 retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); 596 retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] );
445 } else { 597 }
598 else
599 {
446 ORecur recur = recurrence(); 600 ORecur recur = recurrence();
@@ -453,2 +607,3 @@ QMap<int, QString> OEvent::toMap()const {
453 607
608
454void OEvent::fromMap( const QMap<int, QString>& map ) 609void OEvent::fromMap( const QMap<int, QString>& map )
@@ -474,3 +629,4 @@ void OEvent::fromMap( const QMap<int, QString>& map )
474 int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); 629 int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
475 if ( ( alarmTime != -1 ) ){ 630 if ( ( alarmTime != -1 ) )
631 {
476 QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); 632 QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 );
@@ -479,3 +635,4 @@ void OEvent::fromMap( const QMap<int, QString>& map )
479 } 635 }
480 if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ 636 if ( !map[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) )
637 {
481 setTimeZone( map[OEvent::FTimeZone] ); 638 setTimeZone( map[OEvent::FTimeZone] );
@@ -487,3 +644,4 @@ void OEvent::fromMap( const QMap<int, QString>& map )
487 /* AllDay is always in UTC */ 644 /* AllDay is always in UTC */
488 if ( isAllDay() ) { 645 if ( isAllDay() )
646 {
489 OTimeZone utc = OTimeZone::utc(); 647 OTimeZone utc = OTimeZone::utc();
@@ -492,3 +650,5 @@ void OEvent::fromMap( const QMap<int, QString>& map )
492 setTimeZone( "UTC"); // make sure it is really utc 650 setTimeZone( "UTC"); // make sure it is really utc
493 }else { 651 }
652 else
653 {
494 /* to current date time */ 654 /* to current date time */
@@ -507,5 +667,7 @@ void OEvent::fromMap( const QMap<int, QString>& map )
507 667
508 if ( !map[OEvent::FRecChildren].isEmpty() ){ 668 if ( !map[ OEvent::FRecChildren ].isEmpty() )
669 {
509 QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); 670 QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] );
510 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 671 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
672 {
511 addChild( (*it).toInt() ); 673 addChild( (*it).toInt() );
@@ -515,3 +677,4 @@ void OEvent::fromMap( const QMap<int, QString>& map )
515 // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. 677 // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap..
516 if( !map[OEvent::FRType].isEmpty() ){ 678 if ( !map[ OEvent::FRType ].isEmpty() )
679 {
517 QMap<int, QString> recFields; 680 QMap<int, QString> recFields;
@@ -532,6 +695,10 @@ void OEvent::fromMap( const QMap<int, QString>& map )
532 695
533int OEvent::parent()const { 696int OEvent::parent() const
697{
534 return data->parent; 698 return data->parent;
535} 699}
536void OEvent::setParent( int uid ) { 700
701
702void OEvent::setParent( int uid )
703{
537 changeOrModify(); 704 changeOrModify();
@@ -539,3 +706,6 @@ void OEvent::setParent( int uid ) {
539} 706}
540QArray<int> OEvent::children() const{ 707
708
709QArray<int> OEvent::children() const
710{
541 if (!data->child) return QArray<int>(); 711 if (!data->child) return QArray<int>();
@@ -544,3 +714,6 @@ QArray<int> OEvent::children() const{
544} 714}
545void OEvent::setChildren( const QArray<int>& arr ) { 715
716
717void OEvent::setChildren( const QArray<int>& arr )
718{
546 changeOrModify(); 719 changeOrModify();
@@ -551,8 +724,14 @@ void OEvent::setChildren( const QArray<int>& arr ) {
551} 724}
552void OEvent::addChild( int uid ) { 725
726
727void OEvent::addChild( int uid )
728{
553 changeOrModify(); 729 changeOrModify();
554 if (!data->child ) { 730 if ( !data->child )
731 {
555 data->child = new QArray<int>(1); 732 data->child = new QArray<int>(1);
556 (*data->child)[0] = uid; 733 (*data->child)[0] = uid;
557 }else{ 734 }
735 else
736 {
558 int count = data->child->count(); 737 int count = data->child->count();
@@ -562,3 +741,6 @@ void OEvent::addChild( int uid ) {
562} 741}
563void OEvent::removeChild( int uid ) { 742
743
744void OEvent::removeChild( int uid )
745{
564 if (!data->child || !data->child->contains( uid ) ) return; 746 if (!data->child || !data->child->contains( uid ) ) return;
@@ -568,4 +750,6 @@ void OEvent::removeChild( int uid ) {
568 uint count = data->child->count(); 750 uint count = data->child->count();
569 for ( uint i = 0; i < count; i++ ) { 751 for ( uint i = 0; i < count; i++ )
570 if ( (*data->child)[i] != uid ) { 752 {
753 if ( ( *data->child ) [ i ] != uid )
754 {
571 newAr[j] = (*data->child)[i]; 755 newAr[j] = (*data->child)[i];
@@ -576,5 +760,8 @@ void OEvent::removeChild( int uid ) {
576} 760}
577struct OEffectiveEvent::Data : public QShared { 761
578 Data() : QShared() { 762
579 } 763struct OEffectiveEvent::Data : public QShared
764{
765 Data() : QShared()
766 {}
580 OEvent event; 767 OEvent event;
@@ -586,3 +773,5 @@ struct OEffectiveEvent::Data : public QShared {
586 773
587OEffectiveEvent::OEffectiveEvent() { 774
775OEffectiveEvent::OEffectiveEvent()
776{
588 data = new Data; 777 data = new Data;
@@ -592,4 +781,7 @@ OEffectiveEvent::OEffectiveEvent() {
592} 781}
782
783
593OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, 784OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
594 Position pos ) { 785 Position pos )
786{
595 data = new Data; 787 data = new Data;
@@ -609,3 +801,6 @@ OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate,
609} 801}
610OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { 802
803
804OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev )
805{
611 data = ev.data; 806 data = ev.data;
@@ -613,4 +808,8 @@ OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) {
613} 808}
614OEffectiveEvent::~OEffectiveEvent() { 809
615 if ( data->deref() ) { 810
811OEffectiveEvent::~OEffectiveEvent()
812{
813 if ( data->deref() )
814 {
616 delete data; 815 delete data;
@@ -619,3 +818,6 @@ OEffectiveEvent::~OEffectiveEvent() {
619} 818}
620OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { 819
820
821OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev )
822{
621 if ( *this == ev ) return *this; 823 if ( *this == ev ) return *this;
@@ -629,3 +831,5 @@ OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) {
629 831
630void OEffectiveEvent::setStartTime( const QTime& ti) { 832
833void OEffectiveEvent::setStartTime( const QTime& ti )
834{
631 changeOrModify(); 835 changeOrModify();
@@ -633,3 +837,6 @@ void OEffectiveEvent::setStartTime( const QTime& ti) {
633} 837}
634void OEffectiveEvent::setEndTime( const QTime& en) { 838
839
840void OEffectiveEvent::setEndTime( const QTime& en )
841{
635 changeOrModify(); 842 changeOrModify();
@@ -637,3 +844,6 @@ void OEffectiveEvent::setEndTime( const QTime& en) {
637} 844}
638void OEffectiveEvent::setEvent( const OEvent& ev) { 845
846
847void OEffectiveEvent::setEvent( const OEvent& ev )
848{
639 changeOrModify(); 849 changeOrModify();
@@ -641,3 +851,6 @@ void OEffectiveEvent::setEvent( const OEvent& ev) {
641} 851}
642void OEffectiveEvent::setDate( const QDate& da) { 852
853
854void OEffectiveEvent::setDate( const QDate& da )
855{
643 changeOrModify(); 856 changeOrModify();
@@ -645,5 +858,9 @@ void OEffectiveEvent::setDate( const QDate& da) {
645} 858}
859
860
646void OEffectiveEvent::setEffectiveDates( const QDate& from, 861void OEffectiveEvent::setEffectiveDates( const QDate& from,
647 const QDate& to ) { 862 const QDate& to )
648 if (!from.isValid() ) { 863{
864 if ( !from.isValid() )
865 {
649 data->dates = false; 866 data->dates = false;
@@ -655,24 +872,48 @@ void OEffectiveEvent::setEffectiveDates( const QDate& from,
655} 872}
656QString OEffectiveEvent::description()const { 873
874
875QString OEffectiveEvent::description() const
876{
657 return data->event.description(); 877 return data->event.description();
658} 878}
659QString OEffectiveEvent::location()const { 879
880
881QString OEffectiveEvent::location() const
882{
660 return data->event.location(); 883 return data->event.location();
661} 884}
662QString OEffectiveEvent::note()const { 885
886
887QString OEffectiveEvent::note() const
888{
663 return data->event.note(); 889 return data->event.note();
664} 890}
665OEvent OEffectiveEvent::event()const { 891
892
893OEvent OEffectiveEvent::event() const
894{
666 return data->event; 895 return data->event;
667} 896}
668QTime OEffectiveEvent::startTime()const { 897
898
899QTime OEffectiveEvent::startTime() const
900{
669 return data->start; 901 return data->start;
670} 902}
671QTime OEffectiveEvent::endTime()const { 903
904
905QTime OEffectiveEvent::endTime() const
906{
672 return data->end; 907 return data->end;
673} 908}
674QDate OEffectiveEvent::date()const { 909
910
911QDate OEffectiveEvent::date() const
912{
675 return data->date; 913 return data->date;
676} 914}
677int OEffectiveEvent::length()const { 915
916
917int OEffectiveEvent::length() const
918{
678 return (data->end.hour() * 60 - data->start.hour() * 60) 919 return (data->end.hour() * 60 - data->start.hour() * 60)
@@ -680,3 +921,6 @@ int OEffectiveEvent::length()const {
680} 921}
681int OEffectiveEvent::size()const { 922
923
924int OEffectiveEvent::size() const
925{
682 return ( data->end.hour() - data->start.hour() ) * 3600 926 return ( data->end.hour() - data->start.hour() ) * 3600
@@ -685,3 +929,6 @@ int OEffectiveEvent::size()const {
685} 929}
686QDate OEffectiveEvent::startDate()const { 930
931
932QDate OEffectiveEvent::startDate() const
933{
687 if ( data->dates ) 934 if ( data->dates )
@@ -693,3 +940,6 @@ QDate OEffectiveEvent::startDate()const {
693} 940}
694QDate OEffectiveEvent::endDate()const { 941
942
943QDate OEffectiveEvent::endDate() const
944{
695 if ( data->dates ) 945 if ( data->dates )
@@ -701,4 +951,8 @@ QDate OEffectiveEvent::endDate()const {
701} 951}
702void OEffectiveEvent::deref() { 952
703 if ( data->deref() ) { 953
954void OEffectiveEvent::deref()
955{
956 if ( data->deref() )
957 {
704 delete data; 958 delete data;
@@ -707,4 +961,8 @@ void OEffectiveEvent::deref() {
707} 961}
708void OEffectiveEvent::changeOrModify() { 962
709 if ( data->count != 1 ) { 963
964void OEffectiveEvent::changeOrModify()
965{
966 if ( data->count != 1 )
967 {
710 data->deref(); 968 data->deref();
@@ -721,3 +979,6 @@ void OEffectiveEvent::changeOrModify() {
721} 979}
722bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ 980
981
982bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const
983{
723 if ( data->date < e.date() ) 984 if ( data->date < e.date() )
@@ -729,6 +990,12 @@ bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{
729} 990}
730bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ 991
992
993bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const
994{
731 return (data->date <= e.date() ); 995 return (data->date <= e.date() );
732} 996}
733bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { 997
998
999bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const
1000{
734 return ( date() == e.date() 1001 return ( date() == e.date()
@@ -738,9 +1005,18 @@ bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const {
738} 1005}
739bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { 1006
1007
1008bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const
1009{
740 return !(*this == e ); 1010 return !(*this == e );
741} 1011}
742bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { 1012
1013
1014bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const
1015{
743 return !(*this <= e ); 1016 return !(*this <= e );
744} 1017}
745bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { 1018
1019
1020bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const
1021{
746 return !(*this < e); 1022 return !(*this < e);