author | zecke <zecke> | 2003-02-22 16:11:16 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-22 16:11:16 (UTC) |
commit | 397a7b1635488deda02b36df70692e27f59bb3e0 (patch) (side-by-side diff) | |
tree | 1232b1b7e8ac84c5d48df79b635ba61acbdf0f62 /libopie/pim/oevent.cpp | |
parent | e7981098a5c373748d98158e8a6c59750bb0d7dc (diff) | |
download | opie-397a7b1635488deda02b36df70692e27f59bb3e0.zip opie-397a7b1635488deda02b36df70692e27f59bb3e0.tar.gz opie-397a7b1635488deda02b36df70692e27f59bb3e0.tar.bz2 |
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
-rw-r--r-- | libopie/pim/oevent.cpp | 64 |
1 files changed, 61 insertions, 3 deletions
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 @@ -43,7 +43,9 @@ 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() { @@ -61,4 +63,6 @@ struct OEvent::Data : public QShared { bool isAllDay : 1; QString timezone; + QArray<int>* child; + int parent; }; @@ -103,5 +107,5 @@ 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 @@ -113,5 +117,11 @@ OPimNotifyManager &OEvent::notifiers() { } 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 { @@ -198,4 +208,5 @@ void OEvent::setTimeZone( const QString& tz ) { } QString OEvent::timeZone()const { + if (data->isAllDay ) return QString::fromLatin1("UTC"); return data->timezone; } @@ -240,4 +251,9 @@ void OEvent::changeOrModify() { d2->isAllDay = data->isAllDay; d2->timezone = data->timezone; + d2->parent = data->parent; + d2->child = data->child; + + if (d2->child ) + d2->child->detach(); data = d2; @@ -257,6 +273,48 @@ QMap<QString, QString> OEvent::toExtraMap()const { return QMap<QString, QString>(); } +int OEvent::parent()const { + return data->parent; +} +void OEvent::setParent( int uid ) { + changeOrModify(); + data->parent = uid; +} +QArray<int> OEvent::children() const{ + if (!data->child) return QArray<int>(); + else + return data->child->copy(); +} +void OEvent::setChildren( const QArray<int>& arr ) { + changeOrModify(); + if (data->child) delete data->child; - + data->child = new QArray<int>( arr ); + data->child->detach(); +} +void OEvent::addChild( int uid ) { + changeOrModify(); + if (!data->child ) { + data->child = new QArray<int>(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<int> 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() { |