-rw-r--r-- | libopie2/opiepim/oevent.cpp | 534 |
1 files changed, 405 insertions, 129 deletions
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index de5e30b..d9cee2b 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -2,3 +2,3 @@ | |||
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) | 3 | Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
@@ -28,9 +28,6 @@ | |||
28 | */ | 28 | */ |
29 | #include <qshared.h> | ||
30 | #include <qarray.h> | ||
31 | 29 | ||
32 | #include <qpe/palmtopuidgen.h> | 30 | #include "oevent.h" |
33 | #include <qpe/categories.h> | ||
34 | #include <qpe/stringutil.h> | ||
35 | 31 | ||
32 | /* OPIE */ | ||
36 | #include <opie2/orecur.h> | 33 | #include <opie2/orecur.h> |
@@ -38,8 +35,15 @@ | |||
38 | #include <opie2/opimnotifymanager.h> | 35 | #include <opie2/opimnotifymanager.h> |
36 | #include <qpe/categories.h> | ||
37 | #include <qpe/palmtopuidgen.h> | ||
38 | #include <qpe/stringutil.h> | ||
39 | 39 | ||
40 | #include <opie2/oevent.h> | 40 | /* QT */ |
41 | #include <qshared.h> | ||
42 | #include <qarray.h> | ||
41 | 43 | ||
42 | namespace Opie { | 44 | namespace Opie |
45 | { | ||
43 | 46 | ||
44 | int OCalendarHelper::week( const QDate& date) { | 47 | int OCalendarHelper::week( const QDate& date ) |
48 | { | ||
45 | // Calculates the week this date is in within that | 49 | // Calculates the week this date is in within that |
@@ -55,3 +59,6 @@ int OCalendarHelper::week( const QDate& date) { | |||
55 | } | 59 | } |
56 | int OCalendarHelper::ocurrence( const QDate& date) { | 60 | |
61 | |||
62 | int OCalendarHelper::ocurrence( const QDate& date ) | ||
63 | { | ||
57 | // calculates the number of occurrances of this day of the | 64 | // calculates the number of occurrances of this day of the |
@@ -60,6 +67,10 @@ int OCalendarHelper::ocurrence( const QDate& date) { | |||
60 | } | 67 | } |
61 | int OCalendarHelper::dayOfWeek( char day ) { | 68 | |
69 | |||
70 | int OCalendarHelper::dayOfWeek( char day ) | ||
71 | { | ||
62 | int dayOfWeek = 1; | 72 | int dayOfWeek = 1; |
63 | char i = ORecur::MON; | 73 | char i = ORecur::MON; |
64 | while ( !( i & day ) && i <= ORecur::SUN ) { | 74 | while ( !( i & day ) && i <= ORecur::SUN ) |
75 | { | ||
65 | i <<= 1; | 76 | i <<= 1; |
@@ -69,3 +80,6 @@ int OCalendarHelper::dayOfWeek( char day ) { | |||
69 | } | 80 | } |
70 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | 81 | |
82 | |||
83 | int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) | ||
84 | { | ||
71 | return ( second.year() - first.year() ) * 12 + | 85 | return ( second.year() - first.year() ) * 12 + |
@@ -74,4 +88,7 @@ int OCalendarHelper::monthDiff( const QDate& first, const QDate& second ) { | |||
74 | 88 | ||
75 | struct OEvent::Data : public QShared { | 89 | |
76 | Data() : QShared() { | 90 | struct OEvent::Data : public QShared |
91 | { | ||
92 | Data() : QShared() | ||
93 | { | ||
77 | child = 0; | 94 | child = 0; |
@@ -82,3 +99,4 @@ struct OEvent::Data : public QShared { | |||
82 | } | 99 | } |
83 | ~Data() { | 100 | ~Data() |
101 | { | ||
84 | delete manager; | 102 | delete manager; |
@@ -100,6 +118,10 @@ struct OEvent::Data : public QShared { | |||
100 | 118 | ||
119 | |||
101 | OEvent::OEvent( int uid ) | 120 | OEvent::OEvent( int uid ) |
102 | : OPimRecord( uid ) { | 121 | : OPimRecord( uid ) |
122 | { | ||
103 | data = new Data; | 123 | data = new Data; |
104 | } | 124 | } |
125 | |||
126 | |||
105 | OEvent::OEvent( const OEvent& ev) | 127 | OEvent::OEvent( const OEvent& ev) |
@@ -110,2 +132,3 @@ OEvent::OEvent( const OEvent& ev) | |||
110 | 132 | ||
133 | |||
111 | OEvent::OEvent( const QMap<int, QString> map ) | 134 | OEvent::OEvent( const QMap<int, QString> map ) |
@@ -118,4 +141,7 @@ OEvent::OEvent( const QMap<int, QString> map ) | |||
118 | 141 | ||
119 | OEvent::~OEvent() { | 142 | |
120 | if ( data->deref() ) { | 143 | OEvent::~OEvent() |
144 | { | ||
145 | if ( data->deref() ) | ||
146 | { | ||
121 | delete data; | 147 | delete data; |
@@ -124,3 +150,6 @@ OEvent::~OEvent() { | |||
124 | } | 150 | } |
125 | OEvent& OEvent::operator=( const OEvent& ev) { | 151 | |
152 | |||
153 | OEvent& OEvent::operator=( const OEvent& ev ) | ||
154 | { | ||
126 | if ( this == &ev ) return *this; | 155 | if ( this == &ev ) return *this; |
@@ -135,6 +164,12 @@ OEvent& OEvent::operator=( const OEvent& ev) { | |||
135 | } | 164 | } |
136 | QString OEvent::description()const { | 165 | |
166 | |||
167 | QString OEvent::description() const | ||
168 | { | ||
137 | return data->description; | 169 | return data->description; |
138 | } | 170 | } |
139 | void OEvent::setDescription( const QString& description ) { | 171 | |
172 | |||
173 | void OEvent::setDescription( const QString& description ) | ||
174 | { | ||
140 | changeOrModify(); | 175 | changeOrModify(); |
@@ -142,3 +177,6 @@ void OEvent::setDescription( const QString& description ) { | |||
142 | } | 177 | } |
143 | void OEvent::setLocation( const QString& loc ) { | 178 | |
179 | |||
180 | void OEvent::setLocation( const QString& loc ) | ||
181 | { | ||
144 | changeOrModify(); | 182 | changeOrModify(); |
@@ -146,6 +184,12 @@ void OEvent::setLocation( const QString& loc ) { | |||
146 | } | 184 | } |
147 | QString OEvent::location()const { | 185 | |
186 | |||
187 | QString OEvent::location() const | ||
188 | { | ||
148 | return data->location; | 189 | return data->location; |
149 | } | 190 | } |
150 | OPimNotifyManager &OEvent::notifiers()const { | 191 | |
192 | |||
193 | OPimNotifyManager &OEvent::notifiers() const | ||
194 | { | ||
151 | // I hope we can skip the changeOrModify here | 195 | // I hope we can skip the changeOrModify here |
@@ -158,3 +202,6 @@ OPimNotifyManager &OEvent::notifiers()const { | |||
158 | } | 202 | } |
159 | bool OEvent::hasNotifiers()const { | 203 | |
204 | |||
205 | bool OEvent::hasNotifiers() const | ||
206 | { | ||
160 | if (!data->manager ) | 207 | if (!data->manager ) |
@@ -167,3 +214,6 @@ bool OEvent::hasNotifiers()const { | |||
167 | } | 214 | } |
168 | ORecur OEvent::recurrence()const { | 215 | |
216 | |||
217 | ORecur OEvent::recurrence() const | ||
218 | { | ||
169 | if (!data->recur) | 219 | if (!data->recur) |
@@ -173,3 +223,6 @@ ORecur OEvent::recurrence()const { | |||
173 | } | 223 | } |
174 | void OEvent::setRecurrence( const ORecur& rec) { | 224 | |
225 | |||
226 | void OEvent::setRecurrence( const ORecur& rec ) | ||
227 | { | ||
175 | changeOrModify(); | 228 | changeOrModify(); |
@@ -180,3 +233,6 @@ void OEvent::setRecurrence( const ORecur& rec) { | |||
180 | } | 233 | } |
181 | bool OEvent::hasRecurrence()const { | 234 | |
235 | |||
236 | bool OEvent::hasRecurrence() const | ||
237 | { | ||
182 | if (!data->recur ) return false; | 238 | if (!data->recur ) return false; |
@@ -184,6 +240,12 @@ bool OEvent::hasRecurrence()const { | |||
184 | } | 240 | } |
185 | QString OEvent::note()const { | 241 | |
242 | |||
243 | QString OEvent::note() const | ||
244 | { | ||
186 | return data->note; | 245 | return data->note; |
187 | } | 246 | } |
188 | void OEvent::setNote( const QString& note ) { | 247 | |
248 | |||
249 | void OEvent::setNote( const QString& note ) | ||
250 | { | ||
189 | changeOrModify(); | 251 | changeOrModify(); |
@@ -191,6 +253,12 @@ void OEvent::setNote( const QString& note ) { | |||
191 | } | 253 | } |
192 | QDateTime OEvent::createdDateTime()const { | 254 | |
255 | |||
256 | QDateTime OEvent::createdDateTime() const | ||
257 | { | ||
193 | return data->created; | 258 | return data->created; |
194 | } | 259 | } |
195 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 260 | |
261 | |||
262 | void OEvent::setCreatedDateTime( const QDateTime& time ) | ||
263 | { | ||
196 | changeOrModify(); | 264 | changeOrModify(); |
@@ -198,3 +266,6 @@ void OEvent::setCreatedDateTime( const QDateTime& time ) { | |||
198 | } | 266 | } |
199 | QDateTime OEvent::startDateTime()const { | 267 | |
268 | |||
269 | QDateTime OEvent::startDateTime() const | ||
270 | { | ||
200 | if ( data->isAllDay ) | 271 | if ( data->isAllDay ) |
@@ -203,3 +274,6 @@ QDateTime OEvent::startDateTime()const { | |||
203 | } | 274 | } |
204 | QDateTime OEvent::startDateTimeInZone()const { | 275 | |
276 | |||
277 | QDateTime OEvent::startDateTimeInZone() const | ||
278 | { | ||
205 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 279 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
@@ -210,3 +284,6 @@ QDateTime OEvent::startDateTimeInZone()const { | |||
210 | } | 284 | } |
211 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 285 | |
286 | |||
287 | void OEvent::setStartDateTime( const QDateTime& dt ) | ||
288 | { | ||
212 | changeOrModify(); | 289 | changeOrModify(); |
@@ -214,3 +291,6 @@ void OEvent::setStartDateTime( const QDateTime& dt ) { | |||
214 | } | 291 | } |
215 | QDateTime OEvent::endDateTime()const { | 292 | |
293 | |||
294 | QDateTime OEvent::endDateTime() const | ||
295 | { | ||
216 | /* | 296 | /* |
@@ -223,3 +303,6 @@ QDateTime OEvent::endDateTime()const { | |||
223 | } | 303 | } |
224 | QDateTime OEvent::endDateTimeInZone()const { | 304 | |
305 | |||
306 | QDateTime OEvent::endDateTimeInZone() const | ||
307 | { | ||
225 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 308 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
@@ -230,3 +313,6 @@ QDateTime OEvent::endDateTimeInZone()const { | |||
230 | } | 313 | } |
231 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 314 | |
315 | |||
316 | void OEvent::setEndDateTime( const QDateTime& dt ) | ||
317 | { | ||
232 | changeOrModify(); | 318 | changeOrModify(); |
@@ -234,9 +320,18 @@ void OEvent::setEndDateTime( const QDateTime& dt ) { | |||
234 | } | 320 | } |
235 | bool OEvent::isMultipleDay()const { | 321 | |
322 | |||
323 | bool OEvent::isMultipleDay() const | ||
324 | { | ||
236 | return data->end.date().day() - data->start.date().day(); | 325 | return data->end.date().day() - data->start.date().day(); |
237 | } | 326 | } |
238 | bool OEvent::isAllDay()const { | 327 | |
328 | |||
329 | bool OEvent::isAllDay() const | ||
330 | { | ||
239 | return data->isAllDay; | 331 | return data->isAllDay; |
240 | } | 332 | } |
241 | void OEvent::setAllDay( bool allDay ) { | 333 | |
334 | |||
335 | void OEvent::setAllDay( bool allDay ) | ||
336 | { | ||
242 | changeOrModify(); | 337 | changeOrModify(); |
@@ -245,3 +340,6 @@ void OEvent::setAllDay( bool allDay ) { | |||
245 | } | 340 | } |
246 | void OEvent::setTimeZone( const QString& tz ) { | 341 | |
342 | |||
343 | void OEvent::setTimeZone( const QString& tz ) | ||
344 | { | ||
247 | changeOrModify(); | 345 | changeOrModify(); |
@@ -249,3 +347,6 @@ void OEvent::setTimeZone( const QString& tz ) { | |||
249 | } | 347 | } |
250 | QString OEvent::timeZone()const { | 348 | |
349 | |||
350 | QString OEvent::timeZone() const | ||
351 | { | ||
251 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 352 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
@@ -253,4 +354,8 @@ QString OEvent::timeZone()const { | |||
253 | } | 354 | } |
254 | bool OEvent::match( const QRegExp& re )const { | 355 | |
255 | if ( re.match( data->description ) != -1 ){ | 356 | |
357 | bool OEvent::match( const QRegExp& re ) const | ||
358 | { | ||
359 | if ( re.match( data->description ) != -1 ) | ||
360 | { | ||
256 | setLastHitField( Qtopia::DatebookDescription ); | 361 | setLastHitField( Qtopia::DatebookDescription ); |
@@ -258,3 +363,4 @@ bool OEvent::match( const QRegExp& re )const { | |||
258 | } | 363 | } |
259 | if ( re.match( data->note ) != -1 ){ | 364 | if ( re.match( data->note ) != -1 ) |
365 | { | ||
260 | setLastHitField( Qtopia::Note ); | 366 | setLastHitField( Qtopia::Note ); |
@@ -262,3 +368,4 @@ bool OEvent::match( const QRegExp& re )const { | |||
262 | } | 368 | } |
263 | if ( re.match( data->location ) != -1 ){ | 369 | if ( re.match( data->location ) != -1 ) |
370 | { | ||
264 | setLastHitField( Qtopia::Location ); | 371 | setLastHitField( Qtopia::Location ); |
@@ -266,3 +373,4 @@ bool OEvent::match( const QRegExp& re )const { | |||
266 | } | 373 | } |
267 | if ( re.match( data->start.toString() ) != -1 ){ | 374 | if ( re.match( data->start.toString() ) != -1 ) |
375 | { | ||
268 | setLastHitField( Qtopia::StartDateTime ); | 376 | setLastHitField( Qtopia::StartDateTime ); |
@@ -270,3 +378,4 @@ bool OEvent::match( const QRegExp& re )const { | |||
270 | } | 378 | } |
271 | if ( re.match( data->end.toString() ) != -1 ){ | 379 | if ( re.match( data->end.toString() ) != -1 ) |
380 | { | ||
272 | setLastHitField( Qtopia::EndDateTime ); | 381 | setLastHitField( Qtopia::EndDateTime ); |
@@ -276,3 +385,6 @@ bool OEvent::match( const QRegExp& re )const { | |||
276 | } | 385 | } |
277 | QString OEvent::toRichText()const { | 386 | |
387 | |||
388 | QString OEvent::toRichText() const | ||
389 | { | ||
278 | QString text, value; | 390 | QString text, value; |
@@ -281,3 +393,4 @@ QString OEvent::toRichText()const { | |||
281 | text += "<b><h3><img src=\"datebook/DateBook\">"; | 393 | text += "<b><h3><img src=\"datebook/DateBook\">"; |
282 | if ( !description().isEmpty() ) { | 394 | if ( !description().isEmpty() ) |
395 | { | ||
283 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); | 396 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); |
@@ -287,3 +400,4 @@ QString OEvent::toRichText()const { | |||
287 | // location | 400 | // location |
288 | if ( !(value = location()).isEmpty() ) { | 401 | if ( !( value = location() ).isEmpty() ) |
402 | { | ||
289 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; | 403 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; |
@@ -293,3 +407,4 @@ QString OEvent::toRichText()const { | |||
293 | // all day event | 407 | // all day event |
294 | if ( isAllDay() ) { | 408 | if ( isAllDay() ) |
409 | { | ||
295 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; | 410 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; |
@@ -297,3 +412,4 @@ QString OEvent::toRichText()const { | |||
297 | // multiple day event | 412 | // multiple day event |
298 | else if ( isMultipleDay () ) { | 413 | else if ( isMultipleDay () ) |
414 | { | ||
299 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; | 415 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; |
@@ -301,5 +417,7 @@ QString OEvent::toRichText()const { | |||
301 | // start & end times | 417 | // start & end times |
302 | else { | 418 | else |
419 | { | ||
303 | // start time | 420 | // start time |
304 | if ( startDateTime().isValid() ) { | 421 | if ( startDateTime().isValid() ) |
422 | { | ||
305 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | 423 | text += "<b>" + QObject::tr( "Start:") + "</b> "; |
@@ -310,3 +428,4 @@ QString OEvent::toRichText()const { | |||
310 | // end time | 428 | // end time |
311 | if ( endDateTime().isValid() ) { | 429 | if ( endDateTime().isValid() ) |
430 | { | ||
312 | text += "<b>" + QObject::tr( "End:") + "</b> "; | 431 | text += "<b>" + QObject::tr( "End:") + "</b> "; |
@@ -318,3 +437,4 @@ QString OEvent::toRichText()const { | |||
318 | // categories | 437 | // categories |
319 | if ( categoryNames("Calendar").count() ){ | 438 | if ( categoryNames( "Calendar" ).count() ) |
439 | { | ||
320 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 440 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
@@ -325,3 +445,4 @@ QString OEvent::toRichText()const { | |||
325 | //notes | 445 | //notes |
326 | if ( !note().isEmpty() ) { | 446 | if ( !note().isEmpty() ) |
447 | { | ||
327 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 448 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
@@ -333,3 +454,6 @@ QString OEvent::toRichText()const { | |||
333 | } | 454 | } |
334 | QString OEvent::toShortText()const { | 455 | |
456 | |||
457 | QString OEvent::toShortText() const | ||
458 | { | ||
335 | QString text; | 459 | QString text; |
@@ -348,19 +472,38 @@ QString OEvent::toShortText()const { | |||
348 | } | 472 | } |
349 | QString OEvent::type()const { | 473 | |
474 | |||
475 | QString OEvent::type() const | ||
476 | { | ||
350 | return QString::fromLatin1("OEvent"); | 477 | return QString::fromLatin1("OEvent"); |
351 | } | 478 | } |
352 | QString OEvent::recordField( int /*id */ )const { | 479 | |
480 | |||
481 | QString OEvent::recordField( int /*id */ ) const | ||
482 | { | ||
353 | return QString::null; | 483 | return QString::null; |
354 | } | 484 | } |
355 | int OEvent::rtti() { | 485 | |
486 | |||
487 | int OEvent::rtti() | ||
488 | { | ||
356 | return OPimResolver::DateBook; | 489 | return OPimResolver::DateBook; |
357 | } | 490 | } |
358 | bool OEvent::loadFromStream( QDataStream& ) { | 491 | |
492 | |||
493 | bool OEvent::loadFromStream( QDataStream& ) | ||
494 | { | ||
359 | return true; | 495 | return true; |
360 | } | 496 | } |
361 | bool OEvent::saveToStream( QDataStream& )const { | 497 | |
498 | |||
499 | bool OEvent::saveToStream( QDataStream& ) const | ||
500 | { | ||
362 | return true; | 501 | return true; |
363 | } | 502 | } |
364 | void OEvent::changeOrModify() { | 503 | |
365 | if ( data->count != 1 ) { | 504 | |
505 | void OEvent::changeOrModify() | ||
506 | { | ||
507 | if ( data->count != 1 ) | ||
508 | { | ||
366 | data->deref(); | 509 | data->deref(); |
@@ -384,3 +527,4 @@ void OEvent::changeOrModify() { | |||
384 | 527 | ||
385 | if ( data->child ) { | 528 | if ( data->child ) |
529 | { | ||
386 | d2->child = new QArray<int>( *data->child ); | 530 | d2->child = new QArray<int>( *data->child ); |
@@ -392,4 +536,8 @@ void OEvent::changeOrModify() { | |||
392 | } | 536 | } |
393 | void OEvent::deref() { | 537 | |
394 | if ( data->deref() ) { | 538 | |
539 | void OEvent::deref() | ||
540 | { | ||
541 | if ( data->deref() ) | ||
542 | { | ||
395 | delete data; | 543 | delete data; |
@@ -403,3 +551,4 @@ void OEvent::deref() { | |||
403 | // Encoding should happen at one place, only ! (eilers) | 551 | // Encoding should happen at one place, only ! (eilers) |
404 | QMap<int, QString> OEvent::toMap()const { | 552 | QMap<int, QString> OEvent::toMap() const |
553 | { | ||
405 | QMap<int, QString> retMap; | 554 | QMap<int, QString> retMap; |
@@ -422,6 +571,8 @@ QMap<int, QString> OEvent::toMap()const { | |||
422 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); | 571 | retMap.insert( OEvent::FRecParent, QString::number( parent() ) ); |
423 | if( children().count() ){ | 572 | if ( children().count() ) |
573 | { | ||
424 | QArray<int> childr = children(); | 574 | QArray<int> childr = children(); |
425 | QString buf; | 575 | QString buf; |
426 | for ( uint i = 0; i < childr.count(); i++ ) { | 576 | for ( uint i = 0; i < childr.count(); i++ ) |
577 | { | ||
427 | if ( i != 0 ) buf += " "; | 578 | if ( i != 0 ) buf += " "; |
@@ -433,3 +584,4 @@ QMap<int, QString> OEvent::toMap()const { | |||
433 | // Add recurrence stuff | 584 | // Add recurrence stuff |
434 | if( hasRecurrence() ){ | 585 | if ( hasRecurrence() ) |
586 | { | ||
435 | ORecur recur = recurrence(); | 587 | ORecur recur = recurrence(); |
@@ -444,3 +596,5 @@ QMap<int, QString> OEvent::toMap()const { | |||
444 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); | 596 | retMap.insert( OEvent::FRExceptions, recFields[ORecur::Exceptions] ); |
445 | } else { | 597 | } |
598 | else | ||
599 | { | ||
446 | ORecur recur = recurrence(); | 600 | ORecur recur = recurrence(); |
@@ -453,2 +607,3 @@ QMap<int, QString> OEvent::toMap()const { | |||
453 | 607 | ||
608 | |||
454 | void OEvent::fromMap( const QMap<int, QString>& map ) | 609 | void OEvent::fromMap( const QMap<int, QString>& map ) |
@@ -474,3 +629,4 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
474 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); | 629 | int sound = ( ( map[OEvent::FSound] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); |
475 | if ( ( alarmTime != -1 ) ){ | 630 | if ( ( alarmTime != -1 ) ) |
631 | { | ||
476 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); | 632 | QDateTime dt = startDateTime().addSecs( -1*alarmTime*60 ); |
@@ -479,3 +635,4 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
479 | } | 635 | } |
480 | if ( !map[OEvent::FTimeZone].isEmpty() && ( map[OEvent::FTimeZone] != "None" ) ){ | 636 | if ( !map[ OEvent::FTimeZone ].isEmpty() && ( map[ OEvent::FTimeZone ] != "None" ) ) |
637 | { | ||
481 | setTimeZone( map[OEvent::FTimeZone] ); | 638 | setTimeZone( map[OEvent::FTimeZone] ); |
@@ -487,3 +644,4 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
487 | /* AllDay is always in UTC */ | 644 | /* AllDay is always in UTC */ |
488 | if ( isAllDay() ) { | 645 | if ( isAllDay() ) |
646 | { | ||
489 | OTimeZone utc = OTimeZone::utc(); | 647 | OTimeZone utc = OTimeZone::utc(); |
@@ -492,3 +650,5 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
492 | setTimeZone( "UTC"); // make sure it is really utc | 650 | setTimeZone( "UTC"); // make sure it is really utc |
493 | }else { | 651 | } |
652 | else | ||
653 | { | ||
494 | /* to current date time */ | 654 | /* to current date time */ |
@@ -507,5 +667,7 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
507 | 667 | ||
508 | if ( !map[OEvent::FRecChildren].isEmpty() ){ | 668 | if ( !map[ OEvent::FRecChildren ].isEmpty() ) |
669 | { | ||
509 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); | 670 | QStringList list = QStringList::split(' ', map[OEvent::FRecChildren] ); |
510 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | 671 | for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
672 | { | ||
511 | addChild( (*it).toInt() ); | 673 | addChild( (*it).toInt() ); |
@@ -515,3 +677,4 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
515 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. | 677 | // Fill recurrence stuff and put it directly into the ORecur-Object using fromMap.. |
516 | if( !map[OEvent::FRType].isEmpty() ){ | 678 | if ( !map[ OEvent::FRType ].isEmpty() ) |
679 | { | ||
517 | QMap<int, QString> recFields; | 680 | QMap<int, QString> recFields; |
@@ -532,6 +695,10 @@ void OEvent::fromMap( const QMap<int, QString>& map ) | |||
532 | 695 | ||
533 | int OEvent::parent()const { | 696 | int OEvent::parent() const |
697 | { | ||
534 | return data->parent; | 698 | return data->parent; |
535 | } | 699 | } |
536 | void OEvent::setParent( int uid ) { | 700 | |
701 | |||
702 | void OEvent::setParent( int uid ) | ||
703 | { | ||
537 | changeOrModify(); | 704 | changeOrModify(); |
@@ -539,3 +706,6 @@ void OEvent::setParent( int uid ) { | |||
539 | } | 706 | } |
540 | QArray<int> OEvent::children() const{ | 707 | |
708 | |||
709 | QArray<int> OEvent::children() const | ||
710 | { | ||
541 | if (!data->child) return QArray<int>(); | 711 | if (!data->child) return QArray<int>(); |
@@ -544,3 +714,6 @@ QArray<int> OEvent::children() const{ | |||
544 | } | 714 | } |
545 | void OEvent::setChildren( const QArray<int>& arr ) { | 715 | |
716 | |||
717 | void OEvent::setChildren( const QArray<int>& arr ) | ||
718 | { | ||
546 | changeOrModify(); | 719 | changeOrModify(); |
@@ -551,8 +724,14 @@ void OEvent::setChildren( const QArray<int>& arr ) { | |||
551 | } | 724 | } |
552 | void OEvent::addChild( int uid ) { | 725 | |
726 | |||
727 | void OEvent::addChild( int uid ) | ||
728 | { | ||
553 | changeOrModify(); | 729 | changeOrModify(); |
554 | if (!data->child ) { | 730 | if ( !data->child ) |
731 | { | ||
555 | data->child = new QArray<int>(1); | 732 | data->child = new QArray<int>(1); |
556 | (*data->child)[0] = uid; | 733 | (*data->child)[0] = uid; |
557 | }else{ | 734 | } |
735 | else | ||
736 | { | ||
558 | int count = data->child->count(); | 737 | int count = data->child->count(); |
@@ -562,3 +741,6 @@ void OEvent::addChild( int uid ) { | |||
562 | } | 741 | } |
563 | void OEvent::removeChild( int uid ) { | 742 | |
743 | |||
744 | void OEvent::removeChild( int uid ) | ||
745 | { | ||
564 | if (!data->child || !data->child->contains( uid ) ) return; | 746 | if (!data->child || !data->child->contains( uid ) ) return; |
@@ -568,4 +750,6 @@ void OEvent::removeChild( int uid ) { | |||
568 | uint count = data->child->count(); | 750 | uint count = data->child->count(); |
569 | for ( uint i = 0; i < count; i++ ) { | 751 | for ( uint i = 0; i < count; i++ ) |
570 | if ( (*data->child)[i] != uid ) { | 752 | { |
753 | if ( ( *data->child ) [ i ] != uid ) | ||
754 | { | ||
571 | newAr[j] = (*data->child)[i]; | 755 | newAr[j] = (*data->child)[i]; |
@@ -576,5 +760,8 @@ void OEvent::removeChild( int uid ) { | |||
576 | } | 760 | } |
577 | struct OEffectiveEvent::Data : public QShared { | 761 | |
578 | Data() : QShared() { | 762 | |
579 | } | 763 | struct OEffectiveEvent::Data : public QShared |
764 | { | ||
765 | Data() : QShared() | ||
766 | {} | ||
580 | OEvent event; | 767 | OEvent event; |
@@ -586,3 +773,5 @@ struct OEffectiveEvent::Data : public QShared { | |||
586 | 773 | ||
587 | OEffectiveEvent::OEffectiveEvent() { | 774 | |
775 | OEffectiveEvent::OEffectiveEvent() | ||
776 | { | ||
588 | data = new Data; | 777 | data = new Data; |
@@ -592,4 +781,7 @@ OEffectiveEvent::OEffectiveEvent() { | |||
592 | } | 781 | } |
782 | |||
783 | |||
593 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 784 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
594 | Position pos ) { | 785 | Position pos ) |
786 | { | ||
595 | data = new Data; | 787 | data = new Data; |
@@ -609,3 +801,6 @@ OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | |||
609 | } | 801 | } |
610 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 802 | |
803 | |||
804 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev ) | ||
805 | { | ||
611 | data = ev.data; | 806 | data = ev.data; |
@@ -613,4 +808,8 @@ OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | |||
613 | } | 808 | } |
614 | OEffectiveEvent::~OEffectiveEvent() { | 809 | |
615 | if ( data->deref() ) { | 810 | |
811 | OEffectiveEvent::~OEffectiveEvent() | ||
812 | { | ||
813 | if ( data->deref() ) | ||
814 | { | ||
616 | delete data; | 815 | delete data; |
@@ -619,3 +818,6 @@ OEffectiveEvent::~OEffectiveEvent() { | |||
619 | } | 818 | } |
620 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { | 819 | |
820 | |||
821 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) | ||
822 | { | ||
621 | if ( *this == ev ) return *this; | 823 | if ( *this == ev ) return *this; |
@@ -629,3 +831,5 @@ OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { | |||
629 | 831 | ||
630 | void OEffectiveEvent::setStartTime( const QTime& ti) { | 832 | |
833 | void OEffectiveEvent::setStartTime( const QTime& ti ) | ||
834 | { | ||
631 | changeOrModify(); | 835 | changeOrModify(); |
@@ -633,3 +837,6 @@ void OEffectiveEvent::setStartTime( const QTime& ti) { | |||
633 | } | 837 | } |
634 | void OEffectiveEvent::setEndTime( const QTime& en) { | 838 | |
839 | |||
840 | void OEffectiveEvent::setEndTime( const QTime& en ) | ||
841 | { | ||
635 | changeOrModify(); | 842 | changeOrModify(); |
@@ -637,3 +844,6 @@ void OEffectiveEvent::setEndTime( const QTime& en) { | |||
637 | } | 844 | } |
638 | void OEffectiveEvent::setEvent( const OEvent& ev) { | 845 | |
846 | |||
847 | void OEffectiveEvent::setEvent( const OEvent& ev ) | ||
848 | { | ||
639 | changeOrModify(); | 849 | changeOrModify(); |
@@ -641,3 +851,6 @@ void OEffectiveEvent::setEvent( const OEvent& ev) { | |||
641 | } | 851 | } |
642 | void OEffectiveEvent::setDate( const QDate& da) { | 852 | |
853 | |||
854 | void OEffectiveEvent::setDate( const QDate& da ) | ||
855 | { | ||
643 | changeOrModify(); | 856 | changeOrModify(); |
@@ -645,5 +858,9 @@ void OEffectiveEvent::setDate( const QDate& da) { | |||
645 | } | 858 | } |
859 | |||
860 | |||
646 | void OEffectiveEvent::setEffectiveDates( const QDate& from, | 861 | void OEffectiveEvent::setEffectiveDates( const QDate& from, |
647 | const QDate& to ) { | 862 | const QDate& to ) |
648 | if (!from.isValid() ) { | 863 | { |
864 | if ( !from.isValid() ) | ||
865 | { | ||
649 | data->dates = false; | 866 | data->dates = false; |
@@ -655,24 +872,48 @@ void OEffectiveEvent::setEffectiveDates( const QDate& from, | |||
655 | } | 872 | } |
656 | QString OEffectiveEvent::description()const { | 873 | |
874 | |||
875 | QString OEffectiveEvent::description() const | ||
876 | { | ||
657 | return data->event.description(); | 877 | return data->event.description(); |
658 | } | 878 | } |
659 | QString OEffectiveEvent::location()const { | 879 | |
880 | |||
881 | QString OEffectiveEvent::location() const | ||
882 | { | ||
660 | return data->event.location(); | 883 | return data->event.location(); |
661 | } | 884 | } |
662 | QString OEffectiveEvent::note()const { | 885 | |
886 | |||
887 | QString OEffectiveEvent::note() const | ||
888 | { | ||
663 | return data->event.note(); | 889 | return data->event.note(); |
664 | } | 890 | } |
665 | OEvent OEffectiveEvent::event()const { | 891 | |
892 | |||
893 | OEvent OEffectiveEvent::event() const | ||
894 | { | ||
666 | return data->event; | 895 | return data->event; |
667 | } | 896 | } |
668 | QTime OEffectiveEvent::startTime()const { | 897 | |
898 | |||
899 | QTime OEffectiveEvent::startTime() const | ||
900 | { | ||
669 | return data->start; | 901 | return data->start; |
670 | } | 902 | } |
671 | QTime OEffectiveEvent::endTime()const { | 903 | |
904 | |||
905 | QTime OEffectiveEvent::endTime() const | ||
906 | { | ||
672 | return data->end; | 907 | return data->end; |
673 | } | 908 | } |
674 | QDate OEffectiveEvent::date()const { | 909 | |
910 | |||
911 | QDate OEffectiveEvent::date() const | ||
912 | { | ||
675 | return data->date; | 913 | return data->date; |
676 | } | 914 | } |
677 | int OEffectiveEvent::length()const { | 915 | |
916 | |||
917 | int OEffectiveEvent::length() const | ||
918 | { | ||
678 | return (data->end.hour() * 60 - data->start.hour() * 60) | 919 | return (data->end.hour() * 60 - data->start.hour() * 60) |
@@ -680,3 +921,6 @@ int OEffectiveEvent::length()const { | |||
680 | } | 921 | } |
681 | int OEffectiveEvent::size()const { | 922 | |
923 | |||
924 | int OEffectiveEvent::size() const | ||
925 | { | ||
682 | return ( data->end.hour() - data->start.hour() ) * 3600 | 926 | return ( data->end.hour() - data->start.hour() ) * 3600 |
@@ -685,3 +929,6 @@ int OEffectiveEvent::size()const { | |||
685 | } | 929 | } |
686 | QDate OEffectiveEvent::startDate()const { | 930 | |
931 | |||
932 | QDate OEffectiveEvent::startDate() const | ||
933 | { | ||
687 | if ( data->dates ) | 934 | if ( data->dates ) |
@@ -693,3 +940,6 @@ QDate OEffectiveEvent::startDate()const { | |||
693 | } | 940 | } |
694 | QDate OEffectiveEvent::endDate()const { | 941 | |
942 | |||
943 | QDate OEffectiveEvent::endDate() const | ||
944 | { | ||
695 | if ( data->dates ) | 945 | if ( data->dates ) |
@@ -701,4 +951,8 @@ QDate OEffectiveEvent::endDate()const { | |||
701 | } | 951 | } |
702 | void OEffectiveEvent::deref() { | 952 | |
703 | if ( data->deref() ) { | 953 | |
954 | void OEffectiveEvent::deref() | ||
955 | { | ||
956 | if ( data->deref() ) | ||
957 | { | ||
704 | delete data; | 958 | delete data; |
@@ -707,4 +961,8 @@ void OEffectiveEvent::deref() { | |||
707 | } | 961 | } |
708 | void OEffectiveEvent::changeOrModify() { | 962 | |
709 | if ( data->count != 1 ) { | 963 | |
964 | void OEffectiveEvent::changeOrModify() | ||
965 | { | ||
966 | if ( data->count != 1 ) | ||
967 | { | ||
710 | data->deref(); | 968 | data->deref(); |
@@ -721,3 +979,6 @@ void OEffectiveEvent::changeOrModify() { | |||
721 | } | 979 | } |
722 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ | 980 | |
981 | |||
982 | bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const | ||
983 | { | ||
723 | if ( data->date < e.date() ) | 984 | if ( data->date < e.date() ) |
@@ -729,6 +990,12 @@ bool OEffectiveEvent::operator<( const OEffectiveEvent &e ) const{ | |||
729 | } | 990 | } |
730 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const{ | 991 | |
992 | |||
993 | bool OEffectiveEvent::operator<=( const OEffectiveEvent &e ) const | ||
994 | { | ||
731 | return (data->date <= e.date() ); | 995 | return (data->date <= e.date() ); |
732 | } | 996 | } |
733 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { | 997 | |
998 | |||
999 | bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const | ||
1000 | { | ||
734 | return ( date() == e.date() | 1001 | return ( date() == e.date() |
@@ -738,9 +1005,18 @@ bool OEffectiveEvent::operator==( const OEffectiveEvent &e ) const { | |||
738 | } | 1005 | } |
739 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const { | 1006 | |
1007 | |||
1008 | bool OEffectiveEvent::operator!=( const OEffectiveEvent &e ) const | ||
1009 | { | ||
740 | return !(*this == e ); | 1010 | return !(*this == e ); |
741 | } | 1011 | } |
742 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const { | 1012 | |
1013 | |||
1014 | bool OEffectiveEvent::operator>( const OEffectiveEvent &e ) const | ||
1015 | { | ||
743 | return !(*this <= e ); | 1016 | return !(*this <= e ); |
744 | } | 1017 | } |
745 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const { | 1018 | |
1019 | |||
1020 | bool OEffectiveEvent::operator>= ( const OEffectiveEvent &e ) const | ||
1021 | { | ||
746 | return !(*this < e); | 1022 | return !(*this < e); |