summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-08 10:34:22 (UTC)
committer zautrix <zautrix>2005-06-08 10:34:22 (UTC)
commit793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (unidiff)
tree5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /libkcal
parent39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff)
downloadkdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2
changed incidence type to a faster access method
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp6
-rw-r--r--libkcal/calendarlocal.cpp6
-rw-r--r--libkcal/calfilter.cpp6
-rw-r--r--libkcal/event.h1
-rw-r--r--libkcal/freebusy.h1
-rw-r--r--libkcal/icalformat.cpp4
-rw-r--r--libkcal/icalformatimpl.cpp6
-rw-r--r--libkcal/incidence.cpp6
-rw-r--r--libkcal/incidencebase.h2
-rw-r--r--libkcal/journal.h1
-rw-r--r--libkcal/kincidenceformatter.cpp4
-rw-r--r--libkcal/todo.cpp5
-rw-r--r--libkcal/todo.h1
13 files changed, 26 insertions, 23 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index ed39ddb..7e8e2c5 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -228,248 +228,248 @@ void Calendar::setEmail(const QString &e)
228{ 228{
229 mOwnerEmail = e; 229 mOwnerEmail = e;
230 230
231 setModified( true ); 231 setModified( true );
232} 232}
233 233
234void Calendar::setFilter(CalFilter *filter) 234void Calendar::setFilter(CalFilter *filter)
235{ 235{
236 mFilter = filter; 236 mFilter = filter;
237} 237}
238 238
239CalFilter *Calendar::filter() 239CalFilter *Calendar::filter()
240{ 240{
241 return mFilter; 241 return mFilter;
242} 242}
243 243
244QPtrList<Incidence> Calendar::incidences() 244QPtrList<Incidence> Calendar::incidences()
245{ 245{
246 QPtrList<Incidence> incidences; 246 QPtrList<Incidence> incidences;
247 247
248 Incidence *i; 248 Incidence *i;
249 249
250 QPtrList<Event> e = events(); 250 QPtrList<Event> e = events();
251 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 251 for( i = e.first(); i; i = e.next() ) incidences.append( i );
252 252
253 QPtrList<Todo> t = todos(); 253 QPtrList<Todo> t = todos();
254 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 254 for( i = t.first(); i; i = t.next() ) incidences.append( i );
255 255
256 QPtrList<Journal> j = journals(); 256 QPtrList<Journal> j = journals();
257 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 257 for( i = j.first(); i; i = j.next() ) incidences.append( i );
258 258
259 return incidences; 259 return incidences;
260} 260}
261 261
262void Calendar::resetPilotStat(int id ) 262void Calendar::resetPilotStat(int id )
263{ 263{
264 QPtrList<Incidence> incidences; 264 QPtrList<Incidence> incidences;
265 265
266 Incidence *i; 266 Incidence *i;
267 267
268 QPtrList<Event> e = rawEvents(); 268 QPtrList<Event> e = rawEvents();
269 for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); 269 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
270 270
271 QPtrList<Todo> t = rawTodos(); 271 QPtrList<Todo> t = rawTodos();
272 for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); 272 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
273 273
274 QPtrList<Journal> j = journals(); 274 QPtrList<Journal> j = journals();
275 for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); 275 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
276} 276}
277void Calendar::resetTempSyncStat() 277void Calendar::resetTempSyncStat()
278{ 278{
279 QPtrList<Incidence> incidences; 279 QPtrList<Incidence> incidences;
280 280
281 Incidence *i; 281 Incidence *i;
282 282
283 QPtrList<Event> e = rawEvents(); 283 QPtrList<Event> e = rawEvents();
284 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 284 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
285 285
286 QPtrList<Todo> t = rawTodos(); 286 QPtrList<Todo> t = rawTodos();
287 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 287 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
288 288
289 QPtrList<Journal> j = journals(); 289 QPtrList<Journal> j = journals();
290 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 290 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
291} 291}
292QPtrList<Incidence> Calendar::rawIncidences() 292QPtrList<Incidence> Calendar::rawIncidences()
293{ 293{
294 QPtrList<Incidence> incidences; 294 QPtrList<Incidence> incidences;
295 295
296 Incidence *i; 296 Incidence *i;
297 297
298 QPtrList<Event> e = rawEvents(); 298 QPtrList<Event> e = rawEvents();
299 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 299 for( i = e.first(); i; i = e.next() ) incidences.append( i );
300 300
301 QPtrList<Todo> t = rawTodos(); 301 QPtrList<Todo> t = rawTodos();
302 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 302 for( i = t.first(); i; i = t.next() ) incidences.append( i );
303 303
304 QPtrList<Journal> j = journals(); 304 QPtrList<Journal> j = journals();
305 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 305 for( i = j.first(); i; i = j.next() ) incidences.append( i );
306 306
307 return incidences; 307 return incidences;
308} 308}
309 309
310QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 310QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
311{ 311{
312 QPtrList<Event> el = rawEventsForDate(date,sorted); 312 QPtrList<Event> el = rawEventsForDate(date,sorted);
313 mFilter->apply(&el); 313 mFilter->apply(&el);
314 return el; 314 return el;
315} 315}
316 316
317QPtrList<Event> Calendar::events( const QDateTime &qdt ) 317QPtrList<Event> Calendar::events( const QDateTime &qdt )
318{ 318{
319 QPtrList<Event> el = rawEventsForDate(qdt); 319 QPtrList<Event> el = rawEventsForDate(qdt);
320 mFilter->apply(&el); 320 mFilter->apply(&el);
321 return el; 321 return el;
322} 322}
323 323
324QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 324QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
325 bool inclusive) 325 bool inclusive)
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}
338void Calendar::addIncidenceBranch(Incidence *i) 338void Calendar::addIncidenceBranch(Incidence *i)
339{ 339{
340 addIncidence( i ); 340 addIncidence( i );
341 Incidence * inc; 341 Incidence * inc;
342 QPtrList<Incidence> Relations = i->relations(); 342 QPtrList<Incidence> Relations = i->relations();
343 for (inc=Relations.first();inc;inc=Relations.next()) { 343 for (inc=Relations.first();inc;inc=Relations.next()) {
344 addIncidenceBranch( inc ); 344 addIncidenceBranch( inc );
345 } 345 }
346} 346}
347 347
348bool Calendar::addIncidence(Incidence *i) 348bool Calendar::addIncidence(Incidence *i)
349{ 349{
350 Incidence::AddVisitor<Calendar> v(this); 350 Incidence::AddVisitor<Calendar> v(this);
351 351
352 return i->accept(v); 352 return i->accept(v);
353} 353}
354void Calendar::deleteIncidence(Incidence *in) 354void Calendar::deleteIncidence(Incidence *in)
355{ 355{
356 if ( in->type() == "Event" ) 356 if ( in->typeID() == eventID )
357 deleteEvent( (Event*) in ); 357 deleteEvent( (Event*) in );
358 else if ( in->type() =="Todo" ) 358 else if ( in->typeID() == todoID )
359 deleteTodo( (Todo*) in); 359 deleteTodo( (Todo*) in);
360 else if ( in->type() =="Journal" ) 360 else if ( in->typeID() == journalID )
361 deleteJournal( (Journal*) in ); 361 deleteJournal( (Journal*) in );
362} 362}
363 363
364Incidence* Calendar::incidence( const QString& uid ) 364Incidence* Calendar::incidence( const QString& uid )
365{ 365{
366 Incidence* i; 366 Incidence* i;
367 367
368 if( (i = todo( uid )) != 0 ) 368 if( (i = todo( uid )) != 0 )
369 return i; 369 return i;
370 if( (i = event( uid )) != 0 ) 370 if( (i = event( uid )) != 0 )
371 return i; 371 return i;
372 if( (i = journal( uid )) != 0 ) 372 if( (i = journal( uid )) != 0 )
373 return i; 373 return i;
374 374
375 return 0; 375 return 0;
376} 376}
377 377
378QPtrList<Todo> Calendar::todos() 378QPtrList<Todo> Calendar::todos()
379{ 379{
380 QPtrList<Todo> tl = rawTodos(); 380 QPtrList<Todo> tl = rawTodos();
381 mFilter->apply( &tl ); 381 mFilter->apply( &tl );
382 return tl; 382 return tl;
383} 383}
384 384
385// When this is called, the todo have already been added to the calendar. 385// When this is called, the todo have already been added to the calendar.
386// This method is only about linking related todos 386// This method is only about linking related todos
387void Calendar::setupRelations( Incidence *incidence ) 387void Calendar::setupRelations( Incidence *incidence )
388{ 388{
389 QString uid = incidence->uid(); 389 QString uid = incidence->uid();
390 //qDebug("Calendar::setupRelations "); 390 //qDebug("Calendar::setupRelations ");
391 // First, go over the list of orphans and see if this is their parent 391 // First, go over the list of orphans and see if this is their parent
392 while( Incidence* i = mOrphans[ uid ] ) { 392 while( Incidence* i = mOrphans[ uid ] ) {
393 mOrphans.remove( uid ); 393 mOrphans.remove( uid );
394 i->setRelatedTo( incidence ); 394 i->setRelatedTo( incidence );
395 incidence->addRelation( i ); 395 incidence->addRelation( i );
396 mOrphanUids.remove( i->uid() ); 396 mOrphanUids.remove( i->uid() );
397 } 397 }
398 398
399 // Now see about this incidences parent 399 // Now see about this incidences parent
400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 400 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
401 // This incidence has a uid it is related to, but is not registered to it yet 401 // This incidence has a uid it is related to, but is not registered to it yet
402 // Try to find it 402 // Try to find it
403 Incidence* parent = this->incidence( incidence->relatedToUid() ); 403 Incidence* parent = this->incidence( incidence->relatedToUid() );
404 if( parent ) { 404 if( parent ) {
405 // Found it 405 // Found it
406 incidence->setRelatedTo( parent ); 406 incidence->setRelatedTo( parent );
407 parent->addRelation( incidence ); 407 parent->addRelation( incidence );
408 } else { 408 } else {
409 // Not found, put this in the mOrphans list 409 // Not found, put this in the mOrphans list
410 mOrphans.insert( incidence->relatedToUid(), incidence ); 410 mOrphans.insert( incidence->relatedToUid(), incidence );
411 mOrphanUids.insert( incidence->uid(), incidence ); 411 mOrphanUids.insert( incidence->uid(), incidence );
412 } 412 }
413 } 413 }
414} 414}
415 415
416// If a task with subtasks is deleted, move it's subtasks to the orphans list 416// If a task with subtasks is deleted, move it's subtasks to the orphans list
417void Calendar::removeRelations( Incidence *incidence ) 417void Calendar::removeRelations( Incidence *incidence )
418{ 418{
419 // qDebug("Calendar::removeRelations "); 419 // qDebug("Calendar::removeRelations ");
420 QString uid = incidence->uid(); 420 QString uid = incidence->uid();
421 421
422 QPtrList<Incidence> relations = incidence->relations(); 422 QPtrList<Incidence> relations = incidence->relations();
423 for( Incidence* i = relations.first(); i; i = relations.next() ) 423 for( Incidence* i = relations.first(); i; i = relations.next() )
424 if( !mOrphanUids.find( i->uid() ) ) { 424 if( !mOrphanUids.find( i->uid() ) ) {
425 mOrphans.insert( uid, i ); 425 mOrphans.insert( uid, i );
426 mOrphanUids.insert( i->uid(), i ); 426 mOrphanUids.insert( i->uid(), i );
427 i->setRelatedTo( 0 ); 427 i->setRelatedTo( 0 );
428 i->setRelatedToUid( uid ); 428 i->setRelatedToUid( uid );
429 } 429 }
430 430
431 // If this incidence is related to something else, tell that about it 431 // If this incidence is related to something else, tell that about it
432 if( incidence->relatedTo() ) 432 if( incidence->relatedTo() )
433 incidence->relatedTo()->removeRelation( incidence ); 433 incidence->relatedTo()->removeRelation( incidence );
434 434
435 // Remove this one from the orphans list 435 // Remove this one from the orphans list
436 if( mOrphanUids.remove( uid ) ) 436 if( mOrphanUids.remove( uid ) )
437 // This incidence is located in the orphans list - it should be removed 437 // This incidence is located in the orphans list - it should be removed
438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 438 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
439 // Removing wasn't that easy 439 // Removing wasn't that easy
440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 440 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
441 if( it.current()->uid() == uid ) { 441 if( it.current()->uid() == uid ) {
442 mOrphans.remove( it.currentKey() ); 442 mOrphans.remove( it.currentKey() );
443 break; 443 break;
444 } 444 }
445 } 445 }
446 } 446 }
447} 447}
448 448
449void Calendar::registerObserver( Observer *observer ) 449void Calendar::registerObserver( Observer *observer )
450{ 450{
451 mObserver = observer; 451 mObserver = observer;
452 mNewObserver = true; 452 mNewObserver = true;
453} 453}
454 454
455void Calendar::setModified( bool modified ) 455void Calendar::setModified( bool modified )
456{ 456{
457 if ( mObserver ) mObserver->calendarModified( modified, this ); 457 if ( mObserver ) mObserver->calendarModified( modified, this );
458 if ( modified != mModified || mNewObserver ) { 458 if ( modified != mModified || mNewObserver ) {
459 mNewObserver = false; 459 mNewObserver = false;
460 // if ( mObserver ) mObserver->calendarModified( modified, this ); 460 // if ( mObserver ) mObserver->calendarModified( modified, this );
461 mModified = modified; 461 mModified = modified;
462 } 462 }
463} 463}
464 464
465void Calendar::setLoadedProductId( const QString &id ) 465void Calendar::setLoadedProductId( const QString &id )
466{ 466{
467 mLoadedProductId = id; 467 mLoadedProductId = id;
468} 468}
469 469
470QString Calendar::loadedProductId() 470QString Calendar::loadedProductId()
471{ 471{
472 return mLoadedProductId; 472 return mLoadedProductId;
473} 473}
474 474
475//#include "calendar.moc" 475//#include "calendar.moc"
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index bc76c0b..fe74052 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -333,288 +333,284 @@ void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted
333 } 333 }
334 } 334 }
335 if ( computeNextAlarm ) { 335 if ( computeNextAlarm ) {
336 deRegisterAlarm(); 336 deRegisterAlarm();
337 nextA = nextAlarm( 1000 ); 337 nextA = nextAlarm( 1000 );
338 if (! mNextAlarmIncidence ) { 338 if (! mNextAlarmIncidence ) {
339 return; 339 return;
340 } 340 }
341 newNextAlarm = true; 341 newNextAlarm = true;
342 } 342 }
343 if ( newNextAlarm ) 343 if ( newNextAlarm )
344 registerAlarm(); 344 registerAlarm();
345} 345}
346QString CalendarLocal:: getAlarmNotification() 346QString CalendarLocal:: getAlarmNotification()
347{ 347{
348 QString ret; 348 QString ret;
349 // this should not happen 349 // this should not happen
350 if (! mNextAlarmIncidence ) 350 if (! mNextAlarmIncidence )
351 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 351 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
352 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 352 Alarm* alarm = mNextAlarmIncidence->alarms().first();
353 if ( alarm->type() == Alarm::Procedure ) { 353 if ( alarm->type() == Alarm::Procedure ) {
354 ret = "proc_alarm" + alarm->programFile()+"+++"; 354 ret = "proc_alarm" + alarm->programFile()+"+++";
355 } else { 355 } else {
356 ret = "audio_alarm" +alarm->audioFile() +"+++"; 356 ret = "audio_alarm" +alarm->audioFile() +"+++";
357 } 357 }
358 ret += "cal_alarm"+ mNextSummary.left( 25 ); 358 ret += "cal_alarm"+ mNextSummary.left( 25 );
359 if ( mNextSummary.length() > 25 ) 359 if ( mNextSummary.length() > 25 )
360 ret += "\n" + mNextSummary.mid(25, 25 ); 360 ret += "\n" + mNextSummary.mid(25, 25 );
361 ret+= "\n"+mNextAlarmEventDateTimeString; 361 ret+= "\n"+mNextAlarmEventDateTimeString;
362 return ret; 362 return ret;
363} 363}
364void CalendarLocal::registerAlarm() 364void CalendarLocal::registerAlarm()
365{ 365{
366 mLastAlarmNotificationString = getAlarmNotification(); 366 mLastAlarmNotificationString = getAlarmNotification();
367 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 367 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
368 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 368 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
369// #ifndef DESKTOP_VERSION 369// #ifndef DESKTOP_VERSION
370// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 370// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
371// #endif 371// #endif
372} 372}
373void CalendarLocal::deRegisterAlarm() 373void CalendarLocal::deRegisterAlarm()
374{ 374{
375 if ( mLastAlarmNotificationString.isNull() ) 375 if ( mLastAlarmNotificationString.isNull() )
376 return; 376 return;
377 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 377 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
378 378
379 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 379 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
380 mNextAlarmEventDateTime = QDateTime(); 380 mNextAlarmEventDateTime = QDateTime();
381// #ifndef DESKTOP_VERSION 381// #ifndef DESKTOP_VERSION
382// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 382// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
383// #endif 383// #endif
384} 384}
385 385
386QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 386QPtrList<Todo> CalendarLocal::todos( const QDate &date )
387{ 387{
388 QPtrList<Todo> todos; 388 QPtrList<Todo> todos;
389 389
390 Todo *todo; 390 Todo *todo;
391 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 391 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
392 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 392 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
393 todos.append( todo ); 393 todos.append( todo );
394 } 394 }
395 } 395 }
396 396
397 filter()->apply( &todos ); 397 filter()->apply( &todos );
398 return todos; 398 return todos;
399} 399}
400void CalendarLocal::reInitAlarmSettings() 400void CalendarLocal::reInitAlarmSettings()
401{ 401{
402 if ( !mNextAlarmIncidence ) { 402 if ( !mNextAlarmIncidence ) {
403 nextAlarm( 1000 ); 403 nextAlarm( 1000 );
404 } 404 }
405 deRegisterAlarm(); 405 deRegisterAlarm();
406 mNextAlarmIncidence = 0; 406 mNextAlarmIncidence = 0;
407 checkAlarmForIncidence( 0, false ); 407 checkAlarmForIncidence( 0, false );
408 408
409} 409}
410 410
411 411
412 412
413QDateTime CalendarLocal::nextAlarm( int daysTo ) 413QDateTime CalendarLocal::nextAlarm( int daysTo )
414{ 414{
415 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); 415 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo );
416 QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); 416 QDateTime start = QDateTime::currentDateTime().addSecs( 30 );
417 QDateTime next; 417 QDateTime next;
418 Event *e; 418 Event *e;
419 bool ok; 419 bool ok;
420 bool found = false; 420 bool found = false;
421 int offset; 421 int offset;
422 mNextAlarmIncidence = 0; 422 mNextAlarmIncidence = 0;
423 for( e = mEventList.first(); e; e = mEventList.next() ) { 423 for( e = mEventList.first(); e; e = mEventList.next() ) {
424 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 424 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
425 if ( ok ) { 425 if ( ok ) {
426 if ( next < nextA ) { 426 if ( next < nextA ) {
427 nextA = next; 427 nextA = next;
428 found = true; 428 found = true;
429 mNextSummary = e->summary(); 429 mNextSummary = e->summary();
430 mNextAlarmEventDateTime = next.addSecs(offset ) ; 430 mNextAlarmEventDateTime = next.addSecs(offset ) ;
431 mNextAlarmIncidence = (Incidence *) e; 431 mNextAlarmIncidence = (Incidence *) e;
432 } 432 }
433 } 433 }
434 } 434 }
435 Todo *t; 435 Todo *t;
436 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 436 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
437 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 437 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
438 if ( ok ) { 438 if ( ok ) {
439 if ( next < nextA ) { 439 if ( next < nextA ) {
440 nextA = next; 440 nextA = next;
441 found = true; 441 found = true;
442 mNextSummary = t->summary(); 442 mNextSummary = t->summary();
443 mNextAlarmEventDateTime = next.addSecs(offset ); 443 mNextAlarmEventDateTime = next.addSecs(offset );
444 mNextAlarmIncidence = (Incidence *) t; 444 mNextAlarmIncidence = (Incidence *) t;
445 } 445 }
446 } 446 }
447 } 447 }
448 if ( mNextAlarmIncidence ) { 448 if ( mNextAlarmIncidence ) {
449 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 449 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
450 mNextAlarmDateTime = nextA; 450 mNextAlarmDateTime = nextA;
451 } 451 }
452 return nextA; 452 return nextA;
453} 453}
454Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) 454Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
455{ 455{
456 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); 456 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
457} 457}
458 458
459Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 459Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
460{ 460{
461 kdDebug(5800) << "CalendarLocal::alarms(" << from.toString() << " - " 461
462 << to.toString() << ")\n";
463
464 Alarm::List alarms; 462 Alarm::List alarms;
465 463
466 Event *e; 464 Event *e;
467 465
468 for( e = mEventList.first(); e; e = mEventList.next() ) { 466 for( e = mEventList.first(); e; e = mEventList.next() ) {
469 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); 467 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
470 else appendAlarms( alarms, e, from, to ); 468 else appendAlarms( alarms, e, from, to );
471 } 469 }
472 470
473 Todo *t; 471 Todo *t;
474 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 472 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
475 appendAlarms( alarms, t, from, to ); 473 appendAlarms( alarms, t, from, to );
476 } 474 }
477 475
478 return alarms; 476 return alarms;
479} 477}
480 478
481void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 479void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
482 const QDateTime &from, const QDateTime &to ) 480 const QDateTime &from, const QDateTime &to )
483{ 481{
484 QPtrList<Alarm> alarmList = incidence->alarms(); 482 QPtrList<Alarm> alarmList = incidence->alarms();
485 Alarm *alarm; 483 Alarm *alarm;
486 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 484 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
487// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 485// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
488// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 486// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
489 if ( alarm->enabled() ) { 487 if ( alarm->enabled() ) {
490 if ( alarm->time() >= from && alarm->time() <= to ) { 488 if ( alarm->time() >= from && alarm->time() <= to ) {
491 kdDebug(5800) << "CalendarLocal::appendAlarms() '" << incidence->summary()
492 << "': " << alarm->time().toString() << endl;
493 alarms.append( alarm ); 489 alarms.append( alarm );
494 } 490 }
495 } 491 }
496 } 492 }
497} 493}
498 494
499void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 495void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
500 Incidence *incidence, 496 Incidence *incidence,
501 const QDateTime &from, 497 const QDateTime &from,
502 const QDateTime &to ) 498 const QDateTime &to )
503{ 499{
504 500
505 QPtrList<Alarm> alarmList = incidence->alarms(); 501 QPtrList<Alarm> alarmList = incidence->alarms();
506 Alarm *alarm; 502 Alarm *alarm;
507 QDateTime qdt; 503 QDateTime qdt;
508 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 504 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
509 if (incidence->recursOn(from.date())) { 505 if (incidence->recursOn(from.date())) {
510 qdt.setTime(alarm->time().time()); 506 qdt.setTime(alarm->time().time());
511 qdt.setDate(from.date()); 507 qdt.setDate(from.date());
512 } 508 }
513 else qdt = alarm->time(); 509 else qdt = alarm->time();
514 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 510 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
515 if ( alarm->enabled() ) { 511 if ( alarm->enabled() ) {
516 if ( qdt >= from && qdt <= to ) { 512 if ( qdt >= from && qdt <= to ) {
517 alarms.append( alarm ); 513 alarms.append( alarm );
518 } 514 }
519 } 515 }
520 } 516 }
521} 517}
522 518
523 519
524/****************************** PROTECTED METHODS ****************************/ 520/****************************** PROTECTED METHODS ****************************/
525 521
526// after changes are made to an event, this should be called. 522// after changes are made to an event, this should be called.
527void CalendarLocal::update( IncidenceBase *incidence ) 523void CalendarLocal::update( IncidenceBase *incidence )
528{ 524{
529 incidence->setSyncStatus( Event::SYNCMOD ); 525 incidence->setSyncStatus( Event::SYNCMOD );
530 incidence->setLastModified( QDateTime::currentDateTime() ); 526 incidence->setLastModified( QDateTime::currentDateTime() );
531 // we should probably update the revision number here, 527 // we should probably update the revision number here,
532 // or internally in the Event itself when certain things change. 528 // or internally in the Event itself when certain things change.
533 // need to verify with ical documentation. 529 // need to verify with ical documentation.
534 530
535 setModified( true ); 531 setModified( true );
536} 532}
537 533
538void CalendarLocal::insertEvent( Event *event ) 534void CalendarLocal::insertEvent( Event *event )
539{ 535{
540 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 536 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
541} 537}
542 538
543 539
544QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 540QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
545{ 541{
546 QPtrList<Event> eventList; 542 QPtrList<Event> eventList;
547 543
548 Event *event; 544 Event *event;
549 for( event = mEventList.first(); event; event = mEventList.next() ) { 545 for( event = mEventList.first(); event; event = mEventList.next() ) {
550 if ( event->doesRecur() ) { 546 if ( event->doesRecur() ) {
551 if ( event->isMultiDay() ) { 547 if ( event->isMultiDay() ) {
552 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 548 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
553 int i; 549 int i;
554 for ( i = 0; i <= extraDays; i++ ) { 550 for ( i = 0; i <= extraDays; i++ ) {
555 if ( event->recursOn( qd.addDays( -i ) ) ) { 551 if ( event->recursOn( qd.addDays( -i ) ) ) {
556 eventList.append( event ); 552 eventList.append( event );
557 break; 553 break;
558 } 554 }
559 } 555 }
560 } else { 556 } else {
561 if ( event->recursOn( qd ) ) 557 if ( event->recursOn( qd ) )
562 eventList.append( event ); 558 eventList.append( event );
563 } 559 }
564 } else { 560 } else {
565 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 561 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
566 eventList.append( event ); 562 eventList.append( event );
567 } 563 }
568 } 564 }
569 } 565 }
570 566
571 if ( !sorted ) { 567 if ( !sorted ) {
572 return eventList; 568 return eventList;
573 } 569 }
574 570
575 // kdDebug(5800) << "Sorting events for date\n" << endl; 571 // kdDebug(5800) << "Sorting events for date\n" << endl;
576 // now, we have to sort it based on dtStart.time() 572 // now, we have to sort it based on dtStart.time()
577 QPtrList<Event> eventListSorted; 573 QPtrList<Event> eventListSorted;
578 Event *sortEvent; 574 Event *sortEvent;
579 for ( event = eventList.first(); event; event = eventList.next() ) { 575 for ( event = eventList.first(); event; event = eventList.next() ) {
580 sortEvent = eventListSorted.first(); 576 sortEvent = eventListSorted.first();
581 int i = 0; 577 int i = 0;
582 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 578 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
583 { 579 {
584 i++; 580 i++;
585 sortEvent = eventListSorted.next(); 581 sortEvent = eventListSorted.next();
586 } 582 }
587 eventListSorted.insert( i, event ); 583 eventListSorted.insert( i, event );
588 } 584 }
589 return eventListSorted; 585 return eventListSorted;
590} 586}
591 587
592 588
593QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 589QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
594 bool inclusive ) 590 bool inclusive )
595{ 591{
596 Event *event = 0; 592 Event *event = 0;
597 593
598 QPtrList<Event> eventList; 594 QPtrList<Event> eventList;
599 595
600 // Get non-recurring events 596 // Get non-recurring events
601 for( event = mEventList.first(); event; event = mEventList.next() ) { 597 for( event = mEventList.first(); event; event = mEventList.next() ) {
602 if ( event->doesRecur() ) { 598 if ( event->doesRecur() ) {
603 QDate rStart = event->dtStart().date(); 599 QDate rStart = event->dtStart().date();
604 bool found = false; 600 bool found = false;
605 if ( inclusive ) { 601 if ( inclusive ) {
606 if ( rStart >= start && rStart <= end ) { 602 if ( rStart >= start && rStart <= end ) {
607 // Start date of event is in range. Now check for end date. 603 // Start date of event is in range. Now check for end date.
608 // if duration is negative, event recurs forever, so do not include it. 604 // if duration is negative, event recurs forever, so do not include it.
609 if ( event->recurrence()->duration() == 0 ) { // End date set 605 if ( event->recurrence()->duration() == 0 ) { // End date set
610 QDate rEnd = event->recurrence()->endDate(); 606 QDate rEnd = event->recurrence()->endDate();
611 if ( rEnd >= start && rEnd <= end ) { // End date within range 607 if ( rEnd >= start && rEnd <= end ) { // End date within range
612 found = true; 608 found = true;
613 } 609 }
614 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 610 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
615 // TODO: Calculate end date from duration. Should be done in Event 611 // TODO: Calculate end date from duration. Should be done in Event
616 // For now exclude all events with a duration. 612 // For now exclude all events with a duration.
617 } 613 }
618 } 614 }
619 } else { 615 } else {
620 bool founOne; 616 bool founOne;
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index c425dfc..20078a7 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -1,212 +1,212 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kdebug.h> 21#include <kdebug.h>
22 22
23#include "calfilter.h" 23#include "calfilter.h"
24 24
25using namespace KCal; 25using namespace KCal;
26 26
27CalFilter::CalFilter() 27CalFilter::CalFilter()
28{ 28{
29 mEnabled = true; 29 mEnabled = true;
30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
31} 31}
32 32
33CalFilter::CalFilter(const QString &name) 33CalFilter::CalFilter(const QString &name)
34{ 34{
35 mName = name; 35 mName = name;
36 mEnabled = true; 36 mEnabled = true;
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38} 38}
39 39
40CalFilter::~CalFilter() 40CalFilter::~CalFilter()
41{ 41{
42} 42}
43 43
44void CalFilter::apply(QPtrList<Event> *eventlist) 44void CalFilter::apply(QPtrList<Event> *eventlist)
45{ 45{
46 if (!mEnabled) return; 46 if (!mEnabled) return;
47 47
48// kdDebug(5800) << "CalFilter::apply()" << endl; 48// kdDebug(5800) << "CalFilter::apply()" << endl;
49 49
50 Event *event = eventlist->first(); 50 Event *event = eventlist->first();
51 while(event) { 51 while(event) {
52 if (!filterEvent(event)) { 52 if (!filterEvent(event)) {
53 eventlist->remove(); 53 eventlist->remove();
54 event = eventlist->current(); 54 event = eventlist->current();
55 } else { 55 } else {
56 event = eventlist->next(); 56 event = eventlist->next();
57 } 57 }
58 } 58 }
59 59
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 60// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 61}
62 62
63// TODO: avoid duplicating apply() code 63// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 64void CalFilter::apply(QPtrList<Todo> *eventlist)
65{ 65{
66 if (!mEnabled) return; 66 if (!mEnabled) return;
67 Todo *event = eventlist->first(); 67 Todo *event = eventlist->first();
68 while(event) { 68 while(event) {
69 if (!filterTodo(event)) { 69 if (!filterTodo(event)) {
70 eventlist->remove(); 70 eventlist->remove();
71 event = eventlist->current(); 71 event = eventlist->current();
72 } else { 72 } else {
73 event = eventlist->next(); 73 event = eventlist->next();
74 } 74 }
75 } 75 }
76 76
77// kdDebug(5800) << "CalFilter::apply() done" << endl; 77// kdDebug(5800) << "CalFilter::apply() done" << endl;
78} 78}
79bool CalFilter::filterCalendarItem(Incidence *in) 79bool CalFilter::filterCalendarItem(Incidence *in)
80{ 80{
81 if ( in->type() == "Event" ) 81 if ( in->typeID() == eventID )
82 return filterEvent( (Event*) in ); 82 return filterEvent( (Event*) in );
83 else if ( in->type() =="Todo" ) 83 else if ( in->typeID() == todoID )
84 return filterTodo( (Todo*) in); 84 return filterTodo( (Todo*) in);
85 else if ( in->type() =="Journal" ) 85 else if ( in->typeID () == journalID )
86 return filterJournal( (Journal*) in ); 86 return filterJournal( (Journal*) in );
87 return false; 87 return false;
88} 88}
89bool CalFilter::filterEvent(Event *event) 89bool CalFilter::filterEvent(Event *event)
90{ 90{
91 if (mCriteria & HideEvents) 91 if (mCriteria & HideEvents)
92 return false; 92 return false;
93 if (mCriteria & HideRecurring) { 93 if (mCriteria & HideRecurring) {
94 if (event->recurrence()->doesRecur()) return false; 94 if (event->recurrence()->doesRecur()) return false;
95 } 95 }
96 96
97 return filterIncidence(event); 97 return filterIncidence(event);
98} 98}
99bool CalFilter::filterJournal(Journal *j) 99bool CalFilter::filterJournal(Journal *j)
100{ 100{
101 if (mCriteria & HideJournals) 101 if (mCriteria & HideJournals)
102 return false; 102 return false;
103 return true; 103 return true;
104} 104}
105bool CalFilter::filterTodo(Todo *todo) 105bool CalFilter::filterTodo(Todo *todo)
106{ 106{
107 if (mCriteria & HideTodos) 107 if (mCriteria & HideTodos)
108 return false; 108 return false;
109 if (mCriteria & HideCompleted) { 109 if (mCriteria & HideCompleted) {
110 if (todo->isCompleted()) return false; 110 if (todo->isCompleted()) return false;
111 } 111 }
112 112
113 return filterIncidence(todo); 113 return filterIncidence(todo);
114} 114}
115bool CalFilter::showCategories() 115bool CalFilter::showCategories()
116{ 116{
117 return mCriteria & ShowCategories; 117 return mCriteria & ShowCategories;
118} 118}
119int CalFilter::getSecrecy() 119int CalFilter::getSecrecy()
120{ 120{
121 if ( (mCriteria & ShowPublic )) 121 if ( (mCriteria & ShowPublic ))
122 return Incidence::SecrecyPublic; 122 return Incidence::SecrecyPublic;
123 if ( (mCriteria & ShowPrivate )) 123 if ( (mCriteria & ShowPrivate ))
124 return Incidence::SecrecyPrivate; 124 return Incidence::SecrecyPrivate;
125 if ( (mCriteria & ShowConfidential )) 125 if ( (mCriteria & ShowConfidential ))
126 return Incidence::SecrecyConfidential; 126 return Incidence::SecrecyConfidential;
127 return Incidence::SecrecyPublic; 127 return Incidence::SecrecyPublic;
128} 128}
129bool CalFilter::filterIncidence(Incidence *incidence) 129bool CalFilter::filterIncidence(Incidence *incidence)
130{ 130{
131 if ( mCriteria > 7 ) { 131 if ( mCriteria > 7 ) {
132 switch (incidence->secrecy()) { 132 switch (incidence->secrecy()) {
133 case Incidence::SecrecyPublic: 133 case Incidence::SecrecyPublic:
134 if (! (mCriteria & ShowPublic )) 134 if (! (mCriteria & ShowPublic ))
135 return false; 135 return false;
136 break; 136 break;
137 case Incidence::SecrecyPrivate: 137 case Incidence::SecrecyPrivate:
138 if (! (mCriteria & ShowPrivate )) 138 if (! (mCriteria & ShowPrivate ))
139 return false; 139 return false;
140 break; 140 break;
141 case Incidence::SecrecyConfidential: 141 case Incidence::SecrecyConfidential:
142 if (! (mCriteria & ShowConfidential )) 142 if (! (mCriteria & ShowConfidential ))
143 return false; 143 return false;
144 break; 144 break;
145 default: 145 default:
146 return false; 146 return false;
147 break; 147 break;
148 } 148 }
149 } 149 }
150 150
151 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl; 151 // kdDebug(5800) << "CalFilter::filterEvent(): " << event->getSummary() << endl;
152 152
153 if (mCriteria & ShowCategories) { 153 if (mCriteria & ShowCategories) {
154 for (QStringList::Iterator it = mCategoryList.begin(); 154 for (QStringList::Iterator it = mCategoryList.begin();
155 it != mCategoryList.end(); ++it ) { 155 it != mCategoryList.end(); ++it ) {
156 QStringList incidenceCategories = incidence->categories(); 156 QStringList incidenceCategories = incidence->categories();
157 for (QStringList::Iterator it2 = incidenceCategories.begin(); 157 for (QStringList::Iterator it2 = incidenceCategories.begin();
158 it2 != incidenceCategories.end(); ++it2 ) { 158 it2 != incidenceCategories.end(); ++it2 ) {
159 if ((*it) == (*it2)) { 159 if ((*it) == (*it2)) {
160 return true; 160 return true;
161 } 161 }
162 } 162 }
163 } 163 }
164 return false; 164 return false;
165 } else { 165 } else {
166 for (QStringList::Iterator it = mCategoryList.begin(); 166 for (QStringList::Iterator it = mCategoryList.begin();
167 it != mCategoryList.end(); ++it ) { 167 it != mCategoryList.end(); ++it ) {
168 QStringList incidenceCategories = incidence->categories(); 168 QStringList incidenceCategories = incidence->categories();
169 for (QStringList::Iterator it2 = incidenceCategories.begin(); 169 for (QStringList::Iterator it2 = incidenceCategories.begin();
170 it2 != incidenceCategories.end(); ++it2 ) { 170 it2 != incidenceCategories.end(); ++it2 ) {
171 if ((*it) == (*it2)) { 171 if ((*it) == (*it2)) {
172 return false; 172 return false;
173 } 173 }
174 } 174 }
175 } 175 }
176 return true; 176 return true;
177 } 177 }
178 178
179// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl; 179// kdDebug(5800) << "CalFilter::filterEvent(): passed" << endl;
180 180
181 return true; 181 return true;
182} 182}
183 183
184void CalFilter::setEnabled(bool enabled) 184void CalFilter::setEnabled(bool enabled)
185{ 185{
186 mEnabled = enabled; 186 mEnabled = enabled;
187} 187}
188 188
189bool CalFilter::isEnabled() 189bool CalFilter::isEnabled()
190{ 190{
191 return mEnabled; 191 return mEnabled;
192} 192}
193 193
194void CalFilter::setCriteria(int criteria) 194void CalFilter::setCriteria(int criteria)
195{ 195{
196 mCriteria = criteria; 196 mCriteria = criteria;
197} 197}
198 198
199int CalFilter::criteria() 199int CalFilter::criteria()
200{ 200{
201 return mCriteria; 201 return mCriteria;
202} 202}
203 203
204void CalFilter::setCategoryList(const QStringList &categoryList) 204void CalFilter::setCategoryList(const QStringList &categoryList)
205{ 205{
206 mCategoryList = categoryList; 206 mCategoryList = categoryList;
207} 207}
208 208
209QStringList CalFilter::categoryList() 209QStringList CalFilter::categoryList()
210{ 210{
211 return mCategoryList; 211 return mCategoryList;
212} 212}
diff --git a/libkcal/event.h b/libkcal/event.h
index 8729956..287d403 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -1,90 +1,91 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#ifndef EVENT_H 21#ifndef EVENT_H
22#define EVENT_H 22#define EVENT_H
23// 23//
24// Event component, representing a VEVENT object 24// Event component, representing a VEVENT object
25// 25//
26 26
27#include "incidence.h" 27#include "incidence.h"
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides an Event in the sense of RFC2445. 31 This class provides an Event in the sense of RFC2445.
32*/ 32*/
33class Event : public Incidence 33class Event : public Incidence
34{ 34{
35 public: 35 public:
36 enum Transparency { Opaque, Transparent }; 36 enum Transparency { Opaque, Transparent };
37 typedef ListBase<Event> List; 37 typedef ListBase<Event> List;
38 Event(); 38 Event();
39 Event(const Event &); 39 Event(const Event &);
40 ~Event(); 40 ~Event();
41 41
42 QCString type() const { return "Event"; } 42 QCString type() const { return "Event"; }
43 IncTypeID typeID() const { return eventID; }
43 44
44 Incidence *clone(); 45 Incidence *clone();
45 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 46 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
46 47
47 /** for setting an event's ending date/time with a QDateTime. */ 48 /** for setting an event's ending date/time with a QDateTime. */
48 void setDtEnd(const QDateTime &dtEnd); 49 void setDtEnd(const QDateTime &dtEnd);
49 /** Return the event's ending date/time as a QDateTime. */ 50 /** Return the event's ending date/time as a QDateTime. */
50 virtual QDateTime dtEnd() const; 51 virtual QDateTime dtEnd() const;
51 /** returns an event's end time as a string formatted according to the 52 /** returns an event's end time as a string formatted according to the
52 users locale settings */ 53 users locale settings */
53 QString dtEndTimeStr() const; 54 QString dtEndTimeStr() const;
54 /** returns an event's end date as a string formatted according to the 55 /** returns an event's end date as a string formatted according to the
55 users locale settings */ 56 users locale settings */
56 QString dtEndDateStr(bool shortfmt=true) const; 57 QString dtEndDateStr(bool shortfmt=true) const;
57 /** returns an event's end date and time as a string formatted according 58 /** returns an event's end date and time as a string formatted according
58 to the users locale settings */ 59 to the users locale settings */
59 QString dtEndStr(bool shortfmt=true) const; 60 QString dtEndStr(bool shortfmt=true) const;
60 void setHasEndDate(bool); 61 void setHasEndDate(bool);
61 /** Return whether the event has an end date/time. */ 62 /** Return whether the event has an end date/time. */
62 bool hasEndDate() const; 63 bool hasEndDate() const;
63 64
64 /** Return true if the event spans multiple days, otherwise return false. */ 65 /** Return true if the event spans multiple days, otherwise return false. */
65 bool isMultiDay() const; 66 bool isMultiDay() const;
66 67
67 /** set the event's time transparency level. */ 68 /** set the event's time transparency level. */
68 void setTransparency(Transparency transparency); 69 void setTransparency(Transparency transparency);
69 /** get the event's time transparency level. */ 70 /** get the event's time transparency level. */
70 Transparency transparency() const; 71 Transparency transparency() const;
71 72
72 void setDuration(int seconds); 73 void setDuration(int seconds);
73 74
74 bool contains ( Event*); 75 bool contains ( Event*);
75 76
76 private: 77 private:
77 bool accept(Visitor &v) { return v.visit(this); } 78 bool accept(Visitor &v) { return v.visit(this); }
78 79
79 QDateTime mDtEnd; 80 QDateTime mDtEnd;
80 bool mHasEndDate; 81 bool mHasEndDate;
81 Transparency mTransparency; 82 Transparency mTransparency;
82}; 83};
83 84
84bool operator==( const Event&, const Event& ); 85bool operator==( const Event&, const Event& );
85 86
86 87
87} 88}
88 89
89 90
90#endif 91#endif
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h
index 054feda..d741c72 100644
--- a/libkcal/freebusy.h
+++ b/libkcal/freebusy.h
@@ -1,72 +1,73 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_FREEBUSY_H 20#ifndef KCAL_FREEBUSY_H
21#define KCAL_FREEBUSY_H 21#define KCAL_FREEBUSY_H
22// 22//
23// FreeBusy - information about free/busy times 23// FreeBusy - information about free/busy times
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qvaluelist.h> 27#include <qvaluelist.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29 29
30#include "period.h" 30#include "period.h"
31#include "calendar.h" 31#include "calendar.h"
32 32
33#include "incidencebase.h" 33#include "incidencebase.h"
34 34
35namespace KCal { 35namespace KCal {
36 36
37/** 37/**
38 This class provides information about free/busy time of a calendar user. 38 This class provides information about free/busy time of a calendar user.
39*/ 39*/
40class FreeBusy : public IncidenceBase 40class FreeBusy : public IncidenceBase
41{ 41{
42 public: 42 public:
43 FreeBusy(); 43 FreeBusy();
44 FreeBusy(const QDateTime &start, const QDateTime &end); 44 FreeBusy(const QDateTime &start, const QDateTime &end);
45 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end); 45 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end);
46 FreeBusy(QValueList<Period> busyPeriods); 46 FreeBusy(QValueList<Period> busyPeriods);
47 47
48 ~FreeBusy(); 48 ~FreeBusy();
49 49
50 QCString type() const { return "FreeBusy"; } 50 QCString type() const { return "FreeBusy"; }
51 IncTypeID typeID() const { return freebusyID; }
51 52
52 virtual QDateTime dtEnd() const; 53 virtual QDateTime dtEnd() const;
53 bool setDtEnd( const QDateTime &end ); 54 bool setDtEnd( const QDateTime &end );
54 55
55 QValueList<Period> busyPeriods() const; 56 QValueList<Period> busyPeriods() const;
56 57
57 void addPeriod(const QDateTime &start, const QDateTime &end); 58 void addPeriod(const QDateTime &start, const QDateTime &end);
58 void sortList(); 59 void sortList();
59 60
60 private: 61 private:
61 62
62 //This is used for creating a freebusy object for the current user 63 //This is used for creating a freebusy object for the current user
63 bool addLocalPeriod(const QDateTime &start, const QDateTime &end); 64 bool addLocalPeriod(const QDateTime &start, const QDateTime &end);
64 65
65 QDateTime mDtEnd; 66 QDateTime mDtEnd;
66 QValueList<Period> mBusyPeriods; 67 QValueList<Period> mBusyPeriods;
67 Calendar *mCalendar; 68 Calendar *mCalendar;
68}; 69};
69 70
70} 71}
71 72
72#endif 73#endif
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 3a2aac6..d9fe40b 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -259,202 +259,202 @@ QString ICalFormat::toString( Recurrence *recurrence )
259 icalproperty_free( property ); 259 icalproperty_free( property );
260 return QString::fromLocal8Bit( text ); 260 return QString::fromLocal8Bit( text );
261} 261}
262/* 262/*
263bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule ) 263bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule )
264{ 264{
265 bool success = true; 265 bool success = true;
266 icalerror_clear_errno(); 266 icalerror_clear_errno();
267 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule ); 267 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule );
268 if ( icalerrno != ICAL_NO_ERROR ) { 268 if ( icalerrno != ICAL_NO_ERROR ) {
269 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl; 269 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl;
270 success = false; 270 success = false;
271 } 271 }
272 272
273 if ( success ) { 273 if ( success ) {
274 mImpl->readRecurrence( recur, recurrence ); 274 mImpl->readRecurrence( recur, recurrence );
275 } 275 }
276 276
277 return success; 277 return success;
278} 278}
279*/ 279*/
280 280
281QString ICalFormat::createScheduleMessage(IncidenceBase *incidence, 281QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
282 Scheduler::Method method) 282 Scheduler::Method method)
283{ 283{
284 icalcomponent *message = mImpl->createScheduleComponent(incidence,method); 284 icalcomponent *message = mImpl->createScheduleComponent(incidence,method);
285 285
286 QString messageText = icalcomponent_as_ical_string(message); 286 QString messageText = icalcomponent_as_ical_string(message);
287 287
288 288
289 289
290 return messageText; 290 return messageText;
291} 291}
292 292
293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, 293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
294 const QString &messageText ) 294 const QString &messageText )
295{ 295{
296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
297 clearException(); 297 clearException();
298 298
299 if (messageText.isEmpty()) return 0; 299 if (messageText.isEmpty()) return 0;
300 300
301 icalcomponent *message; 301 icalcomponent *message;
302 message = icalparser_parse_string(messageText.local8Bit()); 302 message = icalparser_parse_string(messageText.local8Bit());
303 303
304 if (!message) return 0; 304 if (!message) return 0;
305 305
306 icalproperty *m = icalcomponent_get_first_property(message, 306 icalproperty *m = icalcomponent_get_first_property(message,
307 ICAL_METHOD_PROPERTY); 307 ICAL_METHOD_PROPERTY);
308 308
309 if (!m) return 0; 309 if (!m) return 0;
310 310
311 icalcomponent *c; 311 icalcomponent *c;
312 312
313 IncidenceBase *incidence = 0; 313 IncidenceBase *incidence = 0;
314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); 314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT);
315 if (c) { 315 if (c) {
316 incidence = mImpl->readEvent(c); 316 incidence = mImpl->readEvent(c);
317 } 317 }
318 318
319 if (!incidence) { 319 if (!incidence) {
320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); 320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT);
321 if (c) { 321 if (c) {
322 incidence = mImpl->readTodo(c); 322 incidence = mImpl->readTodo(c);
323 } 323 }
324 } 324 }
325 325
326 if (!incidence) { 326 if (!incidence) {
327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); 327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT);
328 if (c) { 328 if (c) {
329 incidence = mImpl->readFreeBusy(c); 329 incidence = mImpl->readFreeBusy(c);
330 } 330 }
331 } 331 }
332 332
333 if (!incidence) { 333 if (!incidence) {
334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; 334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl;
335 return 0; 335 return 0;
336 } 336 }
337 337
338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; 338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl;
339 339
340 icalproperty_method icalmethod = icalproperty_get_method(m); 340 icalproperty_method icalmethod = icalproperty_get_method(m);
341 Scheduler::Method method; 341 Scheduler::Method method;
342 342
343 switch (icalmethod) { 343 switch (icalmethod) {
344 case ICAL_METHOD_PUBLISH: 344 case ICAL_METHOD_PUBLISH:
345 method = Scheduler::Publish; 345 method = Scheduler::Publish;
346 break; 346 break;
347 case ICAL_METHOD_REQUEST: 347 case ICAL_METHOD_REQUEST:
348 method = Scheduler::Request; 348 method = Scheduler::Request;
349 break; 349 break;
350 case ICAL_METHOD_REFRESH: 350 case ICAL_METHOD_REFRESH:
351 method = Scheduler::Refresh; 351 method = Scheduler::Refresh;
352 break; 352 break;
353 case ICAL_METHOD_CANCEL: 353 case ICAL_METHOD_CANCEL:
354 method = Scheduler::Cancel; 354 method = Scheduler::Cancel;
355 break; 355 break;
356 case ICAL_METHOD_ADD: 356 case ICAL_METHOD_ADD:
357 method = Scheduler::Add; 357 method = Scheduler::Add;
358 break; 358 break;
359 case ICAL_METHOD_REPLY: 359 case ICAL_METHOD_REPLY:
360 method = Scheduler::Reply; 360 method = Scheduler::Reply;
361 break; 361 break;
362 case ICAL_METHOD_COUNTER: 362 case ICAL_METHOD_COUNTER:
363 method = Scheduler::Counter; 363 method = Scheduler::Counter;
364 break; 364 break;
365 case ICAL_METHOD_DECLINECOUNTER: 365 case ICAL_METHOD_DECLINECOUNTER:
366 method = Scheduler::Declinecounter; 366 method = Scheduler::Declinecounter;
367 break; 367 break;
368 default: 368 default:
369 method = Scheduler::NoMethod; 369 method = Scheduler::NoMethod;
370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; 370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
371 break; 371 break;
372 } 372 }
373 373
374 374
375 if (!icalrestriction_check(message)) { 375 if (!icalrestriction_check(message)) {
376 setException(new ErrorFormat(ErrorFormat::Restriction, 376 setException(new ErrorFormat(ErrorFormat::Restriction,
377 Scheduler::translatedMethodName(method) + ": " + 377 Scheduler::translatedMethodName(method) + ": " +
378 mImpl->extractErrorProperty(c))); 378 mImpl->extractErrorProperty(c)));
379 return 0; 379 return 0;
380 } 380 }
381 381
382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); 382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
383 383
384 Incidence *existingIncidence = cal->event(incidence->uid()); 384 Incidence *existingIncidence = cal->event(incidence->uid());
385 if (existingIncidence) { 385 if (existingIncidence) {
386 // TODO: check, if cast is required, or if it can be done by virtual funcs. 386 // TODO: check, if cast is required, or if it can be done by virtual funcs.
387 if (existingIncidence->type() == "Todo") { 387 if (existingIncidence->typeID() == todoID ) {
388 Todo *todo = static_cast<Todo *>(existingIncidence); 388 Todo *todo = static_cast<Todo *>(existingIncidence);
389 icalcomponent_add_component(calendarComponent, 389 icalcomponent_add_component(calendarComponent,
390 mImpl->writeTodo(todo)); 390 mImpl->writeTodo(todo));
391 } 391 }
392 if (existingIncidence->type() == "Event") { 392 if (existingIncidence->typeID() == eventID ) {
393 Event *event = static_cast<Event *>(existingIncidence); 393 Event *event = static_cast<Event *>(existingIncidence);
394 icalcomponent_add_component(calendarComponent, 394 icalcomponent_add_component(calendarComponent,
395 mImpl->writeEvent(event)); 395 mImpl->writeEvent(event));
396 } 396 }
397 } else { 397 } else {
398 calendarComponent = 0; 398 calendarComponent = 0;
399 } 399 }
400 qDebug("icalclassify commented out "); 400 qDebug("icalclassify commented out ");
401 ScheduleMessage::Status status; 401 ScheduleMessage::Status status;
402#if 0 402#if 0
403 403
404 icalclass result = icalclassify(message,calendarComponent,(char *)""); 404 icalclass result = icalclassify(message,calendarComponent,(char *)"");
405 405
406 406
407 407
408 switch (result) { 408 switch (result) {
409 case ICAL_PUBLISH_NEW_CLASS: 409 case ICAL_PUBLISH_NEW_CLASS:
410 status = ScheduleMessage::PublishNew; 410 status = ScheduleMessage::PublishNew;
411 break; 411 break;
412 case ICAL_OBSOLETE_CLASS: 412 case ICAL_OBSOLETE_CLASS:
413 status = ScheduleMessage::Obsolete; 413 status = ScheduleMessage::Obsolete;
414 break; 414 break;
415 case ICAL_REQUEST_NEW_CLASS: 415 case ICAL_REQUEST_NEW_CLASS:
416 status = ScheduleMessage::RequestNew; 416 status = ScheduleMessage::RequestNew;
417 break; 417 break;
418 case ICAL_REQUEST_UPDATE_CLASS: 418 case ICAL_REQUEST_UPDATE_CLASS:
419 status = ScheduleMessage::RequestUpdate; 419 status = ScheduleMessage::RequestUpdate;
420 break; 420 break;
421 case ICAL_UNKNOWN_CLASS: 421 case ICAL_UNKNOWN_CLASS:
422 default: 422 default:
423 status = ScheduleMessage::Unknown; 423 status = ScheduleMessage::Unknown;
424 break; 424 break;
425 } 425 }
426#endif 426#endif
427 status = ScheduleMessage::RequestUpdate; 427 status = ScheduleMessage::RequestUpdate;
428 return new ScheduleMessage(incidence,method,status); 428 return new ScheduleMessage(incidence,method,status);
429} 429}
430 430
431void ICalFormat::setTimeZone( const QString &id, bool utc ) 431void ICalFormat::setTimeZone( const QString &id, bool utc )
432{ 432{
433 433
434 434
435 mTimeZoneId = id; 435 mTimeZoneId = id;
436 mUtc = utc; 436 mUtc = utc;
437 437
438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); 438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId);
439 439
440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); 440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin);
441} 441}
442 442
443QString ICalFormat::timeZoneId() const 443QString ICalFormat::timeZoneId() const
444{ 444{
445 return mTimeZoneId; 445 return mTimeZoneId;
446} 446}
447 447
448bool ICalFormat::utc() const 448bool ICalFormat::utc() const
449{ 449{
450 return mUtc; 450 return mUtc;
451} 451}
452int ICalFormat::timeOffset() 452int ICalFormat::timeOffset()
453{ 453{
454 return tzOffsetMin; 454 return tzOffsetMin;
455} 455}
456const char *ICalFormat::tzString() 456const char *ICalFormat::tzString()
457{ 457{
458 const char* ret = (const char* ) mTzString; 458 const char* ret = (const char* ) mTzString;
459 return ret; 459 return ret;
460} 460}
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 2405682..3e28714 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -2030,143 +2030,143 @@ bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar)
2030 ; 2030 ;
2031 } else { 2031 } else {
2032 ; 2032 ;
2033 } 2033 }
2034 SKIP: 2034 SKIP:
2035 ; 2035 ;
2036 } // while 2036 } // while
2037#endif 2037#endif
2038 2038
2039 // Post-Process list of events with relations, put Event objects in relation 2039 // Post-Process list of events with relations, put Event objects in relation
2040 Event *ev; 2040 Event *ev;
2041 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { 2041 for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) {
2042 Incidence * inc = cal->event(ev->relatedToUid()); 2042 Incidence * inc = cal->event(ev->relatedToUid());
2043 if ( inc ) 2043 if ( inc )
2044 ev->setRelatedTo( inc ); 2044 ev->setRelatedTo( inc );
2045 } 2045 }
2046 Todo *todo; 2046 Todo *todo;
2047 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { 2047 for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) {
2048 Incidence * inc = cal->todo(todo->relatedToUid()); 2048 Incidence * inc = cal->todo(todo->relatedToUid());
2049 if ( inc ) 2049 if ( inc )
2050 todo->setRelatedTo( inc ); 2050 todo->setRelatedTo( inc );
2051 } 2051 }
2052 2052
2053 return true; 2053 return true;
2054} 2054}
2055 2055
2056QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) 2056QString ICalFormatImpl::extractErrorProperty(icalcomponent *c)
2057{ 2057{
2058// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " 2058// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: "
2059// << icalcomponent_as_ical_string(c) << endl; 2059// << icalcomponent_as_ical_string(c) << endl;
2060 2060
2061 QString errorMessage; 2061 QString errorMessage;
2062 2062
2063 icalproperty *error; 2063 icalproperty *error;
2064 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); 2064 error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY);
2065 while(error) { 2065 while(error) {
2066 errorMessage += icalproperty_get_xlicerror(error); 2066 errorMessage += icalproperty_get_xlicerror(error);
2067 errorMessage += "\n"; 2067 errorMessage += "\n";
2068 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); 2068 error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY);
2069 } 2069 }
2070 2070
2071// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; 2071// kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl;
2072 2072
2073 return errorMessage; 2073 return errorMessage;
2074} 2074}
2075 2075
2076void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) 2076void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r)
2077{ 2077{
2078 int i; 2078 int i;
2079 2079
2080 2080
2081 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2081 if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2082 int index = 0; 2082 int index = 0;
2083 QString out = " By Day: "; 2083 QString out = " By Day: ";
2084 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2084 while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2085 out.append(QString::number(i) + " "); 2085 out.append(QString::number(i) + " ");
2086 } 2086 }
2087 } 2087 }
2088 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2088 if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2089 int index = 0; 2089 int index = 0;
2090 QString out = " By Month Day: "; 2090 QString out = " By Month Day: ";
2091 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2091 while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2092 out.append(QString::number(i) + " "); 2092 out.append(QString::number(i) + " ");
2093 } 2093 }
2094 } 2094 }
2095 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2095 if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2096 int index = 0; 2096 int index = 0;
2097 QString out = " By Year Day: "; 2097 QString out = " By Year Day: ";
2098 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2098 while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2099 out.append(QString::number(i) + " "); 2099 out.append(QString::number(i) + " ");
2100 } 2100 }
2101 } 2101 }
2102 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2102 if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2103 int index = 0; 2103 int index = 0;
2104 QString out = " By Month: "; 2104 QString out = " By Month: ";
2105 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2105 while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2106 out.append(QString::number(i) + " "); 2106 out.append(QString::number(i) + " ");
2107 } 2107 }
2108 } 2108 }
2109 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { 2109 if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) {
2110 int index = 0; 2110 int index = 0;
2111 QString out = " By Set Pos: "; 2111 QString out = " By Set Pos: ";
2112 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { 2112 while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) {
2113 out.append(QString::number(i) + " "); 2113 out.append(QString::number(i) + " ");
2114 } 2114 }
2115 } 2115 }
2116} 2116}
2117 2117
2118icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, 2118icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence,
2119 Scheduler::Method method) 2119 Scheduler::Method method)
2120{ 2120{
2121 icalcomponent *message = createCalendarComponent(); 2121 icalcomponent *message = createCalendarComponent();
2122 2122
2123 icalproperty_method icalmethod = ICAL_METHOD_NONE; 2123 icalproperty_method icalmethod = ICAL_METHOD_NONE;
2124 2124
2125 switch (method) { 2125 switch (method) {
2126 case Scheduler::Publish: 2126 case Scheduler::Publish:
2127 icalmethod = ICAL_METHOD_PUBLISH; 2127 icalmethod = ICAL_METHOD_PUBLISH;
2128 break; 2128 break;
2129 case Scheduler::Request: 2129 case Scheduler::Request:
2130 icalmethod = ICAL_METHOD_REQUEST; 2130 icalmethod = ICAL_METHOD_REQUEST;
2131 break; 2131 break;
2132 case Scheduler::Refresh: 2132 case Scheduler::Refresh:
2133 icalmethod = ICAL_METHOD_REFRESH; 2133 icalmethod = ICAL_METHOD_REFRESH;
2134 break; 2134 break;
2135 case Scheduler::Cancel: 2135 case Scheduler::Cancel:
2136 icalmethod = ICAL_METHOD_CANCEL; 2136 icalmethod = ICAL_METHOD_CANCEL;
2137 break; 2137 break;
2138 case Scheduler::Add: 2138 case Scheduler::Add:
2139 icalmethod = ICAL_METHOD_ADD; 2139 icalmethod = ICAL_METHOD_ADD;
2140 break; 2140 break;
2141 case Scheduler::Reply: 2141 case Scheduler::Reply:
2142 icalmethod = ICAL_METHOD_REPLY; 2142 icalmethod = ICAL_METHOD_REPLY;
2143 break; 2143 break;
2144 case Scheduler::Counter: 2144 case Scheduler::Counter:
2145 icalmethod = ICAL_METHOD_COUNTER; 2145 icalmethod = ICAL_METHOD_COUNTER;
2146 break; 2146 break;
2147 case Scheduler::Declinecounter: 2147 case Scheduler::Declinecounter:
2148 icalmethod = ICAL_METHOD_DECLINECOUNTER; 2148 icalmethod = ICAL_METHOD_DECLINECOUNTER;
2149 break; 2149 break;
2150 default: 2150 default:
2151 2151
2152 return message; 2152 return message;
2153 } 2153 }
2154 2154
2155 icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); 2155 icalcomponent_add_property(message,icalproperty_new_method(icalmethod));
2156 2156
2157 // TODO: check, if dynamic cast is required 2157 // TODO: check, if dynamic cast is required
2158 if(incidence->type() == "Todo") { 2158 if(incidence->typeID() == todoID ) {
2159 Todo *todo = static_cast<Todo *>(incidence); 2159 Todo *todo = static_cast<Todo *>(incidence);
2160 icalcomponent_add_component(message,writeTodo(todo)); 2160 icalcomponent_add_component(message,writeTodo(todo));
2161 } 2161 }
2162 if(incidence->type() == "Event") { 2162 if(incidence->typeID() == eventID ) {
2163 Event *event = static_cast<Event *>(incidence); 2163 Event *event = static_cast<Event *>(incidence);
2164 icalcomponent_add_component(message,writeEvent(event)); 2164 icalcomponent_add_component(message,writeEvent(event));
2165 } 2165 }
2166 if(incidence->type() == "FreeBusy") { 2166 if(incidence->typeID() == freebusyID) {
2167 FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); 2167 FreeBusy *freebusy = static_cast<FreeBusy *>(incidence);
2168 icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); 2168 icalcomponent_add_component(message,writeFreeBusy(freebusy, method));
2169 } 2169 }
2170 2170
2171 return message; 2171 return message;
2172} 2172}
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 762103f..f446197 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -111,257 +111,257 @@ bool Incidence::isAnniversary() const
111 return mAnniversary ; 111 return mAnniversary ;
112 112
113} 113}
114 114
115bool Incidence::hasRecurrenceID() const 115bool Incidence::hasRecurrenceID() const
116{ 116{
117 return mHasRecurrenceID; 117 return mHasRecurrenceID;
118} 118}
119 119
120void Incidence::setHasRecurrenceID( bool b ) 120void Incidence::setHasRecurrenceID( bool b )
121{ 121{
122 mHasRecurrenceID = b; 122 mHasRecurrenceID = b;
123} 123}
124 124
125void Incidence::setRecurrenceID(QDateTime d) 125void Incidence::setRecurrenceID(QDateTime d)
126{ 126{
127 mRecurrenceID = d; 127 mRecurrenceID = d;
128 mHasRecurrenceID = true; 128 mHasRecurrenceID = true;
129 updated(); 129 updated();
130} 130}
131QDateTime Incidence::recurrenceID () const 131QDateTime Incidence::recurrenceID () const
132{ 132{
133 return mRecurrenceID; 133 return mRecurrenceID;
134} 134}
135 135
136bool Incidence::cancelled() const 136bool Incidence::cancelled() const
137{ 137{
138 return mCancelled; 138 return mCancelled;
139} 139}
140void Incidence::setCancelled( bool b ) 140void Incidence::setCancelled( bool b )
141{ 141{
142 mCancelled = b; 142 mCancelled = b;
143 updated(); 143 updated();
144} 144}
145bool Incidence::hasStartDate() const 145bool Incidence::hasStartDate() const
146{ 146{
147 return mHasStartDate; 147 return mHasStartDate;
148} 148}
149 149
150void Incidence::setHasStartDate(bool f) 150void Incidence::setHasStartDate(bool f)
151{ 151{
152 if (mReadOnly) return; 152 if (mReadOnly) return;
153 mHasStartDate = f; 153 mHasStartDate = f;
154 updated(); 154 updated();
155} 155}
156 156
157// A string comparison that considers that null and empty are the same 157// A string comparison that considers that null and empty are the same
158static bool stringCompare( const QString& s1, const QString& s2 ) 158static bool stringCompare( const QString& s1, const QString& s2 )
159{ 159{
160 if ( s1.isEmpty() && s2.isEmpty() ) 160 if ( s1.isEmpty() && s2.isEmpty() )
161 return true; 161 return true;
162 return s1 == s2; 162 return s1 == s2;
163} 163}
164 164
165bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 165bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
166{ 166{
167 167
168 if( i1.alarms().count() != i2.alarms().count() ) { 168 if( i1.alarms().count() != i2.alarms().count() ) {
169 return false; // no need to check further 169 return false; // no need to check further
170 } 170 }
171 if ( i1.alarms().count() > 0 ) { 171 if ( i1.alarms().count() > 0 ) {
172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
173 { 173 {
174 qDebug("alarm not equal "); 174 qDebug("alarm not equal ");
175 return false; 175 return false;
176 } 176 }
177 } 177 }
178#if 0 178#if 0
179 QPtrListIterator<Alarm> a1( i1.alarms() ); 179 QPtrListIterator<Alarm> a1( i1.alarms() );
180 QPtrListIterator<Alarm> a2( i2.alarms() ); 180 QPtrListIterator<Alarm> a2( i2.alarms() );
181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
182 if( *a1.current() == *a2.current() ) { 182 if( *a1.current() == *a2.current() ) {
183 continue; 183 continue;
184 } 184 }
185 else { 185 else {
186 return false; 186 return false;
187 } 187 }
188 } 188 }
189#endif 189#endif
190 190
191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
192 if ( i1.hasRecurrenceID() ) { 192 if ( i1.hasRecurrenceID() ) {
193 if ( i1.recurrenceID() != i2.recurrenceID() ) 193 if ( i1.recurrenceID() != i2.recurrenceID() )
194 return false; 194 return false;
195 } 195 }
196 196
197 } else { 197 } else {
198 return false; 198 return false;
199 } 199 }
200 200
201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
202 return false; 202 return false;
203 if ( i1.hasStartDate() == i2.hasStartDate() ) { 203 if ( i1.hasStartDate() == i2.hasStartDate() ) {
204 if ( i1.hasStartDate() ) { 204 if ( i1.hasStartDate() ) {
205 if ( i1.dtStart() != i2.dtStart() ) 205 if ( i1.dtStart() != i2.dtStart() )
206 return false; 206 return false;
207 } 207 }
208 } else { 208 } else {
209 return false; 209 return false;
210 } 210 }
211 if (!( *i1.recurrence() == *i2.recurrence()) ) { 211 if (!( *i1.recurrence() == *i2.recurrence()) ) {
212 qDebug("recurrence is NOT equal "); 212 qDebug("recurrence is NOT equal ");
213 return false; 213 return false;
214 } 214 }
215 return 215 return
216 // i1.created() == i2.created() && 216 // i1.created() == i2.created() &&
217 stringCompare( i1.description(), i2.description() ) && 217 stringCompare( i1.description(), i2.description() ) &&
218 stringCompare( i1.summary(), i2.summary() ) && 218 stringCompare( i1.summary(), i2.summary() ) &&
219 i1.categories() == i2.categories() && 219 i1.categories() == i2.categories() &&
220 // no need to compare mRelatedTo 220 // no need to compare mRelatedTo
221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
222 // i1.relations() == i2.relations() && 222 // i1.relations() == i2.relations() &&
223 i1.exDates() == i2.exDates() && 223 i1.exDates() == i2.exDates() &&
224 i1.attachments() == i2.attachments() && 224 i1.attachments() == i2.attachments() &&
225 i1.resources() == i2.resources() && 225 i1.resources() == i2.resources() &&
226 i1.secrecy() == i2.secrecy() && 226 i1.secrecy() == i2.secrecy() &&
227 i1.priority() == i2.priority() && 227 i1.priority() == i2.priority() &&
228 i1.cancelled() == i2.cancelled() && 228 i1.cancelled() == i2.cancelled() &&
229 stringCompare( i1.location(), i2.location() ); 229 stringCompare( i1.location(), i2.location() );
230} 230}
231 231
232Incidence* Incidence::recreateCloneException( QDate d ) 232Incidence* Incidence::recreateCloneException( QDate d )
233{ 233{
234 Incidence* newInc = clone(); 234 Incidence* newInc = clone();
235 newInc->recreate(); 235 newInc->recreate();
236 if ( doesRecur() ) { 236 if ( doesRecur() ) {
237 addExDate( d ); 237 addExDate( d );
238 newInc->recurrence()->unsetRecurs(); 238 newInc->recurrence()->unsetRecurs();
239 if ( type() == "Event") { 239 if ( typeID() == eventID ) {
240 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 240 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
241 QTime tim = dtStart().time(); 241 QTime tim = dtStart().time();
242 newInc->setDtStart( QDateTime(d, tim) ); 242 newInc->setDtStart( QDateTime(d, tim) );
243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
244 } else { 244 } else {
245 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 245 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
246 QTime tim = ((Todo*)this)->dtDue().time(); 246 QTime tim = ((Todo*)this)->dtDue().time();
247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
249 ((Todo*)this)->setRecurDates(); 249 ((Todo*)this)->setRecurDates();
250 } 250 }
251 newInc->setExDates( DateList () ); 251 newInc->setExDates( DateList () );
252 } 252 }
253 return newInc; 253 return newInc;
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}
266void Incidence::cloneRelations( Incidence * newInc ) 266void Incidence::cloneRelations( Incidence * newInc )
267{ 267{
268 // newInc is already a clone of this incidence 268 // newInc is already a clone of this incidence
269 Incidence * inc; 269 Incidence * inc;
270 Incidence * cloneInc; 270 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations(); 271 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) { 272 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone(); 273 cloneInc = inc->clone();
274 cloneInc->recreate(); 274 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc ); 275 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc ); 276 inc->cloneRelations( cloneInc );
277 } 277 }
278} 278}
279void Incidence::setReadOnly( bool readOnly ) 279void Incidence::setReadOnly( bool readOnly )
280{ 280{
281 IncidenceBase::setReadOnly( readOnly ); 281 IncidenceBase::setReadOnly( readOnly );
282 recurrence()->setRecurReadOnly( readOnly); 282 recurrence()->setRecurReadOnly( readOnly);
283} 283}
284 284
285void Incidence::setCreated(QDateTime created) 285void Incidence::setCreated(QDateTime created)
286{ 286{
287 if (mReadOnly) return; 287 if (mReadOnly) return;
288 mCreated = getEvenTime(created); 288 mCreated = getEvenTime(created);
289} 289}
290 290
291QDateTime Incidence::created() const 291QDateTime Incidence::created() const
292{ 292{
293 return mCreated; 293 return mCreated;
294} 294}
295 295
296void Incidence::setRevision(int rev) 296void Incidence::setRevision(int rev)
297{ 297{
298 if (mReadOnly) return; 298 if (mReadOnly) return;
299 mRevision = rev; 299 mRevision = rev;
300 300
301 updated(); 301 updated();
302} 302}
303 303
304int Incidence::revision() const 304int Incidence::revision() const
305{ 305{
306 return mRevision; 306 return mRevision;
307} 307}
308 308
309void Incidence::setDtStart(const QDateTime &dtStart) 309void Incidence::setDtStart(const QDateTime &dtStart)
310{ 310{
311 311
312 QDateTime dt = getEvenTime(dtStart); 312 QDateTime dt = getEvenTime(dtStart);
313 recurrence()->setRecurStart( dt); 313 recurrence()->setRecurStart( dt);
314 IncidenceBase::setDtStart( dt ); 314 IncidenceBase::setDtStart( dt );
315} 315}
316 316
317void Incidence::setDescription(const QString &description) 317void Incidence::setDescription(const QString &description)
318{ 318{
319 if (mReadOnly) return; 319 if (mReadOnly) return;
320 mDescription = description; 320 mDescription = description;
321 updated(); 321 updated();
322} 322}
323 323
324QString Incidence::description() const 324QString Incidence::description() const
325{ 325{
326 return mDescription; 326 return mDescription;
327} 327}
328 328
329 329
330void Incidence::setSummary(const QString &summary) 330void Incidence::setSummary(const QString &summary)
331{ 331{
332 if (mReadOnly) return; 332 if (mReadOnly) return;
333 mSummary = summary; 333 mSummary = summary;
334 updated(); 334 updated();
335} 335}
336 336
337QString Incidence::summary() const 337QString Incidence::summary() const
338{ 338{
339 return mSummary; 339 return mSummary;
340} 340}
341void Incidence::checkCategories() 341void Incidence::checkCategories()
342{ 342{
343 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 343 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
344 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 344 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
345 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 345 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
346} 346}
347 347
348void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 348void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
349{ 349{
350 if (mReadOnly) return; 350 if (mReadOnly) return;
351 int i; 351 int i;
352 for( i = 0; i < categories.count(); ++i ) { 352 for( i = 0; i < categories.count(); ++i ) {
353 if ( !mCategories.contains (categories[i])) 353 if ( !mCategories.contains (categories[i]))
354 mCategories.append( categories[i] ); 354 mCategories.append( categories[i] );
355 } 355 }
356 checkCategories(); 356 checkCategories();
357 updated(); 357 updated();
358 if ( addToRelations ) { 358 if ( addToRelations ) {
359 Incidence * inc; 359 Incidence * inc;
360 QPtrList<Incidence> Relations = relations(); 360 QPtrList<Incidence> Relations = relations();
361 for (inc=Relations.first();inc;inc=Relations.next()) { 361 for (inc=Relations.first();inc;inc=Relations.next()) {
362 inc->addCategories( categories, true ); 362 inc->addCategories( categories, true );
363 } 363 }
364 } 364 }
365} 365}
366 366
367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 367void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
@@ -599,146 +599,146 @@ QString Incidence::secrecyName(int secrecy)
599 case SecrecyPublic: 599 case SecrecyPublic:
600 return i18n("Public"); 600 return i18n("Public");
601 break; 601 break;
602 case SecrecyPrivate: 602 case SecrecyPrivate:
603 return i18n("Private"); 603 return i18n("Private");
604 break; 604 break;
605 case SecrecyConfidential: 605 case SecrecyConfidential:
606 return i18n("Confidential"); 606 return i18n("Confidential");
607 break; 607 break;
608 default: 608 default:
609 return i18n("Undefined"); 609 return i18n("Undefined");
610 break; 610 break;
611 } 611 }
612} 612}
613 613
614QStringList Incidence::secrecyList() 614QStringList Incidence::secrecyList()
615{ 615{
616 QStringList list; 616 QStringList list;
617 list << secrecyName(SecrecyPublic); 617 list << secrecyName(SecrecyPublic);
618 list << secrecyName(SecrecyPrivate); 618 list << secrecyName(SecrecyPrivate);
619 list << secrecyName(SecrecyConfidential); 619 list << secrecyName(SecrecyConfidential);
620 620
621 return list; 621 return list;
622} 622}
623 623
624 624
625QPtrList<Alarm> Incidence::alarms() const 625QPtrList<Alarm> Incidence::alarms() const
626{ 626{
627 return mAlarms; 627 return mAlarms;
628} 628}
629 629
630Alarm* Incidence::newAlarm() 630Alarm* Incidence::newAlarm()
631{ 631{
632 Alarm* alarm = new Alarm(this); 632 Alarm* alarm = new Alarm(this);
633 mAlarms.append(alarm); 633 mAlarms.append(alarm);
634// updated(); 634// updated();
635 return alarm; 635 return alarm;
636} 636}
637 637
638void Incidence::addAlarm(Alarm *alarm) 638void Incidence::addAlarm(Alarm *alarm)
639{ 639{
640 mAlarms.append(alarm); 640 mAlarms.append(alarm);
641 updated(); 641 updated();
642} 642}
643 643
644void Incidence::removeAlarm(Alarm *alarm) 644void Incidence::removeAlarm(Alarm *alarm)
645{ 645{
646 mAlarms.removeRef(alarm); 646 mAlarms.removeRef(alarm);
647 updated(); 647 updated();
648} 648}
649 649
650void Incidence::clearAlarms() 650void Incidence::clearAlarms()
651{ 651{
652 mAlarms.clear(); 652 mAlarms.clear();
653 updated(); 653 updated();
654} 654}
655 655
656bool Incidence::isAlarmEnabled() const 656bool Incidence::isAlarmEnabled() const
657{ 657{
658 Alarm* alarm; 658 Alarm* alarm;
659 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 659 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
660 if (alarm->enabled()) 660 if (alarm->enabled())
661 return true; 661 return true;
662 } 662 }
663 return false; 663 return false;
664} 664}
665 665
666Recurrence *Incidence::recurrence() const 666Recurrence *Incidence::recurrence() const
667{ 667{
668 return mRecurrence; 668 return mRecurrence;
669} 669}
670void Incidence::setRecurrence( Recurrence * r) 670void Incidence::setRecurrence( Recurrence * r)
671{ 671{
672 delete mRecurrence; 672 delete mRecurrence;
673 mRecurrence = r; 673 mRecurrence = r;
674} 674}
675 675
676void Incidence::setLocation(const QString &location) 676void Incidence::setLocation(const QString &location)
677{ 677{
678 if (mReadOnly) return; 678 if (mReadOnly) return;
679 mLocation = location; 679 mLocation = location;
680 updated(); 680 updated();
681} 681}
682 682
683QString Incidence::location() const 683QString Incidence::location() const
684{ 684{
685 return mLocation; 685 return mLocation;
686} 686}
687 687
688ushort Incidence::doesRecur() const 688ushort Incidence::doesRecur() const
689{ 689{
690 if ( mRecurrence ) return mRecurrence->doesRecur(); 690 if ( mRecurrence ) return mRecurrence->doesRecur();
691 else return Recurrence::rNone; 691 else return Recurrence::rNone;
692} 692}
693 693
694QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 694QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
695{ 695{
696 QDateTime incidenceStart = dt; 696 QDateTime incidenceStart = dt;
697 *ok = false; 697 *ok = false;
698 if ( doesRecur() ) { 698 if ( doesRecur() ) {
699 bool last; 699 bool last;
700 recurrence()->getPreviousDateTime( incidenceStart , &last ); 700 recurrence()->getPreviousDateTime( incidenceStart , &last );
701 int count = 0; 701 int count = 0;
702 if ( !last ) { 702 if ( !last ) {
703 while ( !last ) { 703 while ( !last ) {
704 ++count; 704 ++count;
705 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 705 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last );
706 if ( recursOn( incidenceStart.date() ) ) { 706 if ( recursOn( incidenceStart.date() ) ) {
707 last = true; // exit while llop 707 last = true; // exit while llop
708 } else { 708 } else {
709 if ( last ) { // no alarm on last recurrence 709 if ( last ) { // no alarm on last recurrence
710 return QDateTime (); 710 return QDateTime ();
711 } 711 }
712 int year = incidenceStart.date().year(); 712 int year = incidenceStart.date().year();
713 // workaround for bug in recurrence 713 // workaround for bug in recurrence
714 if ( count == 100 || year < 1000 || year > 5000 ) { 714 if ( count == 100 || year < 1000 || year > 5000 ) {
715 return QDateTime (); 715 return QDateTime ();
716 } 716 }
717 incidenceStart = incidenceStart.addSecs( 1 ); 717 incidenceStart = incidenceStart.addSecs( 1 );
718 } 718 }
719 } 719 }
720 } else { 720 } else {
721 return QDateTime (); 721 return QDateTime ();
722 } 722 }
723 } else { 723 } else {
724 if ( hasStartDate () ) { 724 if ( hasStartDate () ) {
725 incidenceStart = dtStart(); 725 incidenceStart = dtStart();
726 } 726 }
727 if ( type() =="Todo" ) { 727 if ( typeID() == todoID ) {
728 if ( ((Todo*)this)->hasDueDate() ) 728 if ( ((Todo*)this)->hasDueDate() )
729 incidenceStart = ((Todo*)this)->dtDue(); 729 incidenceStart = ((Todo*)this)->dtDue();
730 } 730 }
731 } 731 }
732 if ( incidenceStart > dt ) 732 if ( incidenceStart > dt )
733 *ok = true; 733 *ok = true;
734 return incidenceStart; 734 return incidenceStart;
735} 735}
736QDateTime Incidence::dtStart() const 736QDateTime Incidence::dtStart() const
737{ 737{
738 if ( doesRecur() ) { 738 if ( doesRecur() ) {
739 if ( type() == "Todo" ) { 739 if ( typeID() == todoID ) {
740 ((Todo*)this)->checkSetCompletedFalse(); 740 ((Todo*)this)->checkSetCompletedFalse();
741 } 741 }
742 } 742 }
743 return mDtStart; 743 return mDtStart;
744} 744}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 8624786..05209e0 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,172 +1,174 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID };
37 38
38/** 39/**
39 This class provides the base class common to all calendar components. 40 This class provides the base class common to all calendar components.
40*/ 41*/
41class IncidenceBase : public CustomProperties 42class IncidenceBase : public CustomProperties
42{ 43{
43 public: 44 public:
44 class Observer { 45 class Observer {
45 public: 46 public:
46 virtual void incidenceUpdated( IncidenceBase * ) = 0; 47 virtual void incidenceUpdated( IncidenceBase * ) = 0;
47 }; 48 };
48 49
49 IncidenceBase(); 50 IncidenceBase();
50 IncidenceBase(const IncidenceBase &); 51 IncidenceBase(const IncidenceBase &);
51 virtual ~IncidenceBase(); 52 virtual ~IncidenceBase();
52 53
53 virtual QCString type() const = 0; 54 virtual QCString type() const = 0;
55 virtual IncTypeID typeID() const = 0;
54 56
55 /** Set the unique id for the event */ 57 /** Set the unique id for the event */
56 void setUid(const QString &); 58 void setUid(const QString &);
57 /** Return the unique id for the event */ 59 /** Return the unique id for the event */
58 QString uid() const; 60 QString uid() const;
59 61
60 /** Sets the time the incidence was last modified. */ 62 /** Sets the time the incidence was last modified. */
61 void setLastModified(const QDateTime &lm); 63 void setLastModified(const QDateTime &lm);
62 /** Return the time the incidence was last modified. */ 64 /** Return the time the incidence was last modified. */
63 QDateTime lastModified() const; 65 QDateTime lastModified() const;
64 66
65 /** sets the organizer for the event */ 67 /** sets the organizer for the event */
66 void setOrganizer(const QString &o); 68 void setOrganizer(const QString &o);
67 QString organizer() const; 69 QString organizer() const;
68 70
69 /** Set readonly status. */ 71 /** Set readonly status. */
70 virtual void setReadOnly( bool ); 72 virtual void setReadOnly( bool );
71 /** Return if the object is read-only. */ 73 /** Return if the object is read-only. */
72 bool isReadOnly() const { return mReadOnly; } 74 bool isReadOnly() const { return mReadOnly; }
73 75
74 /** for setting the event's starting date/time with a QDateTime. */ 76 /** for setting the event's starting date/time with a QDateTime. */
75 virtual void setDtStart(const QDateTime &dtStart); 77 virtual void setDtStart(const QDateTime &dtStart);
76 /** returns an event's starting date/time as a QDateTime. */ 78 /** returns an event's starting date/time as a QDateTime. */
77 virtual QDateTime dtStart() const; 79 virtual QDateTime dtStart() const;
78 /** returns an event's starting time as a string formatted according to the 80 /** returns an event's starting time as a string formatted according to the
79 users locale settings */ 81 users locale settings */
80 QString dtStartTimeStr() const; 82 QString dtStartTimeStr() const;
81 /** returns an event's starting date as a string formatted according to the 83 /** returns an event's starting date as a string formatted according to the
82 users locale settings */ 84 users locale settings */
83 QString dtStartDateStr(bool shortfmt=true) const; 85 QString dtStartDateStr(bool shortfmt=true) const;
84 /** returns an event's starting date and time as a string formatted according 86 /** returns an event's starting date and time as a string formatted according
85 to the users locale settings */ 87 to the users locale settings */
86 QString dtStartStr(bool shortfmt=true) const; 88 QString dtStartStr(bool shortfmt=true) const;
87 89
88 virtual void setDuration(int seconds); 90 virtual void setDuration(int seconds);
89 int duration() const; 91 int duration() const;
90 void setHasDuration(bool); 92 void setHasDuration(bool);
91 bool hasDuration() const; 93 bool hasDuration() const;
92 94
93 /** Return true or false depending on whether the incidence "floats," 95 /** Return true or false depending on whether the incidence "floats,"
94 * i.e. has a date but no time attached to it. */ 96 * i.e. has a date but no time attached to it. */
95 bool doesFloat() const; 97 bool doesFloat() const;
96 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
97 void setFloats(bool f); 99 void setFloats(bool f);
98 100
99 /** 101 /**
100 Add Attendee to this incidence. IncidenceBase takes ownership of the 102 Add Attendee to this incidence. IncidenceBase takes ownership of the
101 Attendee object. 103 Attendee object.
102 */ 104 */
103 bool addAttendee(Attendee *a, bool doupdate=true ); 105 bool addAttendee(Attendee *a, bool doupdate=true );
104// void removeAttendee(Attendee *a); 106// void removeAttendee(Attendee *a);
105// void removeAttendee(const char *n); 107// void removeAttendee(const char *n);
106 /** Remove all Attendees. */ 108 /** Remove all Attendees. */
107 void clearAttendees(); 109 void clearAttendees();
108 /** Return list of attendees. */ 110 /** Return list of attendees. */
109 QPtrList<Attendee> attendees() const { return mAttendees; }; 111 QPtrList<Attendee> attendees() const { return mAttendees; };
110 /** Return number of attendees. */ 112 /** Return number of attendees. */
111 int attendeeCount() const { return mAttendees.count(); }; 113 int attendeeCount() const { return mAttendees.count(); };
112 /** Return the Attendee with this email */ 114 /** Return the Attendee with this email */
113 Attendee* attendeeByMail(const QString &); 115 Attendee* attendeeByMail(const QString &);
114 /** Return first Attendee with one of this emails */ 116 /** Return first Attendee with one of this emails */
115 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
116 118
117 /** pilot syncronization states */ 119 /** pilot syncronization states */
118 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
119 /** Set synchronisation satus. */ 121 /** Set synchronisation satus. */
120 void setSyncStatus(int stat); 122 void setSyncStatus(int stat);
121 /** Return synchronisation status. */ 123 /** Return synchronisation status. */
122 int syncStatus() const; 124 int syncStatus() const;
123 125
124 /** Set Pilot Id. */ 126 /** Set Pilot Id. */
125 void setPilotId(int id); 127 void setPilotId(int id);
126 /** Return Pilot Id. */ 128 /** Return Pilot Id. */
127 int pilotId() const; 129 int pilotId() const;
128 130
129 void setTempSyncStat(int id); 131 void setTempSyncStat(int id);
130 int tempSyncStat() const; 132 int tempSyncStat() const;
131 void setIDStr( const QString & ); 133 void setIDStr( const QString & );
132 QString IDStr() const; 134 QString IDStr() const;
133 void setID( const QString &, const QString & ); 135 void setID( const QString &, const QString & );
134 QString getID( const QString & ); 136 QString getID( const QString & );
135 void setCsum( const QString &, const QString & ); 137 void setCsum( const QString &, const QString & );
136 QString getCsum( const QString & ); 138 QString getCsum( const QString & );
137 void removeID(const QString &); 139 void removeID(const QString &);
138 140
139 void registerObserver( Observer * ); 141 void registerObserver( Observer * );
140 void unRegisterObserver( Observer * ); 142 void unRegisterObserver( Observer * );
141 void updated(); 143 void updated();
142 144
143 protected: 145 protected:
144 QDateTime mDtStart; 146 QDateTime mDtStart;
145 bool mReadOnly; 147 bool mReadOnly;
146 QDateTime getEvenTime( QDateTime ); 148 QDateTime getEvenTime( QDateTime );
147 149
148 private: 150 private:
149 // base components 151 // base components
150 QString mOrganizer; 152 QString mOrganizer;
151 QString mUid; 153 QString mUid;
152 QDateTime mLastModified; 154 QDateTime mLastModified;
153 QPtrList<Attendee> mAttendees; 155 QPtrList<Attendee> mAttendees;
154 156
155 bool mFloats; 157 bool mFloats;
156 158
157 int mDuration; 159 int mDuration;
158 bool mHasDuration; 160 bool mHasDuration;
159 QString mExternalId; 161 QString mExternalId;
160 int mTempSyncStat; 162 int mTempSyncStat;
161 163
162 // PILOT SYNCHRONIZATION STUFF 164 // PILOT SYNCHRONIZATION STUFF
163 int mPilotId; // unique id for pilot sync 165 int mPilotId; // unique id for pilot sync
164 int mSyncStatus; // status (for sync) 166 int mSyncStatus; // status (for sync)
165 167
166 QPtrList<Observer> mObservers; 168 QPtrList<Observer> mObservers;
167}; 169};
168 170
169bool operator==( const IncidenceBase&, const IncidenceBase& ); 171bool operator==( const IncidenceBase&, const IncidenceBase& );
170} 172}
171 173
172#endif 174#endif
diff --git a/libkcal/journal.h b/libkcal/journal.h
index 2c1d7ea..1cd0a22 100644
--- a/libkcal/journal.h
+++ b/libkcal/journal.h
@@ -1,50 +1,51 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef JOURNAL_H 20#ifndef JOURNAL_H
21#define JOURNAL_H 21#define JOURNAL_H
22// 22//
23// Journal component, representing a VJOURNAL object 23// Journal component, representing a VJOURNAL object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28namespace KCal { 28namespace KCal {
29 29
30/** 30/**
31 This class provides a Journal in the sense of RFC2445. 31 This class provides a Journal in the sense of RFC2445.
32*/ 32*/
33class Journal : public Incidence 33class Journal : public Incidence
34{ 34{
35 public: 35 public:
36 Journal(); 36 Journal();
37 ~Journal(); 37 ~Journal();
38 38
39 QCString type() const { return "Journal"; } 39 QCString type() const { return "Journal"; }
40 IncTypeID typeID() const { return journalID; }
40 41
41 Incidence *clone(); 42 Incidence *clone();
42 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 43 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
43private: 44private:
44 bool accept(Visitor &v) { return v.visit(this); } 45 bool accept(Visitor &v) { return v.visit(this); }
45}; 46};
46 47
47 bool operator==( const Journal&, const Journal& ); 48 bool operator==( const Journal&, const Journal& );
48} 49}
49 50
50#endif 51#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 7d61b7f..d1ace4f 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,154 +1,154 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details; 20 mDetails = details;
21 mCreated = created ; 21 mCreated = created ;
22 mModified = modified; 22 mModified = modified;
23 mText = ""; 23 mText = "";
24 if ( inc->type() == "Event" ) 24 if ( inc->typeID() == eventID )
25 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
26 else if ( inc->type() == "Todo" ) 26 else if ( inc->typeID() == todoID )
27 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
28 return mText; 28 return mText;
29} 29}
30 30
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
32{ 32{
33 if (!mInstance) { 33 if (!mInstance) {
34 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
35 } 35 }
36 return mInstance; 36 return mInstance;
37} 37}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~KIncidenceFormatter()
39{ 39{
40 if (mInstance == this) 40 if (mInstance == this)
41 mInstance = insd.setObject(0); 41 mInstance = insd.setObject(0);
42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
43} 43}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",deTag(event->summary())); 54 addTag("h3",deTag(event->summary()));
55 } 55 }
56 else { 56 else {
57 if ( mColorMode == 1 ) { 57 if ( mColorMode == 1 ) {
58 mText +="<font color=\"#00A000\">"; 58 mText +="<font color=\"#00A000\">";
59 } 59 }
60 if ( mColorMode == 2 ) { 60 if ( mColorMode == 2 ) {
61 mText +="<font color=\"#C00000\">"; 61 mText +="<font color=\"#C00000\">";
62 } 62 }
63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
64 if ( mode == 1 ) { 64 if ( mode == 1 ) {
65 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 65 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
66 } else { 66 } else {
67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
68 } 68 }
69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
70 if ( mColorMode ) 70 if ( mColorMode )
71 mText += "</font>"; 71 mText += "</font>";
72 } 72 }
73 if (event->cancelled ()) { 73 if (event->cancelled ()) {
74 mText +="<font color=\"#B00000\">"; 74 mText +="<font color=\"#B00000\">";
75 addTag("i",i18n("This event has been cancelled!")); 75 addTag("i",i18n("This event has been cancelled!"));
76 mText.append("<br>"); 76 mText.append("<br>");
77 mText += "</font>"; 77 mText += "</font>";
78 } 78 }
79 if (event->doesFloat()) { 79 if (event->doesFloat()) {
80 if (event->isMultiDay()) { 80 if (event->isMultiDay()) {
81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
82 .arg(event->dtStartDateStr(shortDate)) 82 .arg(event->dtStartDateStr(shortDate))
83 .arg(event->dtEndDateStr(shortDate))); 83 .arg(event->dtEndDateStr(shortDate)));
84 } else { 84 } else {
85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
86 } 86 }
87 } else { 87 } else {
88 if (event->isMultiDay()) { 88 if (event->isMultiDay()) {
89 mText.append(i18n("<p><b>From:</b> %1</p> ") 89 mText.append(i18n("<p><b>From:</b> %1</p> ")
90 .arg(event->dtStartStr( shortDate))); 90 .arg(event->dtStartStr( shortDate)));
91 mText.append(i18n("<p><b>To:</b> %1</p>") 91 mText.append(i18n("<p><b>To:</b> %1</p>")
92 .arg(event->dtEndStr(shortDate))); 92 .arg(event->dtEndStr(shortDate)));
93 } else { 93 } else {
94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
95 .arg(event->dtStartTimeStr()) 95 .arg(event->dtStartTimeStr())
96 .arg(event->dtEndTimeStr())); 96 .arg(event->dtEndTimeStr()));
97 mText.append(i18n("<p><b>On:</b> %1</p> ") 97 mText.append(i18n("<p><b>On:</b> %1</p> ")
98 .arg(event->dtStartDateStr( shortDate ))); 98 .arg(event->dtStartDateStr( shortDate )));
99 } 99 }
100 } 100 }
101 if (!event->location().isEmpty()) { 101 if (!event->location().isEmpty()) {
102 addTag("b",i18n("Location: ")); 102 addTag("b",i18n("Location: "));
103 mText.append(deTag(event->location())+"<br>"); 103 mText.append(deTag(event->location())+"<br>");
104 } 104 }
105 105
106 if (event->recurrence()->doesRecur()) { 106 if (event->recurrence()->doesRecur()) {
107 107
108 QString recurText = event->recurrence()->recurrenceText(); 108 QString recurText = event->recurrence()->recurrenceText();
109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
110 110
111 bool ok; 111 bool ok;
112 QDate start = QDate::currentDate(); 112 QDate start = QDate::currentDate();
113 QDateTime next; 113 QDateTime next;
114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
115 if ( ok ) { 115 if ( ok ) {
116 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 116 addTag("p",i18n("<b>Next recurrence is on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
118 118
119 } else { 119 } else {
120 bool last; 120 bool last;
121 QDate nextd; 121 QDate nextd;
122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
123 if ( last ) { 123 if ( last ) {
124 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 124 addTag("p",i18n("<b>Last recurrence was on:</b>") );
125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 130
131 if (event->isAlarmEnabled()) { 131 if (event->isAlarmEnabled()) {
132 Alarm *alarm =event->alarms().first() ; 132 Alarm *alarm =event->alarms().first() ;
133 QDateTime t = alarm->time(); 133 QDateTime t = alarm->time();
134 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 134 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
135 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 135 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
136 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 136 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
137 //addTag("p",s); 137 //addTag("p",s);
138 } 138 }
139 139
140 140
141 141
142 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 142 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
143 // mText.append(event->secrecyStr()+"<br>"); 143 // mText.append(event->secrecyStr()+"<br>");
144 formatCategories(event); 144 formatCategories(event);
145 145
146 formatReadOnly(event); 146 formatReadOnly(event);
147 formatAttendees(event); 147 formatAttendees(event);
148 148
149 if ( mCreated ) { 149 if ( mCreated ) {
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 151 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
152#else 152#else
153 addTag("p",i18n("<b>Created: ") +" </b>"); 153 addTag("p",i18n("<b>Created: ") +" </b>");
154 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 154 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 38ba2c7..c97a61e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -5,257 +5,257 @@
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34Todo::Todo(): QObject(), Incidence() 34Todo::Todo(): QObject(), Incidence()
35{ 35{
36// mStatus = TENTATIVE; 36// mStatus = TENTATIVE;
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::setRunning( bool run ) 72void Todo::setRunning( bool run )
73{ 73{
74 if ( run == mRunning ) 74 if ( run == mRunning )
75 return; 75 return;
76 //qDebug("Todo::setRunning %d ", run); 76 //qDebug("Todo::setRunning %d ", run);
77 if ( !mRunSaveTimer ) { 77 if ( !mRunSaveTimer ) {
78 mRunSaveTimer = new QTimer ( this ); 78 mRunSaveTimer = new QTimer ( this );
79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
80 } 80 }
81 mRunning = run; 81 mRunning = run;
82 if ( mRunning ) { 82 if ( mRunning ) {
83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
84 mRunStart = QDateTime::currentDateTime(); 84 mRunStart = QDateTime::currentDateTime();
85 } else { 85 } else {
86 mRunSaveTimer->stop(); 86 mRunSaveTimer->stop();
87 saveRunningInfoToFile(); 87 saveRunningInfoToFile();
88 } 88 }
89} 89}
90 90
91void Todo::saveRunningInfoToFile( QString comment ) 91void Todo::saveRunningInfoToFile( QString comment )
92{ 92{
93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
95 qDebug("Running time < 30 seconds. Skipped. "); 95 qDebug("Running time < 30 seconds. Skipped. ");
96 return; 96 return;
97 } 97 }
98 QString dir = KGlobalSettings::timeTrackerDir(); 98 QString dir = KGlobalSettings::timeTrackerDir();
99 //qDebug("%s ", dir.latin1()); 99 //qDebug("%s ", dir.latin1());
100 QString file = "%1%2%3-%4%5%6-"; 100 QString file = "%1%2%3-%4%5%6-";
101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
102 file.replace ( QRegExp (" "), "0" ); 102 file.replace ( QRegExp (" "), "0" );
103 file += uid(); 103 file += uid();
104 //qDebug("File %s ",file.latin1() ); 104 //qDebug("File %s ",file.latin1() );
105 CalendarLocal cal; 105 CalendarLocal cal;
106 cal.setLocalTime(); 106 cal.setLocalTime();
107 Todo * to = (Todo*) clone(); 107 Todo * to = (Todo*) clone();
108 to->setFloats( false ); 108 to->setFloats( false );
109 to->setDtStart( mRunStart ); 109 to->setDtStart( mRunStart );
110 to->setHasStartDate( true ); 110 to->setHasStartDate( true );
111 to->setDtDue( QDateTime::currentDateTime() ); 111 to->setDtDue( QDateTime::currentDateTime() );
112 to->setHasDueDate( true ); 112 to->setHasDueDate( true );
113 to->setUid( file ); 113 to->setUid( file );
114 if ( !comment.isEmpty() ) { 114 if ( !comment.isEmpty() ) {
115 QString des = to->description(); 115 QString des = to->description();
116 if ( des.isEmpty () ) 116 if ( des.isEmpty () )
117 to->setDescription( "TT-Note: " + comment ); 117 to->setDescription( "TT-Note: " + comment );
118 else 118 else
119 to->setDescription( "TT-Note: " + comment +"\n" + des ); 119 to->setDescription( "TT-Note: " + comment +"\n" + des );
120 } 120 }
121 cal.addIncidence( to ); 121 cal.addIncidence( to );
122 ICalFormat format; 122 ICalFormat format;
123 file = dir +"/" +file +".ics"; 123 file = dir +"/" +file +".ics";
124 format.save( &cal, file ); 124 format.save( &cal, file );
125 saveParents(); 125 saveParents();
126 126
127} 127}
128void Todo::saveParents() 128void Todo::saveParents()
129{ 129{
130 if (!relatedTo() ) 130 if (!relatedTo() )
131 return; 131 return;
132 Incidence * inc = relatedTo(); 132 Incidence * inc = relatedTo();
133 if ( inc->type() != "Todo" ) 133 if ( inc->typeID() != todoID )
134 return; 134 return;
135 Todo* to = (Todo*)inc; 135 Todo* to = (Todo*)inc;
136 bool saveTodo = false; 136 bool saveTodo = false;
137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
138 QFileInfo fi ( file ); 138 QFileInfo fi ( file );
139 if ( fi.exists() ) { 139 if ( fi.exists() ) {
140 if ( fi.lastModified () < to->lastModified ()) 140 if ( fi.lastModified () < to->lastModified ())
141 saveTodo = true; 141 saveTodo = true;
142 } else { 142 } else {
143 saveTodo = true; 143 saveTodo = true;
144 } 144 }
145 if ( saveTodo ) { 145 if ( saveTodo ) {
146 CalendarLocal cal; 146 CalendarLocal cal;
147 cal.setLocalTime(); 147 cal.setLocalTime();
148 Todo * par = (Todo *) to->clone(); 148 Todo * par = (Todo *) to->clone();
149 cal.addIncidence( par ); 149 cal.addIncidence( par );
150 ICalFormat format; 150 ICalFormat format;
151 format.save( &cal, file ); 151 format.save( &cal, file );
152 } 152 }
153 to->saveParents(); 153 to->saveParents();
154} 154}
155 155
156int Todo::runTime() 156int Todo::runTime()
157{ 157{
158 if ( !mRunning ) 158 if ( !mRunning )
159 return 0; 159 return 0;
160 return mRunStart.secsTo( QDateTime::currentDateTime() ); 160 return mRunStart.secsTo( QDateTime::currentDateTime() );
161} 161}
162bool Todo::hasRunningSub() 162bool Todo::hasRunningSub()
163{ 163{
164 if ( mRunning ) 164 if ( mRunning )
165 return true; 165 return true;
166 Incidence *aTodo; 166 Incidence *aTodo;
167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
168 if ( ((Todo*)aTodo)->hasRunningSub() ) 168 if ( ((Todo*)aTodo)->hasRunningSub() )
169 return true; 169 return true;
170 } 170 }
171 return false; 171 return false;
172} 172}
173Incidence *Todo::clone() 173Incidence *Todo::clone()
174{ 174{
175 return new Todo(*this); 175 return new Todo(*this);
176} 176}
177 177
178bool Todo::contains ( Todo* from ) 178bool Todo::contains ( Todo* from )
179{ 179{
180 180
181 if ( !from->summary().isEmpty() ) 181 if ( !from->summary().isEmpty() )
182 if ( !summary().startsWith( from->summary() )) 182 if ( !summary().startsWith( from->summary() ))
183 return false; 183 return false;
184 if ( from->hasStartDate() ) { 184 if ( from->hasStartDate() ) {
185 if ( !hasStartDate() ) 185 if ( !hasStartDate() )
186 return false; 186 return false;
187 if ( from->dtStart() != dtStart()) 187 if ( from->dtStart() != dtStart())
188 return false; 188 return false;
189 } 189 }
190 if ( from->hasDueDate() ){ 190 if ( from->hasDueDate() ){
191 if ( !hasDueDate() ) 191 if ( !hasDueDate() )
192 return false; 192 return false;
193 if ( from->dtDue() != dtDue()) 193 if ( from->dtDue() != dtDue())
194 return false; 194 return false;
195 } 195 }
196 if ( !from->location().isEmpty() ) 196 if ( !from->location().isEmpty() )
197 if ( !location().startsWith( from->location() ) ) 197 if ( !location().startsWith( from->location() ) )
198 return false; 198 return false;
199 if ( !from->description().isEmpty() ) 199 if ( !from->description().isEmpty() )
200 if ( !description().startsWith( from->description() )) 200 if ( !description().startsWith( from->description() ))
201 return false; 201 return false;
202 if ( from->alarms().count() ) { 202 if ( from->alarms().count() ) {
203 Alarm *a = from->alarms().first(); 203 Alarm *a = from->alarms().first();
204 if ( a->enabled() ){ 204 if ( a->enabled() ){
205 if ( !alarms().count() ) 205 if ( !alarms().count() )
206 return false; 206 return false;
207 Alarm *b = alarms().first(); 207 Alarm *b = alarms().first();
208 if( ! b->enabled() ) 208 if( ! b->enabled() )
209 return false; 209 return false;
210 if ( ! (a->offset() == b->offset() )) 210 if ( ! (a->offset() == b->offset() ))
211 return false; 211 return false;
212 } 212 }
213 } 213 }
214 214
215 QStringList cat = categories(); 215 QStringList cat = categories();
216 QStringList catFrom = from->categories(); 216 QStringList catFrom = from->categories();
217 QString nCat; 217 QString nCat;
218 unsigned int iii; 218 unsigned int iii;
219 for ( iii = 0; iii < catFrom.count();++iii ) { 219 for ( iii = 0; iii < catFrom.count();++iii ) {
220 nCat = catFrom[iii]; 220 nCat = catFrom[iii];
221 if ( !nCat.isEmpty() ) 221 if ( !nCat.isEmpty() )
222 if ( !cat.contains( nCat )) { 222 if ( !cat.contains( nCat )) {
223 return false; 223 return false;
224 } 224 }
225 } 225 }
226 if ( from->isCompleted() ) { 226 if ( from->isCompleted() ) {
227 if ( !isCompleted() ) 227 if ( !isCompleted() )
228 return false; 228 return false;
229 } 229 }
230 if( priority() != from->priority() ) 230 if( priority() != from->priority() )
231 return false; 231 return false;
232 232
233 233
234 return true; 234 return true;
235 235
236} 236}
237bool KCal::operator==( const Todo& t1, const Todo& t2 ) 237bool KCal::operator==( const Todo& t1, const Todo& t2 )
238{ 238{
239 239
240 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 240 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
241 if ( ! ret ) 241 if ( ! ret )
242 return false; 242 return false;
243 if ( t1.hasDueDate() == t2.hasDueDate() ) { 243 if ( t1.hasDueDate() == t2.hasDueDate() ) {
244 if ( t1.hasDueDate() ) { 244 if ( t1.hasDueDate() ) {
245 if ( t1.doesFloat() == t2.doesFloat() ) { 245 if ( t1.doesFloat() == t2.doesFloat() ) {
246 if ( t1.doesFloat() ) { 246 if ( t1.doesFloat() ) {
247 if ( t1.dtDue().date() != t2.dtDue().date() ) 247 if ( t1.dtDue().date() != t2.dtDue().date() )
248 return false; 248 return false;
249 } else 249 } else
250 if ( t1.dtDue() != t2.dtDue() ) 250 if ( t1.dtDue() != t2.dtDue() )
251 return false; 251 return false;
252 } else 252 } else
253 return false;// float != 253 return false;// float !=
254 } 254 }
255 255
256 } else 256 } else
257 return false; 257 return false;
258 if ( t1.percentComplete() != t2.percentComplete() ) 258 if ( t1.percentComplete() != t2.percentComplete() )
259 return false; 259 return false;
260 if ( t1.isCompleted() ) { 260 if ( t1.isCompleted() ) {
261 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 261 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
@@ -439,142 +439,143 @@ bool Todo::isCompleted() const
439 439
440void Todo::setCompleted(bool completed) 440void Todo::setCompleted(bool completed)
441{ 441{
442 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 442 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
443 if ( !setRecurDates() ) 443 if ( !setRecurDates() )
444 completed = false; 444 completed = false;
445 } 445 }
446 if (completed) mPercentComplete = 100; 446 if (completed) mPercentComplete = 100;
447 else { 447 else {
448 mPercentComplete = 0; 448 mPercentComplete = 0;
449 mHasCompletedDate = false; 449 mHasCompletedDate = false;
450 } 450 }
451 updated(); 451 updated();
452} 452}
453 453
454QDateTime Todo::completed() const 454QDateTime Todo::completed() const
455{ 455{
456 return mCompleted; 456 return mCompleted;
457} 457}
458 458
459QString Todo::completedStr( bool shortF ) const 459QString Todo::completedStr( bool shortF ) const
460{ 460{
461 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 461 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
462} 462}
463 463
464void Todo::setCompleted(const QDateTime &completed) 464void Todo::setCompleted(const QDateTime &completed)
465{ 465{
466 //qDebug("Todo::setCompleted "); 466 //qDebug("Todo::setCompleted ");
467 if ( mHasCompletedDate ) { 467 if ( mHasCompletedDate ) {
468 // qDebug("has completed data - return "); 468 // qDebug("has completed data - return ");
469 return; 469 return;
470 } 470 }
471 mHasCompletedDate = true; 471 mHasCompletedDate = true;
472 mPercentComplete = 100; 472 mPercentComplete = 100;
473 mCompleted = getEvenTime(completed); 473 mCompleted = getEvenTime(completed);
474 updated(); 474 updated();
475} 475}
476 476
477bool Todo::hasCompletedDate() const 477bool Todo::hasCompletedDate() const
478{ 478{
479 return mHasCompletedDate; 479 return mHasCompletedDate;
480} 480}
481 481
482int Todo::percentComplete() const 482int Todo::percentComplete() const
483{ 483{
484 return mPercentComplete; 484 return mPercentComplete;
485} 485}
486bool Todo::setRecurDates() 486bool Todo::setRecurDates()
487{ 487{
488 if ( !mHasRecurrenceID ) 488 if ( !mHasRecurrenceID )
489 return true; 489 return true;
490 int secs = mDtStart.secsTo( dtDue() ); 490 int secs = mDtStart.secsTo( dtDue() );
491 bool ok; 491 bool ok;
492 qDebug("T:setRecurDates() "); 492 qDebug("T:setRecurDates() ");
493 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 493 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
494 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 494 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
495 if ( ok ) { 495 if ( ok ) {
496 mRecurrenceID = next; 496 mRecurrenceID = next;
497 mDtStart = next; 497 mDtStart = next;
498 setDtDue( next.addSecs( secs ) ); 498 setDtDue( next.addSecs( secs ) );
499 if ( QDateTime::currentDateTime() > next) 499 if ( QDateTime::currentDateTime() > next)
500 return false; 500 return false;
501 } else { 501 } else {
502 setHasRecurrenceID( false ); 502 setHasRecurrenceID( false );
503 recurrence()->unsetRecurs(); 503 recurrence()->unsetRecurs();
504 } 504 }
505 return true; 505 return true;
506} 506}
507void Todo::setPercentComplete(int v) 507void Todo::setPercentComplete(int v)
508{ 508{
509 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 509 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
510 if ( !setRecurDates() ) 510 if ( !setRecurDates() )
511 v = 0; 511 v = 0;
512 } 512 }
513 mPercentComplete = v; 513 mPercentComplete = v;
514 if ( v != 100 ) 514 if ( v != 100 )
515 mHasCompletedDate = false; 515 mHasCompletedDate = false;
516 updated(); 516 updated();
517} 517}
518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
519{ 519{
520 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 520 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
521 *ok = false; 521 *ok = false;
522 return QDateTime (); 522 return QDateTime ();
523 } 523 }
524 QDateTime incidenceStart; 524 QDateTime incidenceStart;
525 incidenceStart = dtDue(); 525 incidenceStart = dtDue();
526 bool enabled = false; 526 bool enabled = false;
527 Alarm* alarm; 527 Alarm* alarm;
528 int off = 0; 528 int off = 0;
529 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 529 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
530 // if ( QDateTime::currentDateTime() > incidenceStart ){ 530 // if ( QDateTime::currentDateTime() > incidenceStart ){
531// *ok = false; 531// *ok = false;
532// return incidenceStart; 532// return incidenceStart;
533// } 533// }
534 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 534 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
535 if (alarm->enabled()) { 535 if (alarm->enabled()) {
536 if ( alarm->hasTime () ) { 536 if ( alarm->hasTime () ) {
537 if ( alarm->time() < alarmStart ) { 537 if ( alarm->time() < alarmStart ) {
538 alarmStart = alarm->time(); 538 alarmStart = alarm->time();
539 enabled = true; 539 enabled = true;
540 off = alarmStart.secsTo( incidenceStart ); 540 off = alarmStart.secsTo( incidenceStart );
541 } 541 }
542 542
543 } else { 543 } else {
544 int secs = alarm->startOffset().asSeconds(); 544 int secs = alarm->startOffset().asSeconds();
545 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 545 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
546 alarmStart = incidenceStart.addSecs( secs ); 546 alarmStart = incidenceStart.addSecs( secs );
547 enabled = true; 547 enabled = true;
548 off = -secs; 548 off = -secs;
549 } 549 }
550 } 550 }
551 } 551 }
552 } 552 }
553 if ( enabled ) { 553 if ( enabled ) {
554 if ( alarmStart > start_dt ) { 554 if ( alarmStart > start_dt ) {
555 *ok = true; 555 *ok = true;
556 * offset = off; 556 * offset = off;
557 return alarmStart; 557 return alarmStart;
558 } 558 }
559 } 559 }
560 *ok = false; 560 *ok = false;
561 return QDateTime (); 561 return QDateTime ();
562 562
563} 563}
564 564
565void Todo::checkSetCompletedFalse() 565void Todo::checkSetCompletedFalse()
566{ 566{
567 if ( !hasRecurrenceID() ) { 567 if ( !mHasRecurrenceID ) {
568 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 568 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
569 return;
569 } 570 }
570 // qDebug("Todo::checkSetCompletedFalse()"); 571 // qDebug("Todo::checkSetCompletedFalse()");
571 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 572 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
572 if ( mPercentComplete == 100 ) { 573 if ( mPercentComplete == 100 ) {
573 QDateTime dt = QDateTime::currentDateTime(); 574 QDateTime dt = QDateTime::currentDateTime();
574 if ( dt > mDtStart && dt > mRecurrenceID ) { 575 if ( dt > mDtStart && dt > mRecurrenceID ) {
575 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 576 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
576 setCompleted( false ); 577 setCompleted( false );
577 qDebug("Todo::checkSetCompletedFalse "); 578 qDebug("Todo::checkSetCompletedFalse ");
578 } 579 }
579 } 580 }
580} 581}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index ab8fdf1..501c2ba 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -1,150 +1,151 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 This class provides a Todo in the sense of RFC2445. 33 This class provides a Todo in the sense of RFC2445.
34*/ 34*/
35 class Todo : public QObject,public Incidence 35 class Todo : public QObject,public Incidence
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 Todo(); 39 Todo();
40 Todo(const Todo &); 40 Todo(const Todo &);
41 ~Todo(); 41 ~Todo();
42 typedef ListBase<Todo> List; 42 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 43 QCString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; }
44 45
45 /** Return an exact copy of this todo. */ 46 /** Return an exact copy of this todo. */
46 Incidence *clone(); 47 Incidence *clone();
47 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
48 49
49 /** for setting the todo's due date/time with a QDateTime. */ 50 /** for setting the todo's due date/time with a QDateTime. */
50 void setDtDue(const QDateTime &dtDue); 51 void setDtDue(const QDateTime &dtDue);
51 /** returns an event's Due date/time as a QDateTime. */ 52 /** returns an event's Due date/time as a QDateTime. */
52 QDateTime dtDue() const; 53 QDateTime dtDue() const;
53 /** returns an event's due time as a string formatted according to the 54 /** returns an event's due time as a string formatted according to the
54 users locale settings */ 55 users locale settings */
55 QString dtDueTimeStr() const; 56 QString dtDueTimeStr() const;
56 /** returns an event's due date as a string formatted according to the 57 /** returns an event's due date as a string formatted according to the
57 users locale settings */ 58 users locale settings */
58 QString dtDueDateStr(bool shortfmt=true) const; 59 QString dtDueDateStr(bool shortfmt=true) const;
59 /** returns an event's due date and time as a string formatted according 60 /** returns an event's due date and time as a string formatted according
60 to the users locale settings */ 61 to the users locale settings */
61 QString dtDueStr(bool shortfmt=true) const; 62 QString dtDueStr(bool shortfmt=true) const;
62 63
63 /** returns TRUE or FALSE depending on whether the todo has a due date */ 64 /** returns TRUE or FALSE depending on whether the todo has a due date */
64 bool hasDueDate() const; 65 bool hasDueDate() const;
65 /** sets the event's hasDueDate value. */ 66 /** sets the event's hasDueDate value. */
66 void setHasDueDate(bool f); 67 void setHasDueDate(bool f);
67 68
68 /* 69 /*
69 Looks for a subtodo (including itself ) which is not complete and is 70 Looks for a subtodo (including itself ) which is not complete and is
70 - overdue, or 71 - overdue, or
71 - due today. 72 - due today.
72 It returns 0 for nothing found, 73 It returns 0 for nothing found,
73 1 for found a todo which is due today and no overdue found 74 1 for found a todo which is due today and no overdue found
74 2 for found a overdue todo 75 2 for found a overdue todo
75 */ 76 */
76 int hasDueSubTodo( bool checkSubtodos = true ); 77 int hasDueSubTodo( bool checkSubtodos = true );
77 /* same as above, but a specific date can be specified*/ 78 /* same as above, but a specific date can be specified*/
78 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ); 79 int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
79 80
80 81
81 /** sets the event's status to the string specified. The string 82 /** sets the event's status to the string specified. The string
82 * must be a recognized value for the status field, i.e. a string 83 * must be a recognized value for the status field, i.e. a string
83 * equivalent of the possible status enumerations previously described. */ 84 * equivalent of the possible status enumerations previously described. */
84// void setStatus(const QString &statStr); 85// void setStatus(const QString &statStr);
85 /** sets the event's status to the value specified. See the enumeration 86 /** sets the event's status to the value specified. See the enumeration
86 * above for possible values. */ 87 * above for possible values. */
87// void setStatus(int); 88// void setStatus(int);
88 /** return the event's status. */ 89 /** return the event's status. */
89// int status() const; 90// int status() const;
90 /** return the event's status in string format. */ 91 /** return the event's status in string format. */
91// QString statusStr() const; 92// QString statusStr() const;
92 93
93 /** return, if this todo is completed */ 94 /** return, if this todo is completed */
94 bool isCompleted() const; 95 bool isCompleted() const;
95 /** set completed state of this todo */ 96 /** set completed state of this todo */
96 void setCompleted(bool); 97 void setCompleted(bool);
97 98
98 /** 99 /**
99 Return how many percent of the task are completed. Returns a value 100 Return how many percent of the task are completed. Returns a value
100 between 0 and 100. 101 between 0 and 100.
101 */ 102 */
102 int percentComplete() const; 103 int percentComplete() const;
103 /** 104 /**
104 Set how many percent of the task are completed. Valid values are in the 105 Set how many percent of the task are completed. Valid values are in the
105 range from 0 to 100. 106 range from 0 to 100.
106 */ 107 */
107 void setPercentComplete(int); 108 void setPercentComplete(int);
108 109
109 /** return date and time when todo was completed */ 110 /** return date and time when todo was completed */
110 QDateTime completed() const; 111 QDateTime completed() const;
111 QString completedStr(bool shortF = true) const; 112 QString completedStr(bool shortF = true) const;
112 /** set date and time of completion */ 113 /** set date and time of completion */
113 void setCompleted(const QDateTime &completed); 114 void setCompleted(const QDateTime &completed);
114 115
115 /** Return true, if todo has a date associated with completion */ 116 /** Return true, if todo has a date associated with completion */
116 bool hasCompletedDate() const; 117 bool hasCompletedDate() const;
117 bool contains ( Todo*); 118 bool contains ( Todo*);
118 void checkSetCompletedFalse(); 119 void checkSetCompletedFalse();
119 bool setRecurDates(); 120 bool setRecurDates();
120 bool isRunning() {return mRunning;} 121 bool isRunning() {return mRunning;}
121 bool hasRunningSub(); 122 bool hasRunningSub();
122 void setRunning( bool ); 123 void setRunning( bool );
123 void setRunningFalse( QString ); 124 void setRunningFalse( QString );
124 int runTime(); 125 int runTime();
125 QDateTime runStart () const { return mRunStart;} 126 QDateTime runStart () const { return mRunStart;}
126 public slots: 127 public slots:
127 void saveRunningInfoToFile( QString st = QString::null ); 128 void saveRunningInfoToFile( QString st = QString::null );
128 void saveParents(); 129 void saveParents();
129 private: 130 private:
130 bool mRunning; 131 bool mRunning;
131 QTimer * mRunSaveTimer; 132 QTimer * mRunSaveTimer;
132 QDateTime mRunStart; 133 QDateTime mRunStart;
133 bool accept(Visitor &v) { return v.visit(this); } 134 bool accept(Visitor &v) { return v.visit(this); }
134 135
135 QDateTime mDtDue; // due date of todo 136 QDateTime mDtDue; // due date of todo
136 137
137 bool mHasDueDate; // if todo has associated due date 138 bool mHasDueDate; // if todo has associated due date
138 139
139// int mStatus; // confirmed/delegated/tentative/etc 140// int mStatus; // confirmed/delegated/tentative/etc
140 141
141 QDateTime mCompleted; 142 QDateTime mCompleted;
142 bool mHasCompletedDate; 143 bool mHasCompletedDate;
143 144
144 int mPercentComplete; 145 int mPercentComplete;
145}; 146};
146 147
147 bool operator==( const Todo&, const Todo& ); 148 bool operator==( const Todo&, const Todo& );
148} 149}
149 150
150#endif 151#endif