-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 | |||
@@ -43,7 +43,9 @@ int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | |||
43 | struct OEvent::Data : public QShared { | 43 | struct OEvent::Data : public QShared { |
44 | Data() : QShared() { | 44 | Data() : QShared() { |
45 | child = 0; | ||
45 | recur = 0; | 46 | recur = 0; |
46 | manager = 0; | 47 | manager = 0; |
47 | isAllDay = false; | 48 | isAllDay = false; |
49 | parent = 0; | ||
48 | } | 50 | } |
49 | ~Data() { | 51 | ~Data() { |
@@ -61,4 +63,6 @@ struct OEvent::Data : public QShared { | |||
61 | bool isAllDay : 1; | 63 | bool isAllDay : 1; |
62 | QString timezone; | 64 | QString timezone; |
65 | QArray<int>* child; | ||
66 | int parent; | ||
63 | }; | 67 | }; |
64 | 68 | ||
@@ -103,5 +107,5 @@ QString OEvent::location()const { | |||
103 | return data->location; | 107 | return data->location; |
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 |
107 | // the notifier should take care of it | 111 | // the notifier should take care of it |
@@ -113,5 +117,11 @@ OPimNotifyManager &OEvent::notifiers() { | |||
113 | } | 117 | } |
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 | } |
117 | ORecur OEvent::recurrence()const { | 127 | ORecur OEvent::recurrence()const { |
@@ -198,4 +208,5 @@ void OEvent::setTimeZone( const QString& tz ) { | |||
198 | } | 208 | } |
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; |
201 | } | 212 | } |
@@ -240,4 +251,9 @@ void OEvent::changeOrModify() { | |||
240 | d2->isAllDay = data->isAllDay; | 251 | d2->isAllDay = data->isAllDay; |
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 | ||
243 | data = d2; | 259 | data = d2; |
@@ -257,6 +273,48 @@ QMap<QString, QString> OEvent::toExtraMap()const { | |||
257 | return QMap<QString, QString>(); | 273 | return QMap<QString, QString>(); |
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 { |
262 | Data() : QShared() { | 320 | Data() : QShared() { |