summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
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
@@ -326,25 +326,33 @@ QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
326{ 326{
327 QPtrList<Event> el = rawEvents(start,end,inclusive); 327 QPtrList<Event> el = rawEvents(start,end,inclusive);
328 mFilter->apply(&el); 328 mFilter->apply(&el);
329 return el; 329 return el;
330} 330}
331 331
332QPtrList<Event> Calendar::events() 332QPtrList<Event> Calendar::events()
333{ 333{
334 QPtrList<Event> el = rawEvents(); 334 QPtrList<Event> el = rawEvents();
335 mFilter->apply(&el); 335 mFilter->apply(&el);
336 return el; 336 return el;
337} 337}
338 338void Calendar::addIncidenceBranch(Incidence *i)
339{
340 addIncidence( i );
341 Incidence * inc;
342 QPtrList<Incidence> Relations = i->relations();
343 for (inc=Relations.first();inc;inc=Relations.next()) {
344 addIncidenceBranch( inc );
345 }
346}
339 347
340bool Calendar::addIncidence(Incidence *i) 348bool Calendar::addIncidence(Incidence *i)
341{ 349{
342 Incidence::AddVisitor<Calendar> v(this); 350 Incidence::AddVisitor<Calendar> v(this);
343 351
344 return i->accept(v); 352 return i->accept(v);
345} 353}
346void Calendar::deleteIncidence(Incidence *in) 354void Calendar::deleteIncidence(Incidence *in)
347{ 355{
348 if ( in->type() == "Event" ) 356 if ( in->type() == "Event" )
349 deleteEvent( (Event*) in ); 357 deleteEvent( (Event*) in );
350 else if ( in->type() =="Todo" ) 358 else if ( in->type() =="Todo" )
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2f2c3aa..ab40970 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -130,25 +130,28 @@ public:
130 */ 130 */
131 void setLocalTime(); 131 void setLocalTime();
132 /** 132 /**
133 Return whether local time is being used. 133 Return whether local time is being used.
134 */ 134 */
135 bool isLocalTime() const; 135 bool isLocalTime() const;
136 136
137 /** 137 /**
138 Add an incidence to calendar. 138 Add an incidence to calendar.
139 139
140 @return true on success, false on error. 140 @return true on success, false on error.
141 */ 141 */
142 virtual bool addIncidence( Incidence * ); 142 virtual bool addIncidence( Incidence * );
143
144 // Adds an incidence and all relatedto incidences to the cal
145 void addIncidenceBranch( Incidence * );
143 /** 146 /**
144 Return filtered list of all incidences of this calendar. 147 Return filtered list of all incidences of this calendar.
145 */ 148 */
146 virtual QPtrList<Incidence> incidences(); 149 virtual QPtrList<Incidence> incidences();
147 150
148 /** 151 /**
149 Return unfiltered list of all incidences of this calendar. 152 Return unfiltered list of all incidences of this calendar.
150 */ 153 */
151 virtual QPtrList<Incidence> rawIncidences(); 154 virtual QPtrList<Incidence> rawIncidences();
152 155
153 /** 156 /**
154 Adds a Event to this calendar object. 157 Adds a Event to this calendar object.
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 6bca12c..78fa24f 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -254,25 +254,37 @@ Incidence* Incidence::recreateCloneException( QDate d )
254} 254}
255 255
256void Incidence::recreate() 256void Incidence::recreate()
257{ 257{
258 setCreated(QDateTime::currentDateTime()); 258 setCreated(QDateTime::currentDateTime());
259 259
260 setUid(CalFormat::createUniqueId()); 260 setUid(CalFormat::createUniqueId());
261 261
262 setRevision(0); 262 setRevision(0);
263 setIDStr( ":" ); 263 setIDStr( ":" );
264 setLastModified(QDateTime::currentDateTime()); 264 setLastModified(QDateTime::currentDateTime());
265} 265}
266 266void Incidence::cloneRelations( Incidence * newInc )
267{
268 // newInc is already a clone of this incidence
269 Incidence * inc;
270 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone();
274 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc );
277 }
278}
267void Incidence::setReadOnly( bool readOnly ) 279void Incidence::setReadOnly( bool readOnly )
268{ 280{
269 IncidenceBase::setReadOnly( readOnly ); 281 IncidenceBase::setReadOnly( readOnly );
270 recurrence()->setRecurReadOnly( readOnly); 282 recurrence()->setRecurReadOnly( readOnly);
271} 283}
272 284
273void Incidence::setCreated(QDateTime created) 285void Incidence::setCreated(QDateTime created)
274{ 286{
275 if (mReadOnly) return; 287 if (mReadOnly) return;
276 mCreated = getEvenTime(created); 288 mCreated = getEvenTime(created);
277} 289}
278 290
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index f8da342..60070a2 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -103,24 +103,25 @@ class Incidence : public IncidenceBase
103 ~Incidence(); 103 ~Incidence();
104 104
105 /** 105 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 107 provide this implementation:
108 <pre> 108 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 109 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 110 </pre>
111 */ 111 */
112 virtual bool accept(Visitor &) { return false; } 112 virtual bool accept(Visitor &) { return false; }
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * );
115 116
116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; 117 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
117 void setReadOnly( bool ); 118 void setReadOnly( bool );
118 119
119 /** 120 /**
120 Recreate event. The event is made a new unique event, but already stored 121 Recreate event. The event is made a new unique event, but already stored
121 event information is preserved. Sets uniquie id, creation date, last 122 event information is preserved. Sets uniquie id, creation date, last
122 modification date and revision number. 123 modification date and revision number.
123 */ 124 */
124 void recreate(); 125 void recreate();
125 Incidence* recreateCloneException(QDate); 126 Incidence* recreateCloneException(QDate);
126 127