summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp10
-rw-r--r--libkcal/calendar.h5
-rw-r--r--libkcal/incidence.cpp14
-rw-r--r--libkcal/incidence.h1
4 files changed, 27 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 406cd48..ed39ddb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -332,13 +332,21 @@ QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
QPtrList<Event> Calendar::events()
{
QPtrList<Event> el = rawEvents();
mFilter->apply(&el);
return el;
}
-
+void Calendar::addIncidenceBranch(Incidence *i)
+{
+ addIncidence( i );
+ Incidence * inc;
+ QPtrList<Incidence> Relations = i->relations();
+ for (inc=Relations.first();inc;inc=Relations.next()) {
+ addIncidenceBranch( inc );
+ }
+}
bool Calendar::addIncidence(Incidence *i)
{
Incidence::AddVisitor<Calendar> v(this);
return i->accept(v);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2f2c3aa..ab40970 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -136,13 +136,16 @@ public:
/**
Add an incidence to calendar.
@return true on success, false on error.
*/
- virtual bool addIncidence( Incidence * );
+ virtual bool addIncidence( Incidence * );
+
+ // Adds an incidence and all relatedto incidences to the cal
+ void addIncidenceBranch( Incidence * );
/**
Return filtered list of all incidences of this calendar.
*/
virtual QPtrList<Incidence> incidences();
/**
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 6bca12c..78fa24f 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -260,13 +260,25 @@ void Incidence::recreate()
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);
}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index f8da342..60070a2 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -109,12 +109,13 @@ class Incidence : public IncidenceBase
bool accept(Visitor &v) { return v.visit(this); }
</pre>
*/
virtual bool accept(Visitor &) { return false; }
virtual Incidence *clone() = 0;
+ virtual void cloneRelations( Incidence * );
virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
void setReadOnly( bool );
/**
Recreate event. The event is made a new unique event, but already stored