-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 { | |||
44 | Data() : QShared() { | 44 | Data() : QShared() { |
45 | child = 0; | ||
45 | recur = 0; | 46 | recur = 0; |
@@ -47,2 +48,3 @@ struct OEvent::Data : public QShared { | |||
47 | isAllDay = false; | 48 | isAllDay = false; |
49 | parent = 0; | ||
48 | } | 50 | } |
@@ -62,2 +64,4 @@ struct OEvent::Data : public QShared { | |||
62 | QString timezone; | 64 | QString timezone; |
65 | QArray<int>* child; | ||
66 | int parent; | ||
63 | }; | 67 | }; |
@@ -104,3 +108,3 @@ QString OEvent::location()const { | |||
104 | } | 108 | } |
105 | OPimNotifyManager &OEvent::notifiers() { | 109 | OPimNotifyManager &OEvent::notifiers()const { |
106 | // I hope we can skip the changeOrModify here | 110 | // I hope we can skip the changeOrModify here |
@@ -114,3 +118,9 @@ OPimNotifyManager &OEvent::notifiers() { | |||
114 | bool OEvent::hasNotifiers()const { | 118 | bool OEvent::hasNotifiers()const { |
115 | return ( data->manager); | 119 | if (!data->manager ) |
120 | return false; | ||
121 | if (data->manager->reminders().isEmpty() && | ||
122 | data->manager->alarms().isEmpty() ) | ||
123 | return false; | ||
124 | |||
125 | return true; | ||
116 | } | 126 | } |
@@ -199,2 +209,3 @@ void OEvent::setTimeZone( const QString& tz ) { | |||
199 | QString OEvent::timeZone()const { | 209 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | ||
200 | return data->timezone; | 211 | return data->timezone; |
@@ -241,2 +252,7 @@ void OEvent::changeOrModify() { | |||
241 | d2->timezone = data->timezone; | 252 | d2->timezone = data->timezone; |
253 | d2->parent = data->parent; | ||
254 | d2->child = data->child; | ||
255 | |||
256 | if (d2->child ) | ||
257 | d2->child->detach(); | ||
242 | 258 | ||
@@ -258,4 +274,46 @@ QMap<QString, QString> OEvent::toExtraMap()const { | |||
258 | } | 274 | } |
275 | int OEvent::parent()const { | ||
276 | return data->parent; | ||
277 | } | ||
278 | void OEvent::setParent( int uid ) { | ||
279 | changeOrModify(); | ||
280 | data->parent = uid; | ||
281 | } | ||
282 | QArray<int> OEvent::children() const{ | ||
283 | if (!data->child) return QArray<int>(); | ||
284 | else | ||
285 | return data->child->copy(); | ||
286 | } | ||
287 | void OEvent::setChildren( const QArray<int>& arr ) { | ||
288 | changeOrModify(); | ||
289 | if (data->child) delete data->child; | ||
259 | 290 | ||
260 | 291 | data->child = new QArray<int>( arr ); | |
292 | data->child->detach(); | ||
293 | } | ||
294 | void OEvent::addChild( int uid ) { | ||
295 | changeOrModify(); | ||
296 | if (!data->child ) { | ||
297 | data->child = new QArray<int>(1); | ||
298 | (*data->child)[0] = uid; | ||
299 | }else{ | ||
300 | int count = data->child->count(); | ||
301 | data->child->resize( count + 1 ); | ||
302 | (*data->child)[count] = uid; | ||
303 | } | ||
304 | } | ||
305 | void OEvent::removeChild( int uid ) { | ||
306 | if (!data->child || !data->child->contains( uid ) ) return; | ||
307 | changeOrModify(); | ||
308 | QArray<int> newAr( data->child->count() - 1 ); | ||
309 | int j = 0; | ||
310 | uint count = data->child->count(); | ||
311 | for ( uint i = 0; i < count; i++ ) { | ||
312 | if ( (*data->child)[i] != uid ) { | ||
313 | newAr[j] = (*data->child)[i]; | ||
314 | j++; | ||
315 | } | ||
316 | } | ||
317 | (*data->child) = newAr; | ||
318 | } | ||
261 | struct OEffectiveEvent::Data : public QShared { | 319 | struct OEffectiveEvent::Data : public QShared { |