author | zautrix <zautrix> | 2005-07-27 22:26:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-27 22:26:08 (UTC) |
commit | 0e38cffd7ba745f237c659e1c48080fcb25b126c (patch) (side-by-side diff) | |
tree | 6069600e18bae5300c6ce427735457dbfed93141 /libkcal/incidence.cpp | |
parent | 136f9082862e7a56abb3a201e96f5e7386c4f1b9 (diff) | |
download | kdepimpi-0e38cffd7ba745f237c659e1c48080fcb25b126c.zip kdepimpi-0e38cffd7ba745f237c659e1c48080fcb25b126c.tar.gz kdepimpi-0e38cffd7ba745f237c659e1c48080fcb25b126c.tar.bz2 |
rec changes
-rw-r--r-- | libkcal/incidence.cpp | 63 |
1 files changed, 47 insertions, 16 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index e4bcc5e..4643a3a 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -30,13 +30,13 @@ using namespace KCal; Incidence::Incidence() : IncidenceBase(), mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) { - mRecurrence = new Recurrence(this); + mRecurrence = 0;//new Recurrence(this); mCancelled = false; recreate(); mHasStartDate = true; mAlarms.setAutoDelete(true); mAttachments.setAutoDelete(true); mHasRecurrenceID = false; @@ -75,13 +75,16 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) ++it; } mAlarms.setAutoDelete(true); mHasRecurrenceID = i.mHasRecurrenceID; mRecurrenceID = i.mRecurrenceID; - mRecurrence = new Recurrence( *(i.mRecurrence), this ); + if ( i.mRecurrence ) + mRecurrence = new Recurrence( *(i.mRecurrence), this ); + else + mRecurrence = 0; mHoliday = i.mHoliday ; mBirthday = i.mBirthday; mAnniversary = i.mAnniversary; } Incidence::~Incidence() @@ -90,13 +93,14 @@ Incidence::~Incidence() Incidence *ev; QPtrList<Incidence> Relations = relations(); for (ev=Relations.first();ev;ev=Relations.next()) { if (ev->relatedTo() == this) ev->setRelatedTo(0); } if (relatedTo()) relatedTo()->removeRelation(this); - delete mRecurrence; + if ( mRecurrence ) + delete mRecurrence; } bool Incidence::isHoliday() const { return mHoliday; @@ -205,16 +209,30 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) if ( i1.dtStart() != i2.dtStart() ) return false; } } else { return false; } - if (!( *i1.recurrence() == *i2.recurrence()) ) { - qDebug("recurrence is NOT equal "); - return false; + if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { + if (!( *i1.mRecurrence == *i2.mRecurrence) ) { + //qDebug("recurrence is NOT equal "); + return false; + } + } else { + // one ( or both ) recurrence is 0 + if ( i1.mRecurrence == 0 ) { + if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) + return false; + } else { + // i1.mRecurrence != 0 + // i2.mRecurrence == 0 + if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) + return false; + } } + return // i1.created() == i2.created() && stringCompare( i1.description(), i2.description() ) && stringCompare( i1.summary(), i2.summary() ) && i1.categories() == i2.categories() && // no need to compare mRelatedTo @@ -276,13 +294,14 @@ void Incidence::cloneRelations( Incidence * newInc ) inc->cloneRelations( cloneInc ); } } void Incidence::setReadOnly( bool readOnly ) { IncidenceBase::setReadOnly( readOnly ); - recurrence()->setRecurReadOnly( readOnly); + if ( mRecurrence ) + mRecurrence->setRecurReadOnly( readOnly); } void Incidence::setLastModifiedSubInvalid() { mLastModifiedSub = QDateTime(); if ( mRelatedTo ) mRelatedTo->setLastModifiedSubInvalid(); @@ -327,13 +346,15 @@ int Incidence::revision() const } void Incidence::setDtStart(const QDateTime &dtStart) { QDateTime dt = getEvenTime(dtStart); - recurrence()->setRecurStart( dt); + + if ( mRecurrence ) + mRecurrence->setRecurStart( dt); IncidenceBase::setDtStart( dt ); } void Incidence::setDescription(const QString &description) { if (mReadOnly) return; @@ -501,21 +522,20 @@ void Incidence::removeRelation(Incidence *event) mRelations.removeRef(event); // if (event->getRelatedTo() == this) event->setRelatedTo(0); } bool Incidence::recursOn(const QDate &qd) const { - if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; + if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; else return false; } void Incidence::setExDates(const DateList &exDates) { if (mReadOnly) return; mExDates = exDates; - recurrence()->setRecurExDatesCount(mExDates.count()); updated(); } void Incidence::addExDate(const QDate &date) @@ -695,21 +715,27 @@ bool Incidence::isAlarmEnabled() const for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { if (alarm->enabled()) return true; } return false; } - -Recurrence *Incidence::recurrence() const +#include <stdlib.h> +Recurrence *Incidence::recurrence() { + if ( ! mRecurrence ) { + mRecurrence = new Recurrence(this); + qDebug("creating new recurence "); + //abort(); + } return mRecurrence; } void Incidence::setRecurrence( Recurrence * r) { - delete mRecurrence; - mRecurrence = r; + if ( mRecurrence ) + delete mRecurrence; + mRecurrence = r; } void Incidence::setLocation(const QString &location) { if (mReadOnly) return; mLocation = location; @@ -717,12 +743,17 @@ void Incidence::setLocation(const QString &location) } QString Incidence::location() const { return mLocation; } +QString Incidence::recurrenceText() const +{ + if ( mRecurrence ) return mRecurrence->recurrenceText(); + return i18n("No"); +} ushort Incidence::doesRecur() const { if ( mRecurrence ) return mRecurrence->doesRecur(); else return Recurrence::rNone; } @@ -730,18 +761,18 @@ ushort Incidence::doesRecur() const QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const { QDateTime incidenceStart = dt; *ok = false; if ( doesRecur() ) { bool last; - recurrence()->getPreviousDateTime( incidenceStart , &last ); + mRecurrence->getPreviousDateTime( incidenceStart , &last ); int count = 0; if ( !last ) { while ( !last ) { ++count; - incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); + incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); if ( recursOn( incidenceStart.date() ) ) { last = true; // exit while llop } else { if ( last ) { // no alarm on last recurrence return QDateTime (); } |