summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Unidiff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index dc198bd..32aac7a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -234,193 +234,193 @@ QPtrList<Incidence> Calendar::incidences()
234{ 234{
235 QPtrList<Incidence> incidences; 235 QPtrList<Incidence> incidences;
236 236
237 Incidence *i; 237 Incidence *i;
238 238
239 QPtrList<Event> e = events(); 239 QPtrList<Event> e = events();
240 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 240 for( i = e.first(); i; i = e.next() ) incidences.append( i );
241 241
242 QPtrList<Todo> t = todos(); 242 QPtrList<Todo> t = todos();
243 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 243 for( i = t.first(); i; i = t.next() ) incidences.append( i );
244 244
245 QPtrList<Journal> j = journals(); 245 QPtrList<Journal> j = journals();
246 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 246 for( i = j.first(); i; i = j.next() ) incidences.append( i );
247 247
248 return incidences; 248 return incidences;
249} 249}
250 250
251QPtrList<Incidence> Calendar::rawIncidences() 251QPtrList<Incidence> Calendar::rawIncidences()
252{ 252{
253 QPtrList<Incidence> incidences; 253 QPtrList<Incidence> incidences;
254 254
255 Incidence *i; 255 Incidence *i;
256 256
257 QPtrList<Event> e = rawEvents(); 257 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 258 for( i = e.first(); i; i = e.next() ) incidences.append( i );
259 259
260 QPtrList<Todo> t = rawTodos(); 260 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 261 for( i = t.first(); i; i = t.next() ) incidences.append( i );
262 262
263 QPtrList<Journal> j = journals(); 263 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 264 for( i = j.first(); i; i = j.next() ) incidences.append( i );
265 265
266 return incidences; 266 return incidences;
267} 267}
268 268
269QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 269QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
270{ 270{
271 QPtrList<Event> el = rawEventsForDate(date,sorted); 271 QPtrList<Event> el = rawEventsForDate(date,sorted);
272 mFilter->apply(&el); 272 mFilter->apply(&el);
273 return el; 273 return el;
274} 274}
275 275
276QPtrList<Event> Calendar::events( const QDateTime &qdt ) 276QPtrList<Event> Calendar::events( const QDateTime &qdt )
277{ 277{
278 QPtrList<Event> el = rawEventsForDate(qdt); 278 QPtrList<Event> el = rawEventsForDate(qdt);
279 mFilter->apply(&el); 279 mFilter->apply(&el);
280 return el; 280 return el;
281} 281}
282 282
283QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 283QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
284 bool inclusive) 284 bool inclusive)
285{ 285{
286 QPtrList<Event> el = rawEvents(start,end,inclusive); 286 QPtrList<Event> el = rawEvents(start,end,inclusive);
287 mFilter->apply(&el); 287 mFilter->apply(&el);
288 return el; 288 return el;
289} 289}
290 290
291QPtrList<Event> Calendar::events() 291QPtrList<Event> Calendar::events()
292{ 292{
293 QPtrList<Event> el = rawEvents(); 293 QPtrList<Event> el = rawEvents();
294 mFilter->apply(&el); 294 mFilter->apply(&el);
295 return el; 295 return el;
296} 296}
297 297
298 298
299bool Calendar::addIncidence(Incidence *i) 299bool Calendar::addIncidence(Incidence *i)
300{ 300{
301 Incidence::AddVisitor<Calendar> v(this); 301 Incidence::AddVisitor<Calendar> v(this);
302 302
303 return i->accept(v); 303 return i->accept(v);
304} 304}
305void Calendar::deleteIncidence(Incidence *in) 305void Calendar::deleteIncidence(Incidence *in)
306{ 306{
307 if ( in->type() == "Event" ) 307 if ( in->type() == "Event" )
308 deleteEvent( (Event*) in ); 308 deleteEvent( (Event*) in );
309 else if ( in->type() =="Todo" ) 309 else if ( in->type() =="Todo" )
310 deleteTodo( (Todo*) in); 310 deleteTodo( (Todo*) in);
311 else if ( in->type() =="Journal" ) 311 else if ( in->type() =="Journal" )
312 deleteJournal( (Journal*) in ); 312 deleteJournal( (Journal*) in );
313} 313}
314 314
315Incidence* Calendar::incidence( const QString& uid ) 315Incidence* Calendar::incidence( const QString& uid )
316{ 316{
317 Incidence* i; 317 Incidence* i;
318 318
319 if( (i = todo( uid )) != 0 ) 319 if( (i = todo( uid )) != 0 )
320 return i; 320 return i;
321 if( (i = event( uid )) != 0 ) 321 if( (i = event( uid )) != 0 )
322 return i; 322 return i;
323 if( (i = journal( uid )) != 0 ) 323 if( (i = journal( uid )) != 0 )
324 return i; 324 return i;
325 325
326 return 0; 326 return 0;
327} 327}
328 328
329QPtrList<Todo> Calendar::todos() 329QPtrList<Todo> Calendar::todos()
330{ 330{
331 QPtrList<Todo> tl = rawTodos(); 331 QPtrList<Todo> tl = rawTodos();
332 mFilter->apply( &tl ); 332 mFilter->apply( &tl );
333 return tl; 333 return tl;
334} 334}
335 335
336// When this is called, the todo have already been added to the calendar. 336// When this is called, the todo have already been added to the calendar.
337// This method is only about linking related todos 337// This method is only about linking related todos
338void Calendar::setupRelations( Incidence *incidence ) 338void Calendar::setupRelations( Incidence *incidence )
339{ 339{
340 QString uid = incidence->uid(); 340 QString uid = incidence->uid();
341 //qDebug("Calendar::setupRelations "); 341 //qDebug("Calendar::setupRelations ");
342 // First, go over the list of orphans and see if this is their parent 342 // First, go over the list of orphans and see if this is their parent
343 while( Incidence* i = mOrphans[ uid ] ) { 343 while( Incidence* i = mOrphans[ uid ] ) {
344 mOrphans.remove( uid ); 344 mOrphans.remove( uid );
345 i->setRelatedTo( incidence ); 345 i->setRelatedTo( incidence );
346 incidence->addRelation( i ); 346 incidence->addRelation( i );
347 mOrphanUids.remove( i->uid() ); 347 mOrphanUids.remove( i->uid() );
348 } 348 }
349 349
350 // Now see about this incidences parent 350 // Now see about this incidences parent
351 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 351 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
352 // This incidence has a uid it is related to, but is not registered to it yet 352 // This incidence has a uid it is related to, but is not registered to it yet
353 // Try to find it 353 // Try to find it
354 Incidence* parent = this->incidence( incidence->relatedToUid() ); 354 Incidence* parent = this->incidence( incidence->relatedToUid() );
355 if( parent ) { 355 if( parent ) {
356 // Found it 356 // Found it
357 incidence->setRelatedTo( parent ); 357 incidence->setRelatedTo( parent );
358 parent->addRelation( incidence ); 358 parent->addRelation( incidence );
359 } else { 359 } else {
360 // Not found, put this in the mOrphans list 360 // Not found, put this in the mOrphans list
361 mOrphans.insert( incidence->relatedToUid(), incidence ); 361 mOrphans.insert( incidence->relatedToUid(), incidence );
362 mOrphanUids.insert( incidence->uid(), incidence ); 362 mOrphanUids.insert( incidence->uid(), incidence );
363 } 363 }
364 } 364 }
365} 365}
366 366
367// If a task with subtasks is deleted, move it's subtasks to the orphans list 367// If a task with subtasks is deleted, move it's subtasks to the orphans list
368void Calendar::removeRelations( Incidence *incidence ) 368void Calendar::removeRelations( Incidence *incidence )
369{ 369{
370 // qDebug("Calendar::removeRelations "); 370 // qDebug("Calendar::removeRelations ");
371 QString uid = incidence->uid(); 371 QString uid = incidence->uid();
372 372
373 QPtrList<Incidence> relations = incidence->relations(); 373 QPtrList<Incidence> relations = incidence->relations();
374 for( Incidence* i = relations.first(); i; i = relations.next() ) 374 for( Incidence* i = relations.first(); i; i = relations.next() )
375 if( !mOrphanUids.find( i->uid() ) ) { 375 if( !mOrphanUids.find( i->uid() ) ) {
376 mOrphans.insert( uid, i ); 376 mOrphans.insert( uid, i );
377 mOrphanUids.insert( i->uid(), i ); 377 mOrphanUids.insert( i->uid(), i );
378 i->setRelatedTo( 0 ); 378 i->setRelatedTo( 0 );
379 i->setRelatedToUid( uid ); 379 i->setRelatedToUid( uid );
380 } 380 }
381 381
382 // If this incidence is related to something else, tell that about it 382 // If this incidence is related to something else, tell that about it
383 if( incidence->relatedTo() ) 383 if( incidence->relatedTo() )
384 incidence->relatedTo()->removeRelation( incidence ); 384 incidence->relatedTo()->removeRelation( incidence );
385 385
386 // Remove this one from the orphans list 386 // Remove this one from the orphans list
387 if( mOrphanUids.remove( uid ) ) 387 if( mOrphanUids.remove( uid ) )
388 // This incidence is located in the orphans list - it should be removed 388 // This incidence is located in the orphans list - it should be removed
389 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 389 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
390 // Removing wasn't that easy 390 // Removing wasn't that easy
391 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 391 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
392 if( it.current()->uid() == uid ) { 392 if( it.current()->uid() == uid ) {
393 mOrphans.remove( it.currentKey() ); 393 mOrphans.remove( it.currentKey() );
394 break; 394 break;
395 } 395 }
396 } 396 }
397 } 397 }
398} 398}
399 399
400void Calendar::registerObserver( Observer *observer ) 400void Calendar::registerObserver( Observer *observer )
401{ 401{
402 mObserver = observer; 402 mObserver = observer;
403 mNewObserver = true; 403 mNewObserver = true;
404} 404}
405 405
406void Calendar::setModified( bool modified ) 406void Calendar::setModified( bool modified )
407{ 407{
408 if ( mObserver ) mObserver->calendarModified( modified, this ); 408 if ( mObserver ) mObserver->calendarModified( modified, this );
409 if ( modified != mModified || mNewObserver ) { 409 if ( modified != mModified || mNewObserver ) {
410 mNewObserver = false; 410 mNewObserver = false;
411 // if ( mObserver ) mObserver->calendarModified( modified, this ); 411 // if ( mObserver ) mObserver->calendarModified( modified, this );
412 mModified = modified; 412 mModified = modified;
413 } 413 }
414} 414}
415 415
416void Calendar::setLoadedProductId( const QString &id ) 416void Calendar::setLoadedProductId( const QString &id )
417{ 417{
418 mLoadedProductId = id; 418 mLoadedProductId = id;
419} 419}
420 420
421QString Calendar::loadedProductId() 421QString Calendar::loadedProductId()
422{ 422{
423 return mLoadedProductId; 423 return mLoadedProductId;
424} 424}
425 425
426#include "calendar.moc" 426//#include "calendar.moc"