summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp3
-rw-r--r--korganizer/kodaymatrix.cpp4
-rw-r--r--korganizer/komonthview.cpp3
-rw-r--r--korganizer/kowhatsnextview.cpp8
-rw-r--r--libkcal/incidence.cpp32
-rw-r--r--libkcal/incidence.h5
6 files changed, 44 insertions, 11 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index e029fdb..eb3a6cd 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1357,130 +1357,129 @@ void KOAgendaView::updateEventIndicatorBottom(int newY)
1357void KOAgendaView::startDrag(Event *event) 1357void KOAgendaView::startDrag(Event *event)
1358{ 1358{
1359#ifndef KORG_NODND 1359#ifndef KORG_NODND
1360 DndFactory factory( calendar() ); 1360 DndFactory factory( calendar() );
1361 ICalDrag *vd = factory.createDrag(event,this); 1361 ICalDrag *vd = factory.createDrag(event,this);
1362 if (vd->drag()) { 1362 if (vd->drag()) {
1363 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1363 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1364 } 1364 }
1365#endif 1365#endif
1366} 1366}
1367 1367
1368void KOAgendaView::readSettings() 1368void KOAgendaView::readSettings()
1369{ 1369{
1370 readSettings(KOGlobals::config()); 1370 readSettings(KOGlobals::config());
1371} 1371}
1372 1372
1373void KOAgendaView::readSettings(KConfig *config) 1373void KOAgendaView::readSettings(KConfig *config)
1374{ 1374{
1375 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1375 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1376 1376
1377 config->setGroup("Views"); 1377 config->setGroup("Views");
1378 1378
1379 //#ifndef KORG_NOSPLITTER 1379 //#ifndef KORG_NOSPLITTER
1380 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1380 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1381 if (sizes.count() == 2) { 1381 if (sizes.count() == 2) {
1382 if ( sizes[0] < 20 ) { 1382 if ( sizes[0] < 20 ) {
1383 sizes[1] = sizes[1] +20 - sizes[0]; 1383 sizes[1] = sizes[1] +20 - sizes[0];
1384 sizes[0] = 20; 1384 sizes[0] = 20;
1385 } 1385 }
1386 mSplitterAgenda->setSizes(sizes); 1386 mSplitterAgenda->setSizes(sizes);
1387 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1387 // qDebug("read %d %d ",sizes[0],sizes[1] );
1388 } 1388 }
1389 //#endif 1389 //#endif
1390 1390
1391 // updateConfig(); 1391 // updateConfig();
1392} 1392}
1393 1393
1394void KOAgendaView::writeSettings(KConfig *config) 1394void KOAgendaView::writeSettings(KConfig *config)
1395{ 1395{
1396 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1396 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1397 1397
1398 config->setGroup("Views"); 1398 config->setGroup("Views");
1399 1399
1400 //#ifndef KORG_NOSPLITTER 1400 //#ifndef KORG_NOSPLITTER
1401 QValueList<int> list = mSplitterAgenda->sizes(); 1401 QValueList<int> list = mSplitterAgenda->sizes();
1402 config->writeEntry("Separator AgendaView",list); 1402 config->writeEntry("Separator AgendaView",list);
1403 //qDebug("write %d %d ", list[0],list[1] ); 1403 //qDebug("write %d %d ", list[0],list[1] );
1404 //#endif 1404 //#endif
1405} 1405}
1406 1406
1407void KOAgendaView::setHolidayMasks() 1407void KOAgendaView::setHolidayMasks()
1408{ 1408{
1409 mHolidayMask.resize(mSelectedDates.count()); 1409 mHolidayMask.resize(mSelectedDates.count());
1410 1410
1411 uint i; 1411 uint i;
1412 for(i=0;i<mSelectedDates.count();++i) { 1412 for(i=0;i<mSelectedDates.count();++i) {
1413 QDate date = mSelectedDates[i]; 1413 QDate date = mSelectedDates[i];
1414 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1414 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1415 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1415 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1416 bool showHoliday = false; 1416 bool showHoliday = false;
1417 if ( KOPrefs::instance()->mExcludeHolidays ) { 1417 if ( KOPrefs::instance()->mExcludeHolidays ) {
1418 QPtrList<Event> events = calendar()->events( date, true ); 1418 QPtrList<Event> events = calendar()->events( date, true );
1419 Event *event; 1419 Event *event;
1420 for( event = events.first(); event; event = events.next() ) { 1420 for( event = events.first(); event; event = events.next() ) {
1421 if ( event->categories().contains("Holiday") || 1421 if ( event->isHoliday()) {
1422 event->categories().contains(i18n("Holiday"))) {
1423 showHoliday = true; 1422 showHoliday = true;
1424 break; 1423 break;
1425 } 1424 }
1426 } 1425 }
1427 1426
1428 } 1427 }
1429 1428
1430#ifndef KORG_NOPLUGINS 1429#ifndef KORG_NOPLUGINS
1431 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1430 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1432 !KOCore::self()->holiday(date).isEmpty(); 1431 !KOCore::self()->holiday(date).isEmpty();
1433#endif 1432#endif
1434 bool showDay = showSaturday || showSunday || showHoliday; 1433 bool showDay = showSaturday || showSunday || showHoliday;
1435 1434
1436 if (showDay) { 1435 if (showDay) {
1437 mHolidayMask.at(i) = true; 1436 mHolidayMask.at(i) = true;
1438 } else { 1437 } else {
1439 mHolidayMask.at(i) = false; 1438 mHolidayMask.at(i) = false;
1440 } 1439 }
1441 } 1440 }
1442 1441
1443 mAgenda->setHolidayMask(&mHolidayMask); 1442 mAgenda->setHolidayMask(&mHolidayMask);
1444 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1443 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1445} 1444}
1446 1445
1447void KOAgendaView::setContentsPos(int y) 1446void KOAgendaView::setContentsPos(int y)
1448{ 1447{
1449 mAgenda->setContentsPos(0,y); 1448 mAgenda->setContentsPos(0,y);
1450} 1449}
1451 1450
1452void KOAgendaView::setExpandedButton( bool expanded ) 1451void KOAgendaView::setExpandedButton( bool expanded )
1453{ 1452{
1454 if ( expanded ) { 1453 if ( expanded ) {
1455 mExpandButton->setPixmap( mExpandedPixmap ); 1454 mExpandButton->setPixmap( mExpandedPixmap );
1456 } else { 1455 } else {
1457 mExpandButton->setPixmap( mNotExpandedPixmap ); 1456 mExpandButton->setPixmap( mNotExpandedPixmap );
1458 } 1457 }
1459} 1458}
1460 1459
1461void KOAgendaView::clearSelection() 1460void KOAgendaView::clearSelection()
1462{ 1461{
1463 mAgenda->deselectItem(); 1462 mAgenda->deselectItem();
1464 mAllDayAgenda->deselectItem(); 1463 mAllDayAgenda->deselectItem();
1465} 1464}
1466 1465
1467void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1466void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1468 int gxEnd, int gyEnd) 1467 int gxEnd, int gyEnd)
1469{ 1468{
1470 mTimeSpanInAllDay = true; 1469 mTimeSpanInAllDay = true;
1471 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1470 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1472} 1471}
1473 1472
1474 1473
1475 1474
1476 1475
1477void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1476void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1478 int gxEnd, int gyEnd) 1477 int gxEnd, int gyEnd)
1479{ 1478{
1480 if (!mSelectedDates.count()) return; 1479 if (!mSelectedDates.count()) return;
1481 1480
1482 QDate dayStart = mSelectedDates[gxStart]; 1481 QDate dayStart = mSelectedDates[gxStart];
1483 QDate dayEnd = mSelectedDates[gxEnd]; 1482 QDate dayEnd = mSelectedDates[gxEnd];
1484 1483
1485 QTime timeStart = mAgenda->gyToTime(gyStart); 1484 QTime timeStart = mAgenda->gyToTime(gyStart);
1486 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1485 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index d7a4112..36cd990 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -287,136 +287,136 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays)
287void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 287void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
288{ 288{
289 mSelStart = startdate.daysTo(start); 289 mSelStart = startdate.daysTo(start);
290 if ( mSelStart < 0 ) 290 if ( mSelStart < 0 )
291 mSelStart = 0; 291 mSelStart = 0;
292 mSelEnd = startdate.daysTo(end); 292 mSelEnd = startdate.daysTo(end);
293 //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); 293 //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd );
294 if ( mSelEnd < 0 ) 294 if ( mSelEnd < 0 )
295 clearSelection(); 295 clearSelection();
296} 296}
297void KODayMatrix::clearSelection() 297void KODayMatrix::clearSelection()
298{ 298{
299 mSelEnd = mSelStart = NOSELECTION; 299 mSelEnd = mSelStart = NOSELECTION;
300} 300}
301 301
302 302
303void KODayMatrix::recalculateToday() 303void KODayMatrix::recalculateToday()
304{ 304{
305 today = -1; 305 today = -1;
306 for (int i=0; i<NUMDAYS; i++) { 306 for (int i=0; i<NUMDAYS; i++) {
307 events[i] = 0; 307 events[i] = 0;
308 days[i] = startdate.addDays(i); 308 days[i] = startdate.addDays(i);
309 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 309 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
310 310
311 // if today is in the currently displayed month, hilight today 311 // if today is in the currently displayed month, hilight today
312 if (days[i].year() == QDate::currentDate().year() && 312 if (days[i].year() == QDate::currentDate().year() &&
313 days[i].month() == QDate::currentDate().month() && 313 days[i].month() == QDate::currentDate().month() &&
314 days[i].day() == QDate::currentDate().day()) { 314 days[i].day() == QDate::currentDate().day()) {
315 today = i; 315 today = i;
316 } 316 }
317 } 317 }
318 // qDebug(QString("Today is visible at %1.").arg(today)); 318 // qDebug(QString("Today is visible at %1.").arg(today));
319} 319}
320 320
321void KODayMatrix::updateView() 321void KODayMatrix::updateView()
322{ 322{
323 updateView(startdate); 323 updateView(startdate);
324} 324}
325void KODayMatrix::repaintViewTimed() 325void KODayMatrix::repaintViewTimed()
326{ 326{
327 mRepaintTimer->stop(); 327 mRepaintTimer->stop();
328 repaint(false); 328 repaint(false);
329} 329}
330void KODayMatrix::updateViewTimed() 330void KODayMatrix::updateViewTimed()
331{ 331{
332 mUpdateTimer->stop(); 332 mUpdateTimer->stop();
333 if ( !mCalendar ) { 333 if ( !mCalendar ) {
334 qDebug("NOT CAL "); 334 qDebug("NOT CAL ");
335 return; 335 return;
336 } 336 }
337 //qDebug("KODayMatrix::updateViewTimed "); 337 //qDebug("KODayMatrix::updateViewTimed ");
338 for(int i = 0; i < NUMDAYS; i++) { 338 for(int i = 0; i < NUMDAYS; i++) {
339 // if events are set for the day then remember to draw it bold 339 // if events are set for the day then remember to draw it bold
340 QPtrList<Event> eventlist = mCalendar->events(days[i]); 340 QPtrList<Event> eventlist = mCalendar->events(days[i]);
341 Event *event; 341 Event *event;
342 int numEvents = eventlist.count(); 342 int numEvents = eventlist.count();
343 QString holiStr = ""; 343 QString holiStr = "";
344 bDays.clearBit(i); 344 bDays.clearBit(i);
345 for(event=eventlist.first();event != 0;event=eventlist.next()) { 345 for(event=eventlist.first();event != 0;event=eventlist.next()) {
346 ushort recurType = event->recurrence()->doesRecur(); 346 ushort recurType = event->recurrence()->doesRecur();
347 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 347 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
348 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 348 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
349 numEvents--; 349 numEvents--;
350 } 350 }
351 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { 351 if ( event->isHoliday()) {
352 if ( !holiStr.isEmpty() ) 352 if ( !holiStr.isEmpty() )
353 holiStr += "\n"; 353 holiStr += "\n";
354 holiStr += event->summary(); 354 holiStr += event->summary();
355 if ( !event->location().isEmpty() ) 355 if ( !event->location().isEmpty() )
356 holiStr += " (" + event->location() + ")"; 356 holiStr += " (" + event->location() + ")";
357 } 357 }
358 if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { 358 if ( event->isBirthday()) {
359 if ( !holiStr.isEmpty() ) 359 if ( !holiStr.isEmpty() )
360 holiStr += "\n"; 360 holiStr += "\n";
361 holiStr += i18n("Birthday") + ": "+event->summary(); 361 holiStr += i18n("Birthday") + ": "+event->summary();
362 if ( !event->location().isEmpty() ) 362 if ( !event->location().isEmpty() )
363 holiStr += " (" + event->location() + ")"; 363 holiStr += " (" + event->location() + ")";
364 bDays.setBit(i); 364 bDays.setBit(i);
365 } 365 }
366 } 366 }
367 events[i] = numEvents; 367 events[i] = numEvents;
368 //if it is a holy day then draw it red. Sundays are consider holidays, too 368 //if it is a holy day then draw it red. Sundays are consider holidays, too
369 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 369 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
370 !holiStr.isEmpty()) { 370 !holiStr.isEmpty()) {
371 mHolidays[i] = holiStr; 371 mHolidays[i] = holiStr;
372 } else { 372 } else {
373 mHolidays[i] = QString::null; 373 mHolidays[i] = QString::null;
374 } 374 }
375 } 375 }
376 if ( ! mPendingUpdateBeforeRepaint ) 376 if ( ! mPendingUpdateBeforeRepaint )
377 repaint(false); 377 repaint(false);
378} 378}
379void KODayMatrix::updateView(QDate actdate) 379void KODayMatrix::updateView(QDate actdate)
380{ 380{
381 381
382 if ( ! actdate.isValid() ) { 382 if ( ! actdate.isValid() ) {
383 //qDebug("date not valid "); 383 //qDebug("date not valid ");
384 return; 384 return;
385 } 385 }
386 mDayChanged = false; 386 mDayChanged = false;
387 //flag to indicate if the starting day of the matrix has changed by this call 387 //flag to indicate if the starting day of the matrix has changed by this call
388 //mDayChanged = false; 388 //mDayChanged = false;
389 // if a new startdate is to be set then apply Cornelius's calculation 389 // if a new startdate is to be set then apply Cornelius's calculation
390 // of the first day to be shown 390 // of the first day to be shown
391 if (actdate != startdate) { 391 if (actdate != startdate) {
392 // reset index of selection according to shift of starting date from startdate to actdate 392 // reset index of selection according to shift of starting date from startdate to actdate
393 if (mSelStart != NOSELECTION) { 393 if (mSelStart != NOSELECTION) {
394 int tmp = actdate.daysTo(startdate); 394 int tmp = actdate.daysTo(startdate);
395 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 395 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
396 // shift selection if new one would be visible at least partly ! 396 // shift selection if new one would be visible at least partly !
397 397
398 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 398 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
399 // nested if is required for next X display pushed from a different month - correction required 399 // nested if is required for next X display pushed from a different month - correction required
400 // otherwise, for month forward and backward, it must be avoided 400 // otherwise, for month forward and backward, it must be avoided
401 if( mSelStart > NUMDAYS || mSelStart < 0 ) 401 if( mSelStart > NUMDAYS || mSelStart < 0 )
402 mSelStart = mSelStart + tmp; 402 mSelStart = mSelStart + tmp;
403 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 403 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
404 mSelEnd = mSelEnd + tmp; 404 mSelEnd = mSelEnd + tmp;
405 } 405 }
406 } 406 }
407 startdate = actdate; 407 startdate = actdate;
408 mDayChanged = true; 408 mDayChanged = true;
409 recalculateToday(); 409 recalculateToday();
410 } 410 }
411 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 411 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
412 if ( !isVisible() ) { 412 if ( !isVisible() ) {
413 mPendingUpdateBeforeRepaint = true; 413 mPendingUpdateBeforeRepaint = true;
414 } else { 414 } else {
415#ifdef DESKTOP_VERSION 415#ifdef DESKTOP_VERSION
416 //mRepaintTimer->start( 100 ); 416 //mRepaintTimer->start( 100 );
417 mUpdateTimer->start( 100 ); 417 mUpdateTimer->start( 100 );
418#else 418#else
419 mRepaintTimer->start( 350 ); 419 mRepaintTimer->start( 350 );
420 mUpdateTimer->start( 1200 ); 420 mUpdateTimer->start( 1200 );
421#endif 421#endif
422 } 422 }
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 004ff50..76982b4 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -454,130 +454,129 @@ void MonthViewCell::setHoliday( bool holiday )
454} 454}
455 455
456void MonthViewCell::setHoliday( const QString &holiday ) 456void MonthViewCell::setHoliday( const QString &holiday )
457{ 457{
458 mHolidayString = holiday; 458 mHolidayString = holiday;
459 459
460 if ( !holiday.isEmpty() ) { 460 if ( !holiday.isEmpty() ) {
461 setHoliday( true ); 461 setHoliday( true );
462 } 462 }
463} 463}
464void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 464void MonthViewCell::keyPressEvent ( QKeyEvent * e )
465{ 465{
466 466
467 e->ignore(); 467 e->ignore();
468 468
469} 469}
470 470
471void MonthViewCell::startUpdateCell() 471void MonthViewCell::startUpdateCell()
472{ 472{
473 473
474 mItemList->setFocusPolicy(NoFocus); 474 mItemList->setFocusPolicy(NoFocus);
475 if ( !mMonthView->isUpdatePossible() ) 475 if ( !mMonthView->isUpdatePossible() )
476 return; 476 return;
477 477
478 /* 478 /*
479 if ( !isVisible() ){ 479 if ( !isVisible() ){
480 return; 480 return;
481 } 481 }
482 */ 482 */
483 // qDebug("MonthViewCell::updateCell() "); 483 // qDebug("MonthViewCell::updateCell() ");
484 setPrimary( mDate.month()%2 ); 484 setPrimary( mDate.month()%2 );
485 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 485 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
486 if ( mDate == QDate::currentDate() ) { 486 if ( mDate == QDate::currentDate() ) {
487 mItemList->setLineWidth( 3 ); 487 mItemList->setLineWidth( 3 );
488 } else { 488 } else {
489 mItemList->setLineWidth( 1 ); 489 mItemList->setLineWidth( 1 );
490 } 490 }
491 mItemList->clear(); 491 mItemList->clear();
492 492
493#ifdef DESKTOP_VERSION 493#ifdef DESKTOP_VERSION
494 QToolTip::remove(this); 494 QToolTip::remove(this);
495#endif 495#endif
496 mToolTip.clear(); 496 mToolTip.clear();
497 //qApp->processEvents(); 497 //qApp->processEvents();
498 if ( !mHolidayString.isEmpty() ) { 498 if ( !mHolidayString.isEmpty() ) {
499 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 499 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
500 item->setPalette( mHolidayPalette ); 500 item->setPalette( mHolidayPalette );
501 mItemList->insertItem( item ); 501 mItemList->insertItem( item );
502 mToolTip.append ( mHolidayString ); 502 mToolTip.append ( mHolidayString );
503 } 503 }
504} 504}
505 505
506void MonthViewCell::insertEvent(Event *event) 506void MonthViewCell::insertEvent(Event *event)
507{ 507{
508 QString mToolTipText; 508 QString mToolTipText;
509 mItemList->setFocusPolicy(WheelFocus); 509 mItemList->setFocusPolicy(WheelFocus);
510 if ( !(event->doesRecur() == Recurrence::rNone) ) { 510 if ( !(event->doesRecur() == Recurrence::rNone) ) {
511 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 511 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
512 return; 512 return;
513 else 513 else
514 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 514 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
515 return; 515 return;
516 } 516 }
517 517
518 if ( event->categories().contains("Holiday") || 518 if ( event->isHoliday()) {
519 event->categories().contains(i18n("Holiday"))) {
520 setHoliday( true ); 519 setHoliday( true );
521 if ( mDate.dayOfWeek() == 7 ) 520 if ( mDate.dayOfWeek() == 7 )
522 mItemList->setLineWidth( 3 ); 521 mItemList->setLineWidth( 3 );
523 } 522 }
524 QString text; 523 QString text;
525 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 524 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
526 if (event->isMultiDay()) { 525 if (event->isMultiDay()) {
527 QString prefix = "<->";multiday = 2; 526 QString prefix = "<->";multiday = 2;
528 QString time; 527 QString time;
529 if ( event->doesRecur() ) { 528 if ( event->doesRecur() ) {
530 if ( event->recursOn( mDate) ) { 529 if ( event->recursOn( mDate) ) {
531 prefix ="->" ;multiday = 1; 530 prefix ="->" ;multiday = 1;
532 } 531 }
533 else { 532 else {
534 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 533 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
535 if ( event->recursOn( mDate.addDays( -days)) ) { 534 if ( event->recursOn( mDate.addDays( -days)) ) {
536 prefix ="<-" ;multiday = 3; 535 prefix ="<-" ;multiday = 3;
537 } 536 }
538 } 537 }
539 538
540 } else { 539 } else {
541 if (mDate == event->dtStart().date()) { 540 if (mDate == event->dtStart().date()) {
542 prefix ="->" ;multiday = 1; 541 prefix ="->" ;multiday = 1;
543 } else if (mDate == event->dtEnd().date()) { 542 } else if (mDate == event->dtEnd().date()) {
544 prefix ="<-" ;multiday = 3; 543 prefix ="<-" ;multiday = 3;
545 } 544 }
546 } 545 }
547 if ( !event->doesFloat() ) { 546 if ( !event->doesFloat() ) {
548 if ( mDate == event->dtStart().date () ) 547 if ( mDate == event->dtStart().date () )
549 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 548 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
550 else if ( mDate == event->dtEnd().date () ) 549 else if ( mDate == event->dtEnd().date () )
551 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 550 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
552 551
553 } 552 }
554 text = time + event->summary(); 553 text = time + event->summary();
555 mToolTipText += prefix + text; 554 mToolTipText += prefix + text;
556 } else { 555 } else {
557 if (event->doesFloat()) { 556 if (event->doesFloat()) {
558 text = event->summary(); 557 text = event->summary();
559 mToolTipText += text; 558 mToolTipText += text;
560 } 559 }
561 else { 560 else {
562 text = KGlobal::locale()->formatTime(event->dtStart().time()); 561 text = KGlobal::locale()->formatTime(event->dtStart().time());
563 text += " " + event->summary(); 562 text += " " + event->summary();
564 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 563 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
565 } 564 }
566 } 565 }
567 566
568 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 567 MonthViewItem *item = new MonthViewItem( event, mDate, text );
569 QPalette pal; 568 QPalette pal;
570 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 569 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
571 QStringList categories = event->categories(); 570 QStringList categories = event->categories();
572 QString cat = categories.first(); 571 QString cat = categories.first();
573 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 572 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
574 pal = getPalette(); 573 pal = getPalette();
575 if (cat.isEmpty()) { 574 if (cat.isEmpty()) {
576 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 575 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
577 } else { 576 } else {
578 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 577 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
579 } 578 }
580 579
581 } else { 580 } else {
582 if (cat.isEmpty()) { 581 if (cat.isEmpty()) {
583 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 582 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 18dc656..66ff75d 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -417,190 +417,190 @@ void KOWhatsNextView::appendDay( int i, QDate eventDate )
417 417
418#ifdef DESKTOP_VERSION 418#ifdef DESKTOP_VERSION
419 else if ( i == 1 ) { 419 else if ( i == 1 ) {
420 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 420 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
421 } 421 }
422 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 422 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
423#else 423#else
424 else if ( i == 1 ) { 424 else if ( i == 1 ) {
425 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 425 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
426 } 426 }
427 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 427 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
428 428
429#endif 429#endif
430 mText += "<h2>" + date + "</h2>\n"; 430 mText += "<h2>" + date + "</h2>\n";
431 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 431 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
432 mText += "<table>\n"; 432 mText += "<table>\n";
433 } 433 }
434} 434}
435 435
436 436
437void KOWhatsNextView::showDates(const QDate &, const QDate &) 437void KOWhatsNextView::showDates(const QDate &, const QDate &)
438{ 438{
439 updateView(); 439 updateView();
440} 440}
441 441
442void KOWhatsNextView::showEvents(QPtrList<Event>) 442void KOWhatsNextView::showEvents(QPtrList<Event>)
443{ 443{
444} 444}
445 445
446void KOWhatsNextView::changeEventDisplay(Event *, int action) 446void KOWhatsNextView::changeEventDisplay(Event *, int action)
447{ 447{
448 switch(action) { 448 switch(action) {
449 case KOGlobals::EVENTADDED: 449 case KOGlobals::EVENTADDED:
450 updateView(); 450 updateView();
451 break; 451 break;
452 case KOGlobals::EVENTEDITED: 452 case KOGlobals::EVENTEDITED:
453 updateView(); 453 updateView();
454 break; 454 break;
455 case KOGlobals::EVENTDELETED: 455 case KOGlobals::EVENTDELETED:
456 updateView(); 456 updateView();
457 break; 457 break;
458 default: 458 default:
459 updateView(); 459 updateView();
460 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 460 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
461 } 461 }
462} 462}
463 463
464bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 464bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
465{ 465{
466 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 466 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
467 return false; 467 return false;
468 QDateTime cdt = QDateTime::currentDateTime(); 468 QDateTime cdt = QDateTime::currentDateTime();
469 QDateTime noc; 469 QDateTime noc;
470 QString tempText; 470 QString tempText;
471 if ( appendTable && !notRed ) { 471 if ( appendTable && !notRed ) {
472 tempText = "<table>"; 472 tempText = "<table>";
473 } 473 }
474 bool ok = true; 474 bool ok = true;
475 if ( reply ) { 475 if ( reply ) {
476 noc = ev->getNextOccurence( cdt, &ok ); 476 noc = ev->getNextOccurence( cdt, &ok );
477 if (! ok && ev->type() == "Event") 477 if (! ok && ev->type() == "Event")
478 return false; 478 return false;
479 } 479 }
480 bool bDay = false; 480 bool bDay = false;
481 if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) 481 if ( ev->isBirthday() || ev->isAnniversary() )
482 bDay = true; 482 bDay = true;
483 tempText += "<tr><td><b>"; 483 tempText += "<tr><td><b>";
484 if (ev->type()=="Event") { 484 if (ev->type()=="Event") {
485 if (reply) { 485 if (reply) {
486 if (!ev->doesFloat()) 486 if (!ev->doesFloat())
487 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 487 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
488 else 488 else
489 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 489 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
490 490
491 } else { 491 } else {
492 if (!ev->doesFloat()) { 492 if (!ev->doesFloat()) {
493 Event *event = static_cast<Event *>(ev); 493 Event *event = static_cast<Event *>(ev);
494 QDateTime st,end; 494 QDateTime st,end;
495 if ( event->recurrence()->doesRecur() ) { 495 if ( event->recurrence()->doesRecur() ) {
496 QDate recDate= mEventDate; 496 QDate recDate= mEventDate;
497 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 497 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
498 while ( ! event->recursOn( recDate ) ) { 498 while ( ! event->recursOn( recDate ) ) {
499 recDate = recDate.addDays( -1 ); 499 recDate = recDate.addDays( -1 );
500 500
501 } 501 }
502 st = QDateTime ( recDate, event->dtStart().time() ); 502 st = QDateTime ( recDate, event->dtStart().time() );
503 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 503 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
504 } 504 }
505 else { 505 else {
506 st = event->dtStart(); 506 st = event->dtStart();
507 end = event->dtEnd(); 507 end = event->dtEnd();
508 } 508 }
509 509
510 510
511 QString dateText; 511 QString dateText;
512 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 512 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
513 if ( st.date() < mEventDate ) 513 if ( st.date() < mEventDate )
514 dateText = "++:++-"; 514 dateText = "++:++-";
515 else 515 else
516 dateText = event->dtStartTimeStr() + "-"; 516 dateText = event->dtStartTimeStr() + "-";
517 if ( end.date() > mEventDate ) 517 if ( end.date() > mEventDate )
518 dateText += "++:++"; 518 dateText += "++:++";
519 else 519 else
520 dateText += event->dtEndTimeStr(); 520 dateText += event->dtEndTimeStr();
521 if ( notRed ) 521 if ( notRed )
522 tempText += dateText; 522 tempText += dateText;
523 else { 523 else {
524 if ( end < cdt ) { 524 if ( end < cdt ) {
525 if ( !KOPrefs::instance()->mWNViewShowsPast ) 525 if ( !KOPrefs::instance()->mWNViewShowsPast )
526 return false; 526 return false;
527 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 527 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
528 } 528 }
529 else if ( st < cdt ) 529 else if ( st < cdt )
530 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 530 tempText += "<font color=\"#008000\">" + dateText + "</font>";
531 else 531 else
532 tempText += dateText; 532 tempText += dateText;
533 533
534 } 534 }
535 535
536 } else { 536 } else {
537 if ( bDay ) { 537 if ( bDay ) {
538 538
539 if ( ev->categories().contains( i18n("Birthday") )) 539 if ( ev->isBirthday())
540 tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; 540 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>";
541 else 541 else
542 tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; 542 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>";
543 } else { 543 } else {
544 tempText += i18n("Allday:"); 544 tempText += i18n("Allday:");
545 } 545 }
546 546
547 } 547 }
548 } 548 }
549 } else { 549 } else {
550 mTodos.append( ev ); 550 mTodos.append( ev );
551 tempText += i18n("ToDo:"); 551 tempText += i18n("ToDo:");
552 if (reply) { 552 if (reply) {
553 tempText += " "; 553 tempText += " ";
554 if ( noc != cdt ) { 554 if ( noc != cdt ) {
555 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 555 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
556 } 556 }
557 } else { 557 } else {
558 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 558 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
559 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 559 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
560 QString dfs = KGlobal::locale()->dateFormatShort(); 560 QString dfs = KGlobal::locale()->dateFormatShort();
561 KGlobal::locale()->setDateFormatShort("%d.%b"); 561 KGlobal::locale()->setDateFormatShort("%d.%b");
562 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 562 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
563 KGlobal::locale()->setDateFormatShort(dfs); 563 KGlobal::locale()->setDateFormatShort(dfs);
564 } else { 564 } else {
565 if (!ev->doesFloat() ) 565 if (!ev->doesFloat() )
566 if( ( (Todo*)ev)->dtDue() < cdt ) { 566 if( ( (Todo*)ev)->dtDue() < cdt ) {
567 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 567 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
568 568
569 569
570 } else 570 } else
571 tempText +=((Todo*)ev)->dtDueTimeStr(); 571 tempText +=((Todo*)ev)->dtDueTimeStr();
572 mTodos.append( ev ); 572 mTodos.append( ev );
573 } 573 }
574 } 574 }
575 } 575 }
576 tempText += "</b></td><td>"; 576 tempText += "</b></td><td>";
577 bool needClose = false; 577 bool needClose = false;
578 if ( ev->cancelled() ) { 578 if ( ev->cancelled() ) {
579 tempText += "<font color=\"#F00000\">[c"; 579 tempText += "<font color=\"#F00000\">[c";
580 needClose =true; 580 needClose =true;
581 581
582 } 582 }
583 if ( ev->isAlarmEnabled() ) { 583 if ( ev->isAlarmEnabled() ) {
584 if ( !needClose) 584 if ( !needClose)
585 tempText +="["; 585 tempText +="[";
586 tempText += "a"; 586 tempText += "a";
587 needClose =true; 587 needClose =true;
588 588
589 } 589 }
590 if ( ev->description().length() > 0 ) { 590 if ( ev->description().length() > 0 ) {
591 if ( !needClose) 591 if ( !needClose)
592 tempText +="["; 592 tempText +="[";
593 tempText += "i"; 593 tempText += "i";
594 needClose =true; 594 needClose =true;
595 } 595 }
596 if ( ev->recurrence()->doesRecur() ) { 596 if ( ev->recurrence()->doesRecur() ) {
597 if ( !needClose) 597 if ( !needClose)
598 tempText +="["; 598 tempText +="[";
599 tempText += "r"; 599 tempText += "r";
600 needClose =true; 600 needClose =true;
601 } 601 }
602 if ( needClose ) { 602 if ( needClose ) {
603 tempText += "] "; 603 tempText += "] ";
604 } 604 }
605 if ( ev->cancelled() ) 605 if ( ev->cancelled() )
606 tempText += "</font>"; 606 tempText += "</font>";
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 708ee6b..9a36939 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,155 +1,178 @@
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 <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32Incidence::Incidence() : 32Incidence::Incidence() :
33 IncidenceBase(), 33 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = new Recurrence(this); 36 mRecurrence = new Recurrence(this);
37 mCancelled = false; 37 mCancelled = false;
38 recreate(); 38 recreate();
39 mHasStartDate = true; 39 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 40 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 41 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 42 mHasRecurrenceID = false;
43 mHoliday = false;
44 mBirthday = false;
45 mAnniversary = false;
46
43} 47}
44 48
45Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
46{ 50{
47// TODO: reenable attributes currently commented out. 51// TODO: reenable attributes currently commented out.
48 mRevision = i.mRevision; 52 mRevision = i.mRevision;
49 mCreated = i.mCreated; 53 mCreated = i.mCreated;
50 mDescription = i.mDescription; 54 mDescription = i.mDescription;
51 mSummary = i.mSummary; 55 mSummary = i.mSummary;
52 mCategories = i.mCategories; 56 mCategories = i.mCategories;
53// Incidence *mRelatedTo; Incidence *mRelatedTo; 57// Incidence *mRelatedTo; Incidence *mRelatedTo;
54 mRelatedTo = 0; 58 mRelatedTo = 0;
55 mRelatedToUid = i.mRelatedToUid; 59 mRelatedToUid = i.mRelatedToUid;
56// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
57 mExDates = i.mExDates; 61 mExDates = i.mExDates;
58 mAttachments = i.mAttachments; 62 mAttachments = i.mAttachments;
59 mResources = i.mResources; 63 mResources = i.mResources;
60 mSecrecy = i.mSecrecy; 64 mSecrecy = i.mSecrecy;
61 mPriority = i.mPriority; 65 mPriority = i.mPriority;
62 mLocation = i.mLocation; 66 mLocation = i.mLocation;
63 mCancelled = i.mCancelled; 67 mCancelled = i.mCancelled;
64 mHasStartDate = i.mHasStartDate; 68 mHasStartDate = i.mHasStartDate;
65 QPtrListIterator<Alarm> it( i.mAlarms ); 69 QPtrListIterator<Alarm> it( i.mAlarms );
66 const Alarm *a; 70 const Alarm *a;
67 while( (a = it.current()) ) { 71 while( (a = it.current()) ) {
68 Alarm *b = new Alarm( *a ); 72 Alarm *b = new Alarm( *a );
69 b->setParent( this ); 73 b->setParent( this );
70 mAlarms.append( b ); 74 mAlarms.append( b );
71 75
72 ++it; 76 ++it;
73 } 77 }
74 mAlarms.setAutoDelete(true); 78 mAlarms.setAutoDelete(true);
75 mHasRecurrenceID = i.mHasRecurrenceID; 79 mHasRecurrenceID = i.mHasRecurrenceID;
76 mRecurrenceID = i.mRecurrenceID; 80 mRecurrenceID = i.mRecurrenceID;
77 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 81 mRecurrence = new Recurrence( *(i.mRecurrence), this );
82 mHoliday = i.mHoliday ;
83 mBirthday = i.mBirthday;
84 mAnniversary = i.mAnniversary;
78} 85}
79 86
80Incidence::~Incidence() 87Incidence::~Incidence()
81{ 88{
82 89
83 Incidence *ev; 90 Incidence *ev;
84 QPtrList<Incidence> Relations = relations(); 91 QPtrList<Incidence> Relations = relations();
85 for (ev=Relations.first();ev;ev=Relations.next()) { 92 for (ev=Relations.first();ev;ev=Relations.next()) {
86 if (ev->relatedTo() == this) ev->setRelatedTo(0); 93 if (ev->relatedTo() == this) ev->setRelatedTo(0);
87 } 94 }
88 if (relatedTo()) relatedTo()->removeRelation(this); 95 if (relatedTo()) relatedTo()->removeRelation(this);
89 delete mRecurrence; 96 delete mRecurrence;
90 97
91} 98}
99
100bool Incidence::isHoliday() const
101{
102 return mHoliday;
103}
104bool Incidence::isBirthday() const
105{
106
107 return mBirthday ;
108}
109bool Incidence::isAnniversary() const
110{
111 return mAnniversary ;
112
113}
114
92bool Incidence::hasRecurrenceID() const 115bool Incidence::hasRecurrenceID() const
93{ 116{
94 return mHasRecurrenceID; 117 return mHasRecurrenceID;
95} 118}
96 119
97void Incidence::setHasRecurrenceID( bool b ) 120void Incidence::setHasRecurrenceID( bool b )
98{ 121{
99 mHasRecurrenceID = b; 122 mHasRecurrenceID = b;
100} 123}
101 124
102void Incidence::setRecurrenceID(QDateTime d) 125void Incidence::setRecurrenceID(QDateTime d)
103{ 126{
104 mRecurrenceID = d; 127 mRecurrenceID = d;
105 mHasRecurrenceID = true; 128 mHasRecurrenceID = true;
106 updated(); 129 updated();
107} 130}
108QDateTime Incidence::recurrenceID () const 131QDateTime Incidence::recurrenceID () const
109{ 132{
110 return mRecurrenceID; 133 return mRecurrenceID;
111} 134}
112 135
113bool Incidence::cancelled() const 136bool Incidence::cancelled() const
114{ 137{
115 return mCancelled; 138 return mCancelled;
116} 139}
117void Incidence::setCancelled( bool b ) 140void Incidence::setCancelled( bool b )
118{ 141{
119 mCancelled = b; 142 mCancelled = b;
120 updated(); 143 updated();
121} 144}
122bool Incidence::hasStartDate() const 145bool Incidence::hasStartDate() const
123{ 146{
124 return mHasStartDate; 147 return mHasStartDate;
125} 148}
126 149
127void Incidence::setHasStartDate(bool f) 150void Incidence::setHasStartDate(bool f)
128{ 151{
129 if (mReadOnly) return; 152 if (mReadOnly) return;
130 mHasStartDate = f; 153 mHasStartDate = f;
131 updated(); 154 updated();
132} 155}
133 156
134// 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
135static bool stringCompare( const QString& s1, const QString& s2 ) 158static bool stringCompare( const QString& s1, const QString& s2 )
136{ 159{
137 if ( s1.isEmpty() && s2.isEmpty() ) 160 if ( s1.isEmpty() && s2.isEmpty() )
138 return true; 161 return true;
139 return s1 == s2; 162 return s1 == s2;
140} 163}
141 164
142bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 165bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
143{ 166{
144 167
145 if( i1.alarms().count() != i2.alarms().count() ) { 168 if( i1.alarms().count() != i2.alarms().count() ) {
146 return false; // no need to check further 169 return false; // no need to check further
147 } 170 }
148 if ( i1.alarms().count() > 0 ) { 171 if ( i1.alarms().count() > 0 ) {
149 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
150 { 173 {
151 qDebug("alarm not equal "); 174 qDebug("alarm not equal ");
152 return false; 175 return false;
153 } 176 }
154 } 177 }
155#if 0 178#if 0
@@ -241,151 +264,158 @@ void Incidence::recreate()
241} 264}
242 265
243void Incidence::setReadOnly( bool readOnly ) 266void Incidence::setReadOnly( bool readOnly )
244{ 267{
245 IncidenceBase::setReadOnly( readOnly ); 268 IncidenceBase::setReadOnly( readOnly );
246 recurrence()->setRecurReadOnly( readOnly); 269 recurrence()->setRecurReadOnly( readOnly);
247} 270}
248 271
249void Incidence::setCreated(QDateTime created) 272void Incidence::setCreated(QDateTime created)
250{ 273{
251 if (mReadOnly) return; 274 if (mReadOnly) return;
252 mCreated = getEvenTime(created); 275 mCreated = getEvenTime(created);
253} 276}
254 277
255QDateTime Incidence::created() const 278QDateTime Incidence::created() const
256{ 279{
257 return mCreated; 280 return mCreated;
258} 281}
259 282
260void Incidence::setRevision(int rev) 283void Incidence::setRevision(int rev)
261{ 284{
262 if (mReadOnly) return; 285 if (mReadOnly) return;
263 mRevision = rev; 286 mRevision = rev;
264 287
265 updated(); 288 updated();
266} 289}
267 290
268int Incidence::revision() const 291int Incidence::revision() const
269{ 292{
270 return mRevision; 293 return mRevision;
271} 294}
272 295
273void Incidence::setDtStart(const QDateTime &dtStart) 296void Incidence::setDtStart(const QDateTime &dtStart)
274{ 297{
275 298
276 QDateTime dt = getEvenTime(dtStart); 299 QDateTime dt = getEvenTime(dtStart);
277 recurrence()->setRecurStart( dt); 300 recurrence()->setRecurStart( dt);
278 IncidenceBase::setDtStart( dt ); 301 IncidenceBase::setDtStart( dt );
279} 302}
280 303
281void Incidence::setDescription(const QString &description) 304void Incidence::setDescription(const QString &description)
282{ 305{
283 if (mReadOnly) return; 306 if (mReadOnly) return;
284 mDescription = description; 307 mDescription = description;
285 updated(); 308 updated();
286} 309}
287 310
288QString Incidence::description() const 311QString Incidence::description() const
289{ 312{
290 return mDescription; 313 return mDescription;
291} 314}
292 315
293 316
294void Incidence::setSummary(const QString &summary) 317void Incidence::setSummary(const QString &summary)
295{ 318{
296 if (mReadOnly) return; 319 if (mReadOnly) return;
297 mSummary = summary; 320 mSummary = summary;
298 updated(); 321 updated();
299} 322}
300 323
301QString Incidence::summary() const 324QString Incidence::summary() const
302{ 325{
303 return mSummary; 326 return mSummary;
304} 327}
328void Incidence::checkCategories()
329{
330 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
331 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
332 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
333}
305 334
306void Incidence::setCategories(const QStringList &categories) 335void Incidence::setCategories(const QStringList &categories)
307{ 336{
308 if (mReadOnly) return; 337 if (mReadOnly) return;
309 mCategories = categories; 338 mCategories = categories;
339 checkCategories();
310 updated(); 340 updated();
311} 341}
312 342
313// TODO: remove setCategories(QString) function 343// TODO: remove setCategories(QString) function
314void Incidence::setCategories(const QString &catStr) 344void Incidence::setCategories(const QString &catStr)
315{ 345{
316 if (mReadOnly) return; 346 if (mReadOnly) return;
317 mCategories.clear(); 347 mCategories.clear();
318 348
319 if (catStr.isEmpty()) return; 349 if (catStr.isEmpty()) return;
320 350
321 mCategories = QStringList::split(",",catStr); 351 mCategories = QStringList::split(",",catStr);
322 352
323 QStringList::Iterator it; 353 QStringList::Iterator it;
324 for(it = mCategories.begin();it != mCategories.end(); ++it) { 354 for(it = mCategories.begin();it != mCategories.end(); ++it) {
325 *it = (*it).stripWhiteSpace(); 355 *it = (*it).stripWhiteSpace();
326 } 356 }
327 357 checkCategories();
328 updated(); 358 updated();
329} 359}
330 360
331QStringList Incidence::categories() const 361QStringList Incidence::categories() const
332{ 362{
333 return mCategories; 363 return mCategories;
334} 364}
335 365
336QString Incidence::categoriesStr() 366QString Incidence::categoriesStr()
337{ 367{
338 return mCategories.join(","); 368 return mCategories.join(",");
339} 369}
340 370
341void Incidence::setRelatedToUid(const QString &relatedToUid) 371void Incidence::setRelatedToUid(const QString &relatedToUid)
342{ 372{
343 if (mReadOnly) return; 373 if (mReadOnly) return;
344 mRelatedToUid = relatedToUid; 374 mRelatedToUid = relatedToUid;
345} 375}
346 376
347QString Incidence::relatedToUid() const 377QString Incidence::relatedToUid() const
348{ 378{
349 return mRelatedToUid; 379 return mRelatedToUid;
350} 380}
351 381
352void Incidence::setRelatedTo(Incidence *relatedTo) 382void Incidence::setRelatedTo(Incidence *relatedTo)
353{ 383{
354 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 384 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
355 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 385 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
356 if (mReadOnly || mRelatedTo == relatedTo) return; 386 if (mReadOnly || mRelatedTo == relatedTo) return;
357 if(mRelatedTo) { 387 if(mRelatedTo) {
358 // updated(); 388 // updated();
359 mRelatedTo->removeRelation(this); 389 mRelatedTo->removeRelation(this);
360 } 390 }
361 mRelatedTo = relatedTo; 391 mRelatedTo = relatedTo;
362 if (mRelatedTo) mRelatedTo->addRelation(this); 392 if (mRelatedTo) mRelatedTo->addRelation(this);
363} 393}
364 394
365Incidence *Incidence::relatedTo() const 395Incidence *Incidence::relatedTo() const
366{ 396{
367 return mRelatedTo; 397 return mRelatedTo;
368} 398}
369 399
370QPtrList<Incidence> Incidence::relations() const 400QPtrList<Incidence> Incidence::relations() const
371{ 401{
372 return mRelations; 402 return mRelations;
373} 403}
374 404
375void Incidence::addRelation(Incidence *event) 405void Incidence::addRelation(Incidence *event)
376{ 406{
377 if( mRelations.findRef( event ) == -1 ) { 407 if( mRelations.findRef( event ) == -1 ) {
378 mRelations.append(event); 408 mRelations.append(event);
379 //updated(); 409 //updated();
380 } 410 }
381} 411}
382 412
383void Incidence::removeRelation(Incidence *event) 413void Incidence::removeRelation(Incidence *event)
384{ 414{
385 415
386 mRelations.removeRef(event); 416 mRelations.removeRef(event);
387 417
388// if (event->getRelatedTo() == this) event->setRelatedTo(0); 418// if (event->getRelatedTo() == this) event->setRelatedTo(0);
389} 419}
390 420
391bool Incidence::recursOn(const QDate &qd) const 421bool Incidence::recursOn(const QDate &qd) const
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 0ae9656..f8da342 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -209,101 +209,106 @@ class Incidence : public IncidenceBase
209 QString secrecyStr() const; 209 QString secrecyStr() const;
210 /** return list of all availbale secrecy classes */ 210 /** return list of all availbale secrecy classes */
211 static QStringList secrecyList(); 211 static QStringList secrecyList();
212 /** return human-readable name of secrecy class */ 212 /** return human-readable name of secrecy class */
213 static QString secrecyName(int); 213 static QString secrecyName(int);
214 214
215 /** returns TRUE if the date specified is one on which the event will 215 /** returns TRUE if the date specified is one on which the event will
216 * recur. */ 216 * recur. */
217 bool recursOn(const QDate &qd) const; 217 bool recursOn(const QDate &qd) const;
218 218
219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 219 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
220 220
221 /** set resources used, such as Office, Car, etc. */ 221 /** set resources used, such as Office, Car, etc. */
222 void setResources(const QStringList &resources); 222 void setResources(const QStringList &resources);
223 /** return list of current resources */ 223 /** return list of current resources */
224 QStringList resources() const; 224 QStringList resources() const;
225 225
226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 226 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
227 void setPriority(int priority); 227 void setPriority(int priority);
228 /** get the event's priority */ 228 /** get the event's priority */
229 int priority() const; 229 int priority() const;
230 230
231 /** All alarms that are associated with this incidence */ 231 /** All alarms that are associated with this incidence */
232 QPtrList<Alarm> alarms() const; 232 QPtrList<Alarm> alarms() const;
233 /** Create a new alarm which is associated with this incidence */ 233 /** Create a new alarm which is associated with this incidence */
234 Alarm* newAlarm(); 234 Alarm* newAlarm();
235 /** Add an alarm which is associated with this incidence */ 235 /** Add an alarm which is associated with this incidence */
236 void addAlarm(Alarm*); 236 void addAlarm(Alarm*);
237 /** Remove an alarm that is associated with this incidence */ 237 /** Remove an alarm that is associated with this incidence */
238 void removeAlarm(Alarm*); 238 void removeAlarm(Alarm*);
239 /** Remove all alarms that are associated with this incidence */ 239 /** Remove all alarms that are associated with this incidence */
240 void clearAlarms(); 240 void clearAlarms();
241 /** return whether any alarm associated with this incidence is enabled */ 241 /** return whether any alarm associated with this incidence is enabled */
242 bool isAlarmEnabled() const; 242 bool isAlarmEnabled() const;
243 243
244 /** 244 /**
245 Return the recurrence rule associated with this incidence. If there is 245 Return the recurrence rule associated with this incidence. If there is
246 none, returns an appropriate (non-0) object. 246 none, returns an appropriate (non-0) object.
247 */ 247 */
248 Recurrence *recurrence() const; 248 Recurrence *recurrence() const;
249 void setRecurrence(Recurrence * r); 249 void setRecurrence(Recurrence * r);
250 /** 250 /**
251 Forward to Recurrence::doesRecur(). 251 Forward to Recurrence::doesRecur().
252 */ 252 */
253 ushort doesRecur() const; 253 ushort doesRecur() const;
254 254
255 /** set the event's/todo's location. Do _not_ use it with journal */ 255 /** set the event's/todo's location. Do _not_ use it with journal */
256 void setLocation(const QString &location); 256 void setLocation(const QString &location);
257 /** return the event's/todo's location. Do _not_ use it with journal */ 257 /** return the event's/todo's location. Do _not_ use it with journal */
258 QString location() const; 258 QString location() const;
259 /** returns TRUE or FALSE depending on whether the todo has a start date */ 259 /** returns TRUE or FALSE depending on whether the todo has a start date */
260 bool hasStartDate() const; 260 bool hasStartDate() const;
261 /** sets the event's hasStartDate value. */ 261 /** sets the event's hasStartDate value. */
262 void setHasStartDate(bool f); 262 void setHasStartDate(bool f);
263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 263 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
264 bool cancelled() const; 264 bool cancelled() const;
265 void setCancelled( bool b ); 265 void setCancelled( bool b );
266 266
267 bool hasRecurrenceID() const; 267 bool hasRecurrenceID() const;
268 void setHasRecurrenceID( bool b ); 268 void setHasRecurrenceID( bool b );
269 269
270 void setRecurrenceID(QDateTime); 270 void setRecurrenceID(QDateTime);
271 QDateTime recurrenceID () const; 271 QDateTime recurrenceID () const;
272 QDateTime dtStart() const; 272 QDateTime dtStart() const;
273 bool isHoliday() const;
274 bool isBirthday() const;
275 bool isAnniversary() const;
273 276
274 277
275protected: 278protected:
276 QPtrList<Alarm> mAlarms; 279 QPtrList<Alarm> mAlarms;
277 QPtrList<Incidence> mRelations; 280 QPtrList<Incidence> mRelations;
278 QDateTime mRecurrenceID; 281 QDateTime mRecurrenceID;
279 bool mHasRecurrenceID; 282 bool mHasRecurrenceID;
280 private: 283 private:
284 void checkCategories();
285 bool mHoliday, mBirthday, mAnniversary;
281 int mRevision; 286 int mRevision;
282 bool mCancelled; 287 bool mCancelled;
283 288
284 // base components of jounal, event and todo 289 // base components of jounal, event and todo
285 QDateTime mCreated; 290 QDateTime mCreated;
286 QString mDescription; 291 QString mDescription;
287 QString mSummary; 292 QString mSummary;
288 QStringList mCategories; 293 QStringList mCategories;
289 Incidence *mRelatedTo; 294 Incidence *mRelatedTo;
290 QString mRelatedToUid; 295 QString mRelatedToUid;
291 DateList mExDates; 296 DateList mExDates;
292 QPtrList<Attachment> mAttachments; 297 QPtrList<Attachment> mAttachments;
293 QStringList mResources; 298 QStringList mResources;
294 bool mHasStartDate; // if todo has associated start date 299 bool mHasStartDate; // if todo has associated start date
295 300
296 int mSecrecy; 301 int mSecrecy;
297 int mPriority; // 1 = highest, 2 = less, etc. 302 int mPriority; // 1 = highest, 2 = less, etc.
298 303
299 //QPtrList<Alarm> mAlarms; 304 //QPtrList<Alarm> mAlarms;
300 Recurrence *mRecurrence; 305 Recurrence *mRecurrence;
301 306
302 QString mLocation; 307 QString mLocation;
303}; 308};
304 309
305bool operator==( const Incidence&, const Incidence& ); 310bool operator==( const Incidence&, const Incidence& );
306 311
307} 312}
308 313
309#endif 314#endif