-rw-r--r-- | libopie/pim/oevent.cpp | 14 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 14 |
2 files changed, 20 insertions, 8 deletions
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index 56ea10d..3ba8a52 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -149,205 +149,211 @@ void OEvent::setNote( const QString& note ) { | |||
149 | data->note = note; | 149 | data->note = note; |
150 | } | 150 | } |
151 | QDateTime OEvent::createdDateTime()const { | 151 | QDateTime OEvent::createdDateTime()const { |
152 | return data->created; | 152 | return data->created; |
153 | } | 153 | } |
154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |
155 | changeOrModify(); | 155 | changeOrModify(); |
156 | data->created = time; | 156 | data->created = time; |
157 | } | 157 | } |
158 | QDateTime OEvent::startDateTime()const { | 158 | QDateTime OEvent::startDateTime()const { |
159 | if ( data->isAllDay ) | 159 | if ( data->isAllDay ) |
160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
161 | return data->start; | 161 | return data->start; |
162 | } | 162 | } |
163 | QDateTime OEvent::startDateTimeInZone()const { | 163 | QDateTime OEvent::startDateTimeInZone()const { |
164 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 164 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
166 | 166 | ||
167 | OTimeZone zone(data->timezone ); | 167 | OTimeZone zone(data->timezone ); |
168 | return zone.toDateTime( data->start, OTimeZone::current() ); | 168 | return zone.toDateTime( data->start, OTimeZone::current() ); |
169 | } | 169 | } |
170 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 170 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
171 | changeOrModify(); | 171 | changeOrModify(); |
172 | data->start = dt; | 172 | data->start = dt; |
173 | } | 173 | } |
174 | QDateTime OEvent::endDateTime()const { | 174 | QDateTime OEvent::endDateTime()const { |
175 | /* | 175 | /* |
176 | * if all Day event the end time needs | 176 | * if all Day event the end time needs |
177 | * to be on the same day as the start | 177 | * to be on the same day as the start |
178 | */ | 178 | */ |
179 | if ( data->isAllDay ) | 179 | if ( data->isAllDay ) |
180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
181 | return data->end; | 181 | return data->end; |
182 | } | 182 | } |
183 | QDateTime OEvent::endDateTimeInZone()const { | 183 | QDateTime OEvent::endDateTimeInZone()const { |
184 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 184 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
186 | 186 | ||
187 | OTimeZone zone(data->timezone ); | 187 | OTimeZone zone(data->timezone ); |
188 | return zone.toDateTime( data->end, OTimeZone::current() ); | 188 | return zone.toDateTime( data->end, OTimeZone::current() ); |
189 | } | 189 | } |
190 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 190 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
191 | changeOrModify(); | 191 | changeOrModify(); |
192 | data->end = dt; | 192 | data->end = dt; |
193 | } | 193 | } |
194 | bool OEvent::isMultipleDay()const { | 194 | bool OEvent::isMultipleDay()const { |
195 | return data->end.date().day() - data->start.date().day(); | 195 | return data->end.date().day() - data->start.date().day(); |
196 | } | 196 | } |
197 | bool OEvent::isAllDay()const { | 197 | bool OEvent::isAllDay()const { |
198 | return data->isAllDay; | 198 | return data->isAllDay; |
199 | } | 199 | } |
200 | void OEvent::setAllDay( bool allDay ) { | 200 | void OEvent::setAllDay( bool allDay ) { |
201 | changeOrModify(); | 201 | changeOrModify(); |
202 | data->isAllDay = allDay; | 202 | data->isAllDay = allDay; |
203 | if (allDay ) data->timezone = "UTC"; | 203 | if (allDay ) data->timezone = "UTC"; |
204 | } | 204 | } |
205 | void OEvent::setTimeZone( const QString& tz ) { | 205 | void OEvent::setTimeZone( const QString& tz ) { |
206 | changeOrModify(); | 206 | changeOrModify(); |
207 | data->timezone = tz; | 207 | data->timezone = tz; |
208 | } | 208 | } |
209 | QString OEvent::timeZone()const { | 209 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
211 | return data->timezone; | 211 | return data->timezone; |
212 | } | 212 | } |
213 | bool OEvent::match( const QRegExp& )const { | 213 | bool OEvent::match( const QRegExp& )const { |
214 | // FIXME | 214 | // FIXME |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | QString OEvent::toRichText()const { | 217 | QString OEvent::toRichText()const { |
218 | // FIXME | 218 | // FIXME |
219 | return "OEvent test"; | 219 | return "OEvent test"; |
220 | } | 220 | } |
221 | QString OEvent::toShortText()const { | 221 | QString OEvent::toShortText()const { |
222 | return "OEvent shotText"; | 222 | return "OEvent shotText"; |
223 | } | 223 | } |
224 | QString OEvent::type()const { | 224 | QString OEvent::type()const { |
225 | return QString::fromLatin1("OEvent"); | 225 | return QString::fromLatin1("OEvent"); |
226 | } | 226 | } |
227 | QString OEvent::recordField( int /*id */ )const { | 227 | QString OEvent::recordField( int /*id */ )const { |
228 | return QString::null; | 228 | return QString::null; |
229 | } | 229 | } |
230 | int OEvent::rtti() { | 230 | int OEvent::rtti() { |
231 | return OPimResolver::DateBook; | 231 | return OPimResolver::DateBook; |
232 | } | 232 | } |
233 | bool OEvent::loadFromStream( QDataStream& ) { | 233 | bool OEvent::loadFromStream( QDataStream& ) { |
234 | return true; | 234 | return true; |
235 | } | 235 | } |
236 | bool OEvent::saveToStream( QDataStream& )const { | 236 | bool OEvent::saveToStream( QDataStream& )const { |
237 | return true; | 237 | return true; |
238 | } | 238 | } |
239 | void OEvent::changeOrModify() { | 239 | void OEvent::changeOrModify() { |
240 | if ( data->count != 1 ) { | 240 | if ( data->count != 1 ) { |
241 | data->deref(); | 241 | data->deref(); |
242 | Data* d2 = new Data; | 242 | Data* d2 = new Data; |
243 | d2->description = data->description; | 243 | d2->description = data->description; |
244 | d2->location = data->location; | 244 | d2->location = data->location; |
245 | d2->manager = data->manager; | 245 | |
246 | d2->recur = data->recur; | 246 | if (data->manager ) |
247 | d2->manager = new OPimNotifyManager( *data->manager ); | ||
248 | |||
249 | if ( data->recur ) | ||
250 | d2->recur = new ORecur( *data->recur ); | ||
251 | |||
247 | d2->note = data->note; | 252 | d2->note = data->note; |
248 | d2->created = data->created; | 253 | d2->created = data->created; |
249 | d2->start = data->start; | 254 | d2->start = data->start; |
250 | d2->end = data->end; | 255 | d2->end = data->end; |
251 | d2->isAllDay = data->isAllDay; | 256 | d2->isAllDay = data->isAllDay; |
252 | d2->timezone = data->timezone; | 257 | d2->timezone = data->timezone; |
253 | d2->parent = data->parent; | 258 | d2->parent = data->parent; |
254 | d2->child = data->child; | ||
255 | 259 | ||
256 | if (d2->child ) | 260 | if ( data->child ) { |
261 | d2->child = new QArray<int>( *data->child ); | ||
257 | d2->child->detach(); | 262 | d2->child->detach(); |
263 | } | ||
258 | 264 | ||
259 | data = d2; | 265 | data = d2; |
260 | } | 266 | } |
261 | } | 267 | } |
262 | void OEvent::deref() { | 268 | void OEvent::deref() { |
263 | if ( data->deref() ) { | 269 | if ( data->deref() ) { |
264 | delete data; | 270 | delete data; |
265 | data = 0; | 271 | data = 0; |
266 | } | 272 | } |
267 | } | 273 | } |
268 | // FIXME | 274 | // FIXME |
269 | QMap<int, QString> OEvent::toMap()const { | 275 | QMap<int, QString> OEvent::toMap()const { |
270 | return QMap<int, QString>(); | 276 | return QMap<int, QString>(); |
271 | } | 277 | } |
272 | QMap<QString, QString> OEvent::toExtraMap()const { | 278 | QMap<QString, QString> OEvent::toExtraMap()const { |
273 | return QMap<QString, QString>(); | 279 | return QMap<QString, QString>(); |
274 | } | 280 | } |
275 | int OEvent::parent()const { | 281 | int OEvent::parent()const { |
276 | return data->parent; | 282 | return data->parent; |
277 | } | 283 | } |
278 | void OEvent::setParent( int uid ) { | 284 | void OEvent::setParent( int uid ) { |
279 | changeOrModify(); | 285 | changeOrModify(); |
280 | data->parent = uid; | 286 | data->parent = uid; |
281 | } | 287 | } |
282 | QArray<int> OEvent::children() const{ | 288 | QArray<int> OEvent::children() const{ |
283 | if (!data->child) return QArray<int>(); | 289 | if (!data->child) return QArray<int>(); |
284 | else | 290 | else |
285 | return data->child->copy(); | 291 | return data->child->copy(); |
286 | } | 292 | } |
287 | void OEvent::setChildren( const QArray<int>& arr ) { | 293 | void OEvent::setChildren( const QArray<int>& arr ) { |
288 | changeOrModify(); | 294 | changeOrModify(); |
289 | if (data->child) delete data->child; | 295 | if (data->child) delete data->child; |
290 | 296 | ||
291 | data->child = new QArray<int>( arr ); | 297 | data->child = new QArray<int>( arr ); |
292 | data->child->detach(); | 298 | data->child->detach(); |
293 | } | 299 | } |
294 | void OEvent::addChild( int uid ) { | 300 | void OEvent::addChild( int uid ) { |
295 | changeOrModify(); | 301 | changeOrModify(); |
296 | if (!data->child ) { | 302 | if (!data->child ) { |
297 | data->child = new QArray<int>(1); | 303 | data->child = new QArray<int>(1); |
298 | (*data->child)[0] = uid; | 304 | (*data->child)[0] = uid; |
299 | }else{ | 305 | }else{ |
300 | int count = data->child->count(); | 306 | int count = data->child->count(); |
301 | data->child->resize( count + 1 ); | 307 | data->child->resize( count + 1 ); |
302 | (*data->child)[count] = uid; | 308 | (*data->child)[count] = uid; |
303 | } | 309 | } |
304 | } | 310 | } |
305 | void OEvent::removeChild( int uid ) { | 311 | void OEvent::removeChild( int uid ) { |
306 | if (!data->child || !data->child->contains( uid ) ) return; | 312 | if (!data->child || !data->child->contains( uid ) ) return; |
307 | changeOrModify(); | 313 | changeOrModify(); |
308 | QArray<int> newAr( data->child->count() - 1 ); | 314 | QArray<int> newAr( data->child->count() - 1 ); |
309 | int j = 0; | 315 | int j = 0; |
310 | uint count = data->child->count(); | 316 | uint count = data->child->count(); |
311 | for ( uint i = 0; i < count; i++ ) { | 317 | for ( uint i = 0; i < count; i++ ) { |
312 | if ( (*data->child)[i] != uid ) { | 318 | if ( (*data->child)[i] != uid ) { |
313 | newAr[j] = (*data->child)[i]; | 319 | newAr[j] = (*data->child)[i]; |
314 | j++; | 320 | j++; |
315 | } | 321 | } |
316 | } | 322 | } |
317 | (*data->child) = newAr; | 323 | (*data->child) = newAr; |
318 | } | 324 | } |
319 | struct OEffectiveEvent::Data : public QShared { | 325 | struct OEffectiveEvent::Data : public QShared { |
320 | Data() : QShared() { | 326 | Data() : QShared() { |
321 | } | 327 | } |
322 | OEvent event; | 328 | OEvent event; |
323 | QDate date; | 329 | QDate date; |
324 | QTime start, end; | 330 | QTime start, end; |
325 | QDate startDate, endDate; | 331 | QDate startDate, endDate; |
326 | bool dates : 1; | 332 | bool dates : 1; |
327 | }; | 333 | }; |
328 | 334 | ||
329 | OEffectiveEvent::OEffectiveEvent() { | 335 | OEffectiveEvent::OEffectiveEvent() { |
330 | data = new Data; | 336 | data = new Data; |
331 | data->date = QDate::currentDate(); | 337 | data->date = QDate::currentDate(); |
332 | data->start = data->end = QTime::currentTime(); | 338 | data->start = data->end = QTime::currentTime(); |
333 | data->dates = false; | 339 | data->dates = false; |
334 | } | 340 | } |
335 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 341 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
336 | Position pos ) { | 342 | Position pos ) { |
337 | data = new Data; | 343 | data = new Data; |
338 | data->event = ev; | 344 | data->event = ev; |
339 | data->date = startDate; | 345 | data->date = startDate; |
340 | if ( pos & Start ) | 346 | if ( pos & Start ) |
341 | data->start = ev.startDateTime().time(); | 347 | data->start = ev.startDateTime().time(); |
342 | else | 348 | else |
343 | data->start = QTime( 0, 0, 0 ); | 349 | data->start = QTime( 0, 0, 0 ); |
344 | 350 | ||
345 | if ( pos & End ) | 351 | if ( pos & End ) |
346 | data->end = ev.endDateTime().time(); | 352 | data->end = ev.endDateTime().time(); |
347 | else | 353 | else |
348 | data->end = QTime( 23, 59, 59 ); | 354 | data->end = QTime( 23, 59, 59 ); |
349 | 355 | ||
350 | data->dates = false; | 356 | data->dates = false; |
351 | } | 357 | } |
352 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 358 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { |
353 | data = ev.data; | 359 | data = ev.data; |
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index 56ea10d..3ba8a52 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -149,205 +149,211 @@ void OEvent::setNote( const QString& note ) { | |||
149 | data->note = note; | 149 | data->note = note; |
150 | } | 150 | } |
151 | QDateTime OEvent::createdDateTime()const { | 151 | QDateTime OEvent::createdDateTime()const { |
152 | return data->created; | 152 | return data->created; |
153 | } | 153 | } |
154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 154 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |
155 | changeOrModify(); | 155 | changeOrModify(); |
156 | data->created = time; | 156 | data->created = time; |
157 | } | 157 | } |
158 | QDateTime OEvent::startDateTime()const { | 158 | QDateTime OEvent::startDateTime()const { |
159 | if ( data->isAllDay ) | 159 | if ( data->isAllDay ) |
160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 160 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
161 | return data->start; | 161 | return data->start; |
162 | } | 162 | } |
163 | QDateTime OEvent::startDateTimeInZone()const { | 163 | QDateTime OEvent::startDateTimeInZone()const { |
164 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 164 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 165 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
166 | 166 | ||
167 | OTimeZone zone(data->timezone ); | 167 | OTimeZone zone(data->timezone ); |
168 | return zone.toDateTime( data->start, OTimeZone::current() ); | 168 | return zone.toDateTime( data->start, OTimeZone::current() ); |
169 | } | 169 | } |
170 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 170 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
171 | changeOrModify(); | 171 | changeOrModify(); |
172 | data->start = dt; | 172 | data->start = dt; |
173 | } | 173 | } |
174 | QDateTime OEvent::endDateTime()const { | 174 | QDateTime OEvent::endDateTime()const { |
175 | /* | 175 | /* |
176 | * if all Day event the end time needs | 176 | * if all Day event the end time needs |
177 | * to be on the same day as the start | 177 | * to be on the same day as the start |
178 | */ | 178 | */ |
179 | if ( data->isAllDay ) | 179 | if ( data->isAllDay ) |
180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 180 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
181 | return data->end; | 181 | return data->end; |
182 | } | 182 | } |
183 | QDateTime OEvent::endDateTimeInZone()const { | 183 | QDateTime OEvent::endDateTimeInZone()const { |
184 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 184 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 185 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
186 | 186 | ||
187 | OTimeZone zone(data->timezone ); | 187 | OTimeZone zone(data->timezone ); |
188 | return zone.toDateTime( data->end, OTimeZone::current() ); | 188 | return zone.toDateTime( data->end, OTimeZone::current() ); |
189 | } | 189 | } |
190 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 190 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
191 | changeOrModify(); | 191 | changeOrModify(); |
192 | data->end = dt; | 192 | data->end = dt; |
193 | } | 193 | } |
194 | bool OEvent::isMultipleDay()const { | 194 | bool OEvent::isMultipleDay()const { |
195 | return data->end.date().day() - data->start.date().day(); | 195 | return data->end.date().day() - data->start.date().day(); |
196 | } | 196 | } |
197 | bool OEvent::isAllDay()const { | 197 | bool OEvent::isAllDay()const { |
198 | return data->isAllDay; | 198 | return data->isAllDay; |
199 | } | 199 | } |
200 | void OEvent::setAllDay( bool allDay ) { | 200 | void OEvent::setAllDay( bool allDay ) { |
201 | changeOrModify(); | 201 | changeOrModify(); |
202 | data->isAllDay = allDay; | 202 | data->isAllDay = allDay; |
203 | if (allDay ) data->timezone = "UTC"; | 203 | if (allDay ) data->timezone = "UTC"; |
204 | } | 204 | } |
205 | void OEvent::setTimeZone( const QString& tz ) { | 205 | void OEvent::setTimeZone( const QString& tz ) { |
206 | changeOrModify(); | 206 | changeOrModify(); |
207 | data->timezone = tz; | 207 | data->timezone = tz; |
208 | } | 208 | } |
209 | QString OEvent::timeZone()const { | 209 | QString OEvent::timeZone()const { |
210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 210 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
211 | return data->timezone; | 211 | return data->timezone; |
212 | } | 212 | } |
213 | bool OEvent::match( const QRegExp& )const { | 213 | bool OEvent::match( const QRegExp& )const { |
214 | // FIXME | 214 | // FIXME |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | QString OEvent::toRichText()const { | 217 | QString OEvent::toRichText()const { |
218 | // FIXME | 218 | // FIXME |
219 | return "OEvent test"; | 219 | return "OEvent test"; |
220 | } | 220 | } |
221 | QString OEvent::toShortText()const { | 221 | QString OEvent::toShortText()const { |
222 | return "OEvent shotText"; | 222 | return "OEvent shotText"; |
223 | } | 223 | } |
224 | QString OEvent::type()const { | 224 | QString OEvent::type()const { |
225 | return QString::fromLatin1("OEvent"); | 225 | return QString::fromLatin1("OEvent"); |
226 | } | 226 | } |
227 | QString OEvent::recordField( int /*id */ )const { | 227 | QString OEvent::recordField( int /*id */ )const { |
228 | return QString::null; | 228 | return QString::null; |
229 | } | 229 | } |
230 | int OEvent::rtti() { | 230 | int OEvent::rtti() { |
231 | return OPimResolver::DateBook; | 231 | return OPimResolver::DateBook; |
232 | } | 232 | } |
233 | bool OEvent::loadFromStream( QDataStream& ) { | 233 | bool OEvent::loadFromStream( QDataStream& ) { |
234 | return true; | 234 | return true; |
235 | } | 235 | } |
236 | bool OEvent::saveToStream( QDataStream& )const { | 236 | bool OEvent::saveToStream( QDataStream& )const { |
237 | return true; | 237 | return true; |
238 | } | 238 | } |
239 | void OEvent::changeOrModify() { | 239 | void OEvent::changeOrModify() { |
240 | if ( data->count != 1 ) { | 240 | if ( data->count != 1 ) { |
241 | data->deref(); | 241 | data->deref(); |
242 | Data* d2 = new Data; | 242 | Data* d2 = new Data; |
243 | d2->description = data->description; | 243 | d2->description = data->description; |
244 | d2->location = data->location; | 244 | d2->location = data->location; |
245 | d2->manager = data->manager; | 245 | |
246 | d2->recur = data->recur; | 246 | if (data->manager ) |
247 | d2->manager = new OPimNotifyManager( *data->manager ); | ||
248 | |||
249 | if ( data->recur ) | ||
250 | d2->recur = new ORecur( *data->recur ); | ||
251 | |||
247 | d2->note = data->note; | 252 | d2->note = data->note; |
248 | d2->created = data->created; | 253 | d2->created = data->created; |
249 | d2->start = data->start; | 254 | d2->start = data->start; |
250 | d2->end = data->end; | 255 | d2->end = data->end; |
251 | d2->isAllDay = data->isAllDay; | 256 | d2->isAllDay = data->isAllDay; |
252 | d2->timezone = data->timezone; | 257 | d2->timezone = data->timezone; |
253 | d2->parent = data->parent; | 258 | d2->parent = data->parent; |
254 | d2->child = data->child; | ||
255 | 259 | ||
256 | if (d2->child ) | 260 | if ( data->child ) { |
261 | d2->child = new QArray<int>( *data->child ); | ||
257 | d2->child->detach(); | 262 | d2->child->detach(); |
263 | } | ||
258 | 264 | ||
259 | data = d2; | 265 | data = d2; |
260 | } | 266 | } |
261 | } | 267 | } |
262 | void OEvent::deref() { | 268 | void OEvent::deref() { |
263 | if ( data->deref() ) { | 269 | if ( data->deref() ) { |
264 | delete data; | 270 | delete data; |
265 | data = 0; | 271 | data = 0; |
266 | } | 272 | } |
267 | } | 273 | } |
268 | // FIXME | 274 | // FIXME |
269 | QMap<int, QString> OEvent::toMap()const { | 275 | QMap<int, QString> OEvent::toMap()const { |
270 | return QMap<int, QString>(); | 276 | return QMap<int, QString>(); |
271 | } | 277 | } |
272 | QMap<QString, QString> OEvent::toExtraMap()const { | 278 | QMap<QString, QString> OEvent::toExtraMap()const { |
273 | return QMap<QString, QString>(); | 279 | return QMap<QString, QString>(); |
274 | } | 280 | } |
275 | int OEvent::parent()const { | 281 | int OEvent::parent()const { |
276 | return data->parent; | 282 | return data->parent; |
277 | } | 283 | } |
278 | void OEvent::setParent( int uid ) { | 284 | void OEvent::setParent( int uid ) { |
279 | changeOrModify(); | 285 | changeOrModify(); |
280 | data->parent = uid; | 286 | data->parent = uid; |
281 | } | 287 | } |
282 | QArray<int> OEvent::children() const{ | 288 | QArray<int> OEvent::children() const{ |
283 | if (!data->child) return QArray<int>(); | 289 | if (!data->child) return QArray<int>(); |
284 | else | 290 | else |
285 | return data->child->copy(); | 291 | return data->child->copy(); |
286 | } | 292 | } |
287 | void OEvent::setChildren( const QArray<int>& arr ) { | 293 | void OEvent::setChildren( const QArray<int>& arr ) { |
288 | changeOrModify(); | 294 | changeOrModify(); |
289 | if (data->child) delete data->child; | 295 | if (data->child) delete data->child; |
290 | 296 | ||
291 | data->child = new QArray<int>( arr ); | 297 | data->child = new QArray<int>( arr ); |
292 | data->child->detach(); | 298 | data->child->detach(); |
293 | } | 299 | } |
294 | void OEvent::addChild( int uid ) { | 300 | void OEvent::addChild( int uid ) { |
295 | changeOrModify(); | 301 | changeOrModify(); |
296 | if (!data->child ) { | 302 | if (!data->child ) { |
297 | data->child = new QArray<int>(1); | 303 | data->child = new QArray<int>(1); |
298 | (*data->child)[0] = uid; | 304 | (*data->child)[0] = uid; |
299 | }else{ | 305 | }else{ |
300 | int count = data->child->count(); | 306 | int count = data->child->count(); |
301 | data->child->resize( count + 1 ); | 307 | data->child->resize( count + 1 ); |
302 | (*data->child)[count] = uid; | 308 | (*data->child)[count] = uid; |
303 | } | 309 | } |
304 | } | 310 | } |
305 | void OEvent::removeChild( int uid ) { | 311 | void OEvent::removeChild( int uid ) { |
306 | if (!data->child || !data->child->contains( uid ) ) return; | 312 | if (!data->child || !data->child->contains( uid ) ) return; |
307 | changeOrModify(); | 313 | changeOrModify(); |
308 | QArray<int> newAr( data->child->count() - 1 ); | 314 | QArray<int> newAr( data->child->count() - 1 ); |
309 | int j = 0; | 315 | int j = 0; |
310 | uint count = data->child->count(); | 316 | uint count = data->child->count(); |
311 | for ( uint i = 0; i < count; i++ ) { | 317 | for ( uint i = 0; i < count; i++ ) { |
312 | if ( (*data->child)[i] != uid ) { | 318 | if ( (*data->child)[i] != uid ) { |
313 | newAr[j] = (*data->child)[i]; | 319 | newAr[j] = (*data->child)[i]; |
314 | j++; | 320 | j++; |
315 | } | 321 | } |
316 | } | 322 | } |
317 | (*data->child) = newAr; | 323 | (*data->child) = newAr; |
318 | } | 324 | } |
319 | struct OEffectiveEvent::Data : public QShared { | 325 | struct OEffectiveEvent::Data : public QShared { |
320 | Data() : QShared() { | 326 | Data() : QShared() { |
321 | } | 327 | } |
322 | OEvent event; | 328 | OEvent event; |
323 | QDate date; | 329 | QDate date; |
324 | QTime start, end; | 330 | QTime start, end; |
325 | QDate startDate, endDate; | 331 | QDate startDate, endDate; |
326 | bool dates : 1; | 332 | bool dates : 1; |
327 | }; | 333 | }; |
328 | 334 | ||
329 | OEffectiveEvent::OEffectiveEvent() { | 335 | OEffectiveEvent::OEffectiveEvent() { |
330 | data = new Data; | 336 | data = new Data; |
331 | data->date = QDate::currentDate(); | 337 | data->date = QDate::currentDate(); |
332 | data->start = data->end = QTime::currentTime(); | 338 | data->start = data->end = QTime::currentTime(); |
333 | data->dates = false; | 339 | data->dates = false; |
334 | } | 340 | } |
335 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 341 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
336 | Position pos ) { | 342 | Position pos ) { |
337 | data = new Data; | 343 | data = new Data; |
338 | data->event = ev; | 344 | data->event = ev; |
339 | data->date = startDate; | 345 | data->date = startDate; |
340 | if ( pos & Start ) | 346 | if ( pos & Start ) |
341 | data->start = ev.startDateTime().time(); | 347 | data->start = ev.startDateTime().time(); |
342 | else | 348 | else |
343 | data->start = QTime( 0, 0, 0 ); | 349 | data->start = QTime( 0, 0, 0 ); |
344 | 350 | ||
345 | if ( pos & End ) | 351 | if ( pos & End ) |
346 | data->end = ev.endDateTime().time(); | 352 | data->end = ev.endDateTime().time(); |
347 | else | 353 | else |
348 | data->end = QTime( 23, 59, 59 ); | 354 | data->end = QTime( 23, 59, 59 ); |
349 | 355 | ||
350 | data->dates = false; | 356 | data->dates = false; |
351 | } | 357 | } |
352 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 358 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { |
353 | data = ev.data; | 359 | data = ev.data; |