-rw-r--r-- | libkcal/incidence.cpp | 28 | ||||
-rw-r--r-- | libkcal/incidence.h | 3 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 4 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 1 |
4 files changed, 32 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 11f7ecc..e4bcc5e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -252,65 +252,85 @@ Incidence* Incidence::recreateCloneException( QDate d ) } return newInc; } void Incidence::recreate() { setCreated(QDateTime::currentDateTime()); setUid(CalFormat::createUniqueId()); setRevision(0); setIDStr( ":" ); setLastModified(QDateTime::currentDateTime()); } void Incidence::cloneRelations( Incidence * newInc ) { // newInc is already a clone of this incidence Incidence * inc; Incidence * cloneInc; QPtrList<Incidence> Relations = relations(); for (inc=Relations.first();inc;inc=Relations.next()) { cloneInc = inc->clone(); cloneInc->recreate(); cloneInc->setRelatedTo( newInc ); inc->cloneRelations( cloneInc ); } } void Incidence::setReadOnly( bool readOnly ) { IncidenceBase::setReadOnly( readOnly ); recurrence()->setRecurReadOnly( readOnly); } - +void Incidence::setLastModifiedSubInvalid() +{ + mLastModifiedSub = QDateTime(); + if ( mRelatedTo ) + mRelatedTo->setLastModifiedSubInvalid(); +} +QDateTime Incidence::lastModifiedSub() +{ + if ( !mRelations.count() ) + return lastModified(); + if ( mLastModifiedSub.isValid() ) + return mLastModifiedSub; + mLastModifiedSub = lastModified(); + Incidence * inc; + QPtrList<Incidence> Relations = relations(); + for (inc=Relations.first();inc;inc=Relations.next()) { + if ( inc->lastModifiedSub() > mLastModifiedSub ) + mLastModifiedSub = inc->lastModifiedSub(); + } + return mLastModifiedSub; +} void Incidence::setCreated(QDateTime created) { if (mReadOnly) return; mCreated = getEvenTime(created); } QDateTime Incidence::created() const { return mCreated; } void Incidence::setRevision(int rev) { if (mReadOnly) return; mRevision = rev; updated(); } int Incidence::revision() const { return mRevision; } void Incidence::setDtStart(const QDateTime &dtStart) { QDateTime dt = getEvenTime(dtStart); recurrence()->setRecurStart( dt); IncidenceBase::setDtStart( dt ); } @@ -439,75 +459,75 @@ void Incidence::setRelatedTo(Incidence *relatedTo) mRelatedTo = relatedTo; if (mRelatedTo) { mRelatedTo->addRelation(this); mRelatedToUid = mRelatedTo->uid(); } else { mRelatedToUid = ""; } } Incidence *Incidence::relatedTo() const { return mRelatedTo; } QPtrList<Incidence> Incidence::relations() const { return mRelations; } void Incidence::addRelationsToList(QPtrList<Incidence> *rel) { Incidence* inc; QPtrList<Incidence> Relations = relations(); for (inc=Relations.first();inc;inc=Relations.next()) { inc->addRelationsToList( rel ); } if ( rel->findRef( this ) == -1 ) rel->append( this ); } void Incidence::addRelation(Incidence *event) { + setLastModifiedSubInvalid(); if( mRelations.findRef( event ) == -1 ) { mRelations.append(event); //updated(); } } void Incidence::removeRelation(Incidence *event) { - - mRelations.removeRef(event); - + setLastModifiedSubInvalid(); + 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; 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) { if (mReadOnly) return; mExDates.append(date); recurrence()->setRecurExDatesCount(mExDates.count()); updated(); } DateList Incidence::exDates() const { return mExDates; diff --git a/libkcal/incidence.h b/libkcal/incidence.h index c88ba2f..d4af9f0 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -248,71 +248,74 @@ class Incidence : public IncidenceBase /** Return the recurrence rule associated with this incidence. If there is none, returns an appropriate (non-0) object. */ Recurrence *recurrence() const; void setRecurrence(Recurrence * r); /** Forward to Recurrence::doesRecur(). */ ushort doesRecur() const; /** set the event's/todo's location. Do _not_ use it with journal */ void setLocation(const QString &location); /** return the event's/todo's location. Do _not_ use it with journal */ QString location() const; /** returns TRUE or FALSE depending on whether the todo has a start date */ bool hasStartDate() const; /** sets the event's hasStartDate value. */ void setHasStartDate(bool f); QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; bool cancelled() const; void setCancelled( bool b ); bool hasRecurrenceID() const; void setHasRecurrenceID( bool b ); void setRecurrenceID(QDateTime); QDateTime recurrenceID () const; QDateTime dtStart() const; bool isHoliday() const; bool isBirthday() const; bool isAnniversary() const; + QDateTime lastModifiedSub(); + void setLastModifiedSubInvalid(); protected: QPtrList<Alarm> mAlarms; QPtrList<Incidence> mRelations; QDateTime mRecurrenceID; bool mHasRecurrenceID; private: void checkCategories(); bool mHoliday, mBirthday, mAnniversary; int mRevision; bool mCancelled; // base components of jounal, event and todo QDateTime mCreated; + QDateTime mLastModifiedSub; QString mDescription; QString mSummary; QStringList mCategories; Incidence *mRelatedTo; QString mRelatedToUid; DateList mExDates; QPtrList<Attachment> mAttachments; QStringList mResources; bool mHasStartDate; // if todo has associated start date int mSecrecy; int mPriority; // 1 = highest, 2 = less, etc. //QPtrList<Alarm> mAlarms; Recurrence *mRecurrence; QString mLocation; }; bool operator==( const Incidence&, const Incidence& ); } #endif diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 1a19f3e..022dead 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -162,71 +162,75 @@ int IncidenceBase::calID() const { return mCalID; } void IncidenceBase::setCalEnabled( bool b ) { mCalEnabled = b; } bool IncidenceBase::calEnabled() const { return mCalEnabled; } void IncidenceBase::setAlarmEnabled( bool b ) { mAlarmEnabled = b; } bool IncidenceBase::alarmEnabled() const { return mAlarmEnabled; } void IncidenceBase::setUid(const QString &uid) { mUid = uid; updated(); } QString IncidenceBase::uid() const { return mUid; } +void IncidenceBase::setLastModifiedSubInvalid() +{ +} void IncidenceBase::setLastModified(const QDateTime &lm) { if ( blockLastModified ) return; // DON'T! updated() because we call this from // Calendar::updateEvent(). mLastModified = getEvenTime(lm); + setLastModifiedSubInvalid(); //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); } QDateTime IncidenceBase::lastModified() const { return mLastModified; } void IncidenceBase::setOrganizer(const QString &o) { // we don't check for readonly here, because it is // possible that by setting the organizer we are changing // the event's readonly status... mOrganizer = o; if (mOrganizer.left(7).upper() == "MAILTO:") mOrganizer = mOrganizer.remove(0,7); updated(); } QString IncidenceBase::organizer() const { return mOrganizer; } void IncidenceBase::setReadOnly( bool readOnly ) { mReadOnly = readOnly; } void IncidenceBase::setDtStart(const QDateTime &dtStart) { diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index bed73db..665c1f6 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -120,64 +120,65 @@ class IncidenceBase : public CustomProperties enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; /** Set synchronisation satus. */ void setSyncStatus(int stat); /** Return synchronisation status. */ int syncStatus() const; /** Set Pilot Id. */ void setPilotId(int id); /** Return Pilot Id. */ int pilotId() const; void setTempSyncStat(int id); int tempSyncStat() const; void setIDStr( const QString & ); QString IDStr() const; void setID( const QString &, const QString & ); QString getID( const QString & ); void setCsum( const QString &, const QString & ); QString getCsum( const QString & ); void removeID(const QString &); void registerObserver( Observer * ); void unRegisterObserver( Observer * ); void updated(); void setCalID( int id ); int calID() const; void setCalEnabled( bool ); bool calEnabled() const; void setAlarmEnabled( bool ); bool alarmEnabled() const; bool isTagged() const; void setTagged( bool ); + virtual void setLastModifiedSubInvalid(); protected: bool blockLastModified; bool mIsTagged; QDateTime mDtStart; bool mReadOnly; QDateTime getEvenTime( QDateTime ); private: // base components QString mOrganizer; QString mUid; int mCalID; bool mCalEnabled; bool mAlarmEnabled; QDateTime mLastModified; QPtrList<Attendee> mAttendees; bool mFloats; int mDuration; bool mHasDuration; QString mExternalId; int mTempSyncStat; // PILOT SYNCHRONIZATION STUFF int mPilotId; // unique id for pilot sync int mSyncStatus; // status (for sync) QPtrList<Observer> mObservers; }; bool operator==( const IncidenceBase&, const IncidenceBase& ); |