-rw-r--r-- | libkcal/event.cpp | 1 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 24 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 63 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 2 |
7 files changed, 67 insertions, 36 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index ad66639..0766fd9 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -174,4 +174,5 @@ void Event::setDuration(int seconds) | |||
174 | bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) | 174 | bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) |
175 | { | 175 | { |
176 | if ( cancelled() ) return false; | ||
176 | if ( ! doesRecur() ) { | 177 | if ( ! doesRecur() ) { |
177 | if ( doesFloat() ) { | 178 | if ( doesFloat() ) { |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 4794bc9..f349681 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -373,16 +373,13 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | |||
373 | 373 | ||
374 | // recurrence rule stuff | 374 | // recurrence rule stuff |
375 | Recurrence *recur = incidence->recurrence(); | 375 | if (incidence->doesRecur()) { |
376 | if (recur->doesRecur()) { | 376 | icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence())); |
377 | 377 | // recurrence excpetion dates | |
378 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); | 378 | DateList dateList = incidence->exDates(); |
379 | } | 379 | DateList::ConstIterator exIt; |
380 | 380 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | |
381 | // recurrence excpetion dates | 381 | icalcomponent_add_property(parent,icalproperty_new_exdate( |
382 | DateList dateList = incidence->exDates(); | 382 | writeICalDate(*exIt))); |
383 | DateList::ConstIterator exIt; | 383 | } |
384 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | ||
385 | icalcomponent_add_property(parent,icalproperty_new_exdate( | ||
386 | writeICalDate(*exIt))); | ||
387 | } | 384 | } |
388 | 385 | ||
@@ -1296,5 +1293,6 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | |||
1296 | 1293 | ||
1297 | // Cancel backwards compatibility mode for subsequent changes by the application | 1294 | // Cancel backwards compatibility mode for subsequent changes by the application |
1298 | incidence->recurrence()->setCompatVersion(); | 1295 | if ( readrec ) |
1296 | incidence->recurrence()->setCompatVersion(); | ||
1299 | 1297 | ||
1300 | // add categories | 1298 | // add categories |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index e4bcc5e..4643a3a 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -34,5 +34,5 @@ Incidence::Incidence() : | |||
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
@@ -79,5 +79,8 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | |||
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 81 | if ( i.mRecurrence ) |
82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | ||
83 | else | ||
84 | mRecurrence = 0; | ||
82 | mHoliday = i.mHoliday ; | 85 | mHoliday = i.mHoliday ; |
83 | mBirthday = i.mBirthday; | 86 | mBirthday = i.mBirthday; |
@@ -94,5 +97,6 @@ Incidence::~Incidence() | |||
94 | } | 97 | } |
95 | if (relatedTo()) relatedTo()->removeRelation(this); | 98 | if (relatedTo()) relatedTo()->removeRelation(this); |
96 | delete mRecurrence; | 99 | if ( mRecurrence ) |
100 | delete mRecurrence; | ||
97 | 101 | ||
98 | } | 102 | } |
@@ -209,8 +213,22 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
209 | return false; | 213 | return false; |
210 | } | 214 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 215 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { |
212 | qDebug("recurrence is NOT equal "); | 216 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { |
213 | return false; | 217 | //qDebug("recurrence is NOT equal "); |
218 | return false; | ||
219 | } | ||
220 | } else { | ||
221 | // one ( or both ) recurrence is 0 | ||
222 | if ( i1.mRecurrence == 0 ) { | ||
223 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) | ||
224 | return false; | ||
225 | } else { | ||
226 | // i1.mRecurrence != 0 | ||
227 | // i2.mRecurrence == 0 | ||
228 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) | ||
229 | return false; | ||
230 | } | ||
214 | } | 231 | } |
232 | |||
215 | return | 233 | return |
216 | // i1.created() == i2.created() && | 234 | // i1.created() == i2.created() && |
@@ -280,5 +298,6 @@ void Incidence::setReadOnly( bool readOnly ) | |||
280 | { | 298 | { |
281 | IncidenceBase::setReadOnly( readOnly ); | 299 | IncidenceBase::setReadOnly( readOnly ); |
282 | recurrence()->setRecurReadOnly( readOnly); | 300 | if ( mRecurrence ) |
301 | mRecurrence->setRecurReadOnly( readOnly); | ||
283 | } | 302 | } |
284 | void Incidence::setLastModifiedSubInvalid() | 303 | void Incidence::setLastModifiedSubInvalid() |
@@ -331,5 +350,7 @@ void Incidence::setDtStart(const QDateTime &dtStart) | |||
331 | 350 | ||
332 | QDateTime dt = getEvenTime(dtStart); | 351 | QDateTime dt = getEvenTime(dtStart); |
333 | recurrence()->setRecurStart( dt); | 352 | |
353 | if ( mRecurrence ) | ||
354 | mRecurrence->setRecurStart( dt); | ||
334 | IncidenceBase::setDtStart( dt ); | 355 | IncidenceBase::setDtStart( dt ); |
335 | } | 356 | } |
@@ -505,5 +526,5 @@ void Incidence::removeRelation(Incidence *event) | |||
505 | bool Incidence::recursOn(const QDate &qd) const | 526 | bool Incidence::recursOn(const QDate &qd) const |
506 | { | 527 | { |
507 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 528 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
508 | else return false; | 529 | else return false; |
509 | } | 530 | } |
@@ -513,5 +534,4 @@ void Incidence::setExDates(const DateList &exDates) | |||
513 | if (mReadOnly) return; | 534 | if (mReadOnly) return; |
514 | mExDates = exDates; | 535 | mExDates = exDates; |
515 | |||
516 | recurrence()->setRecurExDatesCount(mExDates.count()); | 536 | recurrence()->setRecurExDatesCount(mExDates.count()); |
517 | 537 | ||
@@ -699,13 +719,19 @@ bool Incidence::isAlarmEnabled() const | |||
699 | return false; | 719 | return false; |
700 | } | 720 | } |
701 | 721 | #include <stdlib.h> | |
702 | Recurrence *Incidence::recurrence() const | 722 | Recurrence *Incidence::recurrence() |
703 | { | 723 | { |
724 | if ( ! mRecurrence ) { | ||
725 | mRecurrence = new Recurrence(this); | ||
726 | qDebug("creating new recurence "); | ||
727 | //abort(); | ||
728 | } | ||
704 | return mRecurrence; | 729 | return mRecurrence; |
705 | } | 730 | } |
706 | void Incidence::setRecurrence( Recurrence * r) | 731 | void Incidence::setRecurrence( Recurrence * r) |
707 | { | 732 | { |
708 | delete mRecurrence; | 733 | if ( mRecurrence ) |
709 | mRecurrence = r; | 734 | delete mRecurrence; |
735 | mRecurrence = r; | ||
710 | } | 736 | } |
711 | 737 | ||
@@ -721,4 +747,9 @@ QString Incidence::location() const | |||
721 | return mLocation; | 747 | return mLocation; |
722 | } | 748 | } |
749 | QString Incidence::recurrenceText() const | ||
750 | { | ||
751 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | ||
752 | return i18n("No"); | ||
753 | } | ||
723 | 754 | ||
724 | ushort Incidence::doesRecur() const | 755 | ushort Incidence::doesRecur() const |
@@ -734,10 +765,10 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
734 | if ( doesRecur() ) { | 765 | if ( doesRecur() ) { |
735 | bool last; | 766 | bool last; |
736 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 767 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); |
737 | int count = 0; | 768 | int count = 0; |
738 | if ( !last ) { | 769 | if ( !last ) { |
739 | while ( !last ) { | 770 | while ( !last ) { |
740 | ++count; | 771 | ++count; |
741 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 772 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); |
742 | if ( recursOn( incidenceStart.date() ) ) { | 773 | if ( recursOn( incidenceStart.date() ) ) { |
743 | last = true; // exit while llop | 774 | last = true; // exit while llop |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index d4af9f0..8519f01 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -250,5 +250,5 @@ class Incidence : public IncidenceBase | |||
250 | none, returns an appropriate (non-0) object. | 250 | none, returns an appropriate (non-0) object. |
251 | */ | 251 | */ |
252 | Recurrence *recurrence() const; | 252 | Recurrence *recurrence(); |
253 | void setRecurrence(Recurrence * r); | 253 | void setRecurrence(Recurrence * r); |
254 | /** | 254 | /** |
@@ -279,7 +279,9 @@ class Incidence : public IncidenceBase | |||
279 | bool isAnniversary() const; | 279 | bool isAnniversary() const; |
280 | QDateTime lastModifiedSub(); | 280 | QDateTime lastModifiedSub(); |
281 | QString recurrenceText() const; | ||
281 | void setLastModifiedSubInvalid(); | 282 | void setLastModifiedSubInvalid(); |
282 | 283 | ||
283 | 284 | ||
285 | Recurrence *mRecurrence; | ||
284 | protected: | 286 | protected: |
285 | QPtrList<Alarm> mAlarms; | 287 | QPtrList<Alarm> mAlarms; |
@@ -310,5 +312,4 @@ protected: | |||
310 | 312 | ||
311 | //QPtrList<Alarm> mAlarms; | 313 | //QPtrList<Alarm> mAlarms; |
312 | Recurrence *mRecurrence; | ||
313 | 314 | ||
314 | QString mLocation; | 315 | QString mLocation; |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 9359fad..f8f40f1 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -106,5 +106,5 @@ void KIncidenceFormatter::setEvent(Event *event) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | if (event->recurrence()->doesRecur()) { | 108 | if (event->doesRecur()) { |
109 | 109 | ||
110 | QString recurText = event->recurrence()->recurrenceText(); | 110 | QString recurText = event->recurrence()->recurrenceText(); |
@@ -217,5 +217,5 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
217 | 217 | ||
218 | 218 | ||
219 | if (event->recurrence()->doesRecur()) { | 219 | if (event->doesRecur()) { |
220 | 220 | ||
221 | QString recurText = event->recurrence()->recurrenceText(); | 221 | QString recurText = event->recurrence()->recurrenceText(); |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 8efc1ea..2e19740 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -393,5 +393,5 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | |||
393 | } | 393 | } |
394 | 394 | ||
395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 395 | VObject* VCalFormat::eventToVEvent(Event *anEvent) |
396 | { | 396 | { |
397 | VObject *vevent; | 397 | VObject *vevent; |
@@ -460,5 +460,5 @@ VObject* VCalFormat::eventToVEvent(const Event *anEvent) | |||
460 | 460 | ||
461 | // recurrence rule stuff | 461 | // recurrence rule stuff |
462 | if (anEvent->recurrence()->doesRecur()) { | 462 | if (anEvent->doesRecur()) { |
463 | // some more variables | 463 | // some more variables |
464 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 464 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index c7df017..6dae3d2 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -75,5 +75,5 @@ class VCalFormat : public CalFormat { | |||
75 | VObject *eventToVTodo(const Todo *anEvent); | 75 | VObject *eventToVTodo(const Todo *anEvent); |
76 | /** translate a Event into a VObject and returns a pointer to it. */ | 76 | /** translate a Event into a VObject and returns a pointer to it. */ |
77 | VObject* eventToVEvent(const Event *anEvent); | 77 | VObject* eventToVEvent(Event *anEvent); |
78 | 78 | ||
79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ | 79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |