From 397a7b1635488deda02b36df70692e27f59bb3e0 Mon Sep 17 00:00:00 2001 From: zecke Date: Sat, 22 Feb 2003 16:11:16 +0000 Subject: Implement saving of events Implement the ExceptionList Add Children and parent to OEvent Make ORecur honor exceptions Extend the test app to add and save --- (limited to 'libopie/pim/oevent.cpp') diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index ada596c..c3eeee2 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp @@ -42,9 +42,11 @@ int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { struct OEvent::Data : public QShared { Data() : QShared() { + child = 0; recur = 0; manager = 0; isAllDay = false; + parent = 0; } ~Data() { delete manager; @@ -60,6 +62,8 @@ struct OEvent::Data : public QShared { QDateTime end; bool isAllDay : 1; QString timezone; + QArray* child; + int parent; }; OEvent::OEvent( int uid ) @@ -102,7 +106,7 @@ void OEvent::setLocation( const QString& loc ) { QString OEvent::location()const { return data->location; } -OPimNotifyManager &OEvent::notifiers() { +OPimNotifyManager &OEvent::notifiers()const { // I hope we can skip the changeOrModify here // the notifier should take care of it // and OPimNotify is shared too @@ -112,7 +116,13 @@ OPimNotifyManager &OEvent::notifiers() { return *data->manager; } bool OEvent::hasNotifiers()const { - return ( data->manager); + if (!data->manager ) + return false; + if (data->manager->reminders().isEmpty() && + data->manager->alarms().isEmpty() ) + return false; + + return true; } ORecur OEvent::recurrence()const { if (!data->recur) @@ -197,6 +207,7 @@ void OEvent::setTimeZone( const QString& tz ) { data->timezone = tz; } QString OEvent::timeZone()const { + if (data->isAllDay ) return QString::fromLatin1("UTC"); return data->timezone; } bool OEvent::match( const QRegExp& )const { @@ -239,6 +250,11 @@ void OEvent::changeOrModify() { d2->end = data->end; d2->isAllDay = data->isAllDay; d2->timezone = data->timezone; + d2->parent = data->parent; + d2->child = data->child; + + if (d2->child ) + d2->child->detach(); data = d2; } @@ -256,8 +272,50 @@ QMap OEvent::toMap()const { QMap OEvent::toExtraMap()const { return QMap(); } +int OEvent::parent()const { + return data->parent; +} +void OEvent::setParent( int uid ) { + changeOrModify(); + data->parent = uid; +} +QArray OEvent::children() const{ + if (!data->child) return QArray(); + else + return data->child->copy(); +} +void OEvent::setChildren( const QArray& arr ) { + changeOrModify(); + if (data->child) delete data->child; - + data->child = new QArray( arr ); + data->child->detach(); +} +void OEvent::addChild( int uid ) { + changeOrModify(); + if (!data->child ) { + data->child = new QArray(1); + (*data->child)[0] = uid; + }else{ + int count = data->child->count(); + data->child->resize( count + 1 ); + (*data->child)[count] = uid; + } +} +void OEvent::removeChild( int uid ) { + if (!data->child || !data->child->contains( uid ) ) return; + changeOrModify(); + QArray newAr( data->child->count() - 1 ); + int j = 0; + uint count = data->child->count(); + for ( uint i = 0; i < count; i++ ) { + if ( (*data->child)[i] != uid ) { + newAr[j] = (*data->child)[i]; + j++; + } + } + (*data->child) = newAr; +} struct OEffectiveEvent::Data : public QShared { Data() : QShared() { } -- cgit v0.9.0.2