-rw-r--r-- | libopie2/opiepim/oevent.cpp | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index ada596c..c3eeee2 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp @@ -44,2 +44,3 @@ struct OEvent::Data : public QShared { Data() : QShared() { + child = 0; recur = 0; @@ -47,2 +48,3 @@ struct OEvent::Data : public QShared { isAllDay = false; + parent = 0; } @@ -62,2 +64,4 @@ struct OEvent::Data : public QShared { QString timezone; + QArray<int>* child; + int parent; }; @@ -104,3 +108,3 @@ QString OEvent::location()const { } -OPimNotifyManager &OEvent::notifiers() { +OPimNotifyManager &OEvent::notifiers()const { // I hope we can skip the changeOrModify here @@ -114,3 +118,9 @@ 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; } @@ -199,2 +209,3 @@ void OEvent::setTimeZone( const QString& tz ) { QString OEvent::timeZone()const { + if (data->isAllDay ) return QString::fromLatin1("UTC"); return data->timezone; @@ -241,2 +252,7 @@ void OEvent::changeOrModify() { d2->timezone = data->timezone; + d2->parent = data->parent; + d2->child = data->child; + + if (d2->child ) + d2->child->detach(); @@ -258,4 +274,46 @@ QMap<QString, QString> OEvent::toExtraMap()const { } +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 { |