-rw-r--r-- | libkcal/incidence.cpp | 11 | ||||
-rw-r--r-- | libkcal/incidence.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index f446197..4382416 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -357,192 +357,203 @@ void Incidence::addCategories(const QStringList &categories, bool addToRelations updated(); if ( addToRelations ) { Incidence * inc; QPtrList<Incidence> Relations = relations(); for (inc=Relations.first();inc;inc=Relations.next()) { inc->addCategories( categories, true ); } } } void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false { if (mReadOnly) return; mCategories = categories; checkCategories(); updated(); if ( setForRelations ) { Incidence * inc; QPtrList<Incidence> Relations = relations(); for (inc=Relations.first();inc;inc=Relations.next()) { inc->setCategories( categories, true ); } } } // TODO: remove setCategories(QString) function void Incidence::setCategories(const QString &catStr) { if (mReadOnly) return; mCategories.clear(); if (catStr.isEmpty()) return; mCategories = QStringList::split(",",catStr); QStringList::Iterator it; for(it = mCategories.begin();it != mCategories.end(); ++it) { *it = (*it).stripWhiteSpace(); } checkCategories(); updated(); } QStringList Incidence::categories() const { return mCategories; } QString Incidence::categoriesStr() { return mCategories.join(","); } QString Incidence::categoriesStrWithSpace() { return mCategories.join(", "); } void Incidence::setRelatedToUid(const QString &relatedToUid) { if (mReadOnly) return; mRelatedToUid = relatedToUid; } QString Incidence::relatedToUid() const { return mRelatedToUid; } void Incidence::setRelatedTo(Incidence *relatedTo) { //qDebug("Incidence::setRelatedTo %d ", relatedTo); //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); if (mReadOnly || mRelatedTo == relatedTo) return; if(mRelatedTo) { // updated(); mRelatedTo->removeRelation(this); } 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) { if( mRelations.findRef( event ) == -1 ) { mRelations.append(event); //updated(); } } 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; 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; } bool Incidence::isException(const QDate &date) const { DateList::ConstIterator it; for( it = mExDates.begin(); it != mExDates.end(); ++it ) { if ( (*it) == date ) { return true; } } return false; } void Incidence::addAttachment(Attachment *attachment) { if (mReadOnly || !attachment) return; mAttachments.append(attachment); updated(); } void Incidence::deleteAttachment(Attachment *attachment) { mAttachments.removeRef(attachment); } void Incidence::deleteAttachments(const QString& mime) { Attachment *at = mAttachments.first(); while (at) { if (at->mimeType() == mime) mAttachments.remove(); else at = mAttachments.next(); } } QPtrList<Attachment> Incidence::attachments() const { return mAttachments; } QPtrList<Attachment> Incidence::attachments(const QString& mime) const { QPtrList<Attachment> attachments; QPtrListIterator<Attachment> it( mAttachments ); Attachment *at; while ( (at = it.current()) ) { if (at->mimeType() == mime) attachments.append(at); ++it; diff --git a/libkcal/incidence.h b/libkcal/incidence.h index aa51e84..fc97ce9 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -20,193 +20,193 @@ #ifndef INCIDENCE_H #define INCIDENCE_H // // Incidence - base class of calendaring components // #include <qdatetime.h> #include <qstringlist.h> #include <qvaluelist.h> #include "recurrence.h" #include "alarm.h" #include "attachment.h" #include "listbase.h" #include "incidencebase.h" namespace KCal { class Event; class Todo; class Journal; /** This class provides the base class common to all calendar components. */ class Incidence : public IncidenceBase { public: /** This class provides the interface for a visitor of calendar components. It serves as base class for concrete visitors, which implement certain actions on calendar components. It allows to add functions, which operate on the concrete types of calendar components, without changing the calendar component classes. */ class Visitor { public: /** Destruct Incidence::Visitor */ virtual ~Visitor() {} /** Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions on an Event object. */ virtual bool visit(Event *) { return false; } /** Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions on an Todo object. */ virtual bool visit(Todo *) { return false; } /** Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions on an Journal object. */ virtual bool visit(Journal *) { return false; } protected: /** Constructor is protected to prevent direct creation of visitor base class. */ Visitor() {} }; /** This class implements a visitor for adding an Incidence to a resource supporting addEvent(), addTodo() and addJournal() calls. */ template<class T> class AddVisitor : public Visitor { public: AddVisitor( T *r ) : mResource( r ) {} bool visit( Event *e ) { return mResource->addEvent( e ); } bool visit( Todo *t ) { return mResource->addTodo( t ); } bool visit( Journal *j ) { return mResource->addJournal( j ); } private: T *mResource; }; /** enumeration for describing an event's secrecy. */ enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; typedef ListBase<Incidence> List; Incidence(); Incidence(const Incidence &); ~Incidence(); /** Accept IncidenceVisitor. A class taking part in the visitor mechanism has to provide this implementation: <pre> bool accept(Visitor &v) { return v.visit(this); } </pre> */ virtual bool accept(Visitor &) { return false; } virtual Incidence *clone() = 0; virtual void cloneRelations( Incidence * ); - + void addRelationsToList(QPtrList<Incidence> *rel); virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; void setReadOnly( bool ); /** Recreate event. The event is made a new unique event, but already stored event information is preserved. Sets uniquie id, creation date, last modification date and revision number. */ void recreate(); Incidence* recreateCloneException(QDate); /** set creation date */ void setCreated(QDateTime); /** return time and date of creation. */ QDateTime created() const; /** set the number of revisions this event has seen */ void setRevision(int rev); /** return the number of revisions this event has seen */ int revision() const; /** Set starting date/time. */ virtual void setDtStart(const QDateTime &dtStart); /** Return the incidence's ending date/time as a QDateTime. */ virtual QDateTime dtEnd() const { return QDateTime(); } /** sets the event's lengthy description. */ void setDescription(const QString &description); /** returns a reference to the event's description. */ QString description() const; /** sets the event's short summary. */ void setSummary(const QString &summary); /** returns a reference to the event's summary. */ QString summary() const; /** set event's applicable categories */ void setCategories(const QStringList &categories, bool setForRelations = false); void addCategories(const QStringList &categories, bool addToRelations = false); /** set event's categories based on a comma delimited string */ void setCategories(const QString &catStr); /** return categories in a list */ QStringList categories() const; /** return categories as a comma separated string */ QString categoriesStr(); QString categoriesStrWithSpace(); /** point at some other event to which the event relates. This function should * only be used when constructing a calendar before the related Event * exists. */ void setRelatedToUid(const QString &); /** what event does this one relate to? This function should * only be used when constructing a calendar before the related Event * exists. */ QString relatedToUid() const; /** point at some other event to which the event relates */ void setRelatedTo(Incidence *relatedTo); /** what event does this one relate to? */ Incidence *relatedTo() const; /** All events that are related to this event */ QPtrList<Incidence> relations() const; /** Add an event which is related to this event */ void addRelation(Incidence *); /** Remove event that is related to this event */ void removeRelation(Incidence *); /** returns the list of dates which are exceptions to the recurrence rule */ DateList exDates() const; /** sets the list of dates which are exceptions to the recurrence rule */ void setExDates(const DateList &_exDates); void setExDates(const char *dates); /** Add a date to the list of exceptions of the recurrence rule. */ void addExDate(const QDate &date); /** returns true if there is an exception for this date in the recurrence rule set, or false otherwise. */ bool isException(const QDate &qd) const; /** add attachment to this event */ void addAttachment(Attachment *attachment); /** remove and delete a specific attachment */ void deleteAttachment(Attachment *attachment); /** remove and delete all attachments with this mime type */ void deleteAttachments(const QString& mime); /** return list of all associated attachments */ QPtrList<Attachment> attachments() const; /** find a list of attachments with this mime type */ QPtrList<Attachment> attachments(const QString& mime) const; /** sets the event's status the value specified. See the enumeration * above for possible values. */ void setSecrecy(int); /** return the event's secrecy. */ int secrecy() const; /** return the event's secrecy in string format. */ QString secrecyStr() const; |