-rw-r--r-- | korganizer/calendarview.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 2 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 2 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 172 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 6 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 4 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 3 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 4 | ||||
-rw-r--r-- | libkcal/event.cpp | 1 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 24 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 63 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 4 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 2 |
18 files changed, 175 insertions, 135 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a76f2ed..a9d42f0 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3378,769 +3378,769 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) | |||
3378 | } | 3378 | } |
3379 | } else { | 3379 | } else { |
3380 | delete t; | 3380 | delete t; |
3381 | } | 3381 | } |
3382 | } | 3382 | } |
3383 | else if ( newInc->typeID() == eventID ) { | 3383 | else if ( newInc->typeID() == eventID ) { |
3384 | Event* e = (Event*) newInc; | 3384 | Event* e = (Event*) newInc; |
3385 | showEventEditor(); | 3385 | showEventEditor(); |
3386 | mEventEditor->editEvent( e ); | 3386 | mEventEditor->editEvent( e ); |
3387 | if ( mEventEditor->exec() ) { | 3387 | if ( mEventEditor->exec() ) { |
3388 | mCalendar->addEvent( e ); | 3388 | mCalendar->addEvent( e ); |
3389 | updateView(); | 3389 | updateView(); |
3390 | } else { | 3390 | } else { |
3391 | delete e; | 3391 | delete e; |
3392 | } | 3392 | } |
3393 | } if ( newInc->typeID() == journalID ) { | 3393 | } if ( newInc->typeID() == journalID ) { |
3394 | mCalendar->addJournal( (Journal*) newInc ); | 3394 | mCalendar->addJournal( (Journal*) newInc ); |
3395 | editJournal( (Journal*) newInc ); | 3395 | editJournal( (Journal*) newInc ); |
3396 | } | 3396 | } |
3397 | setActiveWindow(); | 3397 | setActiveWindow(); |
3398 | } | 3398 | } |
3399 | 3399 | ||
3400 | void CalendarView::newEvent() | 3400 | void CalendarView::newEvent() |
3401 | { | 3401 | { |
3402 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3402 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3403 | KOAgendaView *aView = mViewManager->agendaView(); | 3403 | KOAgendaView *aView = mViewManager->agendaView(); |
3404 | if (aView) { | 3404 | if (aView) { |
3405 | if (aView->selectionStart().isValid()) { | 3405 | if (aView->selectionStart().isValid()) { |
3406 | if (aView->selectedIsAllDay()) { | 3406 | if (aView->selectedIsAllDay()) { |
3407 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3407 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3408 | } else { | 3408 | } else { |
3409 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3409 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3410 | } | 3410 | } |
3411 | return; | 3411 | return; |
3412 | } | 3412 | } |
3413 | } | 3413 | } |
3414 | 3414 | ||
3415 | QDate date = mNavigator->selectedDates().first(); | 3415 | QDate date = mNavigator->selectedDates().first(); |
3416 | #if 0 | 3416 | #if 0 |
3417 | QDateTime current = QDateTime::currentDateTime(); | 3417 | QDateTime current = QDateTime::currentDateTime(); |
3418 | if ( date <= current.date() ) { | 3418 | if ( date <= current.date() ) { |
3419 | int hour = current.time().hour() +1; | 3419 | int hour = current.time().hour() +1; |
3420 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3420 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3421 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3421 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3422 | } else | 3422 | } else |
3423 | #endif | 3423 | #endif |
3424 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3424 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3425 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3425 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3426 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3426 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3427 | } | 3427 | } |
3428 | 3428 | ||
3429 | void CalendarView::newEvent(QDateTime fh) | 3429 | void CalendarView::newEvent(QDateTime fh) |
3430 | { | 3430 | { |
3431 | newEvent(fh, | 3431 | newEvent(fh, |
3432 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3432 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3433 | } | 3433 | } |
3434 | 3434 | ||
3435 | void CalendarView::newEvent(QDate dt) | 3435 | void CalendarView::newEvent(QDate dt) |
3436 | { | 3436 | { |
3437 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3437 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3438 | QDateTime(dt, QTime(0,0,0)), true); | 3438 | QDateTime(dt, QTime(0,0,0)), true); |
3439 | } | 3439 | } |
3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3440 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3441 | { | 3441 | { |
3442 | newEvent(fromHint, toHint, false); | 3442 | newEvent(fromHint, toHint, false); |
3443 | } | 3443 | } |
3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3445 | { | 3445 | { |
3446 | 3446 | ||
3447 | showEventEditor(); | 3447 | showEventEditor(); |
3448 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3448 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3449 | if ( mFilterView->filtersEnabled() ) { | 3449 | if ( mFilterView->filtersEnabled() ) { |
3450 | CalFilter *filter = mFilterView->selectedFilter(); | 3450 | CalFilter *filter = mFilterView->selectedFilter(); |
3451 | if (filter && filter->showCategories()) { | 3451 | if (filter && filter->showCategories()) { |
3452 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3452 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3453 | } | 3453 | } |
3454 | if ( filter ) | 3454 | if ( filter ) |
3455 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3455 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3456 | } | 3456 | } |
3457 | mEventEditor->exec(); | 3457 | mEventEditor->exec(); |
3458 | setActiveWindow(); | 3458 | setActiveWindow(); |
3459 | } | 3459 | } |
3460 | void CalendarView::todoAdded(Todo * t) | 3460 | void CalendarView::todoAdded(Todo * t) |
3461 | { | 3461 | { |
3462 | 3462 | ||
3463 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3463 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3464 | updateTodoViews(); | 3464 | updateTodoViews(); |
3465 | } | 3465 | } |
3466 | void CalendarView::todoChanged(Todo * t) | 3466 | void CalendarView::todoChanged(Todo * t) |
3467 | { | 3467 | { |
3468 | emit todoModified( t, 4 ); | 3468 | emit todoModified( t, 4 ); |
3469 | // updateTodoViews(); | 3469 | // updateTodoViews(); |
3470 | } | 3470 | } |
3471 | void CalendarView::todoToBeDeleted(Todo *) | 3471 | void CalendarView::todoToBeDeleted(Todo *) |
3472 | { | 3472 | { |
3473 | //qDebug("todoToBeDeleted(Todo *) "); | 3473 | //qDebug("todoToBeDeleted(Todo *) "); |
3474 | updateTodoViews(); | 3474 | updateTodoViews(); |
3475 | } | 3475 | } |
3476 | void CalendarView::todoDeleted() | 3476 | void CalendarView::todoDeleted() |
3477 | { | 3477 | { |
3478 | //qDebug(" todoDeleted()"); | 3478 | //qDebug(" todoDeleted()"); |
3479 | updateTodoViews(); | 3479 | updateTodoViews(); |
3480 | } | 3480 | } |
3481 | 3481 | ||
3482 | 3482 | ||
3483 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3483 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3484 | { | 3484 | { |
3485 | showTodoEditor(); | 3485 | showTodoEditor(); |
3486 | mTodoEditor->newTodo(dt,0,allday); | 3486 | mTodoEditor->newTodo(dt,0,allday); |
3487 | if ( mFilterView->filtersEnabled() ) { | 3487 | if ( mFilterView->filtersEnabled() ) { |
3488 | CalFilter *filter = mFilterView->selectedFilter(); | 3488 | CalFilter *filter = mFilterView->selectedFilter(); |
3489 | if (filter && filter->showCategories()) { | 3489 | if (filter && filter->showCategories()) { |
3490 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3490 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3491 | } | 3491 | } |
3492 | if ( filter ) | 3492 | if ( filter ) |
3493 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3493 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3494 | } | 3494 | } |
3495 | mTodoEditor->exec(); | 3495 | mTodoEditor->exec(); |
3496 | setActiveWindow(); | 3496 | setActiveWindow(); |
3497 | } | 3497 | } |
3498 | 3498 | ||
3499 | void CalendarView::newTodo() | 3499 | void CalendarView::newTodo() |
3500 | { | 3500 | { |
3501 | newTodoDateTime( QDateTime(),true ); | 3501 | newTodoDateTime( QDateTime(),true ); |
3502 | } | 3502 | } |
3503 | 3503 | ||
3504 | void CalendarView::newSubTodo() | 3504 | void CalendarView::newSubTodo() |
3505 | { | 3505 | { |
3506 | Todo *todo = selectedTodo(); | 3506 | Todo *todo = selectedTodo(); |
3507 | if ( todo ) newSubTodo( todo ); | 3507 | if ( todo ) newSubTodo( todo ); |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | void CalendarView::newSubTodo(Todo *parentEvent) | 3510 | void CalendarView::newSubTodo(Todo *parentEvent) |
3511 | { | 3511 | { |
3512 | 3512 | ||
3513 | showTodoEditor(); | 3513 | showTodoEditor(); |
3514 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3514 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3515 | mTodoEditor->exec(); | 3515 | mTodoEditor->exec(); |
3516 | setActiveWindow(); | 3516 | setActiveWindow(); |
3517 | } | 3517 | } |
3518 | 3518 | ||
3519 | void CalendarView::newFloatingEvent() | 3519 | void CalendarView::newFloatingEvent() |
3520 | { | 3520 | { |
3521 | DateList tmpList = mNavigator->selectedDates(); | 3521 | DateList tmpList = mNavigator->selectedDates(); |
3522 | QDate date = tmpList.first(); | 3522 | QDate date = tmpList.first(); |
3523 | 3523 | ||
3524 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3524 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3525 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3525 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3526 | } | 3526 | } |
3527 | 3527 | ||
3528 | 3528 | ||
3529 | void CalendarView::editEvent( Event *event ) | 3529 | void CalendarView::editEvent( Event *event ) |
3530 | { | 3530 | { |
3531 | 3531 | ||
3532 | if ( !event ) return; | 3532 | if ( !event ) return; |
3533 | if ( event->isReadOnly() ) { | 3533 | if ( event->isReadOnly() ) { |
3534 | showEvent( event ); | 3534 | showEvent( event ); |
3535 | return; | 3535 | return; |
3536 | } | 3536 | } |
3537 | showEventEditor(); | 3537 | showEventEditor(); |
3538 | mEventEditor->editEvent( event , mFlagEditDescription); | 3538 | mEventEditor->editEvent( event , mFlagEditDescription); |
3539 | mEventEditor->exec(); | 3539 | mEventEditor->exec(); |
3540 | setActiveWindow(); | 3540 | setActiveWindow(); |
3541 | 3541 | ||
3542 | } | 3542 | } |
3543 | void CalendarView::editJournal( Journal *jour ) | 3543 | void CalendarView::editJournal( Journal *jour ) |
3544 | { | 3544 | { |
3545 | if ( !jour ) return; | 3545 | if ( !jour ) return; |
3546 | mDialogManager->hideSearchDialog(); | 3546 | mDialogManager->hideSearchDialog(); |
3547 | mViewManager->showJournalView(); | 3547 | mViewManager->showJournalView(); |
3548 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3548 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3549 | } | 3549 | } |
3550 | void CalendarView::editTodo( Todo *todo ) | 3550 | void CalendarView::editTodo( Todo *todo ) |
3551 | { | 3551 | { |
3552 | if ( !todo ) return; | 3552 | if ( !todo ) return; |
3553 | 3553 | ||
3554 | if ( todo->isReadOnly() ) { | 3554 | if ( todo->isReadOnly() ) { |
3555 | showTodo( todo ); | 3555 | showTodo( todo ); |
3556 | return; | 3556 | return; |
3557 | } | 3557 | } |
3558 | showTodoEditor(); | 3558 | showTodoEditor(); |
3559 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3559 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3560 | mTodoEditor->exec(); | 3560 | mTodoEditor->exec(); |
3561 | setActiveWindow(); | 3561 | setActiveWindow(); |
3562 | 3562 | ||
3563 | } | 3563 | } |
3564 | 3564 | ||
3565 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3565 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3566 | { | 3566 | { |
3567 | if ( !mEventViewerDialog ) { | 3567 | if ( !mEventViewerDialog ) { |
3568 | mEventViewerDialog = new KOEventViewerDialog(0); | 3568 | mEventViewerDialog = new KOEventViewerDialog(0); |
3569 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3569 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3570 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3570 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3571 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3571 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3572 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3572 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3573 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3573 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3574 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3574 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3575 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3575 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3576 | this, SLOT( slotViewerClosed() ) ); | 3576 | this, SLOT( slotViewerClosed() ) ); |
3577 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3577 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3578 | this, SLOT( todoChanged(Todo *) ) ); | 3578 | this, SLOT( todoChanged(Todo *) ) ); |
3579 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3579 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3580 | mEventViewerDialog->resize( 640, 480 ); | 3580 | mEventViewerDialog->resize( 640, 480 ); |
3581 | 3581 | ||
3582 | } | 3582 | } |
3583 | return mEventViewerDialog; | 3583 | return mEventViewerDialog; |
3584 | } | 3584 | } |
3585 | void CalendarView::showEvent(Event *event) | 3585 | void CalendarView::showEvent(Event *event) |
3586 | { | 3586 | { |
3587 | getEventViewerDialog()->setEvent(event); | 3587 | getEventViewerDialog()->setEvent(event); |
3588 | getEventViewerDialog()->showMe(); | 3588 | getEventViewerDialog()->showMe(); |
3589 | } | 3589 | } |
3590 | 3590 | ||
3591 | void CalendarView::showTodo(Todo *event) | 3591 | void CalendarView::showTodo(Todo *event) |
3592 | { | 3592 | { |
3593 | getEventViewerDialog()->setTodo(event); | 3593 | getEventViewerDialog()->setTodo(event); |
3594 | getEventViewerDialog()->showMe(); | 3594 | getEventViewerDialog()->showMe(); |
3595 | } | 3595 | } |
3596 | void CalendarView::showJournal( Journal *jour ) | 3596 | void CalendarView::showJournal( Journal *jour ) |
3597 | { | 3597 | { |
3598 | getEventViewerDialog()->setJournal(jour); | 3598 | getEventViewerDialog()->setJournal(jour); |
3599 | getEventViewerDialog()->showMe(); | 3599 | getEventViewerDialog()->showMe(); |
3600 | 3600 | ||
3601 | } | 3601 | } |
3602 | // void CalendarView::todoModified (Todo *event, int changed) | 3602 | // void CalendarView::todoModified (Todo *event, int changed) |
3603 | // { | 3603 | // { |
3604 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3604 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3605 | // // kdDebug() << "Todo modified and open" << endl; | 3605 | // // kdDebug() << "Todo modified and open" << endl; |
3606 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3606 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3607 | // // temp->modified (changed); | 3607 | // // temp->modified (changed); |
3608 | 3608 | ||
3609 | // // } | 3609 | // // } |
3610 | 3610 | ||
3611 | // mViewManager->updateView(); | 3611 | // mViewManager->updateView(); |
3612 | // } | 3612 | // } |
3613 | 3613 | ||
3614 | void CalendarView::appointment_show() | 3614 | void CalendarView::appointment_show() |
3615 | { | 3615 | { |
3616 | Event *anEvent = 0; | 3616 | Event *anEvent = 0; |
3617 | 3617 | ||
3618 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3618 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3619 | 3619 | ||
3620 | if (mViewManager->currentView()->isEventView()) { | 3620 | if (mViewManager->currentView()->isEventView()) { |
3621 | if ( incidence && incidence->typeID() == eventID ) { | 3621 | if ( incidence && incidence->typeID() == eventID ) { |
3622 | anEvent = static_cast<Event *>(incidence); | 3622 | anEvent = static_cast<Event *>(incidence); |
3623 | } | 3623 | } |
3624 | } | 3624 | } |
3625 | 3625 | ||
3626 | if (!anEvent) { | 3626 | if (!anEvent) { |
3627 | KNotifyClient::beep(); | 3627 | KNotifyClient::beep(); |
3628 | return; | 3628 | return; |
3629 | } | 3629 | } |
3630 | 3630 | ||
3631 | showEvent(anEvent); | 3631 | showEvent(anEvent); |
3632 | } | 3632 | } |
3633 | 3633 | ||
3634 | void CalendarView::appointment_edit() | 3634 | void CalendarView::appointment_edit() |
3635 | { | 3635 | { |
3636 | Event *anEvent = 0; | 3636 | Event *anEvent = 0; |
3637 | 3637 | ||
3638 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3638 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3639 | 3639 | ||
3640 | if (mViewManager->currentView()->isEventView()) { | 3640 | if (mViewManager->currentView()->isEventView()) { |
3641 | if ( incidence && incidence->typeID() == eventID ) { | 3641 | if ( incidence && incidence->typeID() == eventID ) { |
3642 | anEvent = static_cast<Event *>(incidence); | 3642 | anEvent = static_cast<Event *>(incidence); |
3643 | } | 3643 | } |
3644 | } | 3644 | } |
3645 | 3645 | ||
3646 | if (!anEvent) { | 3646 | if (!anEvent) { |
3647 | KNotifyClient::beep(); | 3647 | KNotifyClient::beep(); |
3648 | return; | 3648 | return; |
3649 | } | 3649 | } |
3650 | 3650 | ||
3651 | editEvent(anEvent); | 3651 | editEvent(anEvent); |
3652 | } | 3652 | } |
3653 | 3653 | ||
3654 | void CalendarView::appointment_delete() | 3654 | void CalendarView::appointment_delete() |
3655 | { | 3655 | { |
3656 | Event *anEvent = 0; | 3656 | Event *anEvent = 0; |
3657 | 3657 | ||
3658 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3658 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3659 | 3659 | ||
3660 | if (mViewManager->currentView()->isEventView()) { | 3660 | if (mViewManager->currentView()->isEventView()) { |
3661 | if ( incidence && incidence->typeID() == eventID ) { | 3661 | if ( incidence && incidence->typeID() == eventID ) { |
3662 | anEvent = static_cast<Event *>(incidence); | 3662 | anEvent = static_cast<Event *>(incidence); |
3663 | } | 3663 | } |
3664 | } | 3664 | } |
3665 | 3665 | ||
3666 | if (!anEvent) { | 3666 | if (!anEvent) { |
3667 | KNotifyClient::beep(); | 3667 | KNotifyClient::beep(); |
3668 | return; | 3668 | return; |
3669 | } | 3669 | } |
3670 | 3670 | ||
3671 | deleteEvent(anEvent); | 3671 | deleteEvent(anEvent); |
3672 | } | 3672 | } |
3673 | 3673 | ||
3674 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3674 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3675 | { | 3675 | { |
3676 | if (!sub) return; | 3676 | if (!sub) return; |
3677 | if ( sub->relatedTo() == parent ) | 3677 | if ( sub->relatedTo() == parent ) |
3678 | return; | 3678 | return; |
3679 | sub->setRelatedTo(parent); | 3679 | sub->setRelatedTo(parent); |
3680 | sub->updated(); | 3680 | sub->updated(); |
3681 | setModified(true); | 3681 | setModified(true); |
3682 | updateView(); | 3682 | updateView(); |
3683 | } | 3683 | } |
3684 | void CalendarView::todo_unsub(Todo *anTodo ) | 3684 | void CalendarView::todo_unsub(Todo *anTodo ) |
3685 | { | 3685 | { |
3686 | todo_resub( 0, anTodo ); | 3686 | todo_resub( 0, anTodo ); |
3687 | } | 3687 | } |
3688 | 3688 | ||
3689 | void CalendarView::deleteTodo(Todo *todo) | 3689 | void CalendarView::deleteTodo(Todo *todo) |
3690 | { | 3690 | { |
3691 | if (!todo) { | 3691 | if (!todo) { |
3692 | KNotifyClient::beep(); | 3692 | KNotifyClient::beep(); |
3693 | return; | 3693 | return; |
3694 | } | 3694 | } |
3695 | if (KOPrefs::instance()->mConfirm) { | 3695 | if (KOPrefs::instance()->mConfirm) { |
3696 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3696 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3697 | if (!todo->relations().isEmpty()) { | 3697 | if (!todo->relations().isEmpty()) { |
3698 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3698 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3699 | 3699 | ||
3700 | } | 3700 | } |
3701 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3701 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3702 | case KMessageBox::Continue: // OK | 3702 | case KMessageBox::Continue: // OK |
3703 | bool deleteT = false; | 3703 | bool deleteT = false; |
3704 | if (!todo->relations().isEmpty()) { | 3704 | if (!todo->relations().isEmpty()) { |
3705 | deleteT = removeCompletedSubTodos( todo ); | 3705 | deleteT = removeCompletedSubTodos( todo ); |
3706 | } | 3706 | } |
3707 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3707 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3708 | if ( !deleteT ) { | 3708 | if ( !deleteT ) { |
3709 | checkExternalId( todo ); | 3709 | checkExternalId( todo ); |
3710 | calendar()->deleteTodo(todo); | 3710 | calendar()->deleteTodo(todo); |
3711 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3711 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3712 | updateView(); | 3712 | updateView(); |
3713 | } | 3713 | } |
3714 | break; | 3714 | break; |
3715 | } // switch | 3715 | } // switch |
3716 | } else { | 3716 | } else { |
3717 | checkExternalId( todo ); | 3717 | checkExternalId( todo ); |
3718 | mCalendar->deleteTodo(todo); | 3718 | mCalendar->deleteTodo(todo); |
3719 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3719 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3720 | updateView(); | 3720 | updateView(); |
3721 | } | 3721 | } |
3722 | 3722 | ||
3723 | emit updateSearchDialog(); | 3723 | emit updateSearchDialog(); |
3724 | } | 3724 | } |
3725 | void CalendarView::deleteJournal(Journal *jour) | 3725 | void CalendarView::deleteJournal(Journal *jour) |
3726 | { | 3726 | { |
3727 | if (!jour) { | 3727 | if (!jour) { |
3728 | KNotifyClient::beep(); | 3728 | KNotifyClient::beep(); |
3729 | return; | 3729 | return; |
3730 | } | 3730 | } |
3731 | if (KOPrefs::instance()->mConfirm) { | 3731 | if (KOPrefs::instance()->mConfirm) { |
3732 | 3732 | ||
3733 | QString des; | 3733 | QString des; |
3734 | if ( !jour->summary().isEmpty() ) { | 3734 | if ( !jour->summary().isEmpty() ) { |
3735 | des = jour->summary(); | 3735 | des = jour->summary(); |
3736 | } else { | 3736 | } else { |
3737 | des = jour->description().left(30); | 3737 | des = jour->description().left(30); |
3738 | des = des.simplifyWhiteSpace (); | 3738 | des = des.simplifyWhiteSpace (); |
3739 | des.replace (QRegExp ("\\n"),"" ); | 3739 | des.replace (QRegExp ("\\n"),"" ); |
3740 | des.replace (QRegExp ("\\r"),"" ); | 3740 | des.replace (QRegExp ("\\r"),"" ); |
3741 | } | 3741 | } |
3742 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3742 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3743 | case KMessageBox::Continue: // OK | 3743 | case KMessageBox::Continue: // OK |
3744 | calendar()->deleteJournal(jour); | 3744 | calendar()->deleteJournal(jour); |
3745 | updateView(); | 3745 | updateView(); |
3746 | break; | 3746 | break; |
3747 | } // switch | 3747 | } // switch |
3748 | } else { | 3748 | } else { |
3749 | calendar()->deleteJournal(jour);; | 3749 | calendar()->deleteJournal(jour);; |
3750 | updateView(); | 3750 | updateView(); |
3751 | } | 3751 | } |
3752 | emit updateSearchDialog(); | 3752 | emit updateSearchDialog(); |
3753 | } | 3753 | } |
3754 | 3754 | ||
3755 | void CalendarView::deleteEvent(Event *anEvent) | 3755 | void CalendarView::deleteEvent(Event *anEvent) |
3756 | { | 3756 | { |
3757 | if (!anEvent) { | 3757 | if (!anEvent) { |
3758 | KNotifyClient::beep(); | 3758 | KNotifyClient::beep(); |
3759 | return; | 3759 | return; |
3760 | } | 3760 | } |
3761 | 3761 | ||
3762 | if (anEvent->recurrence()->doesRecur()) { | 3762 | if (anEvent->doesRecur()) { |
3763 | QDate itemDate = mViewManager->currentSelectionDate(); | 3763 | QDate itemDate = mViewManager->currentSelectionDate(); |
3764 | int km; | 3764 | int km; |
3765 | if (!itemDate.isValid()) { | 3765 | if (!itemDate.isValid()) { |
3766 | //kdDebug() << "Date Not Valid" << endl; | 3766 | //kdDebug() << "Date Not Valid" << endl; |
3767 | if (KOPrefs::instance()->mConfirm) { | 3767 | if (KOPrefs::instance()->mConfirm) { |
3768 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3768 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3769 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3769 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3770 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3770 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3771 | if ( km == KMessageBox::Continue ) | 3771 | if ( km == KMessageBox::Continue ) |
3772 | km = KMessageBox::No; // No = all below | 3772 | km = KMessageBox::No; // No = all below |
3773 | } else | 3773 | } else |
3774 | km = KMessageBox::No; | 3774 | km = KMessageBox::No; |
3775 | } else { | 3775 | } else { |
3776 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3776 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3777 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3777 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3778 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3778 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3779 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3779 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3780 | i18n("All")); | 3780 | i18n("All")); |
3781 | } | 3781 | } |
3782 | switch(km) { | 3782 | switch(km) { |
3783 | 3783 | ||
3784 | case KMessageBox::No: // Continue // all | 3784 | case KMessageBox::No: // Continue // all |
3785 | //qDebug("KMessageBox::No "); | 3785 | //qDebug("KMessageBox::No "); |
3786 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3786 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3787 | schedule(Scheduler::Cancel,anEvent); | 3787 | schedule(Scheduler::Cancel,anEvent); |
3788 | 3788 | ||
3789 | checkExternalId( anEvent); | 3789 | checkExternalId( anEvent); |
3790 | mCalendar->deleteEvent(anEvent); | 3790 | mCalendar->deleteEvent(anEvent); |
3791 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3791 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3792 | break; | 3792 | break; |
3793 | 3793 | ||
3794 | // Disabled because it does not work | 3794 | // Disabled because it does not work |
3795 | //#if 0 | 3795 | //#if 0 |
3796 | case KMessageBox::Yes: // just this one | 3796 | case KMessageBox::Yes: // just this one |
3797 | //QDate qd = mNavigator->selectedDates().first(); | 3797 | //QDate qd = mNavigator->selectedDates().first(); |
3798 | //if (!qd.isValid()) { | 3798 | //if (!qd.isValid()) { |
3799 | // kdDebug() << "no date selected, or invalid date" << endl; | 3799 | // kdDebug() << "no date selected, or invalid date" << endl; |
3800 | // KNotifyClient::beep(); | 3800 | // KNotifyClient::beep(); |
3801 | // return; | 3801 | // return; |
3802 | //} | 3802 | //} |
3803 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3803 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3804 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3804 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3805 | anEvent->addExDate(itemDate); | 3805 | anEvent->addExDate(itemDate); |
3806 | int duration = anEvent->recurrence()->duration(); | 3806 | int duration = anEvent->recurrence()->duration(); |
3807 | if ( duration > 0 ) { | 3807 | if ( duration > 0 ) { |
3808 | anEvent->recurrence()->setDuration( duration - 1 ); | 3808 | anEvent->recurrence()->setDuration( duration - 1 ); |
3809 | } | 3809 | } |
3810 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3810 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3811 | } | 3811 | } |
3812 | break; | 3812 | break; |
3813 | //#endif | 3813 | //#endif |
3814 | } // switch | 3814 | } // switch |
3815 | } else { | 3815 | } else { |
3816 | if (KOPrefs::instance()->mConfirm) { | 3816 | if (KOPrefs::instance()->mConfirm) { |
3817 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3817 | switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3818 | i18n("\nAre you sure you want\nto delete this event?"), | 3818 | i18n("\nAre you sure you want\nto delete this event?"), |
3819 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3819 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3820 | case KMessageBox::Continue: // OK | 3820 | case KMessageBox::Continue: // OK |
3821 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3821 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3822 | schedule(Scheduler::Cancel,anEvent); | 3822 | schedule(Scheduler::Cancel,anEvent); |
3823 | checkExternalId( anEvent); | 3823 | checkExternalId( anEvent); |
3824 | mCalendar->deleteEvent(anEvent); | 3824 | mCalendar->deleteEvent(anEvent); |
3825 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3825 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3826 | break; | 3826 | break; |
3827 | } // switch | 3827 | } // switch |
3828 | } else { | 3828 | } else { |
3829 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3829 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3830 | schedule(Scheduler::Cancel,anEvent); | 3830 | schedule(Scheduler::Cancel,anEvent); |
3831 | checkExternalId( anEvent); | 3831 | checkExternalId( anEvent); |
3832 | mCalendar->deleteEvent(anEvent); | 3832 | mCalendar->deleteEvent(anEvent); |
3833 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3833 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3834 | } | 3834 | } |
3835 | } // if-else | 3835 | } // if-else |
3836 | emit updateSearchDialog(); | 3836 | emit updateSearchDialog(); |
3837 | } | 3837 | } |
3838 | 3838 | ||
3839 | bool CalendarView::deleteEvent(const QString &uid) | 3839 | bool CalendarView::deleteEvent(const QString &uid) |
3840 | { | 3840 | { |
3841 | Event *ev = mCalendar->event(uid); | 3841 | Event *ev = mCalendar->event(uid); |
3842 | if (ev) { | 3842 | if (ev) { |
3843 | deleteEvent(ev); | 3843 | deleteEvent(ev); |
3844 | return true; | 3844 | return true; |
3845 | } else { | 3845 | } else { |
3846 | return false; | 3846 | return false; |
3847 | } | 3847 | } |
3848 | } | 3848 | } |
3849 | 3849 | ||
3850 | /*****************************************************************************/ | 3850 | /*****************************************************************************/ |
3851 | 3851 | ||
3852 | void CalendarView::action_mail() | 3852 | void CalendarView::action_mail() |
3853 | { | 3853 | { |
3854 | #ifndef KORG_NOMAIL | 3854 | #ifndef KORG_NOMAIL |
3855 | KOMailClient mailClient; | 3855 | KOMailClient mailClient; |
3856 | 3856 | ||
3857 | Incidence *incidence = currentSelection(); | 3857 | Incidence *incidence = currentSelection(); |
3858 | 3858 | ||
3859 | if (!incidence) { | 3859 | if (!incidence) { |
3860 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3860 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3861 | return; | 3861 | return; |
3862 | } | 3862 | } |
3863 | if(incidence->attendeeCount() == 0 ) { | 3863 | if(incidence->attendeeCount() == 0 ) { |
3864 | KMessageBox::sorry(this, | 3864 | KMessageBox::sorry(this, |
3865 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3865 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3866 | return; | 3866 | return; |
3867 | } | 3867 | } |
3868 | 3868 | ||
3869 | CalendarLocal cal_tmp; | 3869 | CalendarLocal cal_tmp; |
3870 | Event *event = 0; | 3870 | Event *event = 0; |
3871 | Event *ev = 0; | 3871 | Event *ev = 0; |
3872 | if ( incidence && incidence->typeID() == eventID ) { | 3872 | if ( incidence && incidence->typeID() == eventID ) { |
3873 | event = static_cast<Event *>(incidence); | 3873 | event = static_cast<Event *>(incidence); |
3874 | ev = new Event(*event); | 3874 | ev = new Event(*event); |
3875 | cal_tmp.addEvent(ev); | 3875 | cal_tmp.addEvent(ev); |
3876 | } | 3876 | } |
3877 | ICalFormat mForm(); | 3877 | ICalFormat mForm(); |
3878 | QString attachment = mForm.toString( &cal_tmp ); | 3878 | QString attachment = mForm.toString( &cal_tmp ); |
3879 | if (ev) delete(ev); | 3879 | if (ev) delete(ev); |
3880 | 3880 | ||
3881 | mailClient.mailAttendees(currentSelection(), attachment); | 3881 | mailClient.mailAttendees(currentSelection(), attachment); |
3882 | 3882 | ||
3883 | #endif | 3883 | #endif |
3884 | 3884 | ||
3885 | #if 0 | 3885 | #if 0 |
3886 | Event *anEvent = 0; | 3886 | Event *anEvent = 0; |
3887 | if (mViewManager->currentView()->isEventView()) { | 3887 | if (mViewManager->currentView()->isEventView()) { |
3888 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3888 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3889 | } | 3889 | } |
3890 | 3890 | ||
3891 | if (!anEvent) { | 3891 | if (!anEvent) { |
3892 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3892 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3893 | return; | 3893 | return; |
3894 | } | 3894 | } |
3895 | if(anEvent->attendeeCount() == 0 ) { | 3895 | if(anEvent->attendeeCount() == 0 ) { |
3896 | KMessageBox::sorry(this, | 3896 | KMessageBox::sorry(this, |
3897 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3897 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3898 | return; | 3898 | return; |
3899 | } | 3899 | } |
3900 | 3900 | ||
3901 | mailobject.emailEvent(anEvent); | 3901 | mailobject.emailEvent(anEvent); |
3902 | #endif | 3902 | #endif |
3903 | } | 3903 | } |
3904 | 3904 | ||
3905 | 3905 | ||
3906 | void CalendarView::schedule_publish(Incidence *incidence) | 3906 | void CalendarView::schedule_publish(Incidence *incidence) |
3907 | { | 3907 | { |
3908 | Event *event = 0; | 3908 | Event *event = 0; |
3909 | Todo *todo = 0; | 3909 | Todo *todo = 0; |
3910 | 3910 | ||
3911 | if (incidence == 0) { | 3911 | if (incidence == 0) { |
3912 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3912 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3913 | if (incidence == 0) { | 3913 | if (incidence == 0) { |
3914 | incidence = mTodoList->selectedIncidences().first(); | 3914 | incidence = mTodoList->selectedIncidences().first(); |
3915 | } | 3915 | } |
3916 | } | 3916 | } |
3917 | if ( incidence && incidence->typeID() == eventID ) { | 3917 | if ( incidence && incidence->typeID() == eventID ) { |
3918 | event = static_cast<Event *>(incidence); | 3918 | event = static_cast<Event *>(incidence); |
3919 | } else { | 3919 | } else { |
3920 | if ( incidence && incidence->typeID() == todoID ) { | 3920 | if ( incidence && incidence->typeID() == todoID ) { |
3921 | todo = static_cast<Todo *>(incidence); | 3921 | todo = static_cast<Todo *>(incidence); |
3922 | } | 3922 | } |
3923 | } | 3923 | } |
3924 | 3924 | ||
3925 | if (!event && !todo) { | 3925 | if (!event && !todo) { |
3926 | KMessageBox::sorry(this,i18n("No event selected.")); | 3926 | KMessageBox::sorry(this,i18n("No event selected.")); |
3927 | return; | 3927 | return; |
3928 | } | 3928 | } |
3929 | 3929 | ||
3930 | PublishDialog *publishdlg = new PublishDialog(); | 3930 | PublishDialog *publishdlg = new PublishDialog(); |
3931 | if (incidence->attendeeCount()>0) { | 3931 | if (incidence->attendeeCount()>0) { |
3932 | QPtrList<Attendee> attendees = incidence->attendees(); | 3932 | QPtrList<Attendee> attendees = incidence->attendees(); |
3933 | attendees.first(); | 3933 | attendees.first(); |
3934 | while ( attendees.current()!=0 ) { | 3934 | while ( attendees.current()!=0 ) { |
3935 | publishdlg->addAttendee(attendees.current()); | 3935 | publishdlg->addAttendee(attendees.current()); |
3936 | attendees.next(); | 3936 | attendees.next(); |
3937 | } | 3937 | } |
3938 | } | 3938 | } |
3939 | bool send = true; | 3939 | bool send = true; |
3940 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3940 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3941 | if ( publishdlg->exec() != QDialog::Accepted ) | 3941 | if ( publishdlg->exec() != QDialog::Accepted ) |
3942 | send = false; | 3942 | send = false; |
3943 | } | 3943 | } |
3944 | if ( send ) { | 3944 | if ( send ) { |
3945 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3945 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3946 | if ( event ) { | 3946 | if ( event ) { |
3947 | Event *ev = new Event(*event); | 3947 | Event *ev = new Event(*event); |
3948 | ev->registerObserver(0); | 3948 | ev->registerObserver(0); |
3949 | ev->clearAttendees(); | 3949 | ev->clearAttendees(); |
3950 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3950 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3951 | delete(ev); | 3951 | delete(ev); |
3952 | } | 3952 | } |
3953 | } else { | 3953 | } else { |
3954 | if ( todo ) { | 3954 | if ( todo ) { |
3955 | Todo *ev = new Todo(*todo); | 3955 | Todo *ev = new Todo(*todo); |
3956 | ev->registerObserver(0); | 3956 | ev->registerObserver(0); |
3957 | ev->clearAttendees(); | 3957 | ev->clearAttendees(); |
3958 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3958 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3959 | delete(ev); | 3959 | delete(ev); |
3960 | } | 3960 | } |
3961 | } | 3961 | } |
3962 | } | 3962 | } |
3963 | } | 3963 | } |
3964 | delete publishdlg; | 3964 | delete publishdlg; |
3965 | } | 3965 | } |
3966 | 3966 | ||
3967 | void CalendarView::schedule_request(Incidence *incidence) | 3967 | void CalendarView::schedule_request(Incidence *incidence) |
3968 | { | 3968 | { |
3969 | schedule(Scheduler::Request,incidence); | 3969 | schedule(Scheduler::Request,incidence); |
3970 | } | 3970 | } |
3971 | 3971 | ||
3972 | void CalendarView::schedule_refresh(Incidence *incidence) | 3972 | void CalendarView::schedule_refresh(Incidence *incidence) |
3973 | { | 3973 | { |
3974 | schedule(Scheduler::Refresh,incidence); | 3974 | schedule(Scheduler::Refresh,incidence); |
3975 | } | 3975 | } |
3976 | 3976 | ||
3977 | void CalendarView::schedule_cancel(Incidence *incidence) | 3977 | void CalendarView::schedule_cancel(Incidence *incidence) |
3978 | { | 3978 | { |
3979 | schedule(Scheduler::Cancel,incidence); | 3979 | schedule(Scheduler::Cancel,incidence); |
3980 | } | 3980 | } |
3981 | 3981 | ||
3982 | void CalendarView::schedule_add(Incidence *incidence) | 3982 | void CalendarView::schedule_add(Incidence *incidence) |
3983 | { | 3983 | { |
3984 | schedule(Scheduler::Add,incidence); | 3984 | schedule(Scheduler::Add,incidence); |
3985 | } | 3985 | } |
3986 | 3986 | ||
3987 | void CalendarView::schedule_reply(Incidence *incidence) | 3987 | void CalendarView::schedule_reply(Incidence *incidence) |
3988 | { | 3988 | { |
3989 | schedule(Scheduler::Reply,incidence); | 3989 | schedule(Scheduler::Reply,incidence); |
3990 | } | 3990 | } |
3991 | 3991 | ||
3992 | void CalendarView::schedule_counter(Incidence *incidence) | 3992 | void CalendarView::schedule_counter(Incidence *incidence) |
3993 | { | 3993 | { |
3994 | schedule(Scheduler::Counter,incidence); | 3994 | schedule(Scheduler::Counter,incidence); |
3995 | } | 3995 | } |
3996 | 3996 | ||
3997 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3997 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3998 | { | 3998 | { |
3999 | schedule(Scheduler::Declinecounter,incidence); | 3999 | schedule(Scheduler::Declinecounter,incidence); |
4000 | } | 4000 | } |
4001 | 4001 | ||
4002 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 4002 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
4003 | { | 4003 | { |
4004 | QDateTime start = QDateTime::currentDateTime(); | 4004 | QDateTime start = QDateTime::currentDateTime(); |
4005 | QDateTime end = start.addDays(daysToPublish); | 4005 | QDateTime end = start.addDays(daysToPublish); |
4006 | 4006 | ||
4007 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 4007 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
4008 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 4008 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
4009 | 4009 | ||
4010 | 4010 | ||
4011 | PublishDialog *publishdlg = new PublishDialog(); | 4011 | PublishDialog *publishdlg = new PublishDialog(); |
4012 | if ( publishdlg->exec() == QDialog::Accepted ) { | 4012 | if ( publishdlg->exec() == QDialog::Accepted ) { |
4013 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4013 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4014 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 4014 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
4015 | delete(freebusy); | 4015 | delete(freebusy); |
4016 | } | 4016 | } |
4017 | } | 4017 | } |
4018 | delete publishdlg; | 4018 | delete publishdlg; |
4019 | } | 4019 | } |
4020 | 4020 | ||
4021 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 4021 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
4022 | { | 4022 | { |
4023 | Event *event = 0; | 4023 | Event *event = 0; |
4024 | Todo *todo = 0; | 4024 | Todo *todo = 0; |
4025 | 4025 | ||
4026 | if (incidence == 0) { | 4026 | if (incidence == 0) { |
4027 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 4027 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
4028 | if (incidence == 0) { | 4028 | if (incidence == 0) { |
4029 | incidence = mTodoList->selectedIncidences().first(); | 4029 | incidence = mTodoList->selectedIncidences().first(); |
4030 | } | 4030 | } |
4031 | } | 4031 | } |
4032 | if ( incidence && incidence->typeID() == eventID ) { | 4032 | if ( incidence && incidence->typeID() == eventID ) { |
4033 | event = static_cast<Event *>(incidence); | 4033 | event = static_cast<Event *>(incidence); |
4034 | } | 4034 | } |
4035 | if ( incidence && incidence->typeID() == todoID ) { | 4035 | if ( incidence && incidence->typeID() == todoID ) { |
4036 | todo = static_cast<Todo *>(incidence); | 4036 | todo = static_cast<Todo *>(incidence); |
4037 | } | 4037 | } |
4038 | 4038 | ||
4039 | if (!event && !todo) { | 4039 | if (!event && !todo) { |
4040 | KMessageBox::sorry(this,i18n("No event selected.")); | 4040 | KMessageBox::sorry(this,i18n("No event selected.")); |
4041 | return; | 4041 | return; |
4042 | } | 4042 | } |
4043 | 4043 | ||
4044 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 4044 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
4045 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 4045 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
4046 | return; | 4046 | return; |
4047 | } | 4047 | } |
4048 | 4048 | ||
4049 | Event *ev = 0; | 4049 | Event *ev = 0; |
4050 | if (event) ev = new Event(*event); | 4050 | if (event) ev = new Event(*event); |
4051 | Todo *to = 0; | 4051 | Todo *to = 0; |
4052 | if (todo) to = new Todo(*todo); | 4052 | if (todo) to = new Todo(*todo); |
4053 | 4053 | ||
4054 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 4054 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
4055 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 4055 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
4056 | if (!me) { | 4056 | if (!me) { |
4057 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 4057 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
4058 | return; | 4058 | return; |
4059 | } | 4059 | } |
4060 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 4060 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
4061 | StatusDialog *statdlg = new StatusDialog(this); | 4061 | StatusDialog *statdlg = new StatusDialog(this); |
4062 | if (!statdlg->exec()==QDialog::Accepted) return; | 4062 | if (!statdlg->exec()==QDialog::Accepted) return; |
4063 | me->setStatus( statdlg->status() ); | 4063 | me->setStatus( statdlg->status() ); |
4064 | delete(statdlg); | 4064 | delete(statdlg); |
4065 | } | 4065 | } |
4066 | Attendee *menew = new Attendee(*me); | 4066 | Attendee *menew = new Attendee(*me); |
4067 | if (ev) { | 4067 | if (ev) { |
4068 | ev->clearAttendees(); | 4068 | ev->clearAttendees(); |
4069 | ev->addAttendee(menew,false); | 4069 | ev->addAttendee(menew,false); |
4070 | } else { | 4070 | } else { |
4071 | if (to) { | 4071 | if (to) { |
4072 | todo->clearAttendees(); | 4072 | todo->clearAttendees(); |
4073 | todo->addAttendee(menew,false); | 4073 | todo->addAttendee(menew,false); |
4074 | } | 4074 | } |
4075 | } | 4075 | } |
4076 | } | 4076 | } |
4077 | 4077 | ||
4078 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 4078 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
4079 | if (ev) { | 4079 | if (ev) { |
4080 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 4080 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
4081 | } else { | 4081 | } else { |
4082 | if (to) { | 4082 | if (to) { |
4083 | if ( !dlg->addMessage(to,method) ) delete(to); | 4083 | if ( !dlg->addMessage(to,method) ) delete(to); |
4084 | } | 4084 | } |
4085 | } | 4085 | } |
4086 | } | 4086 | } |
4087 | 4087 | ||
4088 | void CalendarView::openAddressbook() | 4088 | void CalendarView::openAddressbook() |
4089 | { | 4089 | { |
4090 | KRun::runCommand("kaddressbook"); | 4090 | KRun::runCommand("kaddressbook"); |
4091 | } | 4091 | } |
4092 | 4092 | ||
4093 | void CalendarView::setModified(bool modified) | 4093 | void CalendarView::setModified(bool modified) |
4094 | { | 4094 | { |
4095 | //qDebug("CalendarView::setModified %d ", modified); | 4095 | //qDebug("CalendarView::setModified %d ", modified); |
4096 | if ( modified ) | 4096 | if ( modified ) |
4097 | emit signalmodified(); | 4097 | emit signalmodified(); |
4098 | mModified = modified; | 4098 | mModified = modified; |
4099 | if ( mModified ) | 4099 | if ( mModified ) |
4100 | emit modifiedChanged(mModified); | 4100 | emit modifiedChanged(mModified); |
4101 | 4101 | ||
4102 | } | 4102 | } |
4103 | 4103 | ||
4104 | bool CalendarView::isReadOnly() | 4104 | bool CalendarView::isReadOnly() |
4105 | { | 4105 | { |
4106 | return mReadOnly; | 4106 | return mReadOnly; |
4107 | } | 4107 | } |
4108 | 4108 | ||
4109 | void CalendarView::setReadOnly(bool readOnly) | 4109 | void CalendarView::setReadOnly(bool readOnly) |
4110 | { | 4110 | { |
4111 | if (mReadOnly != readOnly) { | 4111 | if (mReadOnly != readOnly) { |
4112 | mReadOnly = readOnly; | 4112 | mReadOnly = readOnly; |
4113 | emit readOnlyChanged(mReadOnly); | 4113 | emit readOnlyChanged(mReadOnly); |
4114 | } | 4114 | } |
4115 | } | 4115 | } |
4116 | 4116 | ||
4117 | bool CalendarView::isModified() | 4117 | bool CalendarView::isModified() |
4118 | { | 4118 | { |
4119 | return mModified; | 4119 | return mModified; |
4120 | } | 4120 | } |
4121 | void CalendarView::slotprintSelInc() | 4121 | void CalendarView::slotprintSelInc() |
4122 | { | 4122 | { |
4123 | if ( currentSelection() == 0 ) { | 4123 | if ( currentSelection() == 0 ) { |
4124 | KMessageBox::sorry(this,i18n("There is nothing selected!")); | 4124 | KMessageBox::sorry(this,i18n("There is nothing selected!")); |
4125 | return; | 4125 | return; |
4126 | } | 4126 | } |
4127 | showIncidence(); | 4127 | showIncidence(); |
4128 | getEventViewerDialog()->print(); | 4128 | getEventViewerDialog()->print(); |
4129 | 4129 | ||
4130 | } | 4130 | } |
4131 | void CalendarView::printSetup() | 4131 | void CalendarView::printSetup() |
4132 | { | 4132 | { |
4133 | #ifndef KORG_NOPRINTER | 4133 | #ifndef KORG_NOPRINTER |
4134 | createPrinter(); | 4134 | createPrinter(); |
4135 | 4135 | ||
4136 | mCalPrinter->setupPrinter(); | 4136 | mCalPrinter->setupPrinter(); |
4137 | #endif | 4137 | #endif |
4138 | } | 4138 | } |
4139 | 4139 | ||
4140 | void CalendarView::print() | 4140 | void CalendarView::print() |
4141 | { | 4141 | { |
4142 | #ifndef KORG_NOPRINTER | 4142 | #ifndef KORG_NOPRINTER |
4143 | createPrinter(); | 4143 | createPrinter(); |
4144 | 4144 | ||
4145 | DateList tmpDateList = mNavigator->selectedDates(); | 4145 | DateList tmpDateList = mNavigator->selectedDates(); |
4146 | mCalPrinter->print(CalPrinter::Month, | 4146 | mCalPrinter->print(CalPrinter::Month, |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 0dd5ef5..c738f7e 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -198,1189 +198,1189 @@ KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | |||
198 | mAllDayMode = true; | 198 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 199 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 201 | #endif |
202 | mHolidayMask = 0; | 202 | mHolidayMask = 0; |
203 | init(); | 203 | init(); |
204 | } | 204 | } |
205 | 205 | ||
206 | 206 | ||
207 | KOAgenda::~KOAgenda() | 207 | KOAgenda::~KOAgenda() |
208 | { | 208 | { |
209 | if(mMarcusBains) delete mMarcusBains; | 209 | if(mMarcusBains) delete mMarcusBains; |
210 | 210 | ||
211 | } | 211 | } |
212 | 212 | ||
213 | Incidence *KOAgenda::selectedIncidence() const | 213 | Incidence *KOAgenda::selectedIncidence() const |
214 | { | 214 | { |
215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | QDate KOAgenda::selectedIncidenceDate() const | 219 | QDate KOAgenda::selectedIncidenceDate() const |
220 | { | 220 | { |
221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | void KOAgenda::init() | 225 | void KOAgenda::init() |
226 | { | 226 | { |
227 | mPopupTimer = new QTimer(this); | 227 | mPopupTimer = new QTimer(this); |
228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
229 | 229 | ||
230 | mNewItemPopup = new QPopupMenu( this ); | 230 | mNewItemPopup = new QPopupMenu( this ); |
231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
232 | QString pathString = ""; | 232 | QString pathString = ""; |
233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
234 | if ( QApplication::desktop()->width() < 480 ) | 234 | if ( QApplication::desktop()->width() < 480 ) |
235 | pathString += "icons16/"; | 235 | pathString += "icons16/"; |
236 | } else | 236 | } else |
237 | pathString += "iconsmini/"; | 237 | pathString += "iconsmini/"; |
238 | 238 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 241 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 248 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 250 | viewport()->setWFlags ( wflags); |
251 | #endif | 251 | #endif |
252 | mGridSpacingX = 80; | 252 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 253 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 254 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 255 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 256 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 257 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 258 | //enableClipper(true); |
259 | 259 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 261 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 262 | setFocusPolicy(WheelFocus); |
263 | 263 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 267 | ||
268 | mStartCellX = 0; | 268 | mStartCellX = 0; |
269 | mStartCellY = 0; | 269 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 270 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 271 | mCurrentCellY = 0; |
272 | 272 | ||
273 | mSelectionCellX = 0; | 273 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 274 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 275 | mSelectionHeight = 0; |
276 | 276 | ||
277 | mOldLowerScrollValue = -1; | 277 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 278 | mOldUpperScrollValue = -1; |
279 | 279 | ||
280 | mClickedItem = 0; | 280 | mClickedItem = 0; |
281 | 281 | ||
282 | mActionItem = 0; | 282 | mActionItem = 0; |
283 | mActionType = NOP; | 283 | mActionType = NOP; |
284 | mItemMoved = false; | 284 | mItemMoved = false; |
285 | 285 | ||
286 | mSelectedItem = 0; | 286 | mSelectedItem = 0; |
287 | 287 | ||
288 | // mItems.setAutoDelete(true); | 288 | // mItems.setAutoDelete(true); |
289 | 289 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 291 | ||
292 | viewport()->update(); | 292 | viewport()->update(); |
293 | 293 | ||
294 | setMinimumSize(30, 1); | 294 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 295 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 296 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 297 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 298 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 299 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 300 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 301 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 302 | setVScrollBarMode(AlwaysOn); |
303 | else | 303 | else |
304 | setVScrollBarMode(AlwaysOff); | 304 | setVScrollBarMode(AlwaysOff); |
305 | 305 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 306 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 307 | ||
308 | calculateWorkingHours(); | 308 | calculateWorkingHours(); |
309 | 309 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 311 | SLOT(checkScrollBoundaries(int))); |
312 | 312 | ||
313 | // Create the Marcus Bains line. | 313 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 314 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 315 | mMarcusBains = 0; |
316 | else { | 316 | else { |
317 | mMarcusBains = new MarcusBains(this); | 317 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 318 | addChild(mMarcusBains); |
319 | } | 319 | } |
320 | mPopupKind = 0; | 320 | mPopupKind = 0; |
321 | mPopupItem = 0; | 321 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 322 | mInvalidPixmap = false; |
323 | 323 | ||
324 | } | 324 | } |
325 | 325 | ||
326 | void KOAgenda::shrinkPixmap() | 326 | void KOAgenda::shrinkPixmap() |
327 | { | 327 | { |
328 | mPaintPixmap.resize( 20,20); | 328 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 329 | mInvalidPixmap = true; |
330 | } | 330 | } |
331 | void KOAgenda::slotContentMove(int,int) | 331 | void KOAgenda::slotContentMove(int,int) |
332 | { | 332 | { |
333 | emit sendPing(); | 333 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 334 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 335 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 336 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 337 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 338 | emit incidenceSelected( 0 ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | void KOAgenda::clear() | 341 | void KOAgenda::clear() |
342 | { | 342 | { |
343 | KOAgendaItem *item; | 343 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 345 | mUnusedItems.append( item ); |
346 | //item->hide(); | 346 | //item->hide(); |
347 | } | 347 | } |
348 | mItems.clear(); | 348 | mItems.clear(); |
349 | mSelectedItem = 0; | 349 | mSelectedItem = 0; |
350 | clearSelection(); | 350 | clearSelection(); |
351 | } | 351 | } |
352 | 352 | ||
353 | void KOAgenda::clearSelection() | 353 | void KOAgenda::clearSelection() |
354 | { | 354 | { |
355 | mSelectionCellX = 0; | 355 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 356 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 357 | mSelectionHeight = 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOAgenda::marcus_bains() | 360 | void KOAgenda::marcus_bains() |
361 | { | 361 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 362 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | void KOAgenda::changeColumns(int columns) | 366 | void KOAgenda::changeColumns(int columns) |
367 | { | 367 | { |
368 | if (columns == 0) { | 368 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 370 | return; |
371 | } | 371 | } |
372 | clear(); | 372 | clear(); |
373 | mColumns = columns; | 373 | mColumns = columns; |
374 | computeSizes(); | 374 | computeSizes(); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* | 377 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 378 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 379 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 380 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 382 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 383 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 384 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 385 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 386 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 387 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 388 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 390 | ||
391 | case (QEvent::Leave): | 391 | case (QEvent::Leave): |
392 | if (!mActionItem) | 392 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 393 | setCursor(arrowCursor); |
394 | return true; | 394 | return true; |
395 | 395 | ||
396 | default: | 396 | default: |
397 | return QScrollView::eventFilter(object,event); | 397 | return QScrollView::eventFilter(object,event); |
398 | } | 398 | } |
399 | } | 399 | } |
400 | void KOAgenda::popupMenu() | 400 | void KOAgenda::popupMenu() |
401 | { | 401 | { |
402 | mPopupTimer->stop(); | 402 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 404 | if (mActionItem ) { |
405 | endItemAction(); | 405 | endItemAction(); |
406 | } | 406 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 407 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 408 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 409 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 410 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 412 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 413 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 414 | ||
415 | } | 415 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 418 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 419 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 420 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 422 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 423 | mNewItemPopup->popup( mPopupPos); |
424 | 424 | ||
425 | } | 425 | } |
426 | mLeftMouseDown = false; | 426 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 427 | mPopupItem = 0; |
428 | mPopupKind = 0; | 428 | mPopupKind = 0; |
429 | } | 429 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 430 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 431 | { |
432 | KOAgendaItem *item; | 432 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 434 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 435 | item->initColor (); |
436 | item->updateItem(); | 436 | item->updateItem(); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 441 | { |
442 | 442 | ||
443 | if ( mInvalidPixmap ) { | 443 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 444 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 445 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 446 | computeSizes(); |
447 | emit updateViewSignal(); | 447 | emit updateViewSignal(); |
448 | return true; | 448 | return true; |
449 | } | 449 | } |
450 | emit sendPing(); | 450 | emit sendPing(); |
451 | static int startX = 0; | 451 | static int startX = 0; |
452 | static int startY = 0; | 452 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 454 | static bool blockMoving = true; |
455 | 455 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 456 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 457 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 458 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 459 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 460 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 461 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 462 | if ( dX < 0 ) |
463 | dX = -dX; | 463 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 464 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 465 | if ( dY < 0 ) |
466 | dY = -dY; | 466 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 468 | mNewItemPopup->hide(); |
469 | } | 469 | } |
470 | } | 470 | } |
471 | return true; | 471 | return true; |
472 | } | 472 | } |
473 | if ( object == mAllAgendaPopup ) { | 473 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 474 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 475 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 476 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 477 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 478 | if ( dX < 0 ) |
479 | dX = -dX; | 479 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 480 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 481 | if ( dY < 0 ) |
482 | dY = -dY; | 482 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 484 | mAllAgendaPopup->hide(); |
485 | } | 485 | } |
486 | } | 486 | } |
487 | return true; | 487 | return true; |
488 | } | 488 | } |
489 | QPoint viewportPos; | 489 | QPoint viewportPos; |
490 | if (object != viewport()) { | 490 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 491 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 493 | } else { |
494 | viewportPos = me->pos(); | 494 | viewportPos = me->pos(); |
495 | } | 495 | } |
496 | bool objIsNotViewport = (object != viewport()); | 496 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 497 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 498 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 499 | leftButt = (me->button() == LeftButton); |
500 | #endif | 500 | #endif |
501 | switch (me->type()) { | 501 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 502 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 503 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 504 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 505 | mLeftMouseDown = true; |
506 | } | 506 | } |
507 | blockMoving = true; | 507 | blockMoving = true; |
508 | startX = viewportPos.x(); | 508 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 509 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 510 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 511 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 513 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 514 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 515 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 516 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 517 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 518 | minV = blockmoveDist; |
519 | else | 519 | else |
520 | minV = (blockmoveDist/2); | 520 | minV = (blockmoveDist/2); |
521 | } | 521 | } |
522 | bool border = false; | 522 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 523 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 524 | if ( diff < 0 ) |
525 | diff *= -1; | 525 | diff *= -1; |
526 | if ( diff < minV ) { | 526 | if ( diff < minV ) { |
527 | border = true; | 527 | border = true; |
528 | objIsNotViewport = false; | 528 | objIsNotViewport = false; |
529 | } | 529 | } |
530 | if ( ! border ) { | 530 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 532 | if ( diff < 0 ) |
533 | diff *= -1; | 533 | diff *= -1; |
534 | if ( diff < minV ) { | 534 | if ( diff < minV ) { |
535 | border = true; | 535 | border = true; |
536 | objIsNotViewport = false; | 536 | objIsNotViewport = false; |
537 | } | 537 | } |
538 | } | 538 | } |
539 | } | 539 | } |
540 | } else { // not allday | 540 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 541 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 542 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 543 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 544 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 545 | minH = blockmoveDist; |
546 | else | 546 | else |
547 | minH = (blockmoveDist/2); | 547 | minH = (blockmoveDist/2); |
548 | } | 548 | } |
549 | bool border = false; | 549 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 550 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 551 | if ( diff < 0 ) |
552 | diff *= -1; | 552 | diff *= -1; |
553 | if ( diff < minH ) { | 553 | if ( diff < minH ) { |
554 | border = true; | 554 | border = true; |
555 | objIsNotViewport = false; | 555 | objIsNotViewport = false; |
556 | } | 556 | } |
557 | if ( ! border ) { | 557 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 559 | if ( diff < 0 ) |
560 | diff *= -1; | 560 | diff *= -1; |
561 | if ( diff < minH ) { | 561 | if ( diff < minH ) { |
562 | border = true; | 562 | border = true; |
563 | objIsNotViewport = false; | 563 | objIsNotViewport = false; |
564 | } | 564 | } |
565 | } | 565 | } |
566 | } | 566 | } |
567 | } | 567 | } |
568 | } | 568 | } |
569 | if ( objIsNotViewport ) { | 569 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 570 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 571 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 572 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 573 | mPopupKind = 3; |
574 | popupMenu(); | 574 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 575 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 576 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 577 | if (mActionItem) { |
578 | emit signalClearSelection(); | 578 | emit signalClearSelection(); |
579 | slotClearSelection(); | 579 | slotClearSelection(); |
580 | selectItem(mActionItem); | 580 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 581 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 582 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { |
583 | mActionItem = 0; | 583 | mActionItem = 0; |
584 | } else { | 584 | } else { |
585 | startItemAction(viewportPos); | 585 | startItemAction(viewportPos); |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } else { // ---------- viewport() | 589 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 590 | mPopupItem = 0; |
591 | mPopupKind = 2; | 591 | mPopupKind = 2; |
592 | selectItem(0); | 592 | selectItem(0); |
593 | mActionItem = 0; | 593 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 594 | if (me->button() == RightButton) { |
595 | int x,y; | 595 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 597 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 598 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 599 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 600 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 601 | mStartCellX = gx; |
602 | mStartCellY = gy; | 602 | mStartCellY = gy; |
603 | mPopupKind = 4; | 603 | mPopupKind = 4; |
604 | popupMenu(); | 604 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 605 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 606 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 607 | startSelectAction(viewportPos); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | break; | 610 | break; |
611 | 611 | ||
612 | case QEvent::MouseButtonRelease: | 612 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 613 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 614 | mPopupTimer->stop(); |
615 | } | 615 | } |
616 | if (object != viewport()) { | 616 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 617 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 618 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 622 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 623 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 624 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 625 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 626 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 627 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 628 | mActionItem = 0; |
629 | mActionType = NOP; | 629 | mActionType = NOP; |
630 | mItemMoved = 0; | 630 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 631 | mLeftMouseDown = false; |
632 | return true; | 632 | return true; |
633 | } | 633 | } |
634 | endItemAction(); | 634 | endItemAction(); |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | } else { // ---------- viewport() | 638 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 640 | endSelectAction( true ); // emit new event signal |
641 | } | 641 | } |
642 | } | 642 | } |
643 | if (me->button() == LeftButton) | 643 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 644 | mLeftMouseDown = false; |
645 | 645 | ||
646 | break; | 646 | break; |
647 | 647 | ||
648 | case QEvent::MouseMove: | 648 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 649 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 650 | if ( !mLeftMouseDown ) |
651 | return false; | 651 | return false; |
652 | if ( blockMoving ) { | 652 | if ( blockMoving ) { |
653 | int dX, dY; | 653 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 654 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 655 | if ( dX < 0 ) |
656 | dX = -dX; | 656 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 657 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 658 | if ( dY < 0 ) |
659 | dY = -dY; | 659 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 662 | blockMoving = false; |
663 | } | 663 | } |
664 | } | 664 | } |
665 | if ( ! blockMoving ) | 665 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 666 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 667 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 669 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 670 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 671 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 672 | else { |
673 | if ( !blockMoving ) | 673 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 674 | performItemAction(viewportPos); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | } else { // ---------- viewport() | 677 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 679 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 680 | performSelectAction( viewportPos ); |
681 | } | 681 | } |
682 | } | 682 | } |
683 | break; | 683 | break; |
684 | 684 | ||
685 | case QEvent::MouseButtonDblClick: | 685 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 686 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 687 | if (object == viewport()) { |
688 | selectItem(0); | 688 | selectItem(0); |
689 | int x,y; | 689 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 691 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 692 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 693 | emit newEventSignal(gx,gy); |
694 | } else { | 694 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 696 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 698 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 699 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 700 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 701 | } |
702 | break; | 702 | break; |
703 | 703 | ||
704 | default: | 704 | default: |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | return true; | 707 | return true; |
708 | 708 | ||
709 | } | 709 | } |
710 | 710 | ||
711 | void KOAgenda::newItem( int item ) | 711 | void KOAgenda::newItem( int item ) |
712 | { | 712 | { |
713 | if ( item == 1 ) { //new event | 713 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 714 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 715 | } else |
716 | if ( item == 2 ) { //new event | 716 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 717 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 718 | } else |
719 | { | 719 | { |
720 | emit showDateView( item, mStartCellX ); | 720 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 721 | // 3Day view |
722 | // 4Week view | 722 | // 4Week view |
723 | // 5Month view | 723 | // 5Month view |
724 | // 6Journal view | 724 | // 6Journal view |
725 | } | 725 | } |
726 | } | 726 | } |
727 | void KOAgenda::slotClearSelection() | 727 | void KOAgenda::slotClearSelection() |
728 | { | 728 | { |
729 | if (mSelectionHeight) { | 729 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 730 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 731 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 732 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 733 | clearSelection(); |
734 | repaintContents( selectionX, top, | 734 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 735 | mGridSpacingX, hei ,false ); |
736 | } | 736 | } |
737 | 737 | ||
738 | } | 738 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 739 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 740 | { |
741 | 741 | ||
742 | emit signalClearSelection(); | 742 | emit signalClearSelection(); |
743 | slotClearSelection(); | 743 | slotClearSelection(); |
744 | 744 | ||
745 | mActionType = SELECT; | 745 | mActionType = SELECT; |
746 | 746 | ||
747 | int x,y; | 747 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 749 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 750 | contentsToGrid(x,y,gx,gy); |
751 | 751 | ||
752 | mStartCellX = gx; | 752 | mStartCellX = gx; |
753 | mStartCellY = gy; | 753 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 754 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 755 | mCurrentCellY = gy; |
756 | 756 | ||
757 | // Store new selection | 757 | // Store new selection |
758 | mSelectionCellX = gx; | 758 | mSelectionCellX = gx; |
759 | mSelectionYTop = gy * mGridSpacingY; | 759 | mSelectionYTop = gy * mGridSpacingY; |
760 | mSelectionHeight = mGridSpacingY; | 760 | mSelectionHeight = mGridSpacingY; |
761 | 761 | ||
762 | // Paint new selection | 762 | // Paint new selection |
763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, | 763 | repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, |
764 | mGridSpacingX-1, mSelectionHeight ); | 764 | mGridSpacingX-1, mSelectionHeight ); |
765 | } | 765 | } |
766 | 766 | ||
767 | void KOAgenda::performSelectAction(QPoint viewportPos) | 767 | void KOAgenda::performSelectAction(QPoint viewportPos) |
768 | { | 768 | { |
769 | int x,y; | 769 | int x,y; |
770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 770 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
771 | int gx,gy; | 771 | int gx,gy; |
772 | contentsToGrid(x,y,gx,gy); | 772 | contentsToGrid(x,y,gx,gy); |
773 | 773 | ||
774 | QPoint clipperPos = clipper()-> | 774 | QPoint clipperPos = clipper()-> |
775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 775 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
776 | 776 | ||
777 | // Scroll if cursor was moved to upper or lower end of agenda. | 777 | // Scroll if cursor was moved to upper or lower end of agenda. |
778 | if (clipperPos.y() < mScrollBorderWidth) { | 778 | if (clipperPos.y() < mScrollBorderWidth) { |
779 | mScrollUpTimer.start(mScrollDelay); | 779 | mScrollUpTimer.start(mScrollDelay); |
780 | } else if (visibleHeight() - clipperPos.y() < | 780 | } else if (visibleHeight() - clipperPos.y() < |
781 | mScrollBorderWidth) { | 781 | mScrollBorderWidth) { |
782 | mScrollDownTimer.start(mScrollDelay); | 782 | mScrollDownTimer.start(mScrollDelay); |
783 | } else { | 783 | } else { |
784 | mScrollUpTimer.stop(); | 784 | mScrollUpTimer.stop(); |
785 | mScrollDownTimer.stop(); | 785 | mScrollDownTimer.stop(); |
786 | } | 786 | } |
787 | 787 | ||
788 | if ( gy > mCurrentCellY ) { | 788 | if ( gy > mCurrentCellY ) { |
789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 789 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
790 | 790 | ||
791 | 791 | ||
792 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 792 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 793 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
794 | mGridSpacingX, mSelectionYTop, | 794 | mGridSpacingX, mSelectionYTop, |
795 | mGridSpacingX, mSelectionHeight , false); | 795 | mGridSpacingX, mSelectionHeight , false); |
796 | 796 | ||
797 | mCurrentCellY = gy; | 797 | mCurrentCellY = gy; |
798 | } else if ( gy < mCurrentCellY ) { | 798 | } else if ( gy < mCurrentCellY ) { |
799 | if ( gy >= mStartCellY ) { | 799 | if ( gy >= mStartCellY ) { |
800 | int selectionHeight = mSelectionHeight; | 800 | int selectionHeight = mSelectionHeight; |
801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 801 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
802 | 802 | ||
803 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 803 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 804 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
805 | mGridSpacingX, mSelectionYTop, | 805 | mGridSpacingX, mSelectionYTop, |
806 | mGridSpacingX, selectionHeight,false ); | 806 | mGridSpacingX, selectionHeight,false ); |
807 | 807 | ||
808 | mCurrentCellY = gy; | 808 | mCurrentCellY = gy; |
809 | } else { | 809 | } else { |
810 | } | 810 | } |
811 | } | 811 | } |
812 | } | 812 | } |
813 | 813 | ||
814 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 814 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
815 | { | 815 | { |
816 | mActionType = NOP; | 816 | mActionType = NOP; |
817 | mScrollUpTimer.stop(); | 817 | mScrollUpTimer.stop(); |
818 | mScrollDownTimer.stop(); | 818 | mScrollDownTimer.stop(); |
819 | 819 | ||
820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 820 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { | 821 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) { |
822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 822 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | void KOAgenda::startItemAction(QPoint viewportPos) | 826 | void KOAgenda::startItemAction(QPoint viewportPos) |
827 | { | 827 | { |
828 | int x,y; | 828 | int x,y; |
829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 829 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
830 | int gx,gy; | 830 | int gx,gy; |
831 | contentsToGrid(x,y,gx,gy); | 831 | contentsToGrid(x,y,gx,gy); |
832 | 832 | ||
833 | mStartCellX = gx; | 833 | mStartCellX = gx; |
834 | mStartCellY = gy; | 834 | mStartCellY = gy; |
835 | mCurrentCellX = gx; | 835 | mCurrentCellX = gx; |
836 | mCurrentCellY = gy; | 836 | mCurrentCellY = gy; |
837 | 837 | ||
838 | if (mAllDayMode) { | 838 | if (mAllDayMode) { |
839 | int gridDistanceX = (x - gx * mGridSpacingX); | 839 | int gridDistanceX = (x - gx * mGridSpacingX); |
840 | if (gridDistanceX < mResizeBorderWidth && | 840 | if (gridDistanceX < mResizeBorderWidth && |
841 | mActionItem->cellX() == mCurrentCellX) { | 841 | mActionItem->cellX() == mCurrentCellX) { |
842 | mActionType = RESIZELEFT; | 842 | mActionType = RESIZELEFT; |
843 | setCursor(sizeHorCursor); | 843 | setCursor(sizeHorCursor); |
844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 844 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
845 | mActionItem->cellXWidth() == mCurrentCellX) { | 845 | mActionItem->cellXWidth() == mCurrentCellX) { |
846 | mActionType = RESIZERIGHT; | 846 | mActionType = RESIZERIGHT; |
847 | setCursor(sizeHorCursor); | 847 | setCursor(sizeHorCursor); |
848 | } else { | 848 | } else { |
849 | mActionType = MOVE; | 849 | mActionType = MOVE; |
850 | mActionItem->startMove(); | 850 | mActionItem->startMove(); |
851 | setCursor(sizeAllCursor); | 851 | setCursor(sizeAllCursor); |
852 | } | 852 | } |
853 | } else { | 853 | } else { |
854 | int gridDistanceY = (y - gy * mGridSpacingY); | 854 | int gridDistanceY = (y - gy * mGridSpacingY); |
855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); | 855 | bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); |
856 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 856 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
857 | mActionItem->cellYTop() == mCurrentCellY && | 857 | mActionItem->cellYTop() == mCurrentCellY && |
858 | !mActionItem->firstMultiItem()) { | 858 | !mActionItem->firstMultiItem()) { |
859 | mActionType = RESIZETOP; | 859 | mActionType = RESIZETOP; |
860 | setCursor(sizeVerCursor); | 860 | setCursor(sizeVerCursor); |
861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 861 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
862 | mActionItem->cellYBottom() == mCurrentCellY && | 862 | mActionItem->cellYBottom() == mCurrentCellY && |
863 | !mActionItem->lastMultiItem()) { | 863 | !mActionItem->lastMultiItem()) { |
864 | mActionType = RESIZEBOTTOM; | 864 | mActionType = RESIZEBOTTOM; |
865 | setCursor(sizeVerCursor); | 865 | setCursor(sizeVerCursor); |
866 | } else { | 866 | } else { |
867 | mActionType = MOVE; | 867 | mActionType = MOVE; |
868 | mActionItem->startMove(); | 868 | mActionItem->startMove(); |
869 | setCursor(sizeAllCursor); | 869 | setCursor(sizeAllCursor); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | } | 872 | } |
873 | 873 | ||
874 | void KOAgenda::performItemAction(QPoint viewportPos) | 874 | void KOAgenda::performItemAction(QPoint viewportPos) |
875 | { | 875 | { |
876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 876 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
877 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 877 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 878 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
879 | // point = clipper()->mapFromGlobal(point); | 879 | // point = clipper()->mapFromGlobal(point); |
880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 880 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
881 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 881 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
882 | int x,y; | 882 | int x,y; |
883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 883 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 884 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
885 | int gx,gy; | 885 | int gx,gy; |
886 | contentsToGrid(x,y,gx,gy); | 886 | contentsToGrid(x,y,gx,gy); |
887 | QPoint clipperPos = clipper()-> | 887 | QPoint clipperPos = clipper()-> |
888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 888 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
889 | 889 | ||
890 | // Cursor left active agenda area. | 890 | // Cursor left active agenda area. |
891 | // This starts a drag. | 891 | // This starts a drag. |
892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 892 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 893 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
894 | if ( mActionType == MOVE ) { | 894 | if ( mActionType == MOVE ) { |
895 | mScrollUpTimer.stop(); | 895 | mScrollUpTimer.stop(); |
896 | mScrollDownTimer.stop(); | 896 | mScrollDownTimer.stop(); |
897 | mActionItem->resetMove(); | 897 | mActionItem->resetMove(); |
898 | placeSubCells( mActionItem ); | 898 | placeSubCells( mActionItem ); |
899 | // emit startDragSignal( mActionItem->incidence() ); | 899 | // emit startDragSignal( mActionItem->incidence() ); |
900 | setCursor( arrowCursor ); | 900 | setCursor( arrowCursor ); |
901 | mActionItem = 0; | 901 | mActionItem = 0; |
902 | mActionType = NOP; | 902 | mActionType = NOP; |
903 | mItemMoved = 0; | 903 | mItemMoved = 0; |
904 | return; | 904 | return; |
905 | } | 905 | } |
906 | } else { | 906 | } else { |
907 | switch ( mActionType ) { | 907 | switch ( mActionType ) { |
908 | case MOVE: | 908 | case MOVE: |
909 | setCursor( sizeAllCursor ); | 909 | setCursor( sizeAllCursor ); |
910 | break; | 910 | break; |
911 | case RESIZETOP: | 911 | case RESIZETOP: |
912 | case RESIZEBOTTOM: | 912 | case RESIZEBOTTOM: |
913 | setCursor( sizeVerCursor ); | 913 | setCursor( sizeVerCursor ); |
914 | break; | 914 | break; |
915 | case RESIZELEFT: | 915 | case RESIZELEFT: |
916 | case RESIZERIGHT: | 916 | case RESIZERIGHT: |
917 | setCursor( sizeHorCursor ); | 917 | setCursor( sizeHorCursor ); |
918 | break; | 918 | break; |
919 | default: | 919 | default: |
920 | setCursor( arrowCursor ); | 920 | setCursor( arrowCursor ); |
921 | } | 921 | } |
922 | } | 922 | } |
923 | 923 | ||
924 | // Scroll if item was moved to upper or lower end of agenda. | 924 | // Scroll if item was moved to upper or lower end of agenda. |
925 | if (clipperPos.y() < mScrollBorderWidth) { | 925 | if (clipperPos.y() < mScrollBorderWidth) { |
926 | mScrollUpTimer.start(mScrollDelay); | 926 | mScrollUpTimer.start(mScrollDelay); |
927 | } else if (visibleHeight() - clipperPos.y() < | 927 | } else if (visibleHeight() - clipperPos.y() < |
928 | mScrollBorderWidth) { | 928 | mScrollBorderWidth) { |
929 | mScrollDownTimer.start(mScrollDelay); | 929 | mScrollDownTimer.start(mScrollDelay); |
930 | } else { | 930 | } else { |
931 | mScrollUpTimer.stop(); | 931 | mScrollUpTimer.stop(); |
932 | mScrollDownTimer.stop(); | 932 | mScrollDownTimer.stop(); |
933 | } | 933 | } |
934 | 934 | ||
935 | // Move or resize item if necessary | 935 | // Move or resize item if necessary |
936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 936 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
937 | mItemMoved = true; | 937 | mItemMoved = true; |
938 | mActionItem->raise(); | 938 | mActionItem->raise(); |
939 | if (mActionType == MOVE) { | 939 | if (mActionType == MOVE) { |
940 | // Move all items belonging to a multi item | 940 | // Move all items belonging to a multi item |
941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 941 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 942 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
943 | if (!moveItem) moveItem = mActionItem; | 943 | if (!moveItem) moveItem = mActionItem; |
944 | while (moveItem) { | 944 | while (moveItem) { |
945 | int dy; | 945 | int dy; |
946 | if (isMultiItem) dy = 0; | 946 | if (isMultiItem) dy = 0; |
947 | else dy = gy - mCurrentCellY; | 947 | else dy = gy - mCurrentCellY; |
948 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 948 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
949 | int x,y; | 949 | int x,y; |
950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 950 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 951 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
952 | mGridSpacingY * moveItem->cellHeight()); | 952 | mGridSpacingY * moveItem->cellHeight()); |
953 | moveItem->raise(); | 953 | moveItem->raise(); |
954 | moveChild(moveItem,x,y); | 954 | moveChild(moveItem,x,y); |
955 | moveItem = moveItem->nextMultiItem(); | 955 | moveItem = moveItem->nextMultiItem(); |
956 | } | 956 | } |
957 | } else if (mActionType == RESIZETOP) { | 957 | } else if (mActionType == RESIZETOP) { |
958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 958 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
959 | mActionItem->expandTop(gy - mCurrentCellY); | 959 | mActionItem->expandTop(gy - mCurrentCellY); |
960 | mActionItem->resize(mActionItem->width(), | 960 | mActionItem->resize(mActionItem->width(), |
961 | mGridSpacingY * mActionItem->cellHeight()); | 961 | mGridSpacingY * mActionItem->cellHeight()); |
962 | int x,y; | 962 | int x,y; |
963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 963 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
964 | //moveChild(mActionItem,childX(mActionItem),y); | 964 | //moveChild(mActionItem,childX(mActionItem),y); |
965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 965 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
966 | } | 966 | } |
967 | } else if (mActionType == RESIZEBOTTOM) { | 967 | } else if (mActionType == RESIZEBOTTOM) { |
968 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 968 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
969 | mActionItem->expandBottom(gy - mCurrentCellY); | 969 | mActionItem->expandBottom(gy - mCurrentCellY); |
970 | mActionItem->resize(mActionItem->width(), | 970 | mActionItem->resize(mActionItem->width(), |
971 | mGridSpacingY * mActionItem->cellHeight()); | 971 | mGridSpacingY * mActionItem->cellHeight()); |
972 | } | 972 | } |
973 | } else if (mActionType == RESIZELEFT) { | 973 | } else if (mActionType == RESIZELEFT) { |
974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 974 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
975 | mActionItem->expandLeft(gx - mCurrentCellX); | 975 | mActionItem->expandLeft(gx - mCurrentCellX); |
976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 976 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
977 | mActionItem->height()); | 977 | mActionItem->height()); |
978 | int x,y; | 978 | int x,y; |
979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 979 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
980 | moveChild(mActionItem,x,childY(mActionItem)); | 980 | moveChild(mActionItem,x,childY(mActionItem)); |
981 | } | 981 | } |
982 | } else if (mActionType == RESIZERIGHT) { | 982 | } else if (mActionType == RESIZERIGHT) { |
983 | if (mCurrentCellX >= mActionItem->cellX()) { | 983 | if (mCurrentCellX >= mActionItem->cellX()) { |
984 | mActionItem->expandRight(gx - mCurrentCellX); | 984 | mActionItem->expandRight(gx - mCurrentCellX); |
985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 985 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
986 | mActionItem->height()); | 986 | mActionItem->height()); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | mCurrentCellX = gx; | 989 | mCurrentCellX = gx; |
990 | mCurrentCellY = gy; | 990 | mCurrentCellY = gy; |
991 | } | 991 | } |
992 | } | 992 | } |
993 | 993 | ||
994 | void KOAgenda::endItemAction() | 994 | void KOAgenda::endItemAction() |
995 | { | 995 | { |
996 | 996 | ||
997 | if ( mItemMoved ) { | 997 | if ( mItemMoved ) { |
998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 998 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
999 | if ( !placeItem ) { | 999 | if ( !placeItem ) { |
1000 | placeItem = mActionItem; | 1000 | placeItem = mActionItem; |
1001 | } | 1001 | } |
1002 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 1002 | if ( placeItem->incidence()->doesRecur() ) { |
1003 | Incidence* oldInc = placeItem->incidence(); | 1003 | Incidence* oldInc = placeItem->incidence(); |
1004 | placeItem->recreateIncidence(); | 1004 | placeItem->recreateIncidence(); |
1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 1005 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
1006 | } | 1006 | } |
1007 | int type = mActionType; | 1007 | int type = mActionType; |
1008 | if ( mAllDayMode ) | 1008 | if ( mAllDayMode ) |
1009 | type = -1; | 1009 | type = -1; |
1010 | KOAgendaItem *modifiedItem = placeItem; | 1010 | KOAgendaItem *modifiedItem = placeItem; |
1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 1011 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 1012 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
1013 | KOAgendaItem *item; | 1013 | KOAgendaItem *item; |
1014 | 1014 | ||
1015 | if ( placeItem->incidence()->typeID() == todoID ) { | 1015 | if ( placeItem->incidence()->typeID() == todoID ) { |
1016 | mSelectedItem = 0; | 1016 | mSelectedItem = 0; |
1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 1017 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 1018 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
1019 | emit itemModified( modifiedItem, mActionType ); | 1019 | emit itemModified( modifiedItem, mActionType ); |
1020 | } | 1020 | } |
1021 | else { | 1021 | else { |
1022 | 1022 | ||
1023 | 1023 | ||
1024 | globalFlagBlockAgendaItemPaint = 1; | 1024 | globalFlagBlockAgendaItemPaint = 1; |
1025 | for ( item=oldconflictItems.first(); item != 0; | 1025 | for ( item=oldconflictItems.first(); item != 0; |
1026 | item=oldconflictItems.next() ) { | 1026 | item=oldconflictItems.next() ) { |
1027 | placeSubCells(item); | 1027 | placeSubCells(item); |
1028 | } | 1028 | } |
1029 | while ( placeItem ) { | 1029 | while ( placeItem ) { |
1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1030 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1031 | oldconflictItems = placeItem->conflictItems(); | 1031 | oldconflictItems = placeItem->conflictItems(); |
1032 | for ( item=oldconflictItems.first(); item != 0; | 1032 | for ( item=oldconflictItems.first(); item != 0; |
1033 | item=oldconflictItems.next() ) { | 1033 | item=oldconflictItems.next() ) { |
1034 | placeSubCells(item); | 1034 | placeSubCells(item); |
1035 | } | 1035 | } |
1036 | placeSubCells( placeItem ); | 1036 | placeSubCells( placeItem ); |
1037 | placeItem = placeItem->nextMultiItem(); | 1037 | placeItem = placeItem->nextMultiItem(); |
1038 | } | 1038 | } |
1039 | globalFlagBlockAgendaItemPaint = 0; | 1039 | globalFlagBlockAgendaItemPaint = 0; |
1040 | for ( item=oldconflictItems.first(); item != 0; | 1040 | for ( item=oldconflictItems.first(); item != 0; |
1041 | item=oldconflictItems.next() ) { | 1041 | item=oldconflictItems.next() ) { |
1042 | globalFlagBlockAgendaItemUpdate = 0; | 1042 | globalFlagBlockAgendaItemUpdate = 0; |
1043 | item->repaintMe(); | 1043 | item->repaintMe(); |
1044 | globalFlagBlockAgendaItemUpdate = 1; | 1044 | globalFlagBlockAgendaItemUpdate = 1; |
1045 | item->repaint( false ); | 1045 | item->repaint( false ); |
1046 | } | 1046 | } |
1047 | placeItem = modifiedItem; | 1047 | placeItem = modifiedItem; |
1048 | 1048 | ||
1049 | while ( placeItem ) { | 1049 | while ( placeItem ) { |
1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 1050 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
1051 | globalFlagBlockAgendaItemUpdate = 0; | 1051 | globalFlagBlockAgendaItemUpdate = 0; |
1052 | placeItem->repaintMe(); | 1052 | placeItem->repaintMe(); |
1053 | globalFlagBlockAgendaItemUpdate = 1; | 1053 | globalFlagBlockAgendaItemUpdate = 1; |
1054 | placeItem->repaint(false); | 1054 | placeItem->repaint(false); |
1055 | placeItem = placeItem->nextMultiItem(); | 1055 | placeItem = placeItem->nextMultiItem(); |
1056 | } | 1056 | } |
1057 | emit itemModified( modifiedItem, mActionType ); | 1057 | emit itemModified( modifiedItem, mActionType ); |
1058 | 1058 | ||
1059 | 1059 | ||
1060 | placeItem = modifiedItem; | 1060 | placeItem = modifiedItem; |
1061 | while ( placeItem ) { | 1061 | while ( placeItem ) { |
1062 | oldconflictItems = placeItem->conflictItems(); | 1062 | oldconflictItems = placeItem->conflictItems(); |
1063 | for ( item=oldconflictItems.first(); item != 0; | 1063 | for ( item=oldconflictItems.first(); item != 0; |
1064 | item=oldconflictItems.next() ) { | 1064 | item=oldconflictItems.next() ) { |
1065 | placeSubCells(item); | 1065 | placeSubCells(item); |
1066 | } | 1066 | } |
1067 | placeSubCells( placeItem ); | 1067 | placeSubCells( placeItem ); |
1068 | placeItem = placeItem->nextMultiItem(); | 1068 | placeItem = placeItem->nextMultiItem(); |
1069 | 1069 | ||
1070 | } | 1070 | } |
1071 | placeItem = modifiedItem; | 1071 | placeItem = modifiedItem; |
1072 | while ( placeItem ) { | 1072 | while ( placeItem ) { |
1073 | oldconflictItems = placeItem->conflictItems(); | 1073 | oldconflictItems = placeItem->conflictItems(); |
1074 | for ( item=oldconflictItems.first(); item != 0; | 1074 | for ( item=oldconflictItems.first(); item != 0; |
1075 | item=oldconflictItems.next() ) { | 1075 | item=oldconflictItems.next() ) { |
1076 | globalFlagBlockAgendaItemUpdate = 0; | 1076 | globalFlagBlockAgendaItemUpdate = 0; |
1077 | item->repaintMe(); | 1077 | item->repaintMe(); |
1078 | globalFlagBlockAgendaItemUpdate = 1; | 1078 | globalFlagBlockAgendaItemUpdate = 1; |
1079 | item->repaint(false); | 1079 | item->repaint(false); |
1080 | } | 1080 | } |
1081 | placeItem = placeItem->nextMultiItem(); | 1081 | placeItem = placeItem->nextMultiItem(); |
1082 | } | 1082 | } |
1083 | /* | 1083 | /* |
1084 | 1084 | ||
1085 | oldconflictItems = modifiedItem->conflictItems(); | 1085 | oldconflictItems = modifiedItem->conflictItems(); |
1086 | for ( item=oldconflictItems.first(); item != 0; | 1086 | for ( item=oldconflictItems.first(); item != 0; |
1087 | item=oldconflictItems.next() ) { | 1087 | item=oldconflictItems.next() ) { |
1088 | globalFlagBlockAgendaItemUpdate = 0; | 1088 | globalFlagBlockAgendaItemUpdate = 0; |
1089 | item->paintMe(false); | 1089 | item->paintMe(false); |
1090 | globalFlagBlockAgendaItemUpdate = 1; | 1090 | globalFlagBlockAgendaItemUpdate = 1; |
1091 | item->repaint(false); | 1091 | item->repaint(false); |
1092 | } | 1092 | } |
1093 | */ | 1093 | */ |
1094 | 1094 | ||
1095 | 1095 | ||
1096 | } | 1096 | } |
1097 | 1097 | ||
1098 | } | 1098 | } |
1099 | if ( mActionItem ) | 1099 | if ( mActionItem ) |
1100 | emit incidenceSelected( mActionItem->incidence() ); | 1100 | emit incidenceSelected( mActionItem->incidence() ); |
1101 | mScrollUpTimer.stop(); | 1101 | mScrollUpTimer.stop(); |
1102 | mScrollDownTimer.stop(); | 1102 | mScrollDownTimer.stop(); |
1103 | setCursor( arrowCursor ); | 1103 | setCursor( arrowCursor ); |
1104 | mActionItem = 0; | 1104 | mActionItem = 0; |
1105 | mActionType = NOP; | 1105 | mActionType = NOP; |
1106 | mItemMoved = 0; | 1106 | mItemMoved = 0; |
1107 | 1107 | ||
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 1110 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
1111 | { | 1111 | { |
1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 1112 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 1113 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 1114 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
1115 | // point = clipper()->mapFromGlobal(point); | 1115 | // point = clipper()->mapFromGlobal(point); |
1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 1116 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
1117 | 1117 | ||
1118 | int x,y; | 1118 | int x,y; |
1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 1119 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 1120 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
1121 | int gx,gy; | 1121 | int gx,gy; |
1122 | contentsToGrid(x,y,gx,gy); | 1122 | contentsToGrid(x,y,gx,gy); |
1123 | 1123 | ||
1124 | // Change cursor to resize cursor if appropriate | 1124 | // Change cursor to resize cursor if appropriate |
1125 | if (mAllDayMode) { | 1125 | if (mAllDayMode) { |
1126 | int gridDistanceX = (x - gx * mGridSpacingX); | 1126 | int gridDistanceX = (x - gx * mGridSpacingX); |
1127 | if (gridDistanceX < mResizeBorderWidth && | 1127 | if (gridDistanceX < mResizeBorderWidth && |
1128 | moveItem->cellX() == gx) { | 1128 | moveItem->cellX() == gx) { |
1129 | setCursor(sizeHorCursor); | 1129 | setCursor(sizeHorCursor); |
1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1130 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1131 | moveItem->cellXWidth() == gx) { | 1131 | moveItem->cellXWidth() == gx) { |
1132 | setCursor(sizeHorCursor); | 1132 | setCursor(sizeHorCursor); |
1133 | } else { | 1133 | } else { |
1134 | setCursor(arrowCursor); | 1134 | setCursor(arrowCursor); |
1135 | } | 1135 | } |
1136 | } else { | 1136 | } else { |
1137 | int gridDistanceY = (y - gy * mGridSpacingY); | 1137 | int gridDistanceY = (y - gy * mGridSpacingY); |
1138 | if (gridDistanceY < mResizeBorderWidth && | 1138 | if (gridDistanceY < mResizeBorderWidth && |
1139 | moveItem->cellYTop() == gy && | 1139 | moveItem->cellYTop() == gy && |
1140 | !moveItem->firstMultiItem()) { | 1140 | !moveItem->firstMultiItem()) { |
1141 | setCursor(sizeVerCursor); | 1141 | setCursor(sizeVerCursor); |
1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1142 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1143 | moveItem->cellYBottom() == gy && | 1143 | moveItem->cellYBottom() == gy && |
1144 | !moveItem->lastMultiItem()) { | 1144 | !moveItem->lastMultiItem()) { |
1145 | setCursor(sizeVerCursor); | 1145 | setCursor(sizeVerCursor); |
1146 | } else { | 1146 | } else { |
1147 | setCursor(arrowCursor); | 1147 | setCursor(arrowCursor); |
1148 | } | 1148 | } |
1149 | } | 1149 | } |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | 1152 | ||
1153 | /* | 1153 | /* |
1154 | Place item in cell and take care that multiple items using the same cell do | 1154 | Place item in cell and take care that multiple items using the same cell do |
1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1155 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1156 | it can get in all cases. | 1156 | it can get in all cases. |
1157 | At the moment the method has a bug: When an item is placed only the sub cell | 1157 | At the moment the method has a bug: When an item is placed only the sub cell |
1158 | widths of the items are changed, which are within the Y region the item to | 1158 | widths of the items are changed, which are within the Y region the item to |
1159 | place spans. When the sub cell width change of one of this items affects a | 1159 | place spans. When the sub cell width change of one of this items affects a |
1160 | cell, where other items are, which do not overlap in Y with the item to place, | 1160 | cell, where other items are, which do not overlap in Y with the item to place, |
1161 | the display gets corrupted, although the corruption looks quite nice. | 1161 | the display gets corrupted, although the corruption looks quite nice. |
1162 | */ | 1162 | */ |
1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1163 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1164 | { | 1164 | { |
1165 | 1165 | ||
1166 | QPtrList<KOAgendaItem> conflictItems; | 1166 | QPtrList<KOAgendaItem> conflictItems; |
1167 | int maxSubCells = 0; | 1167 | int maxSubCells = 0; |
1168 | QIntDict<KOAgendaItem> subCellDict(7); | 1168 | QIntDict<KOAgendaItem> subCellDict(7); |
1169 | 1169 | ||
1170 | KOAgendaItem *item; | 1170 | KOAgendaItem *item; |
1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1171 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1172 | if (item != placeItem) { | 1172 | if (item != placeItem) { |
1173 | if (placeItem->cellX() <= item->cellXWidth() && | 1173 | if (placeItem->cellX() <= item->cellXWidth() && |
1174 | placeItem->cellXWidth() >= item->cellX()) { | 1174 | placeItem->cellXWidth() >= item->cellX()) { |
1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1175 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1176 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1176 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1177 | conflictItems.append(item); | 1177 | conflictItems.append(item); |
1178 | if (item->subCells() > maxSubCells) | 1178 | if (item->subCells() > maxSubCells) |
1179 | maxSubCells = item->subCells(); | 1179 | maxSubCells = item->subCells(); |
1180 | subCellDict.insert(item->subCell(),item); | 1180 | subCellDict.insert(item->subCell(),item); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | 1185 | ||
1186 | if (conflictItems.count() > 0) { | 1186 | if (conflictItems.count() > 0) { |
1187 | // Look for unused sub cell and insert item | 1187 | // Look for unused sub cell and insert item |
1188 | int i; | 1188 | int i; |
1189 | for(i=0;i<maxSubCells;++i) { | 1189 | for(i=0;i<maxSubCells;++i) { |
1190 | if (!subCellDict.find(i)) { | 1190 | if (!subCellDict.find(i)) { |
1191 | placeItem->setSubCell(i); | 1191 | placeItem->setSubCell(i); |
1192 | break; | 1192 | break; |
1193 | } | 1193 | } |
1194 | } | 1194 | } |
1195 | if (i == maxSubCells) { | 1195 | if (i == maxSubCells) { |
1196 | placeItem->setSubCell(maxSubCells); | 1196 | placeItem->setSubCell(maxSubCells); |
1197 | maxSubCells++; // add new item to number of sub cells | 1197 | maxSubCells++; // add new item to number of sub cells |
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | // Prepare for sub cell geometry adjustment | 1200 | // Prepare for sub cell geometry adjustment |
1201 | int newSubCellWidth; | 1201 | int newSubCellWidth; |
1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1202 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1203 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1204 | conflictItems.append(placeItem); | 1204 | conflictItems.append(placeItem); |
1205 | 1205 | ||
1206 | 1206 | ||
1207 | // Adjust sub cell geometry of all direct conflict items | 1207 | // Adjust sub cell geometry of all direct conflict items |
1208 | for ( item=conflictItems.first(); item != 0; | 1208 | for ( item=conflictItems.first(); item != 0; |
1209 | item=conflictItems.next() ) { | 1209 | item=conflictItems.next() ) { |
1210 | item->setSubCells(maxSubCells); | 1210 | item->setSubCells(maxSubCells); |
1211 | if (mAllDayMode) { | 1211 | if (mAllDayMode) { |
1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1212 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1213 | } else { | 1213 | } else { |
1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1214 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1215 | } | 1215 | } |
1216 | int x,y; | 1216 | int x,y; |
1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1217 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1218 | if (mAllDayMode) { | 1218 | if (mAllDayMode) { |
1219 | y += item->subCell() * newSubCellWidth; | 1219 | y += item->subCell() * newSubCellWidth; |
1220 | } else { | 1220 | } else { |
1221 | x += item->subCell() * newSubCellWidth; | 1221 | x += item->subCell() * newSubCellWidth; |
1222 | } | 1222 | } |
1223 | moveChild(item,x,y); | 1223 | moveChild(item,x,y); |
1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1224 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1225 | //item->updateItem(); | 1225 | //item->updateItem(); |
1226 | } | 1226 | } |
1227 | // Adjust sub cell geometry of all conflict items of all conflict items | 1227 | // Adjust sub cell geometry of all conflict items of all conflict items |
1228 | for ( item=conflictItems.first(); item != 0; | 1228 | for ( item=conflictItems.first(); item != 0; |
1229 | item=conflictItems.next() ) { | 1229 | item=conflictItems.next() ) { |
1230 | if ( placeItem != item ) { | 1230 | if ( placeItem != item ) { |
1231 | KOAgendaItem *item2; | 1231 | KOAgendaItem *item2; |
1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1232 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1233 | for ( item2=conflictItems2.first(); item2 != 0; | 1233 | for ( item2=conflictItems2.first(); item2 != 0; |
1234 | item2=conflictItems2.next() ) { | 1234 | item2=conflictItems2.next() ) { |
1235 | if ( item2->subCells() != maxSubCells) { | 1235 | if ( item2->subCells() != maxSubCells) { |
1236 | item2->setSubCells(maxSubCells); | 1236 | item2->setSubCells(maxSubCells); |
1237 | if (mAllDayMode) { | 1237 | if (mAllDayMode) { |
1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1238 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1239 | } else { | 1239 | } else { |
1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1240 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1241 | } | 1241 | } |
1242 | int x,y; | 1242 | int x,y; |
1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1243 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1244 | if (mAllDayMode) { | 1244 | if (mAllDayMode) { |
1245 | y += item2->subCell() * newSubCellWidth; | 1245 | y += item2->subCell() * newSubCellWidth; |
1246 | } else { | 1246 | } else { |
1247 | x += item2->subCell() * newSubCellWidth; | 1247 | x += item2->subCell() * newSubCellWidth; |
1248 | } | 1248 | } |
1249 | moveChild(item2,x,y); | 1249 | moveChild(item2,x,y); |
1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1250 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | } | 1254 | } |
1255 | } else { | 1255 | } else { |
1256 | placeItem->setSubCell(0); | 1256 | placeItem->setSubCell(0); |
1257 | placeItem->setSubCells(1); | 1257 | placeItem->setSubCells(1); |
1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1258 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1259 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1260 | int x,y; | 1260 | int x,y; |
1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1261 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1262 | moveChild(placeItem,x,y); | 1262 | moveChild(placeItem,x,y); |
1263 | } | 1263 | } |
1264 | placeItem->setConflictItems(conflictItems); | 1264 | placeItem->setConflictItems(conflictItems); |
1265 | // for ( item=conflictItems.first(); item != 0; | 1265 | // for ( item=conflictItems.first(); item != 0; |
1266 | // item=conflictItems.next() ) { | 1266 | // item=conflictItems.next() ) { |
1267 | // //item->updateItem(); | 1267 | // //item->updateItem(); |
1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1268 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1269 | // } | 1269 | // } |
1270 | // placeItem->updateItem(); | 1270 | // placeItem->updateItem(); |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1273 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1274 | { | 1274 | { |
1275 | if ( globalFlagBlockAgenda ) | 1275 | if ( globalFlagBlockAgenda ) |
1276 | return; | 1276 | return; |
1277 | 1277 | ||
1278 | if ( mInvalidPixmap ) { | 1278 | if ( mInvalidPixmap ) { |
1279 | mInvalidPixmap = false; | 1279 | mInvalidPixmap = false; |
1280 | qDebug("KO: Upsizing Pixmaps "); | 1280 | qDebug("KO: Upsizing Pixmaps "); |
1281 | computeSizes(); | 1281 | computeSizes(); |
1282 | emit updateViewSignal(); | 1282 | emit updateViewSignal(); |
1283 | return; | 1283 | return; |
1284 | } | 1284 | } |
1285 | if ( ! mAllDayMode ) { | 1285 | if ( ! mAllDayMode ) { |
1286 | // currently not working for | 1286 | // currently not working for |
1287 | 1287 | ||
1288 | //qDebug("KOAgenda::drawContents "); | 1288 | //qDebug("KOAgenda::drawContents "); |
1289 | #if 0 | 1289 | #if 0 |
1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1290 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1291 | qDebug("WAU "); | 1291 | qDebug("WAU "); |
1292 | drawContentsToPainter(); | 1292 | drawContentsToPainter(); |
1293 | } | 1293 | } |
1294 | #endif | 1294 | #endif |
1295 | QPaintDevice* pd = p->device(); | 1295 | QPaintDevice* pd = p->device(); |
1296 | p->end(); | 1296 | p->end(); |
1297 | int vx, vy; | 1297 | int vx, vy; |
1298 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1298 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1299 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1300 | mSelectionCellX * mGridSpacingX; | 1300 | mSelectionCellX * mGridSpacingX; |
1301 | contentsToViewport ( cx, cy, vx,vy); | 1301 | contentsToViewport ( cx, cy, vx,vy); |
1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; | 1302 | //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; |
1303 | 1303 | ||
1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { | 1304 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { |
1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1305 | if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { | 1306 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { |
1307 | 1307 | ||
1308 | int vxSel, vySel; | 1308 | int vxSel, vySel; |
1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); | 1309 | contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); |
1310 | int off = mSelectionHeight; | 1310 | int off = mSelectionHeight; |
1311 | if ( vySel < 0 ) | 1311 | if ( vySel < 0 ) |
1312 | off += vySel; | 1312 | off += vySel; |
1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); | 1313 | //qDebug("OFF %d %d %d", off,vySel, vy ); |
1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); | 1314 | bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); |
1315 | } else { | 1315 | } else { |
1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1316 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | if ( mSelectionHeight > 0 ) { | 1319 | if ( mSelectionHeight > 0 ) { |
1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1320 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1323 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1324 | // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1325 | int hei = mSelectionHeight; | 1325 | int hei = mSelectionHeight; |
1326 | int offset = 0; | 1326 | int offset = 0; |
1327 | while ( hei > 0 ) { | 1327 | while ( hei > 0 ) { |
1328 | int p_hei = 5; | 1328 | int p_hei = 5; |
1329 | if ( hei < 5 ) p_hei = hei; | 1329 | if ( hei < 5 ) p_hei = hei; |
1330 | hei -= 5; | 1330 | hei -= 5; |
1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1331 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1332 | offset += 5; | 1332 | offset += 5; |
1333 | } | 1333 | } |
1334 | } | 1334 | } |
1335 | } | 1335 | } |
1336 | p->begin( pd ); | 1336 | p->begin( pd ); |
1337 | } else { | 1337 | } else { |
1338 | #if 0 | 1338 | #if 0 |
1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1339 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1340 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1341 | qDebug("WAUWAU "); | 1341 | qDebug("WAUWAU "); |
1342 | drawContentsToPainter(); | 1342 | drawContentsToPainter(); |
1343 | } | 1343 | } |
1344 | #endif | 1344 | #endif |
1345 | QPaintDevice* pd = p->device(); | 1345 | QPaintDevice* pd = p->device(); |
1346 | p->end(); | 1346 | p->end(); |
1347 | int vx, vy; | 1347 | int vx, vy; |
1348 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1348 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1349 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1350 | mSelectionCellX * mGridSpacingX; | 1350 | mSelectionCellX * mGridSpacingX; |
1351 | contentsToViewport ( cx, cy, vx,vy); | 1351 | contentsToViewport ( cx, cy, vx,vy); |
1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1352 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1353 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1354 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1355 | 1355 | ||
1356 | if ( mSelectionHeight > 0 ) { | 1356 | if ( mSelectionHeight > 0 ) { |
1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1357 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1358 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1359 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1360 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1361 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1362 | int hei = mSelectionHeight; | 1362 | int hei = mSelectionHeight; |
1363 | int offset = 0; | 1363 | int offset = 0; |
1364 | while ( hei > 0 ) { | 1364 | while ( hei > 0 ) { |
1365 | int p_hei = 5; | 1365 | int p_hei = 5; |
1366 | if ( hei < 5 ) p_hei = hei; | 1366 | if ( hei < 5 ) p_hei = hei; |
1367 | hei -= 5; | 1367 | hei -= 5; |
1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1368 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1369 | offset += 5; | 1369 | offset += 5; |
1370 | } | 1370 | } |
1371 | } | 1371 | } |
1372 | } | 1372 | } |
1373 | p->begin( pd ); | 1373 | p->begin( pd ); |
1374 | } | 1374 | } |
1375 | 1375 | ||
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void KOAgenda::finishUpdate() | 1378 | void KOAgenda::finishUpdate() |
1379 | { | 1379 | { |
1380 | 1380 | ||
1381 | KOAgendaItem *item; | 1381 | KOAgendaItem *item; |
1382 | globalFlagBlockAgendaItemPaint = 1; | 1382 | globalFlagBlockAgendaItemPaint = 1; |
1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1383 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1384 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1385 | if ( !item->checkLayout() ) { | 1385 | if ( !item->checkLayout() ) { |
1386 | //qDebug(" conflictitem found "); | 1386 | //qDebug(" conflictitem found "); |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 303a92a..49ad9b8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,621 +1,621 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #define AGENDA_ICON_SIZE 7 | 39 | #define AGENDA_ICON_SIZE 7 |
40 | #endif | 40 | #endif |
41 | #include <libkcal/icaldrag.h> | 41 | #include <libkcal/icaldrag.h> |
42 | #include <libkcal/vcaldrag.h> | 42 | #include <libkcal/vcaldrag.h> |
43 | #include <libkcal/kincidenceformatter.h> | 43 | #include <libkcal/kincidenceformatter.h> |
44 | extern int globalFlagBlockAgenda; | 44 | extern int globalFlagBlockAgenda; |
45 | extern int globalFlagBlockAgendaItemPaint; | 45 | extern int globalFlagBlockAgendaItemPaint; |
46 | extern int globalFlagBlockAgendaItemUpdate; | 46 | extern int globalFlagBlockAgendaItemUpdate; |
47 | 47 | ||
48 | #include "koprefs.h" | 48 | #include "koprefs.h" |
49 | 49 | ||
50 | #include "koagendaitem.h" | 50 | #include "koagendaitem.h" |
51 | //#include "koagendaitem.moc" | 51 | //#include "koagendaitem.moc" |
52 | 52 | ||
53 | 53 | ||
54 | //-------------------------------------------------------------------------- | 54 | //-------------------------------------------------------------------------- |
55 | 55 | ||
56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 56 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
57 | 57 | ||
58 | //-------------------------------------------------------------------------- | 58 | //-------------------------------------------------------------------------- |
59 | 59 | ||
60 | class KOAgendaItemWhatsThis :public QWhatsThis | 60 | class KOAgendaItemWhatsThis :public QWhatsThis |
61 | { | 61 | { |
62 | public: | 62 | public: |
63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 63 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | virtual QString text( const QPoint& ) | 66 | virtual QString text( const QPoint& ) |
67 | { | 67 | { |
68 | return _view->getWhatsThisText() ; | 68 | return _view->getWhatsThisText() ; |
69 | } | 69 | } |
70 | private: | 70 | private: |
71 | KOAgendaItem * _view; | 71 | KOAgendaItem * _view; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 74 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
75 | const char *name,WFlags) : | 75 | const char *name,WFlags) : |
76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 76 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
77 | { | 77 | { |
78 | #ifndef DESKTOP_VERSION | 78 | #ifndef DESKTOP_VERSION |
79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 79 | //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
80 | #endif | 80 | #endif |
81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); | 81 | mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); |
82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 82 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
83 | setWFlags ( wflags); | 83 | setWFlags ( wflags); |
84 | mAllDay = allday; | 84 | mAllDay = allday; |
85 | init ( incidence, qd ); | 85 | init ( incidence, qd ); |
86 | //setMouseTracking(true); | 86 | //setMouseTracking(true); |
87 | //setAcceptDrops(true); | 87 | //setAcceptDrops(true); |
88 | xPaintCoord = -1; | 88 | xPaintCoord = -1; |
89 | yPaintCoord = -1; | 89 | yPaintCoord = -1; |
90 | } | 90 | } |
91 | QString KOAgendaItem::getWhatsThisText() | 91 | QString KOAgendaItem::getWhatsThisText() |
92 | { | 92 | { |
93 | if ( mIncidence ) | 93 | if ( mIncidence ) |
94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 94 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
95 | KOPrefs::instance()->mWTshowDetails, | 95 | KOPrefs::instance()->mWTshowDetails, |
96 | KOPrefs::instance()->mWTshowCreated, | 96 | KOPrefs::instance()->mWTshowCreated, |
97 | KOPrefs::instance()->mWTshowChanged); | 97 | KOPrefs::instance()->mWTshowChanged); |
98 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 98 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
99 | } | 99 | } |
100 | 100 | ||
101 | void KOAgendaItem::initColor () | 101 | void KOAgendaItem::initColor () |
102 | { | 102 | { |
103 | if ( (mIncidence->typeID() == todoID ) && | 103 | if ( (mIncidence->typeID() == todoID ) && |
104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && | 104 | ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && |
105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 105 | ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) | 106 | if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) |
107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 107 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
108 | else | 108 | else |
109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 109 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
110 | } | 110 | } |
111 | else { | 111 | else { |
112 | QStringList categories = mIncidence->categories(); | 112 | QStringList categories = mIncidence->categories(); |
113 | QString cat = categories.first(); | 113 | QString cat = categories.first(); |
114 | if (cat.isEmpty()) { | 114 | if (cat.isEmpty()) { |
115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) | 115 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) |
116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 116 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
117 | else | 117 | else |
118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 118 | mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
119 | } else { | 119 | } else { |
120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 120 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { | 121 | if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { |
122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 122 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; | 123 | mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; |
124 | } | 124 | } |
125 | } | 125 | } |
126 | 126 | ||
127 | } | 127 | } |
128 | 128 | ||
129 | QColor BackgroundColor ( mBackgroundColor ); | 129 | QColor BackgroundColor ( mBackgroundColor ); |
130 | if ( mIncidence->calID() > 1 ) { | 130 | if ( mIncidence->calID() > 1 ) { |
131 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); | 131 | //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); |
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( BackgroundColor.light(), | 133 | mColorGroup = QColorGroup( BackgroundColor.light(), |
134 | BackgroundColor.dark(),BackgroundColor.light(), | 134 | BackgroundColor.dark(),BackgroundColor.light(), |
135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; | 135 | BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); | 137 | mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); |
138 | } | 138 | } |
139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 139 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
140 | { | 140 | { |
141 | mIncidence = incidence; | 141 | mIncidence = incidence; |
142 | mDate = qd; | 142 | mDate = qd; |
143 | mFirstMultiItem = 0; | 143 | mFirstMultiItem = 0; |
144 | mNextMultiItem = 0; | 144 | mNextMultiItem = 0; |
145 | mLastMultiItem = 0; | 145 | mLastMultiItem = 0; |
146 | computeText(); | 146 | computeText(); |
147 | initColor(); | 147 | initColor(); |
148 | mConflictItems.clear(); | 148 | mConflictItems.clear(); |
149 | setCellXY(0,0,1); | 149 | setCellXY(0,0,1); |
150 | setCellXWidth(0); | 150 | setCellXWidth(0); |
151 | setSubCell(0); | 151 | setSubCell(0); |
152 | setSubCells(1); | 152 | setSubCells(1); |
153 | setMultiItem(0,0,0); | 153 | setMultiItem(0,0,0); |
154 | startMove(); | 154 | startMove(); |
155 | mSelected = true; | 155 | mSelected = true; |
156 | select(false); | 156 | select(false); |
157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 157 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
158 | mFontPixelSize = fontinf.height();; | 158 | mFontPixelSize = fontinf.height();; |
159 | hide(); | 159 | hide(); |
160 | xPaintCoord = -1; | 160 | xPaintCoord = -1; |
161 | yPaintCoord = -1; | 161 | yPaintCoord = -1; |
162 | } | 162 | } |
163 | 163 | ||
164 | 164 | ||
165 | KOAgendaItem::~KOAgendaItem() | 165 | KOAgendaItem::~KOAgendaItem() |
166 | { | 166 | { |
167 | #if QT_VERSION >= 0x030000 | 167 | #if QT_VERSION >= 0x030000 |
168 | 168 | ||
169 | #else | 169 | #else |
170 | delete mKOAgendaItemWhatsThis; | 170 | delete mKOAgendaItemWhatsThis; |
171 | #endif | 171 | #endif |
172 | 172 | ||
173 | } | 173 | } |
174 | 174 | ||
175 | void KOAgendaItem::recreateIncidence() | 175 | void KOAgendaItem::recreateIncidence() |
176 | { | 176 | { |
177 | #if 0 | 177 | #if 0 |
178 | Incidence* newInc = mIncidence->clone(); | 178 | Incidence* newInc = mIncidence->clone(); |
179 | newInc->recreate(); | 179 | newInc->recreate(); |
180 | if ( mIncidence->doesRecur() ) { | 180 | if ( mIncidence->doesRecur() ) { |
181 | mIncidence->addExDate( mDate ); | 181 | mIncidence->addExDate( mDate ); |
182 | newInc->recurrence()->unsetRecurs(); | 182 | newInc->recurrence()->unsetRecurs(); |
183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 183 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
184 | QTime tim = mIncidence->dtStart().time(); | 184 | QTime tim = mIncidence->dtStart().time(); |
185 | newInc->setDtStart( QDateTime(mDate, tim) ); | 185 | newInc->setDtStart( QDateTime(mDate, tim) ); |
186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 186 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
187 | } | 187 | } |
188 | #endif | 188 | #endif |
189 | mIncidence = mIncidence->recreateCloneException( mDate ); | 189 | mIncidence = mIncidence->recreateCloneException( mDate ); |
190 | } | 190 | } |
191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 191 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
192 | { | 192 | { |
193 | int size = AGENDA_ICON_SIZE; | 193 | int size = AGENDA_ICON_SIZE; |
194 | 194 | ||
195 | int yOff = 0; | 195 | int yOff = 0; |
196 | int xOff = 0; | 196 | int xOff = 0; |
197 | int x = pos().x(); | 197 | int x = pos().x(); |
198 | 198 | ||
199 | if ( x < 0 ) x = 0; | 199 | if ( x < 0 ) x = 0; |
200 | x += 3; | 200 | x += 3; |
201 | int y; | 201 | int y; |
202 | if ( mAllDay ) | 202 | if ( mAllDay ) |
203 | y = pos().y()+3; | 203 | y = pos().y()+3; |
204 | else | 204 | else |
205 | y = mCellYTop * ( height() / cellHeight() ) +3; | 205 | y = mCellYTop * ( height() / cellHeight() ) +3; |
206 | 206 | ||
207 | 207 | ||
208 | if ( mIncidence->calID() > 1 ) { | 208 | if ( mIncidence->calID() > 1 ) { |
209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 209 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); | 210 | p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); |
211 | if ( horLayout ){ | 211 | if ( horLayout ){ |
212 | ++xOff; | 212 | ++xOff; |
213 | ++x; | 213 | ++x; |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | ++yOff; | 216 | ++yOff; |
217 | ++y; | 217 | ++y; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | if (mIncidence->cancelled() && height() < 20 ) { | 220 | if (mIncidence->cancelled() && height() < 20 ) { |
221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 221 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 222 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 223 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 224 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
225 | if ( horLayout ) | 225 | if ( horLayout ) |
226 | ++xOff; | 226 | ++xOff; |
227 | else | 227 | else |
228 | ++yOff; | 228 | ++yOff; |
229 | } | 229 | } |
230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { | 230 | if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } | 236 | } |
237 | if (mIncidence->recurrence()->doesRecur()) { | 237 | if (mIncidence->doesRecur()) { |
238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 238 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
239 | if ( horLayout ) | 239 | if ( horLayout ) |
240 | ++xOff; | 240 | ++xOff; |
241 | else | 241 | else |
242 | ++yOff; | 242 | ++yOff; |
243 | } | 243 | } |
244 | if (mIncidence->description().length() > 0) { | 244 | if (mIncidence->description().length() > 0) { |
245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 245 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
246 | if ( horLayout ) | 246 | if ( horLayout ) |
247 | ++xOff; | 247 | ++xOff; |
248 | else | 248 | else |
249 | ++yOff; | 249 | ++yOff; |
250 | } | 250 | } |
251 | if (mIncidence->isReadOnly()) { | 251 | if (mIncidence->isReadOnly()) { |
252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 252 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
253 | if ( horLayout ) | 253 | if ( horLayout ) |
254 | ++xOff; | 254 | ++xOff; |
255 | else | 255 | else |
256 | ++yOff; | 256 | ++yOff; |
257 | } | 257 | } |
258 | 258 | ||
259 | if (mIncidence->attendeeCount()>0) { | 259 | if (mIncidence->attendeeCount()>0) { |
260 | 260 | ||
261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 261 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 262 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
263 | if ( horLayout ) | 263 | if ( horLayout ) |
264 | ++xOff; | 264 | ++xOff; |
265 | else | 265 | else |
266 | ++yOff; | 266 | ++yOff; |
267 | } else { | 267 | } else { |
268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 268 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
269 | if (me!=0) { | 269 | if (me!=0) { |
270 | 270 | ||
271 | 271 | ||
272 | } else { | 272 | } else { |
273 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 273 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
274 | if ( horLayout ) | 274 | if ( horLayout ) |
275 | ++xOff; | 275 | ++xOff; |
276 | else | 276 | else |
277 | ++yOff; | 277 | ++yOff; |
278 | 278 | ||
279 | } | 279 | } |
280 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 280 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
281 | if ( horLayout ) | 281 | if ( horLayout ) |
282 | ++xOff; | 282 | ++xOff; |
283 | else | 283 | else |
284 | ++yOff; | 284 | ++yOff; |
285 | 285 | ||
286 | } | 286 | } |
287 | 287 | ||
288 | } | 288 | } |
289 | return ( yOff || xOff ); | 289 | return ( yOff || xOff ); |
290 | } | 290 | } |
291 | 291 | ||
292 | 292 | ||
293 | void KOAgendaItem::select(bool selected) | 293 | void KOAgendaItem::select(bool selected) |
294 | { | 294 | { |
295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 295 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
296 | if (mSelected == selected) return; | 296 | if (mSelected == selected) return; |
297 | mSelected = selected; | 297 | mSelected = selected; |
298 | if ( ! isVisible() ) | 298 | if ( ! isVisible() ) |
299 | return; | 299 | return; |
300 | if ( firstMultiItem() ) | 300 | if ( firstMultiItem() ) |
301 | firstMultiItem()->select( selected ); | 301 | firstMultiItem()->select( selected ); |
302 | if ( !firstMultiItem() && nextMultiItem() ) { | 302 | if ( !firstMultiItem() && nextMultiItem() ) { |
303 | KOAgendaItem * placeItem = nextMultiItem(); | 303 | KOAgendaItem * placeItem = nextMultiItem(); |
304 | while ( placeItem ) { | 304 | while ( placeItem ) { |
305 | placeItem->select( selected ); | 305 | placeItem->select( selected ); |
306 | placeItem = placeItem->nextMultiItem(); | 306 | placeItem = placeItem->nextMultiItem(); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | globalFlagBlockAgendaItemUpdate = 0; | 309 | globalFlagBlockAgendaItemUpdate = 0; |
310 | paintMe( selected ); | 310 | paintMe( selected ); |
311 | globalFlagBlockAgendaItemUpdate = 1; | 311 | globalFlagBlockAgendaItemUpdate = 1; |
312 | repaint( false ); | 312 | repaint( false ); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | /* | 316 | /* |
317 | The eventFilter has to filter the mouse events of the agenda item childs. The | 317 | The eventFilter has to filter the mouse events of the agenda item childs. The |
318 | events are fed into the event handling method of KOAgendaItem. This allows the | 318 | events are fed into the event handling method of KOAgendaItem. This allows the |
319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 319 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
320 | */ | 320 | */ |
321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 321 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
322 | { | 322 | { |
323 | if (e->type() == QEvent::MouseButtonPress || | 323 | if (e->type() == QEvent::MouseButtonPress || |
324 | e->type() == QEvent::MouseButtonDblClick || | 324 | e->type() == QEvent::MouseButtonDblClick || |
325 | e->type() == QEvent::MouseButtonRelease || | 325 | e->type() == QEvent::MouseButtonRelease || |
326 | e->type() == QEvent::MouseMove) { | 326 | e->type() == QEvent::MouseMove) { |
327 | QMouseEvent *me = (QMouseEvent *)e; | 327 | QMouseEvent *me = (QMouseEvent *)e; |
328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 328 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
329 | mapToGlobal(me->pos())); | 329 | mapToGlobal(me->pos())); |
330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 330 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
331 | return event(&returnEvent); | 331 | return event(&returnEvent); |
332 | } else { | 332 | } else { |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | } | 335 | } |
336 | void KOAgendaItem::repaintMe( ) | 336 | void KOAgendaItem::repaintMe( ) |
337 | { | 337 | { |
338 | paintMe ( mSelected ); | 338 | paintMe ( mSelected ); |
339 | } | 339 | } |
340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 340 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
341 | { | 341 | { |
342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 342 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
343 | return; | 343 | return; |
344 | QPainter pa; | 344 | QPainter pa; |
345 | 345 | ||
346 | if ( mSelected ) { | 346 | if ( mSelected ) { |
347 | pa.begin( this ); | 347 | pa.begin( this ); |
348 | } else { | 348 | } else { |
349 | if ( mAllDay ) | 349 | if ( mAllDay ) |
350 | pa.begin( paintPixAllday() ); | 350 | pa.begin( paintPixAllday() ); |
351 | else | 351 | else |
352 | pa.begin( paintPix() ); | 352 | pa.begin( paintPix() ); |
353 | } | 353 | } |
354 | int x, yy, w, h; | 354 | int x, yy, w, h; |
355 | float nfh = 7.0; | 355 | float nfh = 7.0; |
356 | x = pos().x(); w = width(); h = height (); | 356 | x = pos().x(); w = width(); h = height (); |
357 | if ( mAllDay ) | 357 | if ( mAllDay ) |
358 | yy = y(); | 358 | yy = y(); |
359 | else | 359 | else |
360 | yy = mCellYTop * ( height() / cellHeight() ); | 360 | yy = mCellYTop * ( height() / cellHeight() ); |
361 | if ( mSelected ) { | 361 | if ( mSelected ) { |
362 | pa.translate( -x, -yy ); | 362 | pa.translate( -x, -yy ); |
363 | } | 363 | } |
364 | xPaintCoord= x; | 364 | xPaintCoord= x; |
365 | yPaintCoord = yy; | 365 | yPaintCoord = yy; |
366 | wPaintCoord = width(); | 366 | wPaintCoord = width(); |
367 | hPaintCoord = height(); | 367 | hPaintCoord = height(); |
368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 368 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
369 | if ( paint == 0 ) | 369 | if ( paint == 0 ) |
370 | paint = &pa; | 370 | paint = &pa; |
371 | bool horLayout = ( w < h ); | 371 | bool horLayout = ( w < h ); |
372 | int maxhei = mFontPixelSize+4; | 372 | int maxhei = mFontPixelSize+4; |
373 | if ( horLayout ) | 373 | if ( horLayout ) |
374 | maxhei += AGENDA_ICON_SIZE -4; | 374 | maxhei += AGENDA_ICON_SIZE -4; |
375 | bool small = ( h < maxhei ); | 375 | bool small = ( h < maxhei ); |
376 | if ( ! small ) | 376 | if ( ! small ) |
377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 377 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
378 | else { | 378 | else { |
379 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 379 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
380 | f.setBold( false ); | 380 | f.setBold( false ); |
381 | int fh = f.pointSize(); | 381 | int fh = f.pointSize(); |
382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 382 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
383 | if ( nfh < 6 ) | 383 | if ( nfh < 6 ) |
384 | nfh = 6; | 384 | nfh = 6; |
385 | f.setPointSize( nfh ); | 385 | f.setPointSize( nfh ); |
386 | paint->setFont(f); | 386 | paint->setFont(f); |
387 | } | 387 | } |
388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 388 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 389 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 390 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
391 | if ( mIncidence->typeID() == todoID ) { | 391 | if ( mIncidence->typeID() == todoID ) { |
392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 392 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
393 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 393 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
394 | int yyy = yy+3; | 394 | int yyy = yy+3; |
395 | if ( tempTodo->isCompleted() ) | 395 | if ( tempTodo->isCompleted() ) |
396 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 396 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
397 | else { | 397 | else { |
398 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 398 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
399 | 399 | ||
400 | } | 400 | } |
401 | } | 401 | } |
402 | bool addIcon = false; | 402 | bool addIcon = false; |
403 | if ( ! small || w > 3 * h || h > 3* w ) | 403 | if ( ! small || w > 3 * h || h > 3* w ) |
404 | addIcon = updateIcons( paint, horLayout ); | 404 | addIcon = updateIcons( paint, horLayout ); |
405 | 405 | ||
406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 406 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | 407 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); |
408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 408 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
409 | if ( ! small ) { | 409 | if ( ! small ) { |
410 | x += 3; yy += 3;w -= 6; h-= 5; | 410 | x += 3; yy += 3;w -= 6; h-= 5; |
411 | } else { | 411 | } else { |
412 | x += 2; yy += 1;w -= 4; h-= 4; | 412 | x += 2; yy += 1;w -= 4; h-= 4; |
413 | if ( nfh < 6.01 ) { | 413 | if ( nfh < 6.01 ) { |
414 | yy -= 2; | 414 | yy -= 2; |
415 | h += 4; | 415 | h += 4; |
416 | } | 416 | } |
417 | else | 417 | else |
418 | if ( nfh < h -2 ) | 418 | if ( nfh < h -2 ) |
419 | ++yy; | 419 | ++yy; |
420 | } | 420 | } |
421 | int align; | 421 | int align; |
422 | #ifndef DESKTOP_VERSION | 422 | #ifndef DESKTOP_VERSION |
423 | align = ( AlignLeft|WordBreak|AlignTop); | 423 | align = ( AlignLeft|WordBreak|AlignTop); |
424 | #else | 424 | #else |
425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 425 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
426 | #endif | 426 | #endif |
427 | if ( addIcon ) { | 427 | if ( addIcon ) { |
428 | if ( ! horLayout ) { | 428 | if ( ! horLayout ) { |
429 | x += AGENDA_ICON_SIZE+3; | 429 | x += AGENDA_ICON_SIZE+3; |
430 | w -= (AGENDA_ICON_SIZE+3); | 430 | w -= (AGENDA_ICON_SIZE+3); |
431 | } | 431 | } |
432 | else { | 432 | else { |
433 | yy+= AGENDA_ICON_SIZE+2; | 433 | yy+= AGENDA_ICON_SIZE+2; |
434 | h -=(AGENDA_ICON_SIZE+3); | 434 | h -=(AGENDA_ICON_SIZE+3); |
435 | } | 435 | } |
436 | } | 436 | } |
437 | if ( mWhiteText ) | 437 | if ( mWhiteText ) |
438 | paint->setPen ( white); | 438 | paint->setPen ( white); |
439 | if ( x < 0 ) { | 439 | if ( x < 0 ) { |
440 | w = w+x-3; | 440 | w = w+x-3; |
441 | x = 3; | 441 | x = 3; |
442 | if ( !horLayout && addIcon ) | 442 | if ( !horLayout && addIcon ) |
443 | x += AGENDA_ICON_SIZE+3; | 443 | x += AGENDA_ICON_SIZE+3; |
444 | if ( w > parentWidget()->width() ){ | 444 | if ( w > parentWidget()->width() ){ |
445 | w = parentWidget()->width() - 6; | 445 | w = parentWidget()->width() - 6; |
446 | #ifndef DESKTOP_VERSION | 446 | #ifndef DESKTOP_VERSION |
447 | align = ( AlignHCenter|WordBreak|AlignTop); | 447 | align = ( AlignHCenter|WordBreak|AlignTop); |
448 | #else | 448 | #else |
449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 449 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
450 | #endif | 450 | #endif |
451 | 451 | ||
452 | } | 452 | } |
453 | } | 453 | } |
454 | QRect dr; | 454 | QRect dr; |
455 | if ( w + x > parentWidget()->width() ) | 455 | if ( w + x > parentWidget()->width() ) |
456 | w = parentWidget()->width()-x; | 456 | w = parentWidget()->width()-x; |
457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 457 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
458 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 458 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
459 | if ( mIncidence->cancelled() ){ | 459 | if ( mIncidence->cancelled() ){ |
460 | 460 | ||
461 | 461 | ||
462 | small = ( height() < 20 ); | 462 | small = ( height() < 20 ); |
463 | 463 | ||
464 | if ( ! small ) { | 464 | if ( ! small ) { |
465 | QFontMetrics fm ( paint->font() ); | 465 | QFontMetrics fm ( paint->font() ); |
466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 466 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
467 | } | 467 | } |
468 | 468 | ||
469 | } | 469 | } |
470 | pa.end(); | 470 | pa.end(); |
471 | 471 | ||
472 | } | 472 | } |
473 | 473 | ||
474 | QPixmap * KOAgendaItem::paintPix() | 474 | QPixmap * KOAgendaItem::paintPix() |
475 | { | 475 | { |
476 | static QPixmap* mPaintPix = 0; | 476 | static QPixmap* mPaintPix = 0; |
477 | if ( ! mPaintPix ) { | 477 | if ( ! mPaintPix ) { |
478 | int w = QApplication::desktop()->width(); | 478 | int w = QApplication::desktop()->width(); |
479 | int h = QApplication::desktop()->height(); | 479 | int h = QApplication::desktop()->height(); |
480 | mPaintPix = new QPixmap(w,h); | 480 | mPaintPix = new QPixmap(w,h); |
481 | } | 481 | } |
482 | return mPaintPix ; | 482 | return mPaintPix ; |
483 | } | 483 | } |
484 | QPixmap * KOAgendaItem::paintPixAllday() | 484 | QPixmap * KOAgendaItem::paintPixAllday() |
485 | { | 485 | { |
486 | static QPixmap* mPaintPixA = 0; | 486 | static QPixmap* mPaintPixA = 0; |
487 | if ( ! mPaintPixA ) { | 487 | if ( ! mPaintPixA ) { |
488 | int w = QApplication::desktop()->width(); | 488 | int w = QApplication::desktop()->width(); |
489 | int h = QApplication::desktop()->height()/5; | 489 | int h = QApplication::desktop()->height()/5; |
490 | mPaintPixA = new QPixmap(w,h); | 490 | mPaintPixA = new QPixmap(w,h); |
491 | } | 491 | } |
492 | return mPaintPixA ; | 492 | return mPaintPixA ; |
493 | } | 493 | } |
494 | 494 | ||
495 | void KOAgendaItem::repaintItem() | 495 | void KOAgendaItem::repaintItem() |
496 | { | 496 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 497 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 498 | globalFlagBlockAgenda = 0; |
499 | repaint( false ); | 499 | repaint( false ); |
500 | } | 500 | } |
501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
502 | { | 502 | { |
503 | 503 | ||
504 | if ( globalFlagBlockAgendaItemPaint ) | 504 | if ( globalFlagBlockAgendaItemPaint ) |
505 | return; | 505 | return; |
506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
507 | return; | 507 | return; |
508 | int yy; | 508 | int yy; |
509 | if ( mAllDay ) | 509 | if ( mAllDay ) |
510 | yy = y(); | 510 | yy = y(); |
511 | else | 511 | else |
512 | yy = mCellYTop * ( height() / cellHeight() ); | 512 | yy = mCellYTop * ( height() / cellHeight() ); |
513 | int xx = x(); | 513 | int xx = x(); |
514 | 514 | ||
515 | if ( xPaintCoord != xx || yPaintCoord != yy || | 515 | if ( xPaintCoord != xx || yPaintCoord != yy || |
516 | wPaintCoord != width() || hPaintCoord != height()) { | 516 | wPaintCoord != width() || hPaintCoord != height()) { |
517 | xPaintCoord= xx; | 517 | xPaintCoord= xx; |
518 | yPaintCoord = yy; | 518 | yPaintCoord = yy; |
519 | wPaintCoord = width(); | 519 | wPaintCoord = width(); |
520 | hPaintCoord = height(); | 520 | hPaintCoord = height(); |
521 | globalFlagBlockAgendaItemUpdate = 0; | 521 | globalFlagBlockAgendaItemUpdate = 0; |
522 | paintMe( mSelected ); | 522 | paintMe( mSelected ); |
523 | //qDebug("calling paintMe "); | 523 | //qDebug("calling paintMe "); |
524 | globalFlagBlockAgendaItemUpdate = 1; | 524 | globalFlagBlockAgendaItemUpdate = 1; |
525 | if ( mSelected ) | 525 | if ( mSelected ) |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | int rx, ry, rw, rh; | 528 | int rx, ry, rw, rh; |
529 | rx = e->rect().x(); | 529 | rx = e->rect().x(); |
530 | ry = e->rect().y(); | 530 | ry = e->rect().y(); |
531 | rw = e->rect().width(); | 531 | rw = e->rect().width(); |
532 | rh = e->rect().height(); | 532 | rh = e->rect().height(); |
533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
534 | 534 | ||
535 | QPixmap* paintFrom ; | 535 | QPixmap* paintFrom ; |
536 | if ( mSelected ) { | 536 | if ( mSelected ) { |
537 | paintMe( mSelected ); | 537 | paintMe( mSelected ); |
538 | return; | 538 | return; |
539 | } else { | 539 | } else { |
540 | if ( mAllDay ) | 540 | if ( mAllDay ) |
541 | paintFrom = paintPixAllday(); | 541 | paintFrom = paintPixAllday(); |
542 | else | 542 | else |
543 | paintFrom = paintPix(); | 543 | paintFrom = paintPix(); |
544 | } | 544 | } |
545 | xx += rx; | 545 | xx += rx; |
546 | 546 | ||
547 | if ( xx < 0 ) { | 547 | if ( xx < 0 ) { |
548 | rw = rw + xx; | 548 | rw = rw + xx; |
549 | rx -= xx; | 549 | rx -= xx; |
550 | xx = 0; | 550 | xx = 0; |
551 | if ( rw <= 1 ) { | 551 | if ( rw <= 1 ) { |
552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( paintFrom->width() < xx+rw ) { | 556 | if ( paintFrom->width() < xx+rw ) { |
557 | rw = paintFrom->width() - xx; | 557 | rw = paintFrom->width() - xx; |
558 | if ( rw <= 1 ) { | 558 | if ( rw <= 1 ) { |
559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
565 | } | 565 | } |
566 | void KOAgendaItem::computeText() | 566 | void KOAgendaItem::computeText() |
567 | { | 567 | { |
568 | mDisplayedText = mIncidence->summary(); | 568 | mDisplayedText = mIncidence->summary(); |
569 | if ( (mIncidence->typeID() == todoID ) ) { | 569 | if ( (mIncidence->typeID() == todoID ) ) { |
570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
573 | else if ( !(mIncidence->doesFloat())) | 573 | else if ( !(mIncidence->doesFloat())) |
574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
579 | 579 | ||
580 | if ( mAllDay ) { | 580 | if ( mAllDay ) { |
581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
582 | if ( mIncidence->doesRecur() ) { | 582 | if ( mIncidence->doesRecur() ) { |
583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
584 | } else { | 584 | } else { |
585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
586 | } | 586 | } |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | if ( !mIncidence->location().isEmpty() ) { | 591 | if ( !mIncidence->location().isEmpty() ) { |
592 | if ( mAllDay ) | 592 | if ( mAllDay ) |
593 | mDisplayedText += " ("; | 593 | mDisplayedText += " ("; |
594 | else | 594 | else |
595 | mDisplayedText += "\n("; | 595 | mDisplayedText += "\n("; |
596 | mDisplayedText += mIncidence->location() +")"; | 596 | mDisplayedText += mIncidence->location() +")"; |
597 | } | 597 | } |
598 | #ifdef DESKTOP_VERSION | 598 | #ifdef DESKTOP_VERSION |
599 | QString tipText = mIncidence->summary(); | 599 | QString tipText = mIncidence->summary(); |
600 | if ( !mIncidence->doesFloat() ) { | 600 | if ( !mIncidence->doesFloat() ) { |
601 | if ( mIncidence->typeID() == eventID ) { | 601 | if ( mIncidence->typeID() == eventID ) { |
602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
605 | } | 605 | } |
606 | else { | 606 | else { |
607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
609 | } | 609 | } |
610 | } | 610 | } |
611 | else if ( mIncidence->typeID() == todoID ) { | 611 | else if ( mIncidence->typeID() == todoID ) { |
612 | if (mIncidence->hasStartDate()) | 612 | if (mIncidence->hasStartDate()) |
613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
614 | if (((Todo*)mIncidence)->hasDueDate()) | 614 | if (((Todo*)mIncidence)->hasDueDate()) |
615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
616 | } | 616 | } |
617 | } else if ( mIncidence->typeID() == todoID ) { | 617 | } else if ( mIncidence->typeID() == todoID ) { |
618 | if (mIncidence->hasStartDate()) | 618 | if (mIncidence->hasStartDate()) |
619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
620 | if (((Todo*)mIncidence)->hasDueDate()) | 620 | if (((Todo*)mIncidence)->hasDueDate()) |
621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index a01323a..04f30bb 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -820,769 +820,769 @@ void KOAgendaView::createDayLabels() | |||
820 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 820 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
821 | break; | 821 | break; |
822 | 822 | ||
823 | default: | 823 | default: |
824 | break; | 824 | break; |
825 | } | 825 | } |
826 | if ( oneday ) { | 826 | if ( oneday ) { |
827 | QString addString; | 827 | QString addString; |
828 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 828 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
829 | addString = i18n("Today"); | 829 | addString = i18n("Today"); |
830 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 830 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
831 | addString = i18n("Tomorrow"); | 831 | addString = i18n("Tomorrow"); |
832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 832 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
833 | addString = i18n("Yesterday"); | 833 | addString = i18n("Yesterday"); |
834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 834 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
835 | addString = i18n("Day before yesterday"); | 835 | addString = i18n("Day before yesterday"); |
836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 836 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
837 | addString = i18n("Day after tomorrow"); | 837 | addString = i18n("Day after tomorrow"); |
838 | if ( !addString.isEmpty() ) { | 838 | if ( !addString.isEmpty() ) { |
839 | if ( QApplication::desktop()->width() < 640 ) | 839 | if ( QApplication::desktop()->width() < 640 ) |
840 | str = addString+", " + str; | 840 | str = addString+", " + str; |
841 | else | 841 | else |
842 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); | 842 | str = addString+", "+ KGlobal::locale()->formatDate( date, false); |
843 | } else { | 843 | } else { |
844 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 844 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
845 | } | 845 | } |
846 | } | 846 | } |
847 | dayLabel->setText(str); | 847 | dayLabel->setText(str); |
848 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 848 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
849 | if (date == QDate::currentDate()) { | 849 | if (date == QDate::currentDate()) { |
850 | QFont bFont = dlf; | 850 | QFont bFont = dlf; |
851 | bFont.setBold( true ); | 851 | bFont.setBold( true ); |
852 | dayLabel->setFont(bFont); | 852 | dayLabel->setFont(bFont); |
853 | } | 853 | } |
854 | //dayLayout->addWidget(dayLabel); | 854 | //dayLayout->addWidget(dayLabel); |
855 | 855 | ||
856 | #ifndef KORG_NOPLUGINS | 856 | #ifndef KORG_NOPLUGINS |
857 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 857 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
858 | CalendarDecoration *it; | 858 | CalendarDecoration *it; |
859 | for(it = cds.first(); it; it = cds.next()) { | 859 | for(it = cds.first(); it; it = cds.next()) { |
860 | QString text = it->shortText( date ); | 860 | QString text = it->shortText( date ); |
861 | if ( !text.isEmpty() ) { | 861 | if ( !text.isEmpty() ) { |
862 | QLabel *label = new QLabel(text,mDayLabels); | 862 | QLabel *label = new QLabel(text,mDayLabels); |
863 | label->setAlignment(AlignCenter); | 863 | label->setAlignment(AlignCenter); |
864 | dayLayout->addWidget(label); | 864 | dayLayout->addWidget(label); |
865 | } | 865 | } |
866 | } | 866 | } |
867 | 867 | ||
868 | for(it = cds.first(); it; it = cds.next()) { | 868 | for(it = cds.first(); it; it = cds.next()) { |
869 | QWidget *wid = it->smallWidget(mDayLabels,date); | 869 | QWidget *wid = it->smallWidget(mDayLabels,date); |
870 | if ( wid ) { | 870 | if ( wid ) { |
871 | // wid->setHeight(20); | 871 | // wid->setHeight(20); |
872 | dayLayout->addWidget(wid); | 872 | dayLayout->addWidget(wid); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | #endif | 875 | #endif |
876 | } | 876 | } |
877 | if ( ! appendLabels ) { | 877 | if ( ! appendLabels ) { |
878 | dayLabel = mDayLabelsList.next(); | 878 | dayLabel = mDayLabelsList.next(); |
879 | if ( !dayLabel ) | 879 | if ( !dayLabel ) |
880 | appendLabels = true; | 880 | appendLabels = true; |
881 | } | 881 | } |
882 | if ( appendLabels ) { | 882 | if ( appendLabels ) { |
883 | dayLabel = getNewDaylabel(); | 883 | dayLabel = getNewDaylabel(); |
884 | } | 884 | } |
885 | //dayLabel->hide();//test only | 885 | //dayLabel->hide();//test only |
886 | 886 | ||
887 | dayLabel->setText(">"); | 887 | dayLabel->setText(">"); |
888 | dayLabel->setFont( dlf ); | 888 | dayLabel->setFont( dlf ); |
889 | dayLabel->setAutoRepeat( true ); | 889 | dayLabel->setAutoRepeat( true ); |
890 | dayLabel->show(); | 890 | dayLabel->show(); |
891 | dayLabel->setNum( -2 ); | 891 | dayLabel->setNum( -2 ); |
892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
893 | 893 | ||
894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
895 | if ( !appendLabels ) { | 895 | if ( !appendLabels ) { |
896 | dayLabel = mDayLabelsList.next(); | 896 | dayLabel = mDayLabelsList.next(); |
897 | while ( dayLabel ) { | 897 | while ( dayLabel ) { |
898 | //qDebug("!dayLabel %d",dayLabel ); | 898 | //qDebug("!dayLabel %d",dayLabel ); |
899 | dayLabel->hide(); | 899 | dayLabel->hide(); |
900 | dayLabel = mDayLabelsList.next(); | 900 | dayLabel = mDayLabelsList.next(); |
901 | } | 901 | } |
902 | } | 902 | } |
903 | 903 | ||
904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
905 | } | 905 | } |
906 | 906 | ||
907 | int KOAgendaView::maxDatesHint() | 907 | int KOAgendaView::maxDatesHint() |
908 | { | 908 | { |
909 | // Not sure about the max number of events, so return 0 for now. | 909 | // Not sure about the max number of events, so return 0 for now. |
910 | return 0; | 910 | return 0; |
911 | } | 911 | } |
912 | 912 | ||
913 | int KOAgendaView::currentDateCount() | 913 | int KOAgendaView::currentDateCount() |
914 | { | 914 | { |
915 | return mSelectedDates.count(); | 915 | return mSelectedDates.count(); |
916 | } | 916 | } |
917 | 917 | ||
918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
919 | { | 919 | { |
920 | QPtrList<Incidence> selected; | 920 | QPtrList<Incidence> selected; |
921 | Incidence *incidence; | 921 | Incidence *incidence; |
922 | 922 | ||
923 | incidence = mAgenda->selectedIncidence(); | 923 | incidence = mAgenda->selectedIncidence(); |
924 | if (incidence) selected.append(incidence); | 924 | if (incidence) selected.append(incidence); |
925 | 925 | ||
926 | incidence = mAllDayAgenda->selectedIncidence(); | 926 | incidence = mAllDayAgenda->selectedIncidence(); |
927 | if (incidence) selected.append(incidence); | 927 | if (incidence) selected.append(incidence); |
928 | 928 | ||
929 | return selected; | 929 | return selected; |
930 | } | 930 | } |
931 | 931 | ||
932 | DateList KOAgendaView::selectedDates() | 932 | DateList KOAgendaView::selectedDates() |
933 | { | 933 | { |
934 | DateList selected; | 934 | DateList selected; |
935 | QDate qd; | 935 | QDate qd; |
936 | 936 | ||
937 | qd = mAgenda->selectedIncidenceDate(); | 937 | qd = mAgenda->selectedIncidenceDate(); |
938 | if (qd.isValid()) selected.append(qd); | 938 | if (qd.isValid()) selected.append(qd); |
939 | 939 | ||
940 | qd = mAllDayAgenda->selectedIncidenceDate(); | 940 | qd = mAllDayAgenda->selectedIncidenceDate(); |
941 | if (qd.isValid()) selected.append(qd); | 941 | if (qd.isValid()) selected.append(qd); |
942 | 942 | ||
943 | return selected; | 943 | return selected; |
944 | } | 944 | } |
945 | 945 | ||
946 | 946 | ||
947 | void KOAgendaView::updateView() | 947 | void KOAgendaView::updateView() |
948 | { | 948 | { |
949 | if ( mBlockUpdating ) | 949 | if ( mBlockUpdating ) |
950 | return; | 950 | return; |
951 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 951 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
952 | fillAgenda(); | 952 | fillAgenda(); |
953 | 953 | ||
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | /* | 957 | /* |
958 | Update configuration settings for the agenda view. This method is not | 958 | Update configuration settings for the agenda view. This method is not |
959 | complete. | 959 | complete. |
960 | */ | 960 | */ |
961 | void KOAgendaView::updateConfig() | 961 | void KOAgendaView::updateConfig() |
962 | { | 962 | { |
963 | if ( mBlockUpdating ) | 963 | if ( mBlockUpdating ) |
964 | return; | 964 | return; |
965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
966 | int old = KOPrefs::instance()->mHourSize; | 966 | int old = KOPrefs::instance()->mHourSize; |
967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
969 | } | 969 | } |
970 | 970 | ||
971 | 971 | ||
972 | // update config for children | 972 | // update config for children |
973 | mTimeLabels->updateConfig(); | 973 | mTimeLabels->updateConfig(); |
974 | mAgenda->storePosition(); | 974 | mAgenda->storePosition(); |
975 | mAgenda->updateConfig(); | 975 | mAgenda->updateConfig(); |
976 | mAllDayAgenda->updateConfig(); | 976 | mAllDayAgenda->updateConfig(); |
977 | // widget synchronization | 977 | // widget synchronization |
978 | //TODO: find a better way, maybe signal/slot | 978 | //TODO: find a better way, maybe signal/slot |
979 | mTimeLabels->positionChanged(); | 979 | mTimeLabels->positionChanged(); |
980 | 980 | ||
981 | // for some reason, this needs to be called explicitly | 981 | // for some reason, this needs to be called explicitly |
982 | mTimeLabels->repaint(); | 982 | mTimeLabels->repaint(); |
983 | 983 | ||
984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
985 | 985 | ||
986 | // ToolTips displaying summary of events | 986 | // ToolTips displaying summary of events |
987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
988 | ->mEnableToolTips); | 988 | ->mEnableToolTips); |
989 | 989 | ||
990 | //setHolidayMasks(); | 990 | //setHolidayMasks(); |
991 | 991 | ||
992 | //createDayLabels(); called by via updateView(); | 992 | //createDayLabels(); called by via updateView(); |
993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
994 | updateView(); | 994 | updateView(); |
995 | mAgenda->restorePosition(); | 995 | mAgenda->restorePosition(); |
996 | } | 996 | } |
997 | 997 | ||
998 | 998 | ||
999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
1000 | { | 1000 | { |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | int xxx = item->cellX(); | 1003 | int xxx = item->cellX(); |
1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
1005 | if ( mMinY.at(xxx) > item->cellYTop() ) | 1005 | if ( mMinY.at(xxx) > item->cellYTop() ) |
1006 | mMinY.at(xxx) = item->cellYTop(); | 1006 | mMinY.at(xxx) = item->cellYTop(); |
1007 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 1007 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
1008 | mMaxY.at(xxx) = item->cellYBottom(); | 1008 | mMaxY.at(xxx) = item->cellYBottom(); |
1009 | 1009 | ||
1010 | QDateTime startDt,endDt; | 1010 | QDateTime startDt,endDt; |
1011 | QDate startDate; | 1011 | QDate startDate; |
1012 | int lenInSecs; | 1012 | int lenInSecs; |
1013 | // if ( type == KOAgenda::RESIZETOP ) | 1013 | // if ( type == KOAgenda::RESIZETOP ) |
1014 | // qDebug("RESIZETOP "); | 1014 | // qDebug("RESIZETOP "); |
1015 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 1015 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
1016 | // qDebug("RESIZEBOTTOM "); | 1016 | // qDebug("RESIZEBOTTOM "); |
1017 | // if ( type == KOAgenda::MOVE ) | 1017 | // if ( type == KOAgenda::MOVE ) |
1018 | // qDebug("MOVE "); | 1018 | // qDebug("MOVE "); |
1019 | if ( item->incidence()->typeID() == eventID ) { | 1019 | if ( item->incidence()->typeID() == eventID ) { |
1020 | startDt =item->incidence()->dtStart(); | 1020 | startDt =item->incidence()->dtStart(); |
1021 | endDt = item->incidence()->dtEnd(); | 1021 | endDt = item->incidence()->dtEnd(); |
1022 | lenInSecs = startDt.secsTo( endDt ); | 1022 | lenInSecs = startDt.secsTo( endDt ); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 1025 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
1026 | 1026 | ||
1027 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { | 1027 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
1028 | startDate = mSelectedDates[item->mLastMoveXPos]; | 1028 | startDate = mSelectedDates[item->mLastMoveXPos]; |
1029 | } else { | 1029 | } else { |
1030 | if (item->cellX() < 0) { | 1030 | if (item->cellX() < 0) { |
1031 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 1031 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
1032 | } else { | 1032 | } else { |
1033 | startDate = mSelectedDates[item->cellX()]; | 1033 | startDate = mSelectedDates[item->cellX()]; |
1034 | } | 1034 | } |
1035 | } | 1035 | } |
1036 | startDt.setDate(startDate); | 1036 | startDt.setDate(startDate); |
1037 | 1037 | ||
1038 | if (item->incidence()->doesFloat()) { | 1038 | if (item->incidence()->doesFloat()) { |
1039 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 1039 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
1040 | } else { | 1040 | } else { |
1041 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 1041 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
1042 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 1042 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
1043 | if ( item->incidence()->typeID() == eventID ) { | 1043 | if ( item->incidence()->typeID() == eventID ) { |
1044 | if ( type == KOAgenda::MOVE ) { | 1044 | if ( type == KOAgenda::MOVE ) { |
1045 | endDt = startDt.addSecs(lenInSecs); | 1045 | endDt = startDt.addSecs(lenInSecs); |
1046 | 1046 | ||
1047 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1047 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1048 | if (item->lastMultiItem()) { | 1048 | if (item->lastMultiItem()) { |
1049 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1049 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1050 | endDt.setDate(startDate. | 1050 | endDt.setDate(startDate. |
1051 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1051 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1052 | } else { | 1052 | } else { |
1053 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1053 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1054 | endDt.setDate(startDate); | 1054 | endDt.setDate(startDate); |
1055 | } | 1055 | } |
1056 | } | 1056 | } |
1057 | } else { | 1057 | } else { |
1058 | // todo | 1058 | // todo |
1059 | if (item->lastMultiItem()) { | 1059 | if (item->lastMultiItem()) { |
1060 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1060 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1061 | endDt.setDate(startDate. | 1061 | endDt.setDate(startDate. |
1062 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1062 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1063 | } else { | 1063 | } else { |
1064 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1064 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1065 | if ( item->cellYBottom() > 0 ) | 1065 | if ( item->cellYBottom() > 0 ) |
1066 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1066 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1067 | else | 1067 | else |
1068 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1068 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1069 | endDt.setDate(startDate); | 1069 | endDt.setDate(startDate); |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | } | 1072 | } |
1073 | if ( item->incidence()->typeID() == eventID ) { | 1073 | if ( item->incidence()->typeID() == eventID ) { |
1074 | item->incidence()->setDtStart(startDt); | 1074 | item->incidence()->setDtStart(startDt); |
1075 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1075 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1076 | } else if ( item->incidence()->typeID() == todoID ) { | 1076 | } else if ( item->incidence()->typeID() == todoID ) { |
1077 | Todo* to = static_cast<Todo*>(item->incidence()); | 1077 | Todo* to = static_cast<Todo*>(item->incidence()); |
1078 | 1078 | ||
1079 | to->setDtDue(endDt); | 1079 | to->setDtDue(endDt); |
1080 | if ( to->hasStartDate() ) { | 1080 | if ( to->hasStartDate() ) { |
1081 | if (to->dtStart() >= to->dtDue() ) | 1081 | if (to->dtStart() >= to->dtDue() ) |
1082 | to->setDtStart(to->dtDue().addDays( -2 )); | 1082 | to->setDtStart(to->dtDue().addDays( -2 )); |
1083 | } | 1083 | } |
1084 | 1084 | ||
1085 | } | 1085 | } |
1086 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1086 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1087 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1087 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1088 | item->setItemDate(startDt.date()); | 1088 | item->setItemDate(startDt.date()); |
1089 | //item->updateItem(); | 1089 | //item->updateItem(); |
1090 | if ( item->incidence()->typeID() == todoID ) { | 1090 | if ( item->incidence()->typeID() == todoID ) { |
1091 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1091 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1092 | 1092 | ||
1093 | } | 1093 | } |
1094 | else | 1094 | else |
1095 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1095 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1096 | item->updateItem(); | 1096 | item->updateItem(); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1099 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1100 | { | 1100 | { |
1101 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1101 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1102 | 1102 | ||
1103 | mSelectedDates.clear(); | 1103 | mSelectedDates.clear(); |
1104 | // qDebug("KOAgendaView::showDates "); | 1104 | // qDebug("KOAgendaView::showDates "); |
1105 | QDate d = start; | 1105 | QDate d = start; |
1106 | while (d <= end) { | 1106 | while (d <= end) { |
1107 | mSelectedDates.append(d); | 1107 | mSelectedDates.append(d); |
1108 | d = d.addDays( 1 ); | 1108 | d = d.addDays( 1 ); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | // and update the view | 1111 | // and update the view |
1112 | fillAgenda(); | 1112 | fillAgenda(); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | 1115 | ||
1116 | void KOAgendaView::showEvents(QPtrList<Event>) | 1116 | void KOAgendaView::showEvents(QPtrList<Event>) |
1117 | { | 1117 | { |
1118 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1118 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | void KOAgendaView::changeEventDisplay(Event *, int) | 1121 | void KOAgendaView::changeEventDisplay(Event *, int) |
1122 | { | 1122 | { |
1123 | // qDebug("KOAgendaView::changeEventDisplay "); | 1123 | // qDebug("KOAgendaView::changeEventDisplay "); |
1124 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1124 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1125 | // this should be re-written to be MUCH smarter. Right now we | 1125 | // this should be re-written to be MUCH smarter. Right now we |
1126 | // are just playing dumb. | 1126 | // are just playing dumb. |
1127 | fillAgenda(); | 1127 | fillAgenda(); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void KOAgendaView::fillAgenda(const QDate &) | 1130 | void KOAgendaView::fillAgenda(const QDate &) |
1131 | { | 1131 | { |
1132 | // qDebug("KOAgendaView::fillAgenda "); | 1132 | // qDebug("KOAgendaView::fillAgenda "); |
1133 | fillAgenda(); | 1133 | fillAgenda(); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void KOAgendaView::fillAgenda() | 1136 | void KOAgendaView::fillAgenda() |
1137 | { | 1137 | { |
1138 | if ( globalFlagBlockStartup ) | 1138 | if ( globalFlagBlockStartup ) |
1139 | return; | 1139 | return; |
1140 | if ( globalFlagBlockAgenda == 1 ) | 1140 | if ( globalFlagBlockAgenda == 1 ) |
1141 | return; | 1141 | return; |
1142 | static bool onlyOne = false; | 1142 | static bool onlyOne = false; |
1143 | if ( onlyOne ) | 1143 | if ( onlyOne ) |
1144 | return; | 1144 | return; |
1145 | onlyOne = true; | 1145 | onlyOne = true; |
1146 | //if ( globalFlagBlockAgenda == 2 ) | 1146 | //if ( globalFlagBlockAgenda == 2 ) |
1147 | //globalFlagBlockAgenda = 0; | 1147 | //globalFlagBlockAgenda = 0; |
1148 | // globalFlagBlockPainting = false; | 1148 | // globalFlagBlockPainting = false; |
1149 | if ( globalFlagBlockAgenda == 0 ) | 1149 | if ( globalFlagBlockAgenda == 0 ) |
1150 | globalFlagBlockAgenda = 1; | 1150 | globalFlagBlockAgenda = 1; |
1151 | // clearView(); | 1151 | // clearView(); |
1152 | //qDebug("fillAgenda()++++ "); | 1152 | //qDebug("fillAgenda()++++ "); |
1153 | globalFlagBlockAgendaItemPaint = 1; | 1153 | globalFlagBlockAgendaItemPaint = 1; |
1154 | 1154 | ||
1155 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1155 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1156 | mAgenda->changeColumns(mSelectedDates.count()); | 1156 | mAgenda->changeColumns(mSelectedDates.count()); |
1157 | qApp->processEvents(); | 1157 | qApp->processEvents(); |
1158 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1158 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1159 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1159 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1160 | setHolidayMasks(); | 1160 | setHolidayMasks(); |
1161 | 1161 | ||
1162 | mMinY.resize(mSelectedDates.count()); | 1162 | mMinY.resize(mSelectedDates.count()); |
1163 | mMaxY.resize(mSelectedDates.count()); | 1163 | mMaxY.resize(mSelectedDates.count()); |
1164 | 1164 | ||
1165 | QPtrList<Event> dayEvents; | 1165 | QPtrList<Event> dayEvents; |
1166 | 1166 | ||
1167 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1167 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1168 | // Therefore, gtodoset all of them. | 1168 | // Therefore, gtodoset all of them. |
1169 | QPtrList<Todo> todos = calendar()->todos(); | 1169 | QPtrList<Todo> todos = calendar()->todos(); |
1170 | 1170 | ||
1171 | mAgenda->setDateList(mSelectedDates); | 1171 | mAgenda->setDateList(mSelectedDates); |
1172 | 1172 | ||
1173 | QDate today = QDate::currentDate(); | 1173 | QDate today = QDate::currentDate(); |
1174 | 1174 | ||
1175 | DateList::ConstIterator dit; | 1175 | DateList::ConstIterator dit; |
1176 | int curCol = 0; | 1176 | int curCol = 0; |
1177 | int maxCol = mSelectedDates.count()-1; | 1177 | int maxCol = mSelectedDates.count()-1; |
1178 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1178 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1179 | QDate currentDate = *dit; | 1179 | QDate currentDate = *dit; |
1180 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1180 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1181 | // << endl; | 1181 | // << endl; |
1182 | 1182 | ||
1183 | dayEvents = calendar()->events(currentDate,false); | 1183 | dayEvents = calendar()->events(currentDate,false); |
1184 | 1184 | ||
1185 | // Default values, which can never be reached | 1185 | // Default values, which can never be reached |
1186 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1186 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1187 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1187 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1188 | 1188 | ||
1189 | unsigned int numEvent; | 1189 | unsigned int numEvent; |
1190 | //qDebug("+++++NUMEVENT %d", dayEvents.count()); | 1190 | //qDebug("+++++NUMEVENT %d", dayEvents.count()); |
1191 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1191 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1192 | Event *event = dayEvents.at(numEvent); | 1192 | Event *event = dayEvents.at(numEvent); |
1193 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1193 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1194 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1194 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1195 | continue; | 1195 | continue; |
1196 | // kdDebug() << " Event: " << event->summary() << endl; | 1196 | // kdDebug() << " Event: " << event->summary() << endl; |
1197 | 1197 | ||
1198 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1198 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1199 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1199 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1200 | 1200 | ||
1201 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1201 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1202 | 1202 | ||
1203 | if (event->doesFloat()) { | 1203 | if (event->doesFloat()) { |
1204 | if (event->recurrence()->doesRecur()) { | 1204 | if (event->doesRecur()) { |
1205 | if (event->isMultiDay() ) { | 1205 | if (event->isMultiDay() ) { |
1206 | endX = endX - beginX;// endX is now number of days | 1206 | endX = endX - beginX;// endX is now number of days |
1207 | if ( event->recursOn( currentDate ) ) { | 1207 | if ( event->recursOn( currentDate ) ) { |
1208 | endX += curCol; | 1208 | endX += curCol; |
1209 | beginX = curCol; | 1209 | beginX = curCol; |
1210 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1210 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1211 | } else { | 1211 | } else { |
1212 | //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); | 1212 | //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); |
1213 | if ( curCol == maxCol && maxCol+1 < endX ) { | 1213 | if ( curCol == maxCol && maxCol+1 < endX ) { |
1214 | int i; | 1214 | int i; |
1215 | for ( i = 1; i< endX; ++i ) { | 1215 | for ( i = 1; i< endX; ++i ) { |
1216 | if ( event->recursOn( currentDate.addDays( -i ) ) ) | 1216 | if ( event->recursOn( currentDate.addDays( -i ) ) ) |
1217 | break; | 1217 | break; |
1218 | } | 1218 | } |
1219 | if ( i > maxCol ) { | 1219 | if ( i > maxCol ) { |
1220 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1220 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1221 | //qDebug("BINGO "); | 1221 | //qDebug("BINGO "); |
1222 | } | 1222 | } |
1223 | 1223 | ||
1224 | } else { | 1224 | } else { |
1225 | QDate dateit = currentDate.addDays( -endX ); | 1225 | QDate dateit = currentDate.addDays( -endX ); |
1226 | if ( event->recursOn( dateit ) ) { | 1226 | if ( event->recursOn( dateit ) ) { |
1227 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1227 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1228 | if ( curCol-endX < 0 ) { | 1228 | if ( curCol-endX < 0 ) { |
1229 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1229 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1230 | } | 1230 | } |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | } else { | 1234 | } else { |
1235 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1235 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | } else { | 1238 | } else { |
1239 | if (beginX <= 0 && curCol == 0) { | 1239 | if (beginX <= 0 && curCol == 0) { |
1240 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1240 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1241 | } else if (beginX == curCol) { | 1241 | } else if (beginX == curCol) { |
1242 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1242 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | } else if (event->isMultiDay()) { | 1245 | } else if (event->isMultiDay()) { |
1246 | if ( event->doesRecur () ) { | 1246 | if ( event->doesRecur () ) { |
1247 | QDate dateit = currentDate; | 1247 | QDate dateit = currentDate; |
1248 | int count = 0; | 1248 | int count = 0; |
1249 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1249 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1250 | while (! event->recursOn( dateit ) && count <= max ) { | 1250 | while (! event->recursOn( dateit ) && count <= max ) { |
1251 | ++count; | 1251 | ++count; |
1252 | dateit = dateit.addDays( -1 ); | 1252 | dateit = dateit.addDays( -1 ); |
1253 | } | 1253 | } |
1254 | bool ok; | 1254 | bool ok; |
1255 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1255 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1256 | if ( ok ) | 1256 | if ( ok ) |
1257 | { | 1257 | { |
1258 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1258 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1259 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1259 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1260 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1260 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1261 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1261 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1262 | 1262 | ||
1263 | } | 1263 | } |
1264 | } | 1264 | } |
1265 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1265 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1266 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1266 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1267 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1267 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1268 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1268 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1269 | //qDebug("insert!!! "); | 1269 | //qDebug("insert!!! "); |
1270 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1270 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1271 | } | 1271 | } |
1272 | if (beginX == curCol) { | 1272 | if (beginX == curCol) { |
1273 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1273 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1274 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1274 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1275 | } else if (endX == curCol) { | 1275 | } else if (endX == curCol) { |
1276 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1276 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1277 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1277 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1278 | } else { | 1278 | } else { |
1279 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1279 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1280 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1280 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1281 | } | 1281 | } |
1282 | } else { | 1282 | } else { |
1283 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1283 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1284 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1284 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1285 | if (endY < startY) endY = startY; | 1285 | if (endY < startY) endY = startY; |
1286 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1286 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1287 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1287 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1288 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1288 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1289 | } | 1289 | } |
1290 | } | 1290 | } |
1291 | // ---------- [display Todos -------------- | 1291 | // ---------- [display Todos -------------- |
1292 | unsigned int numTodo; | 1292 | unsigned int numTodo; |
1293 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1293 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1294 | Todo *todo = todos.at(numTodo); | 1294 | Todo *todo = todos.at(numTodo); |
1295 | 1295 | ||
1296 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1296 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1297 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; | 1297 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; |
1298 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1298 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1299 | // Already completed items can be displayed on their original due date | 1299 | // Already completed items can be displayed on their original due date |
1300 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1300 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1301 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1301 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1302 | bool fillIn = false; | 1302 | bool fillIn = false; |
1303 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1303 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1304 | fillIn = true; | 1304 | fillIn = true; |
1305 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1305 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1306 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1306 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1307 | if ( fillIn ) { | 1307 | if ( fillIn ) { |
1308 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1308 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1309 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1309 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1310 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1310 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1311 | } | 1311 | } |
1312 | else { | 1312 | else { |
1313 | QDateTime dt; | 1313 | QDateTime dt; |
1314 | if ( todo->hasCompletedDate() ) | 1314 | if ( todo->hasCompletedDate() ) |
1315 | dt = todo->completed(); | 1315 | dt = todo->completed(); |
1316 | else | 1316 | else |
1317 | dt = todo->dtDue();; | 1317 | dt = todo->dtDue();; |
1318 | 1318 | ||
1319 | 1319 | ||
1320 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1320 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1321 | int hi = (18/KOPrefs::instance()->mHourSize); | 1321 | int hi = (18/KOPrefs::instance()->mHourSize); |
1322 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1322 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1323 | int startY = endY -hi; | 1323 | int startY = endY -hi; |
1324 | 1324 | ||
1325 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1325 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1326 | 1326 | ||
1327 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1327 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1328 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1328 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1329 | } | 1329 | } |
1330 | } | 1330 | } |
1331 | } | 1331 | } |
1332 | // ---------- display Todos] -------------- | 1332 | // ---------- display Todos] -------------- |
1333 | 1333 | ||
1334 | ++curCol; | 1334 | ++curCol; |
1335 | } | 1335 | } |
1336 | mAgenda->hideUnused(); | 1336 | mAgenda->hideUnused(); |
1337 | mAllDayAgenda->hideUnused(); | 1337 | mAllDayAgenda->hideUnused(); |
1338 | mAgenda->checkScrollBoundaries(); | 1338 | mAgenda->checkScrollBoundaries(); |
1339 | deleteSelectedDateTime(); | 1339 | deleteSelectedDateTime(); |
1340 | createDayLabels(); | 1340 | createDayLabels(); |
1341 | emit incidenceSelected( 0 ); | 1341 | emit incidenceSelected( 0 ); |
1342 | 1342 | ||
1343 | if ( globalFlagBlockAgenda == 2 ) { | 1343 | if ( globalFlagBlockAgenda == 2 ) { |
1344 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1344 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1345 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1345 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1346 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1346 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1347 | setStartHour( QTime::currentTime ().hour() ); | 1347 | setStartHour( QTime::currentTime ().hour() ); |
1348 | } | 1348 | } |
1349 | qApp->processEvents(); | 1349 | qApp->processEvents(); |
1350 | globalFlagBlockAgenda = 0; | 1350 | globalFlagBlockAgenda = 0; |
1351 | mAllDayAgenda->drawContentsToPainter(); | 1351 | mAllDayAgenda->drawContentsToPainter(); |
1352 | mAgenda->drawContentsToPainter(); | 1352 | mAgenda->drawContentsToPainter(); |
1353 | repaintAgenda(); | 1353 | repaintAgenda(); |
1354 | startIdleTimeout(); | 1354 | startIdleTimeout(); |
1355 | onlyOne = false; | 1355 | onlyOne = false; |
1356 | } | 1356 | } |
1357 | void KOAgendaView::repaintAgenda() | 1357 | void KOAgendaView::repaintAgenda() |
1358 | { | 1358 | { |
1359 | mAgenda->viewport()->repaint( false ); | 1359 | mAgenda->viewport()->repaint( false ); |
1360 | mAllDayAgenda->viewport()->repaint( false ); | 1360 | mAllDayAgenda->viewport()->repaint( false ); |
1361 | mAgenda->finishUpdate(); | 1361 | mAgenda->finishUpdate(); |
1362 | mAllDayAgenda->finishUpdate(); | 1362 | mAllDayAgenda->finishUpdate(); |
1363 | } | 1363 | } |
1364 | 1364 | ||
1365 | 1365 | ||
1366 | void KOAgendaView::clearView() | 1366 | void KOAgendaView::clearView() |
1367 | { | 1367 | { |
1368 | mAllDayAgenda->clear(); | 1368 | mAllDayAgenda->clear(); |
1369 | mAgenda->clear(); | 1369 | mAgenda->clear(); |
1370 | } | 1370 | } |
1371 | void KOAgendaView::clearList() | 1371 | void KOAgendaView::clearList() |
1372 | { | 1372 | { |
1373 | clearView(); | 1373 | clearView(); |
1374 | mAllDayAgenda->hideUnused(); | 1374 | mAllDayAgenda->hideUnused(); |
1375 | mAgenda->hideUnused(); | 1375 | mAgenda->hideUnused(); |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1378 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1379 | const QDate &td) | 1379 | const QDate &td) |
1380 | { | 1380 | { |
1381 | #ifndef KORG_NOPRINTER | 1381 | #ifndef KORG_NOPRINTER |
1382 | if (fd == td) | 1382 | if (fd == td) |
1383 | calPrinter->preview(CalPrinter::Day, fd, td); | 1383 | calPrinter->preview(CalPrinter::Day, fd, td); |
1384 | else | 1384 | else |
1385 | calPrinter->preview(CalPrinter::Week, fd, td); | 1385 | calPrinter->preview(CalPrinter::Week, fd, td); |
1386 | #endif | 1386 | #endif |
1387 | } | 1387 | } |
1388 | 1388 | ||
1389 | // void KOAgendaView::updateMovedTodo() | 1389 | // void KOAgendaView::updateMovedTodo() |
1390 | // { | 1390 | // { |
1391 | // // updateConfig(); | 1391 | // // updateConfig(); |
1392 | // // emit updateTodoViews(); | 1392 | // // emit updateTodoViews(); |
1393 | // } | 1393 | // } |
1394 | 1394 | ||
1395 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1395 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1396 | { | 1396 | { |
1397 | if ( d >= mSelectedDates.count() ) { | 1397 | if ( d >= mSelectedDates.count() ) { |
1398 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); | 1398 | qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); |
1399 | 1399 | ||
1400 | } else { | 1400 | } else { |
1401 | QDate day = mSelectedDates[d]; | 1401 | QDate day = mSelectedDates[d]; |
1402 | emit showDateView(mode , day ); | 1402 | emit showDateView(mode , day ); |
1403 | } | 1403 | } |
1404 | 1404 | ||
1405 | } | 1405 | } |
1406 | void KOAgendaView::newEvent(int gx, int gy) | 1406 | void KOAgendaView::newEvent(int gx, int gy) |
1407 | { | 1407 | { |
1408 | if (!mSelectedDates.count()) return; | 1408 | if (!mSelectedDates.count()) return; |
1409 | 1409 | ||
1410 | QDate day = mSelectedDates[gx]; | 1410 | QDate day = mSelectedDates[gx]; |
1411 | 1411 | ||
1412 | QTime time = mAgenda->gyToTime(gy); | 1412 | QTime time = mAgenda->gyToTime(gy); |
1413 | QDateTime dt(day,time); | 1413 | QDateTime dt(day,time); |
1414 | // if ( dt < QDateTime::currentDateTime () ) | 1414 | // if ( dt < QDateTime::currentDateTime () ) |
1415 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1415 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1416 | emit newEventSignal(dt); | 1416 | emit newEventSignal(dt); |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1419 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1420 | { | 1420 | { |
1421 | if (!mSelectedDates.count()) return; | 1421 | if (!mSelectedDates.count()) return; |
1422 | 1422 | ||
1423 | QDate dayStart = mSelectedDates[gxStart]; | 1423 | QDate dayStart = mSelectedDates[gxStart]; |
1424 | QDate dayEnd = mSelectedDates[gxEnd]; | 1424 | QDate dayEnd = mSelectedDates[gxEnd]; |
1425 | 1425 | ||
1426 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1426 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1427 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1427 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1428 | 1428 | ||
1429 | QDateTime dtStart(dayStart,timeStart); | 1429 | QDateTime dtStart(dayStart,timeStart); |
1430 | QDateTime dtEnd(dayEnd,timeEnd); | 1430 | QDateTime dtEnd(dayEnd,timeEnd); |
1431 | 1431 | ||
1432 | emit newEventSignal(dtStart,dtEnd); | 1432 | emit newEventSignal(dtStart,dtEnd); |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | void KOAgendaView::newEventAllDay(int gx, int ) | 1435 | void KOAgendaView::newEventAllDay(int gx, int ) |
1436 | { | 1436 | { |
1437 | if (!mSelectedDates.count()) return; | 1437 | if (!mSelectedDates.count()) return; |
1438 | 1438 | ||
1439 | QDate day = mSelectedDates[gx]; | 1439 | QDate day = mSelectedDates[gx]; |
1440 | 1440 | ||
1441 | emit newEventSignal(day); | 1441 | emit newEventSignal(day); |
1442 | } | 1442 | } |
1443 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1443 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1444 | { | 1444 | { |
1445 | if (!mSelectedDates.count()) return; | 1445 | if (!mSelectedDates.count()) return; |
1446 | 1446 | ||
1447 | QDateTime day (mSelectedDates[gx] ); | 1447 | QDateTime day (mSelectedDates[gx] ); |
1448 | emit newTodoSignal(day, true); | 1448 | emit newTodoSignal(day, true); |
1449 | } | 1449 | } |
1450 | void KOAgendaView::newTodo(int gx, int gy ) | 1450 | void KOAgendaView::newTodo(int gx, int gy ) |
1451 | { | 1451 | { |
1452 | if (!mSelectedDates.count()) return; | 1452 | if (!mSelectedDates.count()) return; |
1453 | QDate dayStart = mSelectedDates[gx]; | 1453 | QDate dayStart = mSelectedDates[gx]; |
1454 | QTime timeStart = mAgenda->gyToTime(gy); | 1454 | QTime timeStart = mAgenda->gyToTime(gy); |
1455 | QDateTime dt (dayStart,timeStart); | 1455 | QDateTime dt (dayStart,timeStart); |
1456 | emit newTodoSignal( dt, false ); | 1456 | emit newTodoSignal( dt, false ); |
1457 | } | 1457 | } |
1458 | 1458 | ||
1459 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1459 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1460 | { | 1460 | { |
1461 | uint i; | 1461 | uint i; |
1462 | for(i=0;i<mMinY.size();++i) { | 1462 | for(i=0;i<mMinY.size();++i) { |
1463 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1463 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1464 | else mEventIndicatorTop->enableColumn(i,false); | 1464 | else mEventIndicatorTop->enableColumn(i,false); |
1465 | } | 1465 | } |
1466 | 1466 | ||
1467 | mEventIndicatorTop->update(); | 1467 | mEventIndicatorTop->update(); |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1470 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1471 | { | 1471 | { |
1472 | uint i; | 1472 | uint i; |
1473 | for(i=0;i<mMaxY.size();++i) { | 1473 | for(i=0;i<mMaxY.size();++i) { |
1474 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1474 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1475 | else mEventIndicatorBottom->enableColumn(i,false); | 1475 | else mEventIndicatorBottom->enableColumn(i,false); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | mEventIndicatorBottom->update(); | 1478 | mEventIndicatorBottom->update(); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | void KOAgendaView::startDrag(Event *event) | 1481 | void KOAgendaView::startDrag(Event *event) |
1482 | { | 1482 | { |
1483 | #ifndef KORG_NODND | 1483 | #ifndef KORG_NODND |
1484 | DndFactory factory( calendar() ); | 1484 | DndFactory factory( calendar() ); |
1485 | ICalDrag *vd = factory.createDrag(event,this); | 1485 | ICalDrag *vd = factory.createDrag(event,this); |
1486 | if (vd->drag()) { | 1486 | if (vd->drag()) { |
1487 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1487 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1488 | } | 1488 | } |
1489 | #endif | 1489 | #endif |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | void KOAgendaView::readSettings() | 1492 | void KOAgendaView::readSettings() |
1493 | { | 1493 | { |
1494 | readSettings(KOGlobals::config()); | 1494 | readSettings(KOGlobals::config()); |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | void KOAgendaView::readSettings(KConfig *config) | 1497 | void KOAgendaView::readSettings(KConfig *config) |
1498 | { | 1498 | { |
1499 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1499 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1500 | 1500 | ||
1501 | config->setGroup("Views"); | 1501 | config->setGroup("Views"); |
1502 | 1502 | ||
1503 | //#ifndef KORG_NOSPLITTER | 1503 | //#ifndef KORG_NOSPLITTER |
1504 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1504 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1505 | if (sizes.count() == 2) { | 1505 | if (sizes.count() == 2) { |
1506 | if ( sizes[0] < 20 ) { | 1506 | if ( sizes[0] < 20 ) { |
1507 | sizes[1] = sizes[1] +20 - sizes[0]; | 1507 | sizes[1] = sizes[1] +20 - sizes[0]; |
1508 | sizes[0] = 20; | 1508 | sizes[0] = 20; |
1509 | } | 1509 | } |
1510 | mSplitterAgenda->setSizes(sizes); | 1510 | mSplitterAgenda->setSizes(sizes); |
1511 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1511 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1512 | } | 1512 | } |
1513 | //#endif | 1513 | //#endif |
1514 | 1514 | ||
1515 | // updateConfig(); | 1515 | // updateConfig(); |
1516 | } | 1516 | } |
1517 | 1517 | ||
1518 | void KOAgendaView::writeSettings(KConfig *config) | 1518 | void KOAgendaView::writeSettings(KConfig *config) |
1519 | { | 1519 | { |
1520 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1520 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1521 | 1521 | ||
1522 | config->setGroup("Views"); | 1522 | config->setGroup("Views"); |
1523 | 1523 | ||
1524 | //#ifndef KORG_NOSPLITTER | 1524 | //#ifndef KORG_NOSPLITTER |
1525 | QValueList<int> list = mSplitterAgenda->sizes(); | 1525 | QValueList<int> list = mSplitterAgenda->sizes(); |
1526 | config->writeEntry("Separator AgendaView",list); | 1526 | config->writeEntry("Separator AgendaView",list); |
1527 | //qDebug("write %d %d ", list[0],list[1] ); | 1527 | //qDebug("write %d %d ", list[0],list[1] ); |
1528 | //#endif | 1528 | //#endif |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | void KOAgendaView::setHolidayMasks() | 1531 | void KOAgendaView::setHolidayMasks() |
1532 | { | 1532 | { |
1533 | mHolidayMask.resize(mSelectedDates.count()); | 1533 | mHolidayMask.resize(mSelectedDates.count()); |
1534 | 1534 | ||
1535 | uint i; | 1535 | uint i; |
1536 | for(i=0;i<mSelectedDates.count();++i) { | 1536 | for(i=0;i<mSelectedDates.count();++i) { |
1537 | QDate date = mSelectedDates[i]; | 1537 | QDate date = mSelectedDates[i]; |
1538 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1538 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1539 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1539 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1540 | bool showHoliday = false; | 1540 | bool showHoliday = false; |
1541 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1541 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1542 | QPtrList<Event> events = calendar()->events( date, true ); | 1542 | QPtrList<Event> events = calendar()->events( date, true ); |
1543 | Event *event; | 1543 | Event *event; |
1544 | for( event = events.first(); event; event = events.next() ) { | 1544 | for( event = events.first(); event; event = events.next() ) { |
1545 | if ( event->isHoliday()) { | 1545 | if ( event->isHoliday()) { |
1546 | showHoliday = true; | 1546 | showHoliday = true; |
1547 | break; | 1547 | break; |
1548 | } | 1548 | } |
1549 | } | 1549 | } |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | 1552 | ||
1553 | #ifndef KORG_NOPLUGINS | 1553 | #ifndef KORG_NOPLUGINS |
1554 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1554 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1555 | !KOCore::self()->holiday(date).isEmpty(); | 1555 | !KOCore::self()->holiday(date).isEmpty(); |
1556 | #endif | 1556 | #endif |
1557 | bool showDay = showSaturday || showSunday || showHoliday; | 1557 | bool showDay = showSaturday || showSunday || showHoliday; |
1558 | 1558 | ||
1559 | if (showDay) { | 1559 | if (showDay) { |
1560 | mHolidayMask.at(i) = true; | 1560 | mHolidayMask.at(i) = true; |
1561 | } else { | 1561 | } else { |
1562 | mHolidayMask.at(i) = false; | 1562 | mHolidayMask.at(i) = false; |
1563 | } | 1563 | } |
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | mAgenda->setHolidayMask(&mHolidayMask); | 1566 | mAgenda->setHolidayMask(&mHolidayMask); |
1567 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1567 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | void KOAgendaView::setContentsPos(int y) | 1570 | void KOAgendaView::setContentsPos(int y) |
1571 | { | 1571 | { |
1572 | mAgenda->setContentsPos(0,y); | 1572 | mAgenda->setContentsPos(0,y); |
1573 | } | 1573 | } |
1574 | 1574 | ||
1575 | void KOAgendaView::clearSelection() | 1575 | void KOAgendaView::clearSelection() |
1576 | { | 1576 | { |
1577 | mAgenda->deselectItem(); | 1577 | mAgenda->deselectItem(); |
1578 | mAllDayAgenda->deselectItem(); | 1578 | mAllDayAgenda->deselectItem(); |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1581 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1582 | int gxEnd, int gyEnd) | 1582 | int gxEnd, int gyEnd) |
1583 | { | 1583 | { |
1584 | mTimeSpanInAllDay = true; | 1584 | mTimeSpanInAllDay = true; |
1585 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1585 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | 1588 | ||
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index ec1154a..057df0d 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -72,769 +72,769 @@ protected: | |||
72 | } | 72 | } |
73 | private: | 73 | private: |
74 | KODayMatrix * _view; | 74 | KODayMatrix * _view; |
75 | }; | 75 | }; |
76 | 76 | ||
77 | void DynamicTip::maybeTip( const QPoint &pos ) | 77 | void DynamicTip::maybeTip( const QPoint &pos ) |
78 | { | 78 | { |
79 | //calculate which cell of the matrix the mouse is in | 79 | //calculate which cell of the matrix the mouse is in |
80 | QRect sz = matrix->frameRect(); | 80 | QRect sz = matrix->frameRect(); |
81 | int dheight = sz.height()*7 / 42; | 81 | int dheight = sz.height()*7 / 42; |
82 | int dwidth = sz.width() / 7; | 82 | int dwidth = sz.width() / 7; |
83 | int row = pos.y()/dheight; | 83 | int row = pos.y()/dheight; |
84 | int col = pos.x()/dwidth; | 84 | int col = pos.x()/dwidth; |
85 | 85 | ||
86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 86 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
87 | 87 | ||
88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 88 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
89 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 89 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
90 | 90 | ||
91 | //show holiday names only | 91 | //show holiday names only |
92 | QString str = matrix->getHolidayLabel(col+row*7); | 92 | QString str = matrix->getHolidayLabel(col+row*7); |
93 | if (str.isEmpty()) return; | 93 | if (str.isEmpty()) return; |
94 | tip(rct, str); | 94 | tip(rct, str); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | // ============================================================================ | 98 | // ============================================================================ |
99 | // K O D A Y M A T R I X | 99 | // K O D A Y M A T R I X |
100 | // ============================================================================ | 100 | // ============================================================================ |
101 | 101 | ||
102 | const int KODayMatrix::NOSELECTION = -1000; | 102 | const int KODayMatrix::NOSELECTION = -1000; |
103 | const int KODayMatrix::NUMDAYS = 42; | 103 | const int KODayMatrix::NUMDAYS = 42; |
104 | 104 | ||
105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 105 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) | 106 | : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) |
107 | 107 | ||
108 | 108 | ||
109 | { | 109 | { |
110 | mLastView = -1; | 110 | mLastView = -1; |
111 | oldW = 0; | 111 | oldW = 0; |
112 | oldH = 0; | 112 | oldH = 0; |
113 | myPix.resize( 150, 120 ); | 113 | myPix.resize( 150, 120 ); |
114 | mRedrawNeeded = true; | 114 | mRedrawNeeded = true; |
115 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); | 115 | mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); |
116 | mPendingUpdateBeforeRepaint = false; | 116 | mPendingUpdateBeforeRepaint = false; |
117 | mouseDown = false; | 117 | mouseDown = false; |
118 | // initialize dynamic arrays | 118 | // initialize dynamic arrays |
119 | bDays.resize ( NUMDAYS ); | 119 | bDays.resize ( NUMDAYS ); |
120 | pDays.resize ( NUMDAYS ); | 120 | pDays.resize ( NUMDAYS ); |
121 | hDays.resize ( NUMDAYS ); | 121 | hDays.resize ( NUMDAYS ); |
122 | eDays.resize ( NUMDAYS ); | 122 | eDays.resize ( NUMDAYS ); |
123 | days = new QDate[NUMDAYS]; | 123 | days = new QDate[NUMDAYS]; |
124 | daylbls = new QString[NUMDAYS]; | 124 | daylbls = new QString[NUMDAYS]; |
125 | //events = new int[NUMDAYS]; | 125 | //events = new int[NUMDAYS]; |
126 | mToolTip = new DynamicTip(this); | 126 | mToolTip = new DynamicTip(this); |
127 | 127 | ||
128 | // set default values used for drawing the matrix | 128 | // set default values used for drawing the matrix |
129 | mDefaultBackColor = palette().active().base(); | 129 | mDefaultBackColor = palette().active().base(); |
130 | mDefaultTextColor = palette().active().foreground(); | 130 | mDefaultTextColor = palette().active().foreground(); |
131 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 131 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
132 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 132 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
133 | mSelectedDaysColor = QColor("white"); | 133 | mSelectedDaysColor = QColor("white"); |
134 | mTodayMarginWidth = 2; | 134 | mTodayMarginWidth = 2; |
135 | mSelEnd = mSelStart = NOSELECTION; | 135 | mSelEnd = mSelStart = NOSELECTION; |
136 | 136 | ||
137 | setAcceptDrops(true); | 137 | setAcceptDrops(true); |
138 | //setFont( QFont("Arial", 10) ); | 138 | //setFont( QFont("Arial", 10) ); |
139 | 139 | ||
140 | mUpdateTimer = new QTimer( this ); | 140 | mUpdateTimer = new QTimer( this ); |
141 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 141 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
142 | mRepaintTimer = new QTimer( this ); | 142 | mRepaintTimer = new QTimer( this ); |
143 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 143 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
144 | mDayChanged = false; | 144 | mDayChanged = false; |
145 | updateView(); | 145 | updateView(); |
146 | } | 146 | } |
147 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 147 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
148 | { | 148 | { |
149 | 149 | ||
150 | int tmp = getDayIndexFrom(p.x(), p.y()); | 150 | int tmp = getDayIndexFrom(p.x(), p.y()); |
151 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 151 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
152 | return QString(); | 152 | return QString(); |
153 | QDate mDate = days[tmp]; | 153 | QDate mDate = days[tmp]; |
154 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 154 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
155 | Event *event; | 155 | Event *event; |
156 | QStringList mToolTip; | 156 | QStringList mToolTip; |
157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 157 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
158 | QString mToolTipText; | 158 | QString mToolTipText; |
159 | QString text; | 159 | QString text; |
160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 160 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
161 | if (event->isMultiDay()) { | 161 | if (event->isMultiDay()) { |
162 | QString prefix = "<->";multiday = 2; | 162 | QString prefix = "<->";multiday = 2; |
163 | QString time; | 163 | QString time; |
164 | if ( event->doesRecur() ) { | 164 | if ( event->doesRecur() ) { |
165 | if ( event->recursOn( mDate) ) { | 165 | if ( event->recursOn( mDate) ) { |
166 | prefix ="->" ;multiday = 1; | 166 | prefix ="->" ;multiday = 1; |
167 | } | 167 | } |
168 | else { | 168 | else { |
169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 169 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
170 | if ( event->recursOn( mDate.addDays( -days)) ) { | 170 | if ( event->recursOn( mDate.addDays( -days)) ) { |
171 | prefix ="<-" ;multiday = 3; | 171 | prefix ="<-" ;multiday = 3; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | } else { | 174 | } else { |
175 | if (mDate == event->dtStart().date()) { | 175 | if (mDate == event->dtStart().date()) { |
176 | prefix ="->" ;multiday = 1; | 176 | prefix ="->" ;multiday = 1; |
177 | } else if (mDate == event->dtEnd().date()) { | 177 | } else if (mDate == event->dtEnd().date()) { |
178 | prefix ="<-" ;multiday = 3; | 178 | prefix ="<-" ;multiday = 3; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | if ( !event->doesFloat() ) { | 181 | if ( !event->doesFloat() ) { |
182 | if ( mDate == event->dtStart().date () ) | 182 | if ( mDate == event->dtStart().date () ) |
183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 183 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
184 | else if ( mDate == event->dtEnd().date () ) | 184 | else if ( mDate == event->dtEnd().date () ) |
185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 185 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
186 | 186 | ||
187 | } | 187 | } |
188 | text = time + event->summary(); | 188 | text = time + event->summary(); |
189 | mToolTipText += prefix + text; | 189 | mToolTipText += prefix + text; |
190 | } else { | 190 | } else { |
191 | if (event->doesFloat()) { | 191 | if (event->doesFloat()) { |
192 | text = event->summary(); | 192 | text = event->summary(); |
193 | mToolTipText += text; | 193 | mToolTipText += text; |
194 | } | 194 | } |
195 | else { | 195 | else { |
196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 196 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
197 | text += " " + event->summary(); | 197 | text += " " + event->summary(); |
198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 198 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | if ( !event->location().isEmpty() ) | 201 | if ( !event->location().isEmpty() ) |
202 | mToolTipText += " (" + event->location() + ")"; | 202 | mToolTipText += " (" + event->location() + ")"; |
203 | //qDebug("TTT: %s ", mToolTipText.latin1()); | 203 | //qDebug("TTT: %s ", mToolTipText.latin1()); |
204 | mToolTip.append( deTag( mToolTipText ) ); | 204 | mToolTip.append( deTag( mToolTipText ) ); |
205 | } | 205 | } |
206 | mToolTip.sort(); | 206 | mToolTip.sort(); |
207 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 207 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
208 | QPtrList<Todo> todolist = mCalendar->todos(mDate); | 208 | QPtrList<Todo> todolist = mCalendar->todos(mDate); |
209 | Todo *todo; | 209 | Todo *todo; |
210 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { | 210 | for(todo=todolist.first();todo != 0;todo=todolist.next()) { |
211 | QString mToolTipText; | 211 | QString mToolTipText; |
212 | if ( !todo->doesFloat() ) | 212 | if ( !todo->doesFloat() ) |
213 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; | 213 | mToolTipText += KGlobal::locale()->formatTime(todo->dtDue().time())+" "; |
214 | mToolTipText += todo->summary(); | 214 | mToolTipText += todo->summary(); |
215 | if ( !todo->location().isEmpty() ) | 215 | if ( !todo->location().isEmpty() ) |
216 | mToolTipText += " (" + todo->location() + ")"; | 216 | mToolTipText += " (" + todo->location() + ")"; |
217 | mToolTipText = deTag( mToolTipText); | 217 | mToolTipText = deTag( mToolTipText); |
218 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; | 218 | mToolTipText = "<b>" + i18n("Todo: ") + "</b>"+ mToolTipText; |
219 | mToolTip.append( mToolTipText ); | 219 | mToolTip.append( mToolTipText ); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 222 | if (KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
223 | QPtrList<Journal> j_list = mCalendar->journals4Date( mDate ); | 223 | QPtrList<Journal> j_list = mCalendar->journals4Date( mDate ); |
224 | Journal *j = j_list.first(); | 224 | Journal *j = j_list.first(); |
225 | while ( j ) { | 225 | while ( j ) { |
226 | QString mToolTipText; | 226 | QString mToolTipText; |
227 | if ( !j->summary().isEmpty() ) { | 227 | if ( !j->summary().isEmpty() ) { |
228 | mToolTipText = j->summary().left(30); | 228 | mToolTipText = j->summary().left(30); |
229 | if ( j->summary().length() > 30 ) | 229 | if ( j->summary().length() > 30 ) |
230 | mToolTipText += " ..."; | 230 | mToolTipText += " ..."; |
231 | } else { | 231 | } else { |
232 | mToolTipText = j->description().left(25); | 232 | mToolTipText = j->description().left(25); |
233 | if ( j->description().length() > 25 ) | 233 | if ( j->description().length() > 25 ) |
234 | mToolTipText += " ..."; | 234 | mToolTipText += " ..."; |
235 | mToolTipText = deTag( mToolTipText); | 235 | mToolTipText = deTag( mToolTipText); |
236 | } | 236 | } |
237 | mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; | 237 | mToolTipText = "<b>" + i18n("Journal: ") + "</b>"+ mToolTipText; |
238 | mToolTip.append( mToolTipText ); | 238 | mToolTip.append( mToolTipText ); |
239 | j = j_list.next(); | 239 | j = j_list.next(); |
240 | } | 240 | } |
241 | } | 241 | } |
242 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 242 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
243 | } | 243 | } |
244 | 244 | ||
245 | 245 | ||
246 | QString KODayMatrix::deTag( QString mToolTipText ) | 246 | QString KODayMatrix::deTag( QString mToolTipText ) |
247 | { | 247 | { |
248 | 248 | ||
249 | #if QT_VERSION >= 0x030000 | 249 | #if QT_VERSION >= 0x030000 |
250 | mToolTipText.replace( '<' , "<" ); | 250 | mToolTipText.replace( '<' , "<" ); |
251 | mToolTipText.replace( '>' , ">" ); | 251 | mToolTipText.replace( '>' , ">" ); |
252 | #else | 252 | #else |
253 | if ( mToolTipText.find ('<') >= 0 ) { | 253 | if ( mToolTipText.find ('<') >= 0 ) { |
254 | mToolTipText.replace( QRegExp("<") , "<" ); | 254 | mToolTipText.replace( QRegExp("<") , "<" ); |
255 | } | 255 | } |
256 | if ( mToolTipText.find ('>') >= 0 ) { | 256 | if ( mToolTipText.find ('>') >= 0 ) { |
257 | mToolTipText.replace( QRegExp(">") , ">" ); | 257 | mToolTipText.replace( QRegExp(">") , ">" ); |
258 | } | 258 | } |
259 | #endif | 259 | #endif |
260 | return mToolTipText; | 260 | return mToolTipText; |
261 | } | 261 | } |
262 | void KODayMatrix::setCalendar( Calendar *cal ) | 262 | void KODayMatrix::setCalendar( Calendar *cal ) |
263 | { | 263 | { |
264 | mCalendar = cal; | 264 | mCalendar = cal; |
265 | 265 | ||
266 | setAcceptDrops( mCalendar ); | 266 | setAcceptDrops( mCalendar ); |
267 | 267 | ||
268 | updateEvents(); | 268 | updateEvents(); |
269 | } | 269 | } |
270 | 270 | ||
271 | QColor KODayMatrix::getShadedColor(QColor color) | 271 | QColor KODayMatrix::getShadedColor(QColor color) |
272 | { | 272 | { |
273 | QColor shaded; | 273 | QColor shaded; |
274 | int h=0; | 274 | int h=0; |
275 | int s=0; | 275 | int s=0; |
276 | int v=0; | 276 | int v=0; |
277 | color.hsv(&h,&s,&v); | 277 | color.hsv(&h,&s,&v); |
278 | s = s/4; | 278 | s = s/4; |
279 | v = 192+v/4; | 279 | v = 192+v/4; |
280 | shaded.setHsv(h,s,v); | 280 | shaded.setHsv(h,s,v); |
281 | 281 | ||
282 | return shaded; | 282 | return shaded; |
283 | } | 283 | } |
284 | 284 | ||
285 | KODayMatrix::~KODayMatrix() | 285 | KODayMatrix::~KODayMatrix() |
286 | { | 286 | { |
287 | #if QT_VERSION >= 0x030000 | 287 | #if QT_VERSION >= 0x030000 |
288 | 288 | ||
289 | #else | 289 | #else |
290 | delete mKODaymatrixWhatsThis; | 290 | delete mKODaymatrixWhatsThis; |
291 | #endif | 291 | #endif |
292 | 292 | ||
293 | // delete mKODaymatrixWhatsThis; | 293 | // delete mKODaymatrixWhatsThis; |
294 | delete [] days; | 294 | delete [] days; |
295 | delete [] daylbls; | 295 | delete [] daylbls; |
296 | //delete [] events; | 296 | //delete [] events; |
297 | delete mToolTip; | 297 | delete mToolTip; |
298 | } | 298 | } |
299 | 299 | ||
300 | /* | 300 | /* |
301 | void KODayMatrix::setStartDate(QDate start) | 301 | void KODayMatrix::setStartDate(QDate start) |
302 | { | 302 | { |
303 | updateView(start); | 303 | updateView(start); |
304 | } | 304 | } |
305 | */ | 305 | */ |
306 | 306 | ||
307 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 307 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
308 | { | 308 | { |
309 | 309 | ||
310 | if (mSelStart == NOSELECTION) { | 310 | if (mSelStart == NOSELECTION) { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | 313 | ||
314 | //cope with selection being out of matrix limits at top (< 0) | 314 | //cope with selection being out of matrix limits at top (< 0) |
315 | int i0 = mSelStart; | 315 | int i0 = mSelStart; |
316 | if (i0 < 0) { | 316 | if (i0 < 0) { |
317 | for (int i = i0; i < 0; i++) { | 317 | for (int i = i0; i < 0; i++) { |
318 | selDays.append(days[0].addDays(i)); | 318 | selDays.append(days[0].addDays(i)); |
319 | } | 319 | } |
320 | i0 = 0; | 320 | i0 = 0; |
321 | } | 321 | } |
322 | 322 | ||
323 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 323 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
324 | if (mSelEnd > NUMDAYS-1) { | 324 | if (mSelEnd > NUMDAYS-1) { |
325 | for (int i = i0; i <= NUMDAYS-1; i++) { | 325 | for (int i = i0; i <= NUMDAYS-1; i++) { |
326 | selDays.append(days[i]); | 326 | selDays.append(days[i]); |
327 | } | 327 | } |
328 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 328 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
329 | selDays.append(days[0].addDays(i)); | 329 | selDays.append(days[0].addDays(i)); |
330 | } | 330 | } |
331 | 331 | ||
332 | // apply normal routine to selection being entirely within matrix limits | 332 | // apply normal routine to selection being entirely within matrix limits |
333 | } else { | 333 | } else { |
334 | for (int i = i0; i <= mSelEnd; i++) { | 334 | for (int i = i0; i <= mSelEnd; i++) { |
335 | selDays.append(days[i]); | 335 | selDays.append(days[i]); |
336 | } | 336 | } |
337 | } | 337 | } |
338 | } | 338 | } |
339 | 339 | ||
340 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 340 | bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
341 | { | 341 | { |
342 | mRedrawNeeded = true; | 342 | mRedrawNeeded = true; |
343 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); | 343 | bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); |
344 | mSelStart = startdate.daysTo(start); | 344 | mSelStart = startdate.daysTo(start); |
345 | if ( mSelStart < 0 ) | 345 | if ( mSelStart < 0 ) |
346 | mSelStart = 0; | 346 | mSelStart = 0; |
347 | mSelEnd = startdate.daysTo(end); | 347 | mSelEnd = startdate.daysTo(end); |
348 | if ( mSelEnd > NUMDAYS-1 ) | 348 | if ( mSelEnd > NUMDAYS-1 ) |
349 | mSelEnd = NUMDAYS-1; | 349 | mSelEnd = NUMDAYS-1; |
350 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { | 350 | if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { |
351 | clearSelection(); | 351 | clearSelection(); |
352 | if ( noSel ) | 352 | if ( noSel ) |
353 | return false; | 353 | return false; |
354 | } | 354 | } |
355 | 355 | ||
356 | return true; | 356 | return true; |
357 | } | 357 | } |
358 | void KODayMatrix::clearSelection() | 358 | void KODayMatrix::clearSelection() |
359 | { | 359 | { |
360 | mSelEnd = mSelStart = NOSELECTION; | 360 | mSelEnd = mSelStart = NOSELECTION; |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void KODayMatrix::recalculateToday() | 364 | void KODayMatrix::recalculateToday() |
365 | { | 365 | { |
366 | today = -1; | 366 | today = -1; |
367 | for (int i=0; i<NUMDAYS; i++) { | 367 | for (int i=0; i<NUMDAYS; i++) { |
368 | //events[i] = 0; | 368 | //events[i] = 0; |
369 | days[i] = startdate.addDays(i); | 369 | days[i] = startdate.addDays(i); |
370 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 370 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
371 | 371 | ||
372 | // if today is in the currently displayed month, hilight today | 372 | // if today is in the currently displayed month, hilight today |
373 | if (days[i].year() == QDate::currentDate().year() && | 373 | if (days[i].year() == QDate::currentDate().year() && |
374 | days[i].month() == QDate::currentDate().month() && | 374 | days[i].month() == QDate::currentDate().month() && |
375 | days[i].day() == QDate::currentDate().day()) { | 375 | days[i].day() == QDate::currentDate().day()) { |
376 | today = i; | 376 | today = i; |
377 | } | 377 | } |
378 | } | 378 | } |
379 | // qDebug(QString("Today is visible at %1.").arg(today)); | 379 | // qDebug(QString("Today is visible at %1.").arg(today)); |
380 | } | 380 | } |
381 | 381 | ||
382 | void KODayMatrix::updateView() | 382 | void KODayMatrix::updateView() |
383 | { | 383 | { |
384 | updateView(startdate); | 384 | updateView(startdate); |
385 | } | 385 | } |
386 | void KODayMatrix::repaintViewTimed() | 386 | void KODayMatrix::repaintViewTimed() |
387 | { | 387 | { |
388 | mRedrawNeeded = true; | 388 | mRedrawNeeded = true; |
389 | // bDays.fill( false); | 389 | // bDays.fill( false); |
390 | //pDays.fill( false); | 390 | //pDays.fill( false); |
391 | //hDays.fill( false); | 391 | //hDays.fill( false); |
392 | //eDays.fill( false); | 392 | //eDays.fill( false); |
393 | mRepaintTimer->stop(); | 393 | mRepaintTimer->stop(); |
394 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 394 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
395 | int i; | 395 | int i; |
396 | for(i = 0; i < NUMDAYS; i++) { | 396 | for(i = 0; i < NUMDAYS; i++) { |
397 | if ( ( (i+startDay) % 7 == 0 ) ) { | 397 | if ( ( (i+startDay) % 7 == 0 ) ) { |
398 | pDays.setBit(i); | 398 | pDays.setBit(i); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | repaint(false); | 401 | repaint(false); |
402 | } | 402 | } |
403 | void KODayMatrix::computeEvent(Event *event, int i ) | 403 | void KODayMatrix::computeEvent(Event *event, int i ) |
404 | { | 404 | { |
405 | QString holiStr = mHolidays[i]; | 405 | QString holiStr = mHolidays[i]; |
406 | if ( event->isHoliday()) { | 406 | if ( event->isHoliday()) { |
407 | pDays.setBit(i); | 407 | pDays.setBit(i); |
408 | hDays.setBit(i); | 408 | hDays.setBit(i); |
409 | if ( !holiStr.isEmpty() ) | 409 | if ( !holiStr.isEmpty() ) |
410 | holiStr += "\n"; | 410 | holiStr += "\n"; |
411 | holiStr += event->summary(); | 411 | holiStr += event->summary(); |
412 | if ( !event->location().isEmpty() ) | 412 | if ( !event->location().isEmpty() ) |
413 | holiStr += " (" + event->location() + ")"; | 413 | holiStr += " (" + event->location() + ")"; |
414 | mHolidays[i] =holiStr ; | 414 | mHolidays[i] =holiStr ; |
415 | eDays.setBit(i); | 415 | eDays.setBit(i); |
416 | } | 416 | } |
417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { | 417 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { |
418 | if ( event->isBirthday()) { | 418 | if ( event->isBirthday()) { |
419 | pDays.setBit(i); | 419 | pDays.setBit(i); |
420 | if ( !holiStr.isEmpty() ) | 420 | if ( !holiStr.isEmpty() ) |
421 | holiStr += "\n"; | 421 | holiStr += "\n"; |
422 | holiStr += i18n("Birthday") + ": "+event->summary(); | 422 | holiStr += i18n("Birthday") + ": "+event->summary(); |
423 | if ( !event->location().isEmpty() ) | 423 | if ( !event->location().isEmpty() ) |
424 | holiStr += " (" + event->location() + ")"; | 424 | holiStr += " (" + event->location() + ")"; |
425 | bDays.setBit(i); | 425 | bDays.setBit(i); |
426 | mHolidays[i] =holiStr ; | 426 | mHolidays[i] =holiStr ; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) | 429 | if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) |
430 | eDays.setBit(i); | 430 | eDays.setBit(i); |
431 | } | 431 | } |
432 | void KODayMatrix::updateViewTimed() | 432 | void KODayMatrix::updateViewTimed() |
433 | { | 433 | { |
434 | mUpdateTimer->stop(); | 434 | mUpdateTimer->stop(); |
435 | if ( !mCalendar ) { | 435 | if ( !mCalendar ) { |
436 | qDebug("NOT CAL "); | 436 | qDebug("NOT CAL "); |
437 | return; | 437 | return; |
438 | } | 438 | } |
439 | #if 1 | 439 | #if 1 |
440 | 440 | ||
441 | 441 | ||
442 | int i; | 442 | int i; |
443 | int timeSpan = NUMDAYS-1; | 443 | int timeSpan = NUMDAYS-1; |
444 | QPtrList<Event> events = mCalendar->events(); | 444 | QPtrList<Event> events = mCalendar->events(); |
445 | Event *event; | 445 | Event *event; |
446 | QDateTime dt; | 446 | QDateTime dt; |
447 | bool ok; | 447 | bool ok; |
448 | bDays.fill( false); | 448 | bDays.fill( false); |
449 | pDays.fill( false); | 449 | pDays.fill( false); |
450 | hDays.fill( false); | 450 | hDays.fill( false); |
451 | eDays.fill( false); | 451 | eDays.fill( false); |
452 | mHolidays.clear(); | 452 | mHolidays.clear(); |
453 | QDate mStartDate = days[0]; | 453 | QDate mStartDate = days[0]; |
454 | QDate endDate = mStartDate.addDays( timeSpan ); | 454 | QDate endDate = mStartDate.addDays( timeSpan ); |
455 | for( event = events.first(); event; event = events.next() ) { // for event | 455 | for( event = events.first(); event; event = events.next() ) { // for event |
456 | ushort recurType = event->recurrence()->doesRecur(); | 456 | ushort recurType = event->doesRecur(); |
457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 457 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 458 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
459 | continue; | 459 | continue; |
460 | } | 460 | } |
461 | if ( event->doesRecur() ) { | 461 | if ( event->doesRecur() ) { |
462 | bool last; | 462 | bool last; |
463 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 463 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
464 | QDateTime incidenceEnd; | 464 | QDateTime incidenceEnd; |
465 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 465 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
466 | bool invalid = false; | 466 | bool invalid = false; |
467 | while( true ) { | 467 | while( true ) { |
468 | if ( incidenceStart.isValid() ) { | 468 | if ( incidenceStart.isValid() ) { |
469 | incidenceEnd = incidenceStart.addDays( eventlen ); | 469 | incidenceEnd = incidenceStart.addDays( eventlen ); |
470 | int st = incidenceStart.date().daysTo( endDate ); | 470 | int st = incidenceStart.date().daysTo( endDate ); |
471 | if ( st >= 0 ) { // start before timeend | 471 | if ( st >= 0 ) { // start before timeend |
472 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 472 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
473 | if ( end >= 0 ) { // end after timestart --- got one! | 473 | if ( end >= 0 ) { // end after timestart --- got one! |
474 | //normalize | 474 | //normalize |
475 | st = timeSpan - st; | 475 | st = timeSpan - st; |
476 | if ( st < 0 ) st = 0; | 476 | if ( st < 0 ) st = 0; |
477 | if ( end > timeSpan ) end = timeSpan; | 477 | if ( end > timeSpan ) end = timeSpan; |
478 | int iii; | 478 | int iii; |
479 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 479 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
480 | for ( iii = st;iii<= end;++iii) { | 480 | for ( iii = st;iii<= end;++iii) { |
481 | computeEvent( event, iii ); | 481 | computeEvent( event, iii ); |
482 | } | 482 | } |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } else { | 485 | } else { |
486 | if ( invalid ) | 486 | if ( invalid ) |
487 | break; | 487 | break; |
488 | invalid = true; | 488 | invalid = true; |
489 | //qDebug("invalid %s", event->summary().latin1()); | 489 | //qDebug("invalid %s", event->summary().latin1()); |
490 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 490 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
491 | } | 491 | } |
492 | if ( last ) | 492 | if ( last ) |
493 | break; | 493 | break; |
494 | bool ok; | 494 | bool ok; |
495 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 495 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
496 | if ( ! ok ) | 496 | if ( ! ok ) |
497 | break; | 497 | break; |
498 | if ( incidenceStart.date() > endDate ) | 498 | if ( incidenceStart.date() > endDate ) |
499 | break; | 499 | break; |
500 | } | 500 | } |
501 | } else { // no recur | 501 | } else { // no recur |
502 | int st = event->dtStart().date().daysTo( endDate ); | 502 | int st = event->dtStart().date().daysTo( endDate ); |
503 | if ( st >= 0 ) { // start before timeend | 503 | if ( st >= 0 ) { // start before timeend |
504 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 504 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
505 | if ( end >= 0 ) { // end after timestart --- got one! | 505 | if ( end >= 0 ) { // end after timestart --- got one! |
506 | //normalize | 506 | //normalize |
507 | st = timeSpan - st; | 507 | st = timeSpan - st; |
508 | if ( st < 0 ) st = 0; | 508 | if ( st < 0 ) st = 0; |
509 | if ( end > timeSpan ) end = timeSpan; | 509 | if ( end > timeSpan ) end = timeSpan; |
510 | int iii; | 510 | int iii; |
511 | for ( iii = st;iii<= end;++iii) | 511 | for ( iii = st;iii<= end;++iii) |
512 | computeEvent( event, iii ); | 512 | computeEvent( event, iii ); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | } | 515 | } |
516 | } | 516 | } |
517 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday | 517 | int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday |
518 | for(i = 0; i < NUMDAYS; i++) { | 518 | for(i = 0; i < NUMDAYS; i++) { |
519 | if ( ( (i+startDay) % 7 == 0 ) ) { | 519 | if ( ( (i+startDay) % 7 == 0 ) ) { |
520 | pDays.setBit(i); | 520 | pDays.setBit(i); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { | 523 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { |
524 | bDays.fill( false); | 524 | bDays.fill( false); |
525 | // insert due todos | 525 | // insert due todos |
526 | QPtrList<Todo> todos = mCalendar->todos( ); | 526 | QPtrList<Todo> todos = mCalendar->todos( ); |
527 | Todo *todo; | 527 | Todo *todo; |
528 | for(todo = todos.first(); todo; todo = todos.next()) { | 528 | for(todo = todos.first(); todo; todo = todos.next()) { |
529 | //insertTodo( todo ); | 529 | //insertTodo( todo ); |
530 | if ( todo->hasDueDate() ) { | 530 | if ( todo->hasDueDate() ) { |
531 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 531 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
532 | if ( day >= 0 && day < timeSpan + 1) { | 532 | if ( day >= 0 && day < timeSpan + 1) { |
533 | int i = day; | 533 | int i = day; |
534 | QString holiStr = mHolidays[i]; | 534 | QString holiStr = mHolidays[i]; |
535 | pDays.setBit(i); | 535 | pDays.setBit(i); |
536 | if ( !holiStr.isEmpty() ) | 536 | if ( !holiStr.isEmpty() ) |
537 | holiStr += "\n"; | 537 | holiStr += "\n"; |
538 | holiStr += i18n("Todo") + ": "+todo->summary(); | 538 | holiStr += i18n("Todo") + ": "+todo->summary(); |
539 | if ( !todo->location().isEmpty() ) | 539 | if ( !todo->location().isEmpty() ) |
540 | holiStr += " (" + todo->location() + ")"; | 540 | holiStr += " (" + todo->location() + ")"; |
541 | bDays.setBit(i); | 541 | bDays.setBit(i); |
542 | mHolidays[i] =holiStr ; | 542 | mHolidays[i] =holiStr ; |
543 | eDays.setBit(i); | 543 | eDays.setBit(i); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | } | 546 | } |
547 | } | 547 | } |
548 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { | 548 | if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { |
549 | bDays.fill( false); | 549 | bDays.fill( false); |
550 | // insert due todos | 550 | // insert due todos |
551 | QPtrList<Journal> todos = mCalendar->journals( ); | 551 | QPtrList<Journal> todos = mCalendar->journals( ); |
552 | Journal *todo; | 552 | Journal *todo; |
553 | for(todo = todos.first(); todo; todo = todos.next()) { | 553 | for(todo = todos.first(); todo; todo = todos.next()) { |
554 | int day = mStartDate.daysTo( todo->dtStart().date() ); | 554 | int day = mStartDate.daysTo( todo->dtStart().date() ); |
555 | if ( day >= 0 && day < timeSpan + 1) { | 555 | if ( day >= 0 && day < timeSpan + 1) { |
556 | int i = day; | 556 | int i = day; |
557 | QString holiStr = mHolidays[i]; | 557 | QString holiStr = mHolidays[i]; |
558 | pDays.setBit(i); | 558 | pDays.setBit(i); |
559 | if ( !holiStr.isEmpty() ) | 559 | if ( !holiStr.isEmpty() ) |
560 | holiStr += "\n"; | 560 | holiStr += "\n"; |
561 | holiStr += i18n("Journal: ")+todo->summary().left(25); | 561 | holiStr += i18n("Journal: ")+todo->summary().left(25); |
562 | if ( todo->summary().length() > 25 ) | 562 | if ( todo->summary().length() > 25 ) |
563 | holiStr +="..."; | 563 | holiStr +="..."; |
564 | bDays.setBit(i); | 564 | bDays.setBit(i); |
565 | mHolidays[i] =holiStr ; | 565 | mHolidays[i] =holiStr ; |
566 | eDays.setBit(i); | 566 | eDays.setBit(i); |
567 | 567 | ||
568 | } | 568 | } |
569 | } | 569 | } |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | //qDebug("KODayMatrix::updateViewTimed "); | 572 | //qDebug("KODayMatrix::updateViewTimed "); |
573 | for(int i = 0; i < NUMDAYS; i++) { | 573 | for(int i = 0; i < NUMDAYS; i++) { |
574 | // if events are set for the day then remember to draw it bold | 574 | // if events are set for the day then remember to draw it bold |
575 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 575 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
576 | Event *event; | 576 | Event *event; |
577 | int numEvents = eventlist.count(); | 577 | int numEvents = eventlist.count(); |
578 | QString holiStr = ""; | 578 | QString holiStr = ""; |
579 | bDays.clearBit(i); | 579 | bDays.clearBit(i); |
580 | hDays.clearBit(i); | 580 | hDays.clearBit(i); |
581 | eDays.clearBit(i); | 581 | eDays.clearBit(i); |
582 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 582 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
583 | ushort recurType = event->recurrence()->doesRecur(); | 583 | ushort recurType = event->recurrence()->doesRecur(); |
584 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 584 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
585 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 585 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
586 | numEvents--; | 586 | numEvents--; |
587 | } | 587 | } |
588 | if ( event->isHoliday()) { | 588 | if ( event->isHoliday()) { |
589 | hDays.setBit(i); | 589 | hDays.setBit(i); |
590 | if ( !holiStr.isEmpty() ) | 590 | if ( !holiStr.isEmpty() ) |
591 | holiStr += "\n"; | 591 | holiStr += "\n"; |
592 | holiStr += event->summary(); | 592 | holiStr += event->summary(); |
593 | if ( !event->location().isEmpty() ) | 593 | if ( !event->location().isEmpty() ) |
594 | holiStr += " (" + event->location() + ")"; | 594 | holiStr += " (" + event->location() + ")"; |
595 | } | 595 | } |
596 | if ( event->isBirthday()) { | 596 | if ( event->isBirthday()) { |
597 | if ( !holiStr.isEmpty() ) | 597 | if ( !holiStr.isEmpty() ) |
598 | holiStr += "\n"; | 598 | holiStr += "\n"; |
599 | holiStr += i18n("Birthday") + ": "+event->summary(); | 599 | holiStr += i18n("Birthday") + ": "+event->summary(); |
600 | if ( !event->location().isEmpty() ) | 600 | if ( !event->location().isEmpty() ) |
601 | holiStr += " (" + event->location() + ")"; | 601 | holiStr += " (" + event->location() + ")"; |
602 | bDays.setBit(i); | 602 | bDays.setBit(i); |
603 | } | 603 | } |
604 | } | 604 | } |
605 | if ( numEvents ) | 605 | if ( numEvents ) |
606 | eDays.setBit(i); | 606 | eDays.setBit(i); |
607 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 607 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
608 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 608 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
609 | !holiStr.isEmpty()) { | 609 | !holiStr.isEmpty()) { |
610 | mHolidays[i] = holiStr; | 610 | mHolidays[i] = holiStr; |
611 | } else { | 611 | } else { |
612 | mHolidays[i] = QString::null; | 612 | mHolidays[i] = QString::null; |
613 | } | 613 | } |
614 | } | 614 | } |
615 | #endif | 615 | #endif |
616 | mRedrawNeeded = true; | 616 | mRedrawNeeded = true; |
617 | if ( ! mPendingUpdateBeforeRepaint ) | 617 | if ( ! mPendingUpdateBeforeRepaint ) |
618 | repaint(false); | 618 | repaint(false); |
619 | } | 619 | } |
620 | void KODayMatrix::updateView(QDate actdate) | 620 | void KODayMatrix::updateView(QDate actdate) |
621 | { | 621 | { |
622 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) | 622 | if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) |
623 | mRedrawNeeded = true; | 623 | mRedrawNeeded = true; |
624 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; | 624 | mLastView = KOPrefs::instance()->mCurrentDisplayedView; |
625 | if ( ! actdate.isValid() ) { | 625 | if ( ! actdate.isValid() ) { |
626 | //qDebug("date not valid "); | 626 | //qDebug("date not valid "); |
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | mDayChanged = false; | 629 | mDayChanged = false; |
630 | //flag to indicate if the starting day of the matrix has changed by this call | 630 | //flag to indicate if the starting day of the matrix has changed by this call |
631 | //mDayChanged = false; | 631 | //mDayChanged = false; |
632 | // if a new startdate is to be set then apply Cornelius's calculation | 632 | // if a new startdate is to be set then apply Cornelius's calculation |
633 | // of the first day to be shown | 633 | // of the first day to be shown |
634 | if (actdate != startdate) { | 634 | if (actdate != startdate) { |
635 | // reset index of selection according to shift of starting date from startdate to actdate | 635 | // reset index of selection according to shift of starting date from startdate to actdate |
636 | if (mSelStart != NOSELECTION) { | 636 | if (mSelStart != NOSELECTION) { |
637 | int tmp = actdate.daysTo(startdate); | 637 | int tmp = actdate.daysTo(startdate); |
638 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 638 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
639 | // shift selection if new one would be visible at least partly ! | 639 | // shift selection if new one would be visible at least partly ! |
640 | 640 | ||
641 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 641 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
642 | // nested if is required for next X display pushed from a different month - correction required | 642 | // nested if is required for next X display pushed from a different month - correction required |
643 | // otherwise, for month forward and backward, it must be avoided | 643 | // otherwise, for month forward and backward, it must be avoided |
644 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 644 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
645 | mSelStart = mSelStart + tmp; | 645 | mSelStart = mSelStart + tmp; |
646 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 646 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
647 | mSelEnd = mSelEnd + tmp; | 647 | mSelEnd = mSelEnd + tmp; |
648 | } | 648 | } |
649 | } | 649 | } |
650 | startdate = actdate; | 650 | startdate = actdate; |
651 | mDayChanged = true; | 651 | mDayChanged = true; |
652 | recalculateToday(); | 652 | recalculateToday(); |
653 | mRedrawNeeded = true; | 653 | mRedrawNeeded = true; |
654 | } | 654 | } |
655 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 655 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
656 | if ( !isVisible() ) { | 656 | if ( !isVisible() ) { |
657 | mPendingUpdateBeforeRepaint = true; | 657 | mPendingUpdateBeforeRepaint = true; |
658 | } else { | 658 | } else { |
659 | #ifdef DESKTOP_VERSION | 659 | #ifdef DESKTOP_VERSION |
660 | //mRepaintTimer->start( 100 ); | 660 | //mRepaintTimer->start( 100 ); |
661 | //updateViewTimed(); | 661 | //updateViewTimed(); |
662 | mUpdateTimer->start( 50 ); | 662 | mUpdateTimer->start( 50 ); |
663 | #else | 663 | #else |
664 | mRepaintTimer->start( 350 ); | 664 | mRepaintTimer->start( 350 ); |
665 | mUpdateTimer->start( 800 ); | 665 | mUpdateTimer->start( 800 ); |
666 | #endif | 666 | #endif |
667 | } | 667 | } |
668 | } | 668 | } |
669 | void KODayMatrix::updateEvents() | 669 | void KODayMatrix::updateEvents() |
670 | { | 670 | { |
671 | if ( !mCalendar ) return; | 671 | if ( !mCalendar ) return; |
672 | 672 | ||
673 | for( int i = 0; i < NUMDAYS; i++ ) { | 673 | for( int i = 0; i < NUMDAYS; i++ ) { |
674 | // if events are set for the day then remember to draw it bold | 674 | // if events are set for the day then remember to draw it bold |
675 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 675 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
676 | int numEvents = eventlist.count(); | 676 | int numEvents = eventlist.count(); |
677 | Event *event; | 677 | Event *event; |
678 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 678 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
679 | ushort recurType = event->doesRecur(); | 679 | ushort recurType = event->doesRecur(); |
680 | 680 | ||
681 | if ( ( recurType == Recurrence::rDaily && | 681 | if ( ( recurType == Recurrence::rDaily && |
682 | !KOPrefs::instance()->mDailyRecur ) || | 682 | !KOPrefs::instance()->mDailyRecur ) || |
683 | ( recurType == Recurrence::rWeekly && | 683 | ( recurType == Recurrence::rWeekly && |
684 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 684 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
685 | numEvents--; | 685 | numEvents--; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | if ( numEvents ) | 688 | if ( numEvents ) |
689 | eDays.setBit(i); | 689 | eDays.setBit(i); |
690 | else | 690 | else |
691 | eDays.clearBit(i); | 691 | eDays.clearBit(i); |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | ||
695 | const QDate& KODayMatrix::getDate(int offset) | 695 | const QDate& KODayMatrix::getDate(int offset) |
696 | { | 696 | { |
697 | if (offset < 0 || offset > NUMDAYS-1) { | 697 | if (offset < 0 || offset > NUMDAYS-1) { |
698 | qDebug("Wrong offset2 %d", offset); | 698 | qDebug("Wrong offset2 %d", offset); |
699 | return days[0]; | 699 | return days[0]; |
700 | } | 700 | } |
701 | return days[offset]; | 701 | return days[offset]; |
702 | } | 702 | } |
703 | 703 | ||
704 | QString KODayMatrix::getHolidayLabel(int offset) | 704 | QString KODayMatrix::getHolidayLabel(int offset) |
705 | { | 705 | { |
706 | if (offset < 0 || offset > NUMDAYS-1) { | 706 | if (offset < 0 || offset > NUMDAYS-1) { |
707 | qDebug("Wrong offset1 %d", offset); | 707 | qDebug("Wrong offset1 %d", offset); |
708 | return QString(); | 708 | return QString(); |
709 | } | 709 | } |
710 | return mHolidays[offset]; | 710 | return mHolidays[offset]; |
711 | } | 711 | } |
712 | 712 | ||
713 | int KODayMatrix::getDayIndexFrom(int x, int y) | 713 | int KODayMatrix::getDayIndexFrom(int x, int y) |
714 | { | 714 | { |
715 | int colModulo = (width()-2) % 7; | 715 | int colModulo = (width()-2) % 7; |
716 | int rowModulo = (height()-2) % 6; | 716 | int rowModulo = (height()-2) % 6; |
717 | #if 0 | 717 | #if 0 |
718 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 718 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
719 | 6 - x/daysize.width() : x/daysize.width()); | 719 | 6 - x/daysize.width() : x/daysize.width()); |
720 | #endif | 720 | #endif |
721 | int xVal = (x-colModulo/2-2)/daysize.width(); | 721 | int xVal = (x-colModulo/2-2)/daysize.width(); |
722 | int yVal = (y-rowModulo/2-2)/daysize.height(); | 722 | int yVal = (y-rowModulo/2-2)/daysize.height(); |
723 | 723 | ||
724 | 724 | ||
725 | return 7*(yVal) + xVal; | 725 | return 7*(yVal) + xVal; |
726 | 726 | ||
727 | } | 727 | } |
728 | 728 | ||
729 | // ---------------------------------------------------------------------------- | 729 | // ---------------------------------------------------------------------------- |
730 | // M O U S E E V E N T H A N D L I N G | 730 | // M O U S E E V E N T H A N D L I N G |
731 | // ---------------------------------------------------------------------------- | 731 | // ---------------------------------------------------------------------------- |
732 | 732 | ||
733 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 733 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
734 | { | 734 | { |
735 | 735 | ||
736 | if ( e->button() == LeftButton ) | 736 | if ( e->button() == LeftButton ) |
737 | mouseDown = true; | 737 | mouseDown = true; |
738 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 738 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
739 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 739 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
740 | mSelInit = mSelStart; | 740 | mSelInit = mSelStart; |
741 | mSelEnd = mSelStart; | 741 | mSelEnd = mSelStart; |
742 | mRedrawNeeded = true; | 742 | mRedrawNeeded = true; |
743 | repaint(false); | 743 | repaint(false); |
744 | } | 744 | } |
745 | 745 | ||
746 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 746 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
747 | { | 747 | { |
748 | mRedrawNeeded = true; | 748 | mRedrawNeeded = true; |
749 | if ( e->button() == LeftButton ) | 749 | if ( e->button() == LeftButton ) |
750 | if ( ! mouseDown ) { | 750 | if ( ! mouseDown ) { |
751 | return; | 751 | return; |
752 | } | 752 | } |
753 | else | 753 | else |
754 | mouseDown = false; | 754 | mouseDown = false; |
755 | int tmp = getDayIndexFrom(e->x(), e->y()); | 755 | int tmp = getDayIndexFrom(e->x(), e->y()); |
756 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 756 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
757 | 757 | ||
758 | if (mSelInit > tmp) { | 758 | if (mSelInit > tmp) { |
759 | mSelEnd = mSelInit; | 759 | mSelEnd = mSelInit; |
760 | if (tmp != mSelStart) { | 760 | if (tmp != mSelStart) { |
761 | mSelStart = tmp; | 761 | mSelStart = tmp; |
762 | repaint(false); | 762 | repaint(false); |
763 | } | 763 | } |
764 | } else { | 764 | } else { |
765 | mSelStart = mSelInit; | 765 | mSelStart = mSelInit; |
766 | 766 | ||
767 | //repaint only if selection has changed | 767 | //repaint only if selection has changed |
768 | if (tmp != mSelEnd) { | 768 | if (tmp != mSelEnd) { |
769 | mSelEnd = tmp; | 769 | mSelEnd = tmp; |
770 | repaint(false); | 770 | repaint(false); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | 773 | ||
774 | DateList daylist; | 774 | DateList daylist; |
775 | if ( mSelStart < 0 ) | 775 | if ( mSelStart < 0 ) |
776 | mSelStart = 0; | 776 | mSelStart = 0; |
777 | for (int i = mSelStart; i <= mSelEnd; i++) { | 777 | for (int i = mSelStart; i <= mSelEnd; i++) { |
778 | daylist.append(days[i]); | 778 | daylist.append(days[i]); |
779 | } | 779 | } |
780 | emit selected((const DateList)daylist); | 780 | emit selected((const DateList)daylist); |
781 | 781 | ||
782 | } | 782 | } |
783 | 783 | ||
784 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 784 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
785 | { | 785 | { |
786 | if ( ! mouseDown ) { | 786 | if ( ! mouseDown ) { |
787 | return; | 787 | return; |
788 | } | 788 | } |
789 | mRedrawNeeded = true; | 789 | mRedrawNeeded = true; |
790 | int tmp = getDayIndexFrom(e->x(), e->y()); | 790 | int tmp = getDayIndexFrom(e->x(), e->y()); |
791 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 791 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
792 | 792 | ||
793 | if (mSelInit > tmp) { | 793 | if (mSelInit > tmp) { |
794 | mSelEnd = mSelInit; | 794 | mSelEnd = mSelInit; |
795 | if (tmp != mSelStart) { | 795 | if (tmp != mSelStart) { |
796 | mSelStart = tmp; | 796 | mSelStart = tmp; |
797 | repaint(false); | 797 | repaint(false); |
798 | } | 798 | } |
799 | } else { | 799 | } else { |
800 | mSelStart = mSelInit; | 800 | mSelStart = mSelInit; |
801 | 801 | ||
802 | //repaint only if selection has changed | 802 | //repaint only if selection has changed |
803 | if (tmp != mSelEnd) { | 803 | if (tmp != mSelEnd) { |
804 | mSelEnd = tmp; | 804 | mSelEnd = tmp; |
805 | repaint(false); | 805 | repaint(false); |
806 | } | 806 | } |
807 | } | 807 | } |
808 | } | 808 | } |
809 | 809 | ||
810 | // ---------------------------------------------------------------------------- | 810 | // ---------------------------------------------------------------------------- |
811 | // D R A G ' N D R O P H A N D L I N G | 811 | // D R A G ' N D R O P H A N D L I N G |
812 | // ---------------------------------------------------------------------------- | 812 | // ---------------------------------------------------------------------------- |
813 | 813 | ||
814 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 814 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
815 | { | 815 | { |
816 | #ifndef KORG_NODND | 816 | #ifndef KORG_NODND |
817 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 817 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
818 | e->ignore(); | 818 | e->ignore(); |
819 | return; | 819 | return; |
820 | } | 820 | } |
821 | 821 | ||
822 | // some visual feedback | 822 | // some visual feedback |
823 | // oldPalette = palette(); | 823 | // oldPalette = palette(); |
824 | // setPalette(my_HilitePalette); | 824 | // setPalette(my_HilitePalette); |
825 | // update(); | 825 | // update(); |
826 | #endif | 826 | #endif |
827 | } | 827 | } |
828 | 828 | ||
829 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 829 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
830 | { | 830 | { |
831 | #ifndef KORG_NODND | 831 | #ifndef KORG_NODND |
832 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 832 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
833 | e->ignore(); | 833 | e->ignore(); |
834 | return; | 834 | return; |
835 | } | 835 | } |
836 | 836 | ||
837 | e->accept(); | 837 | e->accept(); |
838 | #endif | 838 | #endif |
839 | } | 839 | } |
840 | 840 | ||
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index de4e4f7..89504db 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -516,605 +516,611 @@ RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | |||
516 | rangeLayout->setMargin( KDialog::marginHintSmall() ); | 516 | rangeLayout->setMargin( KDialog::marginHintSmall() ); |
517 | 517 | ||
518 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); | 518 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); |
519 | rangeLayout->addWidget( mStartDateLabel ); | 519 | rangeLayout->addWidget( mStartDateLabel ); |
520 | 520 | ||
521 | QButtonGroup *rangeButtonGroup = new QButtonGroup; | 521 | QButtonGroup *rangeButtonGroup = new QButtonGroup; |
522 | 522 | ||
523 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); | 523 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); |
524 | rangeButtonGroup->insert( mNoEndDateButton ); | 524 | rangeButtonGroup->insert( mNoEndDateButton ); |
525 | rangeLayout->addWidget( mNoEndDateButton ); | 525 | rangeLayout->addWidget( mNoEndDateButton ); |
526 | 526 | ||
527 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); | 527 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); |
528 | durationLayout->setSpacing( KDialog::spacingHint() ); | 528 | durationLayout->setSpacing( KDialog::spacingHint() ); |
529 | 529 | ||
530 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); | 530 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); |
531 | rangeButtonGroup->insert( mEndDurationButton ); | 531 | rangeButtonGroup->insert( mEndDurationButton ); |
532 | durationLayout->addWidget( mEndDurationButton ); | 532 | durationLayout->addWidget( mEndDurationButton ); |
533 | 533 | ||
534 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); | 534 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); |
535 | durationLayout->addWidget( mEndDurationEdit ); | 535 | durationLayout->addWidget( mEndDurationEdit ); |
536 | 536 | ||
537 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); | 537 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); |
538 | durationLayout ->addWidget( endDurationLabel ); | 538 | durationLayout ->addWidget( endDurationLabel ); |
539 | 539 | ||
540 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); | 540 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); |
541 | endDateLayout->setSpacing( KDialog::spacingHint() ); | 541 | endDateLayout->setSpacing( KDialog::spacingHint() ); |
542 | 542 | ||
543 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); | 543 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); |
544 | rangeButtonGroup->insert( mEndDateButton ); | 544 | rangeButtonGroup->insert( mEndDateButton ); |
545 | endDateLayout->addWidget( mEndDateButton ); | 545 | endDateLayout->addWidget( mEndDateButton ); |
546 | 546 | ||
547 | mEndDateEdit = new KDateEdit( rangeBox ); | 547 | mEndDateEdit = new KDateEdit( rangeBox ); |
548 | endDateLayout->addWidget( mEndDateEdit ); | 548 | endDateLayout->addWidget( mEndDateEdit ); |
549 | 549 | ||
550 | //endDateLayout->addStretch( 1 ); | 550 | //endDateLayout->addStretch( 1 ); |
551 | 551 | ||
552 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), | 552 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), |
553 | SLOT( showCurrentRange() ) ); | 553 | SLOT( showCurrentRange() ) ); |
554 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 554 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
555 | SLOT( showCurrentRange() ) ); | 555 | SLOT( showCurrentRange() ) ); |
556 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 556 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
557 | SLOT( showCurrentRange() ) ); | 557 | SLOT( showCurrentRange() ) ); |
558 | } | 558 | } |
559 | 559 | ||
560 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 560 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
561 | { | 561 | { |
562 | mNoEndDateButton->setChecked( true ); | 562 | mNoEndDateButton->setChecked( true ); |
563 | 563 | ||
564 | setDateTimes( from ); | 564 | setDateTimes( from ); |
565 | mEndDateEdit->setDate( from.date() ); | 565 | mEndDateEdit->setDate( from.date() ); |
566 | } | 566 | } |
567 | 567 | ||
568 | void RecurrenceRangeWidget::setDuration( int duration ) | 568 | void RecurrenceRangeWidget::setDuration( int duration ) |
569 | { | 569 | { |
570 | if ( duration == -1 ) { | 570 | if ( duration == -1 ) { |
571 | mNoEndDateButton->setChecked( true ); | 571 | mNoEndDateButton->setChecked( true ); |
572 | } else if ( duration == 0 ) { | 572 | } else if ( duration == 0 ) { |
573 | mEndDateButton->setChecked( true ); | 573 | mEndDateButton->setChecked( true ); |
574 | } else { | 574 | } else { |
575 | mEndDurationButton->setChecked( true ); | 575 | mEndDurationButton->setChecked( true ); |
576 | mEndDurationEdit->setValue( duration ); | 576 | mEndDurationEdit->setValue( duration ); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | int RecurrenceRangeWidget::duration() | 580 | int RecurrenceRangeWidget::duration() |
581 | { | 581 | { |
582 | if ( mNoEndDateButton->isChecked() ) { | 582 | if ( mNoEndDateButton->isChecked() ) { |
583 | return -1; | 583 | return -1; |
584 | } else if ( mEndDurationButton->isChecked() ) { | 584 | } else if ( mEndDurationButton->isChecked() ) { |
585 | return mEndDurationEdit->value(); | 585 | return mEndDurationEdit->value(); |
586 | } else { | 586 | } else { |
587 | return 0; | 587 | return 0; |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) | 591 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) |
592 | { | 592 | { |
593 | mEndDateEdit->setDate( date ); | 593 | mEndDateEdit->setDate( date ); |
594 | } | 594 | } |
595 | 595 | ||
596 | QDate RecurrenceRangeWidget::endDate() | 596 | QDate RecurrenceRangeWidget::endDate() |
597 | { | 597 | { |
598 | return mEndDateEdit->date(); | 598 | return mEndDateEdit->date(); |
599 | } | 599 | } |
600 | 600 | ||
601 | void RecurrenceRangeWidget::showCurrentRange() | 601 | void RecurrenceRangeWidget::showCurrentRange() |
602 | { | 602 | { |
603 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); | 603 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); |
604 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); | 604 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); |
605 | } | 605 | } |
606 | 606 | ||
607 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, | 607 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, |
608 | const QDateTime & ) | 608 | const QDateTime & ) |
609 | { | 609 | { |
610 | mStartDateLabel->setText( i18n("Start date: %1") | 610 | mStartDateLabel->setText( i18n("Start date: %1") |
611 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); | 611 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); |
612 | 612 | ||
613 | if(!mEndDateButton->isChecked()) | 613 | if(!mEndDateButton->isChecked()) |
614 | mEndDateEdit->setDate( start.date() ); | 614 | mEndDateEdit->setDate( start.date() ); |
615 | } | 615 | } |
616 | 616 | ||
617 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// | 617 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// |
618 | 618 | ||
619 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, | 619 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, |
620 | const char *name ) : | 620 | const char *name ) : |
621 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) | 621 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) |
622 | { | 622 | { |
623 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 623 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
624 | setMainWidget( mRecurrenceRangeWidget ); | 624 | setMainWidget( mRecurrenceRangeWidget ); |
625 | } | 625 | } |
626 | 626 | ||
627 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) | 627 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) |
628 | { | 628 | { |
629 | mRecurrenceRangeWidget->setDefaults( from ); | 629 | mRecurrenceRangeWidget->setDefaults( from ); |
630 | } | 630 | } |
631 | 631 | ||
632 | void RecurrenceRangeDialog::setDuration( int duration ) | 632 | void RecurrenceRangeDialog::setDuration( int duration ) |
633 | { | 633 | { |
634 | mRecurrenceRangeWidget->setDuration( duration ); | 634 | mRecurrenceRangeWidget->setDuration( duration ); |
635 | } | 635 | } |
636 | 636 | ||
637 | int RecurrenceRangeDialog::duration() | 637 | int RecurrenceRangeDialog::duration() |
638 | { | 638 | { |
639 | return mRecurrenceRangeWidget->duration(); | 639 | return mRecurrenceRangeWidget->duration(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) | 642 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) |
643 | { | 643 | { |
644 | mRecurrenceRangeWidget->setEndDate( date ); | 644 | mRecurrenceRangeWidget->setEndDate( date ); |
645 | } | 645 | } |
646 | 646 | ||
647 | QDate RecurrenceRangeDialog::endDate() | 647 | QDate RecurrenceRangeDialog::endDate() |
648 | { | 648 | { |
649 | return mRecurrenceRangeWidget->endDate(); | 649 | return mRecurrenceRangeWidget->endDate(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
653 | const QDateTime &end ) | 653 | const QDateTime &end ) |
654 | { | 654 | { |
655 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 655 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
656 | } | 656 | } |
657 | 657 | ||
658 | //////////////////////////// RecurrenceChooser //////////////////////// | 658 | //////////////////////////// RecurrenceChooser //////////////////////// |
659 | 659 | ||
660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
661 | QWidget( parent, name ) | 661 | QWidget( parent, name ) |
662 | { | 662 | { |
663 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 663 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
664 | 664 | ||
665 | mTypeCombo = new QComboBox( this ); | 665 | mTypeCombo = new QComboBox( this ); |
666 | mTypeCombo->insertItem( i18n("Daily") ); | 666 | mTypeCombo->insertItem( i18n("Daily") ); |
667 | mTypeCombo->insertItem( i18n("Weekly") ); | 667 | mTypeCombo->insertItem( i18n("Weekly") ); |
668 | mTypeCombo->insertItem( i18n("Monthly") ); | 668 | mTypeCombo->insertItem( i18n("Monthly") ); |
669 | mTypeCombo->insertItem( i18n("Yearly") ); | 669 | mTypeCombo->insertItem( i18n("Yearly") ); |
670 | 670 | ||
671 | topLayout->addWidget( mTypeCombo ); | 671 | topLayout->addWidget( mTypeCombo ); |
672 | 672 | ||
673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
674 | 674 | ||
675 | } | 675 | } |
676 | 676 | ||
677 | int RecurrenceChooser::type() | 677 | int RecurrenceChooser::type() |
678 | { | 678 | { |
679 | if ( mTypeCombo ) { | 679 | if ( mTypeCombo ) { |
680 | return mTypeCombo->currentItem(); | 680 | return mTypeCombo->currentItem(); |
681 | } else { | 681 | } else { |
682 | if ( mDailyButton->isChecked() ) return Daily; | 682 | if ( mDailyButton->isChecked() ) return Daily; |
683 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 683 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
684 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 684 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
685 | else return Yearly; | 685 | else return Yearly; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | void RecurrenceChooser::setType( int type ) | 689 | void RecurrenceChooser::setType( int type ) |
690 | { | 690 | { |
691 | if ( mTypeCombo ) { | 691 | if ( mTypeCombo ) { |
692 | mTypeCombo->setCurrentItem( type ); | 692 | mTypeCombo->setCurrentItem( type ); |
693 | } else { | 693 | } else { |
694 | switch ( type ) { | 694 | switch ( type ) { |
695 | case Daily: | 695 | case Daily: |
696 | mDailyButton->setChecked( true ); | 696 | mDailyButton->setChecked( true ); |
697 | break; | 697 | break; |
698 | case Weekly: | 698 | case Weekly: |
699 | mWeeklyButton->setChecked( true ); | 699 | mWeeklyButton->setChecked( true ); |
700 | break; | 700 | break; |
701 | case Monthly: | 701 | case Monthly: |
702 | mMonthlyButton->setChecked( true ); | 702 | mMonthlyButton->setChecked( true ); |
703 | break; | 703 | break; |
704 | case Yearly: | 704 | case Yearly: |
705 | default: | 705 | default: |
706 | mYearlyButton->setChecked( true ); | 706 | mYearlyButton->setChecked( true ); |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void RecurrenceChooser::emitChoice() | 712 | void RecurrenceChooser::emitChoice() |
713 | { | 713 | { |
714 | emit chosen ( type() ); | 714 | emit chosen ( type() ); |
715 | } | 715 | } |
716 | 716 | ||
717 | /////////////////////////////// Main Widget ///////////////////////////// | 717 | /////////////////////////////// Main Widget ///////////////////////////// |
718 | 718 | ||
719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
720 | QWidget( parent, name ) | 720 | QWidget( parent, name ) |
721 | { | 721 | { |
722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
723 | topLayout->setSpacing( KDialog::spacingHint() ); | 723 | topLayout->setSpacing( KDialog::spacingHint() ); |
724 | topLayout->setMargin( KDialog::marginHintSmall() ); | 724 | topLayout->setMargin( KDialog::marginHintSmall() ); |
725 | 725 | ||
726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
728 | SLOT( setEnabled( bool ) ) ); | 728 | SLOT( setEnabled( bool ) ) ); |
729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
730 | 730 | ||
731 | 731 | ||
732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), | 732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), |
733 | this ); | 733 | this ); |
734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
735 | 735 | ||
736 | if ( QApplication::desktop()->width() <= 640 ) { | 736 | if ( QApplication::desktop()->width() <= 640 ) { |
737 | mTimeGroupBox->hide(); | 737 | mTimeGroupBox->hide(); |
738 | } | 738 | } |
739 | 739 | ||
740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
743 | 743 | ||
744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
745 | // mDateTimeLabel = new QLabel( timeFrame ); | 745 | // mDateTimeLabel = new QLabel( timeFrame ); |
746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); | 748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); |
749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); | 749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); |
750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
753 | SLOT( showCurrentRule( int ) ) ); | 753 | SLOT( showCurrentRule( int ) ) ); |
754 | 754 | ||
755 | 755 | ||
756 | mRuleStack = new QWidgetStack( mRuleBox ); | 756 | mRuleStack = new QWidgetStack( mRuleBox ); |
757 | 757 | ||
758 | mDaily = new RecurDaily( mRuleStack ); | 758 | mDaily = new RecurDaily( mRuleStack ); |
759 | mRuleStack->addWidget( mDaily, 0 ); | 759 | mRuleStack->addWidget( mDaily, 0 ); |
760 | 760 | ||
761 | mWeekly = new RecurWeekly( mRuleStack ); | 761 | mWeekly = new RecurWeekly( mRuleStack ); |
762 | mRuleStack->addWidget( mWeekly, 0 ); | 762 | mRuleStack->addWidget( mWeekly, 0 ); |
763 | 763 | ||
764 | mMonthly = new RecurMonthly( mRuleStack ); | 764 | mMonthly = new RecurMonthly( mRuleStack ); |
765 | mRuleStack->addWidget( mMonthly, 0 ); | 765 | mRuleStack->addWidget( mMonthly, 0 ); |
766 | 766 | ||
767 | mYearly = new RecurYearly( mRuleStack ); | 767 | mYearly = new RecurYearly( mRuleStack ); |
768 | mRuleStack->addWidget( mYearly, 0 ); | 768 | mRuleStack->addWidget( mYearly, 0 ); |
769 | 769 | ||
770 | showCurrentRule( mRecurrenceChooser->type() ); | 770 | showCurrentRule( mRecurrenceChooser->type() ); |
771 | mRecurrenceRangeWidget = 0; | 771 | mRecurrenceRangeWidget = 0; |
772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
773 | mRecurrenceRange = mRecurrenceRangeDialog; | 773 | mRecurrenceRange = mRecurrenceRangeDialog; |
774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
775 | this ); | 775 | this ); |
776 | 776 | ||
777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
778 | SLOT( showRecurrenceRangeDialog() ) ); | 778 | SLOT( showRecurrenceRangeDialog() ) ); |
779 | 779 | ||
780 | mExceptionsWidget = 0; | 780 | mExceptionsWidget = 0; |
781 | mExceptionsDialog = new ExceptionsDialog( this ); | 781 | mExceptionsDialog = new ExceptionsDialog( this ); |
782 | mExceptions = mExceptionsDialog; | 782 | mExceptions = mExceptionsDialog; |
783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
784 | if ( QApplication::desktop()->width() < 320 ) { | 784 | if ( QApplication::desktop()->width() < 320 ) { |
785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
787 | } else { | 787 | } else { |
788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
790 | } | 790 | } |
791 | connect( mExceptionsButton, SIGNAL( clicked() ), | 791 | connect( mExceptionsButton, SIGNAL( clicked() ), |
792 | SLOT( showExceptionsDialog() ) ); | 792 | SLOT( showExceptionsDialog() ) ); |
793 | } | 793 | } |
794 | 794 | ||
795 | KOEditorRecurrence::~KOEditorRecurrence() | 795 | KOEditorRecurrence::~KOEditorRecurrence() |
796 | { | 796 | { |
797 | } | 797 | } |
798 | 798 | ||
799 | void KOEditorRecurrence::setEnabled( bool enabled ) | 799 | void KOEditorRecurrence::setEnabled( bool enabled ) |
800 | { | 800 | { |
801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
802 | 802 | ||
803 | mTimeGroupBox->setEnabled( enabled ); | 803 | mTimeGroupBox->setEnabled( enabled ); |
804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
808 | mRuleBox->setEnabled( enabled ); | 808 | mRuleBox->setEnabled( enabled ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KOEditorRecurrence::showCurrentRule( int current ) | 811 | void KOEditorRecurrence::showCurrentRule( int current ) |
812 | { | 812 | { |
813 | switch ( current ) { | 813 | switch ( current ) { |
814 | case Daily: | 814 | case Daily: |
815 | mRuleStack->raiseWidget( mDaily ); | 815 | mRuleStack->raiseWidget( mDaily ); |
816 | break; | 816 | break; |
817 | case Weekly: | 817 | case Weekly: |
818 | mRuleStack->raiseWidget( mWeekly ); | 818 | mRuleStack->raiseWidget( mWeekly ); |
819 | break; | 819 | break; |
820 | case Monthly: | 820 | case Monthly: |
821 | mRuleStack->raiseWidget( mMonthly ); | 821 | mRuleStack->raiseWidget( mMonthly ); |
822 | break; | 822 | break; |
823 | default: | 823 | default: |
824 | case Yearly: | 824 | case Yearly: |
825 | mRuleStack->raiseWidget( mYearly ); | 825 | mRuleStack->raiseWidget( mYearly ); |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) | 838 | void KOEditorRecurrence::setDefaultsDates( QDateTime from, QDateTime to ) |
839 | { | 839 | { |
840 | setDateTimes( from, to ); | 840 | setDateTimes( from, to ); |
841 | QBitArray days( 7 ); | 841 | QBitArray days( 7 ); |
842 | days.fill( 0 ); | 842 | days.fill( 0 ); |
843 | days.setBit( from.date().dayOfWeek()- 1); | 843 | days.setBit( from.date().dayOfWeek()- 1); |
844 | mWeekly->setDays( days ); | 844 | mWeekly->setDays( days ); |
845 | bool byPos = mMonthly->byPos(); | 845 | bool byPos = mMonthly->byPos(); |
846 | if ( byPos ) | 846 | if ( byPos ) |
847 | mMonthly->setByDay( from.date().day()-1 ); | 847 | mMonthly->setByDay( from.date().day()-1 ); |
848 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 848 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
849 | if ( ! byPos) | 849 | if ( ! byPos) |
850 | mMonthly->setByDay( from.date().day()-1 ); | 850 | mMonthly->setByDay( from.date().day()-1 ); |
851 | 851 | ||
852 | bool byDay = mYearly->byDay(); | 852 | bool byDay = mYearly->byDay(); |
853 | if ( ! byDay ) | 853 | if ( ! byDay ) |
854 | mYearly->setByDay( from.date().dayOfYear() ); | 854 | mYearly->setByDay( from.date().dayOfYear() ); |
855 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 855 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
856 | if ( byDay ) | 856 | if ( byDay ) |
857 | mYearly->setByDay( from.date().dayOfYear() ); | 857 | mYearly->setByDay( from.date().dayOfYear() ); |
858 | } | 858 | } |
859 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) | 859 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to ) |
860 | { | 860 | { |
861 | 861 | ||
862 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 862 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
863 | //setDateTimes( from, to ); | 863 | //setDateTimes( from, to ); |
864 | 864 | ||
865 | bool enabled = false; | 865 | bool enabled = false; |
866 | mEnabledCheck->setChecked( enabled ); | 866 | mEnabledCheck->setChecked( enabled ); |
867 | setEnabled( enabled ); | 867 | setEnabled( enabled ); |
868 | 868 | ||
869 | mExceptions->setDefaults( to ); | 869 | mExceptions->setDefaults( to ); |
870 | mRecurrenceRange->setDefaults( to ); | 870 | mRecurrenceRange->setDefaults( to ); |
871 | 871 | ||
872 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 872 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
873 | showCurrentRule( mRecurrenceChooser->type() ); | 873 | showCurrentRule( mRecurrenceChooser->type() ); |
874 | 874 | ||
875 | mDaily->setFrequency( 1 ); | 875 | mDaily->setFrequency( 1 ); |
876 | mWeekly->setFrequency( 1 ); | 876 | mWeekly->setFrequency( 1 ); |
877 | mMonthly->setFrequency( 1 ); | 877 | mMonthly->setFrequency( 1 ); |
878 | mYearly->setFrequency( 1 ); | 878 | mYearly->setFrequency( 1 ); |
879 | setDefaultsDates( from, to ); | 879 | setDefaultsDates( from, to ); |
880 | } | 880 | } |
881 | 881 | ||
882 | void KOEditorRecurrence::readEvent(Incidence *event) | 882 | void KOEditorRecurrence::readEvent(Incidence *event) |
883 | { | 883 | { |
884 | 884 | ||
885 | QDateTime dtEnd; | 885 | QDateTime dtEnd; |
886 | if ( event->typeID() == eventID ) | 886 | if ( event->typeID() == eventID ) |
887 | dtEnd = ((Event*)event)->dtEnd(); | 887 | dtEnd = ((Event*)event)->dtEnd(); |
888 | else | 888 | else |
889 | dtEnd = ((Todo*)event)->dtDue(); | 889 | dtEnd = ((Todo*)event)->dtDue(); |
890 | 890 | ||
891 | setDefaults( event->dtStart(), dtEnd ); | 891 | setDefaults( event->dtStart(), dtEnd ); |
892 | QBitArray rDays( 7 ); | 892 | QBitArray rDays( 7 ); |
893 | QPtrList<Recurrence::rMonthPos> rmp; | 893 | QPtrList<Recurrence::rMonthPos> rmp; |
894 | QPtrList<int> rmd; | 894 | QPtrList<int> rmd; |
895 | int day = 0; | 895 | int day = 0; |
896 | int count = 0; | 896 | int count = 0; |
897 | int month = 0; | 897 | int month = 0; |
898 | setDateTimes( event->dtStart(), dtEnd ); | 898 | setDateTimes( event->dtStart(), dtEnd ); |
899 | 899 | ||
900 | Recurrence *r = event->recurrence(); | 900 | |
901 | int f = r->frequency(); | ||
902 | 901 | ||
903 | int recurs = r->doesRecur(); | 902 | int recurs = event->doesRecur(); |
904 | 903 | ||
905 | mEnabledCheck->setChecked( recurs ); | 904 | mEnabledCheck->setChecked( recurs ); |
906 | setEnabled( recurs ); | 905 | setEnabled( recurs ); |
907 | 906 | ||
908 | int recurrenceType = RecurrenceChooser::Weekly; | 907 | int recurrenceType = RecurrenceChooser::Weekly; |
909 | 908 | if ( recurs ) { | |
910 | switch ( recurs ) { | 909 | Recurrence *r = event->recurrence(); |
911 | case Recurrence::rNone: | 910 | int f = r->frequency(); |
912 | setDefaults( event->dtStart(), dtEnd ); | 911 | switch ( recurs ) { |
913 | break; | 912 | case Recurrence::rNone: |
914 | case Recurrence::rDaily: | 913 | setDefaults( event->dtStart(), dtEnd ); |
915 | recurrenceType = RecurrenceChooser::Daily; | 914 | break; |
916 | mDaily->setFrequency( f ); | 915 | case Recurrence::rDaily: |
917 | break; | 916 | recurrenceType = RecurrenceChooser::Daily; |
918 | case Recurrence::rWeekly: | 917 | mDaily->setFrequency( f ); |
919 | recurrenceType = RecurrenceChooser::Weekly; | 918 | break; |
920 | mWeekly->setFrequency( f ); | 919 | case Recurrence::rWeekly: |
921 | mWeekly->setDays( r->days() ); | 920 | recurrenceType = RecurrenceChooser::Weekly; |
922 | break; | 921 | mWeekly->setFrequency( f ); |
923 | case Recurrence::rMonthlyPos: | 922 | mWeekly->setDays( r->days() ); |
924 | // we only handle one possibility in the list right now, | 923 | break; |
925 | // so I have hardcoded calls with first(). If we make the GUI | 924 | case Recurrence::rMonthlyPos: |
926 | // more extended, this can be changed. | 925 | // we only handle one possibility in the list right now, |
927 | recurrenceType = RecurrenceChooser::Monthly; | 926 | // so I have hardcoded calls with first(). If we make the GUI |
928 | 927 | // more extended, this can be changed. | |
929 | rmp = r->monthPositions(); | 928 | recurrenceType = RecurrenceChooser::Monthly; |
930 | if ( rmp.first()->negative ) | 929 | |
931 | count = 5 - rmp.first()->rPos - 1; | 930 | rmp = r->monthPositions(); |
932 | else | 931 | if ( rmp.first()->negative ) |
933 | count = rmp.first()->rPos - 1; | 932 | count = 5 - rmp.first()->rPos - 1; |
934 | day = 0; | 933 | else |
935 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 934 | count = rmp.first()->rPos - 1; |
936 | mMonthly->setByPos( count, day ); | 935 | day = 0; |
937 | 936 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | |
938 | mMonthly->setFrequency( f ); | 937 | mMonthly->setByPos( count, day ); |
939 | 938 | ||
940 | break; | 939 | mMonthly->setFrequency( f ); |
941 | case Recurrence::rMonthlyDay: | 940 | |
942 | recurrenceType = RecurrenceChooser::Monthly; | 941 | break; |
943 | 942 | case Recurrence::rMonthlyDay: | |
944 | rmd = r->monthDays(); | 943 | recurrenceType = RecurrenceChooser::Monthly; |
945 | day = *rmd.first() - 1; | 944 | |
946 | mMonthly->setByDay( day ); | 945 | rmd = r->monthDays(); |
947 | 946 | day = *rmd.first() - 1; | |
948 | mMonthly->setFrequency( f ); | 947 | mMonthly->setByDay( day ); |
949 | 948 | ||
950 | break; | 949 | mMonthly->setFrequency( f ); |
951 | case Recurrence::rYearlyMonth: | 950 | |
952 | { | 951 | break; |
953 | recurrenceType = RecurrenceChooser::Yearly; | 952 | case Recurrence::rYearlyMonth: |
954 | //qDebug("Recurrence::rYearlyMonth: "); | 953 | { |
955 | day = event->dtStart().date().day(); | 954 | recurrenceType = RecurrenceChooser::Yearly; |
956 | rmd = r->yearNums(); | 955 | //qDebug("Recurrence::rYearlyMonth: "); |
957 | if ( rmd.count() > 0 ) | 956 | day = event->dtStart().date().day(); |
958 | month = *rmd.first(); | 957 | rmd = r->yearNums(); |
959 | else | 958 | if ( rmd.count() > 0 ) |
960 | month = event->dtStart().date().month() ; | 959 | month = *rmd.first(); |
961 | mYearly->setByMonth( month, day ); | 960 | else |
961 | month = event->dtStart().date().month() ; | ||
962 | mYearly->setByMonth( month, day ); | ||
962 | #if 0 | 963 | #if 0 |
963 | //qDebug("2day = %d ",day ); | 964 | //qDebug("2day = %d ",day ); |
964 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 965 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
965 | int month; | 966 | int month; |
966 | if ( !monthlist.isEmpty() ) { | 967 | if ( !monthlist.isEmpty() ) { |
967 | month = monthlist.first()->rPos ; | 968 | month = monthlist.first()->rPos ; |
968 | } else { | 969 | } else { |
969 | month = event->dtStart().date().month() ; | 970 | month = event->dtStart().date().month() ; |
970 | } | 971 | } |
971 | mYearly->setByMonth( day, month ); | 972 | mYearly->setByMonth( day, month ); |
972 | #endif | 973 | #endif |
973 | mYearly->setFrequency( f ); | 974 | mYearly->setFrequency( f ); |
974 | } | 975 | } |
975 | 976 | ||
976 | break; | 977 | break; |
977 | case Recurrence::rYearlyDay: | 978 | case Recurrence::rYearlyDay: |
978 | //qDebug("Recurrence::rYearlyDay: "); | 979 | //qDebug("Recurrence::rYearlyDay: "); |
979 | recurrenceType = RecurrenceChooser::Yearly; | 980 | recurrenceType = RecurrenceChooser::Yearly; |
980 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 981 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
981 | mYearly->setFrequency( f ); | 982 | mYearly->setFrequency( f ); |
982 | break; | 983 | break; |
983 | default: | 984 | default: |
984 | setDefaults( event->dtStart(), dtEnd ); | 985 | setDefaults( event->dtStart(), dtEnd ); |
985 | break; | 986 | break; |
987 | } | ||
986 | } | 988 | } |
987 | |||
988 | mRecurrenceChooser->setType( recurrenceType ); | 989 | mRecurrenceChooser->setType( recurrenceType ); |
989 | showCurrentRule( recurrenceType ); | 990 | showCurrentRule( recurrenceType ); |
990 | 991 | ||
991 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 992 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
992 | 993 | ||
993 | if ( r->doesRecur() ) { | 994 | if ( event->doesRecur() ) { |
995 | Recurrence *r = event->recurrence(); | ||
994 | mRecurrenceRange->setDuration( r->duration() ); | 996 | mRecurrenceRange->setDuration( r->duration() ); |
995 | if ( r->duration() == 0 ) | 997 | if ( r->duration() == 0 ) |
996 | { | 998 | { |
997 | if ( r->endDate() < event->dtStart().date() ) | 999 | if ( r->endDate() < event->dtStart().date() ) |
998 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1000 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
999 | else | 1001 | else |
1000 | mRecurrenceRange->setEndDate( r->endDate() ); | 1002 | mRecurrenceRange->setEndDate( r->endDate() ); |
1001 | } else | 1003 | } else |
1002 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 1004 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
1003 | } | 1005 | } |
1004 | 1006 | ||
1005 | mExceptions->setDates( event->exDates() ); | 1007 | mExceptions->setDates( event->exDates() ); |
1006 | } | 1008 | } |
1007 | 1009 | ||
1008 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 1010 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
1009 | { | 1011 | { |
1010 | Recurrence *r = event->recurrence(); | 1012 | |
1011 | 1013 | ||
1012 | // clear out any old settings; | 1014 | if ( !mEnabledCheck->isChecked() ) { |
1013 | r->unsetRecurs(); | 1015 | if ( event->doesRecur() ) |
1016 | event->recurrence()->unsetRecurs(); | ||
1017 | } else { | ||
1018 | Recurrence *r = event->recurrence(); | ||
1014 | 1019 | ||
1015 | if ( mEnabledCheck->isChecked() ) { | 1020 | // clear out any old settings; |
1021 | r->unsetRecurs(); | ||
1016 | int duration = mRecurrenceRange->duration(); | 1022 | int duration = mRecurrenceRange->duration(); |
1017 | QDate endDate; | 1023 | QDate endDate; |
1018 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1024 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1019 | 1025 | ||
1020 | int recurrenceType = mRecurrenceChooser->type(); | 1026 | int recurrenceType = mRecurrenceChooser->type(); |
1021 | 1027 | ||
1022 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1028 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1023 | int freq = mDaily->frequency(); | 1029 | int freq = mDaily->frequency(); |
1024 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1030 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1025 | else r->setDaily( freq, endDate ); | 1031 | else r->setDaily( freq, endDate ); |
1026 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1032 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1027 | int freq = mWeekly->frequency(); | 1033 | int freq = mWeekly->frequency(); |
1028 | QBitArray days = mWeekly->days(); | 1034 | QBitArray days = mWeekly->days(); |
1029 | int j; | 1035 | int j; |
1030 | bool found = false; | 1036 | bool found = false; |
1031 | for (j = 0; j < 7 ; ++j ) { | 1037 | for (j = 0; j < 7 ; ++j ) { |
1032 | found |=days.at(j); | 1038 | found |=days.at(j); |
1033 | } | 1039 | } |
1034 | if ( !found ) { | 1040 | if ( !found ) { |
1035 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1041 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1036 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1042 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1037 | } | 1043 | } |
1038 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1044 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1039 | else r->setWeekly( freq, days, endDate ); | 1045 | else r->setWeekly( freq, days, endDate ); |
1040 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1046 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1041 | int freq = mMonthly->frequency(); | 1047 | int freq = mMonthly->frequency(); |
1042 | if ( mMonthly->byPos() ) { | 1048 | if ( mMonthly->byPos() ) { |
1043 | int pos = mMonthly->count(); | 1049 | int pos = mMonthly->count(); |
1044 | 1050 | ||
1045 | QBitArray days( 7 ); | 1051 | QBitArray days( 7 ); |
1046 | days.fill( false ); | 1052 | days.fill( false ); |
1047 | 1053 | ||
1048 | days.setBit( mMonthly->weekday() ); | 1054 | days.setBit( mMonthly->weekday() ); |
1049 | if ( duration != 0 ) | 1055 | if ( duration != 0 ) |
1050 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1056 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1051 | else | 1057 | else |
1052 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1058 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1053 | r->addMonthlyPos( pos, days ); | 1059 | r->addMonthlyPos( pos, days ); |
1054 | } else { | 1060 | } else { |
1055 | // it's by day | 1061 | // it's by day |
1056 | int day = mMonthly->day(); | 1062 | int day = mMonthly->day(); |
1057 | 1063 | ||
1058 | if ( duration != 0 ) { | 1064 | if ( duration != 0 ) { |
1059 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1065 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1060 | } else { | 1066 | } else { |
1061 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1067 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1062 | } | 1068 | } |
1063 | r->addMonthlyDay( day ); | 1069 | r->addMonthlyDay( day ); |
1064 | } | 1070 | } |
1065 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1071 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1066 | //qDebug("RecurrenceChooser::Yearly "); | 1072 | //qDebug("RecurrenceChooser::Yearly "); |
1067 | int freq = mYearly->frequency(); | 1073 | int freq = mYearly->frequency(); |
1068 | if ( mYearly->byDay() ) { | 1074 | if ( mYearly->byDay() ) { |
1069 | if ( duration != 0 ) { | 1075 | if ( duration != 0 ) { |
1070 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1076 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1071 | } else { | 1077 | } else { |
1072 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1078 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1073 | } | 1079 | } |
1074 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1080 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1075 | } else { | 1081 | } else { |
1076 | if ( duration != 0 ) { | 1082 | if ( duration != 0 ) { |
1077 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1083 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1078 | } else { | 1084 | } else { |
1079 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1085 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1080 | } | 1086 | } |
1081 | r->addYearlyNum( mYearly->month() ); | 1087 | r->addYearlyNum( mYearly->month() ); |
1082 | } | 1088 | } |
1083 | 1089 | ||
1084 | } | 1090 | } |
1085 | 1091 | ||
1086 | event->setExDates( mExceptions->dates() ); | 1092 | event->setExDates( mExceptions->dates() ); |
1087 | } | 1093 | } |
1088 | } | 1094 | } |
1089 | 1095 | ||
1090 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1096 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1091 | { | 1097 | { |
1092 | mDateTimeLabel->setText( str ); | 1098 | mDateTimeLabel->setText( str ); |
1093 | } | 1099 | } |
1094 | 1100 | ||
1095 | bool KOEditorRecurrence::validateInput() | 1101 | bool KOEditorRecurrence::validateInput() |
1096 | { | 1102 | { |
1097 | // Check input here | 1103 | // Check input here |
1098 | 1104 | ||
1099 | return true; | 1105 | return true; |
1100 | } | 1106 | } |
1101 | 1107 | ||
1102 | void KOEditorRecurrence::showExceptionsDialog() | 1108 | void KOEditorRecurrence::showExceptionsDialog() |
1103 | { | 1109 | { |
1104 | DateList dates = mExceptions->dates(); | 1110 | DateList dates = mExceptions->dates(); |
1105 | int result = mExceptionsDialog->exec(); | 1111 | int result = mExceptionsDialog->exec(); |
1106 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1112 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1107 | } | 1113 | } |
1108 | 1114 | ||
1109 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1115 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1110 | { | 1116 | { |
1111 | int duration = mRecurrenceRange->duration(); | 1117 | int duration = mRecurrenceRange->duration(); |
1112 | QDate endDate = mRecurrenceRange->endDate(); | 1118 | QDate endDate = mRecurrenceRange->endDate(); |
1113 | 1119 | ||
1114 | int result = mRecurrenceRangeDialog->exec(); | 1120 | int result = mRecurrenceRangeDialog->exec(); |
1115 | if ( result == QDialog::Rejected ) { | 1121 | if ( result == QDialog::Rejected ) { |
1116 | mRecurrenceRange->setDuration( duration ); | 1122 | mRecurrenceRange->setDuration( duration ); |
1117 | mRecurrenceRange->setEndDate( endDate ); | 1123 | mRecurrenceRange->setEndDate( endDate ); |
1118 | } | 1124 | } |
1119 | 1125 | ||
1120 | } | 1126 | } |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index a690ab1..db695f5 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,831 +1,831 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program 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 | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #include <qprinter.h> | 56 | #include <qprinter.h> |
57 | #include <qpainter.h> | 57 | #include <qpainter.h> |
58 | #include <qpaintdevicemetrics.h> | 58 | #include <qpaintdevicemetrics.h> |
59 | #else //DESKTOP_VERSION | 59 | #else //DESKTOP_VERSION |
60 | #include <externalapphandler.h> | 60 | #include <externalapphandler.h> |
61 | #include <qtopia/qcopenvelope_qws.h> | 61 | #include <qtopia/qcopenvelope_qws.h> |
62 | #endif //DESKTOP_VERSION | 62 | #endif //DESKTOP_VERSION |
63 | 63 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
65 | : QTextBrowser(parent,name) | 65 | : QTextBrowser(parent,name) |
66 | { | 66 | { |
67 | mSyncMode = false; | 67 | mSyncMode = false; |
68 | mColorMode = 0; | 68 | mColorMode = 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KOEventViewer::printMe() | 75 | void KOEventViewer::printMe() |
76 | { | 76 | { |
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | 78 | ||
79 | KOPrintPrefs pp ( this ); | 79 | KOPrintPrefs pp ( this ); |
80 | if (!pp.exec() ) | 80 | if (!pp.exec() ) |
81 | return; | 81 | return; |
82 | int scaleval = pp.printMode() ; | 82 | int scaleval = pp.printMode() ; |
83 | 83 | ||
84 | QPrinter printer; | 84 | QPrinter printer; |
85 | if (!printer.setup() ) | 85 | if (!printer.setup() ) |
86 | return; | 86 | return; |
87 | QPainter p; | 87 | QPainter p; |
88 | p.begin ( &printer ); | 88 | p.begin ( &printer ); |
89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 89 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
90 | float dx, dy; | 90 | float dx, dy; |
91 | int wid = (m.width() * 9)/10; | 91 | int wid = (m.width() * 9)/10; |
92 | dx = (float) wid/(float)contentsWidth (); | 92 | dx = (float) wid/(float)contentsWidth (); |
93 | dy = (float)(m.height()) / (float)contentsHeight (); | 93 | dy = (float)(m.height()) / (float)contentsHeight (); |
94 | float scale; | 94 | float scale; |
95 | // scale to fit the width or height of the paper | 95 | // scale to fit the width or height of the paper |
96 | if ( dx < dy ) | 96 | if ( dx < dy ) |
97 | scale = dx; | 97 | scale = dx; |
98 | else | 98 | else |
99 | scale = dy; | 99 | scale = dy; |
100 | 100 | ||
101 | p.translate( m.width()/10,0 ); | 101 | p.translate( m.width()/10,0 ); |
102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { | 102 | if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { |
103 | p.scale( scale, scale ); | 103 | p.scale( scale, scale ); |
104 | } | 104 | } |
105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 105 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
106 | p.end(); | 106 | p.end(); |
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | } | 109 | } |
110 | void KOEventViewer::setSource(const QString& n) | 110 | void KOEventViewer::setSource(const QString& n) |
111 | { | 111 | { |
112 | 112 | ||
113 | if ( n.left(8) == "todo_uid" ) { | 113 | if ( n.left(8) == "todo_uid" ) { |
114 | int midstr = 9; | 114 | int midstr = 9; |
115 | #ifdef DESKTOP_VERSION | 115 | #ifdef DESKTOP_VERSION |
116 | midstr = 11; | 116 | midstr = 11; |
117 | #endif | 117 | #endif |
118 | //qDebug("-%s- ", n.mid(midstr).latin1()); | 118 | //qDebug("-%s- ", n.mid(midstr).latin1()); |
119 | emit showIncidence( n.mid(midstr) ); | 119 | emit showIncidence( n.mid(midstr) ); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | if ( n.left(3) == "uid" ) | 123 | if ( n.left(3) == "uid" ) |
124 | #ifdef DESKTOP_VERSION | 124 | #ifdef DESKTOP_VERSION |
125 | { | 125 | { |
126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
127 | KABC::AddressBook::Iterator it; | 127 | KABC::AddressBook::Iterator it; |
128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
129 | // LR I do not understand, why the uid string is different on zaurus and desktop | 129 | // LR I do not understand, why the uid string is different on zaurus and desktop |
130 | QString uid = "uid://"+(*it).uid(); | 130 | QString uid = "uid://"+(*it).uid(); |
131 | 131 | ||
132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
133 | if (n == uid ) { | 133 | if (n == uid ) { |
134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
135 | QDialog dia( this,"dia123", true ); | 135 | QDialog dia( this,"dia123", true ); |
136 | dia.setCaption( i18n("Details of attendee") ); | 136 | dia.setCaption( i18n("Details of attendee") ); |
137 | QVBoxLayout lay ( &dia ); | 137 | QVBoxLayout lay ( &dia ); |
138 | KABC::AddresseeView av ( &dia ); | 138 | KABC::AddresseeView av ( &dia ); |
139 | av.setAddressee( (*it) ); | 139 | av.setAddressee( (*it) ); |
140 | lay.addWidget( &av ); | 140 | lay.addWidget( &av ); |
141 | if ( QApplication::desktop()->width() < 480 ) | 141 | if ( QApplication::desktop()->width() < 480 ) |
142 | dia.resize( 220, 240); | 142 | dia.resize( 220, 240); |
143 | else { | 143 | else { |
144 | dia.resize( 400,400); | 144 | dia.resize( 400,400); |
145 | } | 145 | } |
146 | dia.exec(); | 146 | dia.exec(); |
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | #else | 152 | #else |
153 | { | 153 | { |
154 | if ( "uid:organizer" == n ) { | 154 | if ( "uid:organizer" == n ) { |
155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
159 | if (attendees.count()) { | 159 | if (attendees.count()) { |
160 | Attendee *a; | 160 | Attendee *a; |
161 | for(a=attendees.first();a;a=attendees.next()) { | 161 | for(a=attendees.first();a;a=attendees.next()) { |
162 | if ( "uid:"+a->uid() == n ) { | 162 | if ( "uid:"+a->uid() == n ) { |
163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
171 | // the result should now arrive through method insertAttendees | 171 | // the result should now arrive through method insertAttendees |
172 | //QString uid = "uid:"+(*it).uid(); | 172 | //QString uid = "uid:"+(*it).uid(); |
173 | #endif | 173 | #endif |
174 | if ( n.left(6) == "mailto" ) { | 174 | if ( n.left(6) == "mailto" ) { |
175 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 175 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
176 | #ifndef DESKTOP_VERSION | 176 | #ifndef DESKTOP_VERSION |
177 | if ( n.mid(7,3) == "ALL" ) { | 177 | if ( n.mid(7,3) == "ALL" ) { |
178 | mailToAttendees( true ); | 178 | mailToAttendees( true ); |
179 | } else if ( n.mid(7,4) == "RSVP" ) { | 179 | } else if ( n.mid(7,4) == "RSVP" ) { |
180 | mailToAttendees( false ); | 180 | mailToAttendees( false ); |
181 | } else { | 181 | } else { |
182 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 182 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
183 | e << n.mid(7); | 183 | e << n.mid(7); |
184 | } | 184 | } |
185 | #endif | 185 | #endif |
186 | 186 | ||
187 | } | 187 | } |
188 | 188 | ||
189 | 189 | ||
190 | #ifndef KORG_NODCOP | 190 | #ifndef KORG_NODCOP |
191 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 191 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
192 | QString tmpStr; | 192 | QString tmpStr; |
193 | if (n.startsWith("mailto:")) { | 193 | if (n.startsWith("mailto:")) { |
194 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 194 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
195 | //emit showIncidence(n); | 195 | //emit showIncidence(n); |
196 | return; | 196 | return; |
197 | } else if (n.startsWith("uid:")) { | 197 | } else if (n.startsWith("uid:")) { |
198 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 198 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
199 | const QByteArray noParamData; | 199 | const QByteArray noParamData; |
200 | const QByteArray paramData; | 200 | const QByteArray paramData; |
201 | QByteArray replyData; | 201 | QByteArray replyData; |
202 | QCString replyTypeStr; | 202 | QCString replyTypeStr; |
203 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 203 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
204 | bool foundAbbrowser = PING_ABBROWSER; | 204 | bool foundAbbrowser = PING_ABBROWSER; |
205 | 205 | ||
206 | if (foundAbbrowser) { | 206 | if (foundAbbrowser) { |
207 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 207 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
208 | //client->send("kaddressbook","KAddressBookIface", | 208 | //client->send("kaddressbook","KAddressBookIface", |
209 | QDataStream arg(paramData, IO_WriteOnly); | 209 | QDataStream arg(paramData, IO_WriteOnly); |
210 | arg << n.mid(6); | 210 | arg << n.mid(6); |
211 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 211 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
212 | return; | 212 | return; |
213 | } else { | 213 | } else { |
214 | /* | 214 | /* |
215 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 215 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
216 | We start it without its main interface | 216 | We start it without its main interface |
217 | */ | 217 | */ |
218 | KIconLoader* iconLoader = new KIconLoader(); | 218 | KIconLoader* iconLoader = new KIconLoader(); |
219 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 219 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
220 | ActionManager::setStartedKAddressBook(true); | 220 | ActionManager::setStartedKAddressBook(true); |
221 | tmpStr = "kaddressbook --editor-only --uid "; | 221 | tmpStr = "kaddressbook --editor-only --uid "; |
222 | tmpStr += KProcess::quote(n.mid(6)); | 222 | tmpStr += KProcess::quote(n.mid(6)); |
223 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 223 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
224 | return; | 224 | return; |
225 | } | 225 | } |
226 | } else { | 226 | } else { |
227 | //QTextBrowser::setSource(n); | 227 | //QTextBrowser::setSource(n); |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | } | 230 | } |
231 | void KOEventViewer::mailToAttendees( bool all ) | 231 | void KOEventViewer::mailToAttendees( bool all ) |
232 | { | 232 | { |
233 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 233 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
234 | if (attendees.count() == 0) return; | 234 | if (attendees.count() == 0) return; |
235 | QStringList nameList; | 235 | QStringList nameList; |
236 | QStringList emailList; | 236 | QStringList emailList; |
237 | QStringList uidList; | 237 | QStringList uidList; |
238 | Attendee* a; | 238 | Attendee* a; |
239 | for(a=attendees.first();a;a=attendees.next()) { | 239 | for(a=attendees.first();a;a=attendees.next()) { |
240 | if ( !all && !a->RSVP() ) continue; | 240 | if ( !all && !a->RSVP() ) continue; |
241 | if (!a->email().isEmpty()) { | 241 | if (!a->email().isEmpty()) { |
242 | nameList.append (a->name() ); | 242 | nameList.append (a->name() ); |
243 | emailList.append (a->email() ); | 243 | emailList.append (a->email() ); |
244 | uidList.append (a->uid() ); | 244 | uidList.append (a->uid() ); |
245 | } | 245 | } |
246 | } | 246 | } |
247 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 247 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
248 | #ifndef DESKTOP_VERSION | 248 | #ifndef DESKTOP_VERSION |
249 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 249 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
250 | #endif | 250 | #endif |
251 | 251 | ||
252 | } | 252 | } |
253 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 253 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
254 | { | 254 | { |
255 | int number=text.contains("\n"); | 255 | int number=text.contains("\n"); |
256 | QString str = "<" + tag + ">"; | 256 | QString str = "<" + tag + ">"; |
257 | QString tmpText=text; | 257 | QString tmpText=text; |
258 | QString tmpStr=str; | 258 | QString tmpStr=str; |
259 | if(number !=-1) | 259 | if(number !=-1) |
260 | { | 260 | { |
261 | if (number > 0) { | 261 | if (number > 0) { |
262 | int pos=0; | 262 | int pos=0; |
263 | QString tmp; | 263 | QString tmp; |
264 | for(int i=0;i<=number;i++) { | 264 | for(int i=0;i<=number;i++) { |
265 | pos=tmpText.find("\n"); | 265 | pos=tmpText.find("\n"); |
266 | tmp=tmpText.left(pos); | 266 | tmp=tmpText.left(pos); |
267 | tmpText=tmpText.right(tmpText.length()-pos-1); | 267 | tmpText=tmpText.right(tmpText.length()-pos-1); |
268 | tmpStr+=tmp+"<br>"; | 268 | tmpStr+=tmp+"<br>"; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | else tmpStr += tmpText; | 271 | else tmpStr += tmpText; |
272 | tmpStr+="</" + tag + ">"; | 272 | tmpStr+="</" + tag + ">"; |
273 | mText.append(tmpStr); | 273 | mText.append(tmpStr); |
274 | } | 274 | } |
275 | else | 275 | else |
276 | { | 276 | { |
277 | str += text + "</" + tag + ">"; | 277 | str += text + "</" + tag + ">"; |
278 | mText.append(str); | 278 | mText.append(str); |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | void KOEventViewer::setColorMode( int m ) | 282 | void KOEventViewer::setColorMode( int m ) |
283 | { | 283 | { |
284 | mColorMode = m; | 284 | mColorMode = m; |
285 | } | 285 | } |
286 | void KOEventViewer::appendEvent(Event *event, int mode ) | 286 | void KOEventViewer::appendEvent(Event *event, int mode ) |
287 | { | 287 | { |
288 | mMailSubject = ""; | 288 | mMailSubject = ""; |
289 | mCurrentIncidence = event; | 289 | mCurrentIncidence = event; |
290 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 290 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
291 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); | 291 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); |
292 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 292 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
293 | if ( mode == 0 ) { | 293 | if ( mode == 0 ) { |
294 | addTag("h2",deTag(event->summary())); | 294 | addTag("h2",deTag(event->summary())); |
295 | formatReadOnly(event); | 295 | formatReadOnly(event); |
296 | } | 296 | } |
297 | else { | 297 | else { |
298 | if ( mColorMode == 1 ) { | 298 | if ( mColorMode == 1 ) { |
299 | mText +="<font color=\"#00A000\">"; | 299 | mText +="<font color=\"#00A000\">"; |
300 | } | 300 | } |
301 | if ( mColorMode == 2 ) { | 301 | if ( mColorMode == 2 ) { |
302 | mText +="<font color=\"#C00000\">"; | 302 | mText +="<font color=\"#C00000\">"; |
303 | } | 303 | } |
304 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 304 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
305 | if ( mode == 1 ) { | 305 | if ( mode == 1 ) { |
306 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 306 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
307 | } else { | 307 | } else { |
308 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 308 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
309 | } | 309 | } |
310 | formatReadOnly(event); | 310 | formatReadOnly(event); |
311 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 311 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
312 | if ( mColorMode ) | 312 | if ( mColorMode ) |
313 | mText += "</font>"; | 313 | mText += "</font>"; |
314 | } | 314 | } |
315 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 315 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
316 | if (event->cancelled ()) { | 316 | if (event->cancelled ()) { |
317 | mText +="<font color=\"#B00000\">"; | 317 | mText +="<font color=\"#B00000\">"; |
318 | addTag("i",i18n("This event has been cancelled!")); | 318 | addTag("i",i18n("This event has been cancelled!")); |
319 | mText.append("<br>"); | 319 | mText.append("<br>"); |
320 | mText += "</font>"; | 320 | mText += "</font>"; |
321 | mMailSubject += i18n("(cancelled)"); | 321 | mMailSubject += i18n("(cancelled)"); |
322 | } | 322 | } |
323 | 323 | ||
324 | if (event->doesFloat()) { | 324 | if (event->doesFloat()) { |
325 | if (event->isMultiDay()) { | 325 | if (event->isMultiDay()) { |
326 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 326 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
327 | .arg(event->dtStartDateStr(shortDate)) | 327 | .arg(event->dtStartDateStr(shortDate)) |
328 | .arg(event->dtEndDateStr(shortDate))); | 328 | .arg(event->dtEndDateStr(shortDate))); |
329 | } else { | 329 | } else { |
330 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 330 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
331 | } | 331 | } |
332 | } else { | 332 | } else { |
333 | if (event->isMultiDay()) { | 333 | if (event->isMultiDay()) { |
334 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 334 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
335 | .arg(event->dtStartStr( shortDate))); | 335 | .arg(event->dtStartStr( shortDate))); |
336 | mText.append(i18n("<p><b>To:</b> %1</p>") | 336 | mText.append(i18n("<p><b>To:</b> %1</p>") |
337 | .arg(event->dtEndStr(shortDate))); | 337 | .arg(event->dtEndStr(shortDate))); |
338 | } else { | 338 | } else { |
339 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 339 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
340 | .arg(event->dtStartTimeStr()) | 340 | .arg(event->dtStartTimeStr()) |
341 | .arg(event->dtEndTimeStr())); | 341 | .arg(event->dtEndTimeStr())); |
342 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 342 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
343 | .arg(event->dtStartDateStr( shortDate ))); | 343 | .arg(event->dtStartDateStr( shortDate ))); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | if (!event->location().isEmpty()) { | 346 | if (!event->location().isEmpty()) { |
347 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); | 347 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); |
348 | mMailSubject += i18n(" at ") + event->location(); | 348 | mMailSubject += i18n(" at ") + event->location(); |
349 | } | 349 | } |
350 | if (event->recurrence()->doesRecur()) { | 350 | if (event->doesRecur()) { |
351 | 351 | ||
352 | QString recurText = event->recurrence()->recurrenceText(); | 352 | QString recurText = event->recurrenceText(); |
353 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 353 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
354 | bool ok; | 354 | bool ok; |
355 | QDate start = QDate::currentDate(); | 355 | QDate start = QDate::currentDate(); |
356 | QDateTime next; | 356 | QDateTime next; |
357 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 357 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
358 | if ( ok ) { | 358 | if ( ok ) { |
359 | if ( wideScreen ){ | 359 | if ( wideScreen ){ |
360 | addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); | 360 | addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); |
361 | } else { | 361 | } else { |
362 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 362 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
363 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 363 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
364 | } | 364 | } |
365 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 365 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
366 | 366 | ||
367 | } else { | 367 | } else { |
368 | bool last; | 368 | bool last; |
369 | QDate nextd; | 369 | QDate nextd; |
370 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 370 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
371 | if ( last ) { | 371 | if ( last ) { |
372 | if ( wideScreen ){ | 372 | if ( wideScreen ){ |
373 | addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); | 373 | addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); |
374 | } else{ | 374 | } else{ |
375 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 375 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
376 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 376 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | } | 379 | } |
380 | } else { | 380 | } else { |
381 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 381 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
382 | 382 | ||
383 | } | 383 | } |
384 | 384 | ||
385 | 385 | ||
386 | if (event->isAlarmEnabled()) { | 386 | if (event->isAlarmEnabled()) { |
387 | Alarm *alarm =event->alarms().first() ; | 387 | Alarm *alarm =event->alarms().first() ; |
388 | QDateTime t = alarm->time(); | 388 | QDateTime t = alarm->time(); |
389 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 389 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
390 | if(wideScreen ){ | 390 | if(wideScreen ){ |
391 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 391 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
392 | }else{ | 392 | }else{ |
393 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 393 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
394 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 394 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
395 | } | 395 | } |
396 | //addTag("p",s); | 396 | //addTag("p",s); |
397 | } | 397 | } |
398 | 398 | ||
399 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 399 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
400 | 400 | ||
401 | formatCategories(event); | 401 | formatCategories(event); |
402 | 402 | ||
403 | formatAttendees(event); | 403 | formatAttendees(event); |
404 | 404 | ||
405 | if ( KOPrefs::instance()->mEVshowCreated ) { | 405 | if ( KOPrefs::instance()->mEVshowCreated ) { |
406 | if(wideScreen ){ | 406 | if(wideScreen ){ |
407 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 407 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
408 | }else{ | 408 | }else{ |
409 | addTag("p",i18n("<b>Created: ") +" </b>"); | 409 | addTag("p",i18n("<b>Created: ") +" </b>"); |
410 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 410 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
411 | } | 411 | } |
412 | 412 | ||
413 | 413 | ||
414 | } | 414 | } |
415 | if ( KOPrefs::instance()->mEVshowChanged ) { | 415 | if ( KOPrefs::instance()->mEVshowChanged ) { |
416 | if(wideScreen ){ | 416 | if(wideScreen ){ |
417 | addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 417 | addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
418 | }else{ | 418 | }else{ |
419 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 419 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
420 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 420 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
421 | } | 421 | } |
422 | 422 | ||
423 | } | 423 | } |
424 | if ( KOPrefs::instance()->mEVshowDetails ) { | 424 | if ( KOPrefs::instance()->mEVshowDetails ) { |
425 | if (!event->description().isEmpty()) { | 425 | if (!event->description().isEmpty()) { |
426 | addTag("p",i18n("<b>Details: </b>")); | 426 | addTag("p",i18n("<b>Details: </b>")); |
427 | addTag("p",deTag(event->description())); | 427 | addTag("p",deTag(event->description())); |
428 | } | 428 | } |
429 | } | 429 | } |
430 | setText(mText); | 430 | setText(mText); |
431 | //QWhatsThis::add(this,mText); | 431 | //QWhatsThis::add(this,mText); |
432 | 432 | ||
433 | } | 433 | } |
434 | 434 | ||
435 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 435 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
436 | { | 436 | { |
437 | mMailSubject = ""; | 437 | mMailSubject = ""; |
438 | mCurrentIncidence = event; | 438 | mCurrentIncidence = event; |
439 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 439 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
440 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 440 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
441 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); | 441 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); |
442 | if (mode == 0 ) { | 442 | if (mode == 0 ) { |
443 | addTag("h2",deTag(event->summary())); | 443 | addTag("h2",deTag(event->summary())); |
444 | formatReadOnly(event); | 444 | formatReadOnly(event); |
445 | } | 445 | } |
446 | else { | 446 | else { |
447 | if ( mColorMode == 1 ) { | 447 | if ( mColorMode == 1 ) { |
448 | mText +="<font color=\"#00A000\">"; | 448 | mText +="<font color=\"#00A000\">"; |
449 | } | 449 | } |
450 | if ( mColorMode == 2 ) { | 450 | if ( mColorMode == 2 ) { |
451 | mText +="<font color=\"#B00000\">"; | 451 | mText +="<font color=\"#B00000\">"; |
452 | } | 452 | } |
453 | if ( mode == 1 ) { | 453 | if ( mode == 1 ) { |
454 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 454 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
455 | } else { | 455 | } else { |
456 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 456 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
457 | } | 457 | } |
458 | formatReadOnly(event); | 458 | formatReadOnly(event); |
459 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 459 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
460 | if ( mColorMode ) | 460 | if ( mColorMode ) |
461 | mText += "</font>"; | 461 | mText += "</font>"; |
462 | } | 462 | } |
463 | mMailSubject += i18n( "Todo " )+ event->summary(); | 463 | mMailSubject += i18n( "Todo " )+ event->summary(); |
464 | 464 | ||
465 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 465 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
466 | mText +="<font color=\"#B00000\">"; | 466 | mText +="<font color=\"#B00000\">"; |
467 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 467 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
468 | mText += "</font>"; | 468 | mText += "</font>"; |
469 | } else { | 469 | } else { |
470 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 470 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
471 | .arg(event->percentComplete())); | 471 | .arg(event->percentComplete())); |
472 | } | 472 | } |
473 | 473 | ||
474 | if (event->cancelled ()) { | 474 | if (event->cancelled ()) { |
475 | mText +="<font color=\"#B00000\">"; | 475 | mText +="<font color=\"#B00000\">"; |
476 | addTag("i",i18n("This todo has been cancelled!")); | 476 | addTag("i",i18n("This todo has been cancelled!")); |
477 | mText.append("<br>"); | 477 | mText.append("<br>"); |
478 | mText += "</font>"; | 478 | mText += "</font>"; |
479 | mMailSubject += i18n("(cancelled)"); | 479 | mMailSubject += i18n("(cancelled)"); |
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | 483 | ||
484 | if (event->recurrence()->doesRecur()) { | 484 | if (event->doesRecur()) { |
485 | 485 | ||
486 | QString recurText = event->recurrence()->recurrenceText(); | 486 | QString recurText = event->recurrence()->recurrenceText(); |
487 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 487 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
488 | 488 | ||
489 | } | 489 | } |
490 | if (event->hasStartDate()) { | 490 | if (event->hasStartDate()) { |
491 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 491 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
492 | } | 492 | } |
493 | if (event->hasDueDate()) { | 493 | if (event->hasDueDate()) { |
494 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 494 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
495 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 495 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
496 | } | 496 | } |
497 | if (!event->location().isEmpty()) { | 497 | if (!event->location().isEmpty()) { |
498 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); | 498 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); |
499 | mMailSubject += i18n(" at ") + event->location(); | 499 | mMailSubject += i18n(" at ") + event->location(); |
500 | } | 500 | } |
501 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 501 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
502 | .arg(QString::number(event->priority()))); | 502 | .arg(QString::number(event->priority()))); |
503 | 503 | ||
504 | if (event->isAlarmEnabled()) { | 504 | if (event->isAlarmEnabled()) { |
505 | Alarm *alarm =event->alarms().first() ; | 505 | Alarm *alarm =event->alarms().first() ; |
506 | QDateTime t = alarm->time(); | 506 | QDateTime t = alarm->time(); |
507 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 507 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
508 | if ( wideScreen ) { | 508 | if ( wideScreen ) { |
509 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 509 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
510 | } else { | 510 | } else { |
511 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 511 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
512 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 512 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
513 | } | 513 | } |
514 | } | 514 | } |
515 | 515 | ||
516 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 516 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
517 | 517 | ||
518 | formatCategories(event); | 518 | formatCategories(event); |
519 | 519 | ||
520 | formatAttendees(event); | 520 | formatAttendees(event); |
521 | 521 | ||
522 | if ( KOPrefs::instance()->mEVshowCreated ) { | 522 | if ( KOPrefs::instance()->mEVshowCreated ) { |
523 | if(wideScreen ){ | 523 | if(wideScreen ){ |
524 | 524 | ||
525 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 525 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
526 | 526 | ||
527 | } else { | 527 | } else { |
528 | addTag("p",i18n("<b>Created: ") +" </b>"); | 528 | addTag("p",i18n("<b>Created: ") +" </b>"); |
529 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 529 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | if ( KOPrefs::instance()->mEVshowChanged ) { | 532 | if ( KOPrefs::instance()->mEVshowChanged ) { |
533 | if(wideScreen ){ | 533 | if(wideScreen ){ |
534 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 534 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
535 | 535 | ||
536 | } else { | 536 | } else { |
537 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 537 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
538 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 538 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | if ( event->relatedTo() ) { | 541 | if ( event->relatedTo() ) { |
542 | addTag("b",i18n("Parent todo:<br>")); | 542 | addTag("b",i18n("Parent todo:<br>")); |
543 | 543 | ||
544 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); | 544 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); |
545 | 545 | ||
546 | mText += t_name; | 546 | mText += t_name; |
547 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; | 547 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; |
548 | mText += deTag(event->relatedTo()->summary()); | 548 | mText += deTag(event->relatedTo()->summary()); |
549 | mText += "</a><br>"; | 549 | mText += "</a><br>"; |
550 | 550 | ||
551 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); | 551 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); |
552 | } | 552 | } |
553 | QPtrList<Incidence> Relations = event->relations(); | 553 | QPtrList<Incidence> Relations = event->relations(); |
554 | Incidence *to; | 554 | Incidence *to; |
555 | if ( Relations.first() ) | 555 | if ( Relations.first() ) |
556 | addTag("b",i18n("Sub todos:<br>")); | 556 | addTag("b",i18n("Sub todos:<br>")); |
557 | for (to=Relations.first();to;to=Relations.next()) { | 557 | for (to=Relations.first();to;to=Relations.next()) { |
558 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); | 558 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); |
559 | mText += t_name; | 559 | mText += t_name; |
560 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; | 560 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; |
561 | mText += deTag(to->summary()); | 561 | mText += deTag(to->summary()); |
562 | mText += "</a><br>"; | 562 | mText += "</a><br>"; |
563 | 563 | ||
564 | } | 564 | } |
565 | 565 | ||
566 | if ( KOPrefs::instance()->mEVshowDetails ) { | 566 | if ( KOPrefs::instance()->mEVshowDetails ) { |
567 | if (!event->description().isEmpty()) { | 567 | if (!event->description().isEmpty()) { |
568 | addTag("p",i18n("<b>Details: </b>")); | 568 | addTag("p",i18n("<b>Details: </b>")); |
569 | addTag("p",deTag(event->description())); | 569 | addTag("p",deTag(event->description())); |
570 | } | 570 | } |
571 | } | 571 | } |
572 | setText(mText); | 572 | setText(mText); |
573 | } | 573 | } |
574 | 574 | ||
575 | void KOEventViewer::formatCategories(Incidence *event) | 575 | void KOEventViewer::formatCategories(Incidence *event) |
576 | { | 576 | { |
577 | if (!event->categoriesStr().isEmpty()) { | 577 | if (!event->categoriesStr().isEmpty()) { |
578 | if (event->categories().count() == 1) { | 578 | if (event->categories().count() == 1) { |
579 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); | 579 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); |
580 | } else { | 580 | } else { |
581 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; | 581 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; |
582 | } | 582 | } |
583 | } | 583 | } |
584 | } | 584 | } |
585 | void KOEventViewer::formatAttendees(Incidence *event) | 585 | void KOEventViewer::formatAttendees(Incidence *event) |
586 | { | 586 | { |
587 | QPtrList<Attendee> attendees = event->attendees(); | 587 | QPtrList<Attendee> attendees = event->attendees(); |
588 | if (attendees.count()) { | 588 | if (attendees.count()) { |
589 | 589 | ||
590 | 590 | ||
591 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 591 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
592 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 592 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
593 | addTag("h3",i18n("Organizer")); | 593 | addTag("h3",i18n("Organizer")); |
594 | mText.append("<ul><li>"); | 594 | mText.append("<ul><li>"); |
595 | #ifndef KORG_NOKABC | 595 | #ifndef KORG_NOKABC |
596 | 596 | ||
597 | #ifdef DESKTOP_VERSION | 597 | #ifdef DESKTOP_VERSION |
598 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 598 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
599 | KABC::Addressee::List addressList; | 599 | KABC::Addressee::List addressList; |
600 | addressList = add_book->findByEmail(event->organizer()); | 600 | addressList = add_book->findByEmail(event->organizer()); |
601 | KABC::Addressee o = addressList.first(); | 601 | KABC::Addressee o = addressList.first(); |
602 | if (!o.isEmpty() && addressList.size()<2) { | 602 | if (!o.isEmpty() && addressList.size()<2) { |
603 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 603 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
604 | mText += o.formattedName(); | 604 | mText += o.formattedName(); |
605 | mText += "</a>\n"; | 605 | mText += "</a>\n"; |
606 | } else { | 606 | } else { |
607 | mText.append(event->organizer()); | 607 | mText.append(event->organizer()); |
608 | } | 608 | } |
609 | #else //DESKTOP_VERSION | 609 | #else //DESKTOP_VERSION |
610 | mText += "<a href=\"uid:organizer\">"; | 610 | mText += "<a href=\"uid:organizer\">"; |
611 | mText += event->organizer(); | 611 | mText += event->organizer(); |
612 | mText += "</a>\n"; | 612 | mText += "</a>\n"; |
613 | #endif //DESKTOP_VERSION | 613 | #endif //DESKTOP_VERSION |
614 | 614 | ||
615 | 615 | ||
616 | #else | 616 | #else |
617 | mText.append(event->organizer()); | 617 | mText.append(event->organizer()); |
618 | #endif | 618 | #endif |
619 | 619 | ||
620 | if (iconPath) { | 620 | if (iconPath) { |
621 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 621 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
622 | mText += "<IMG src=\"" + iconPath + "\">"; | 622 | mText += "<IMG src=\"" + iconPath + "\">"; |
623 | mText += "</a>\n"; | 623 | mText += "</a>\n"; |
624 | } | 624 | } |
625 | mText.append("</li></ul>"); | 625 | mText.append("</li></ul>"); |
626 | 626 | ||
627 | addTag("h3",i18n("Attendees")); | 627 | addTag("h3",i18n("Attendees")); |
628 | Attendee *a; | 628 | Attendee *a; |
629 | mText.append("<ul>"); | 629 | mText.append("<ul>"); |
630 | int a_count = 0; | 630 | int a_count = 0; |
631 | int a_count_nr = 0; | 631 | int a_count_nr = 0; |
632 | 632 | ||
633 | for(a=attendees.first();a;a=attendees.next()) { | 633 | for(a=attendees.first();a;a=attendees.next()) { |
634 | #ifndef KORG_NOKABC | 634 | #ifndef KORG_NOKABC |
635 | #ifdef DESKTOP_VERSION | 635 | #ifdef DESKTOP_VERSION |
636 | if (a->name().isEmpty()) { | 636 | if (a->name().isEmpty()) { |
637 | addressList = add_book->findByEmail(a->email()); | 637 | addressList = add_book->findByEmail(a->email()); |
638 | KABC::Addressee o = addressList.first(); | 638 | KABC::Addressee o = addressList.first(); |
639 | if (!o.isEmpty() && addressList.size()<2) { | 639 | if (!o.isEmpty() && addressList.size()<2) { |
640 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 640 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
641 | mText += o.formattedName(); | 641 | mText += o.formattedName(); |
642 | mText += "</a>\n"; | 642 | mText += "</a>\n"; |
643 | } else { | 643 | } else { |
644 | mText += "<li>"; | 644 | mText += "<li>"; |
645 | mText.append(a->email()); | 645 | mText.append(a->email()); |
646 | mText += "\n"; | 646 | mText += "\n"; |
647 | } | 647 | } |
648 | } else { | 648 | } else { |
649 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 649 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
650 | if (!a->name().isEmpty()) mText += a->name(); | 650 | if (!a->name().isEmpty()) mText += a->name(); |
651 | else mText += a->email(); | 651 | else mText += a->email(); |
652 | mText += "</a>\n"; | 652 | mText += "</a>\n"; |
653 | } | 653 | } |
654 | #else //DESKTOP_VERSION | 654 | #else //DESKTOP_VERSION |
655 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 655 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
656 | if (!a->name().isEmpty()) mText += a->name(); | 656 | if (!a->name().isEmpty()) mText += a->name(); |
657 | else mText += a->email(); | 657 | else mText += a->email(); |
658 | mText += "</a>\n"; | 658 | mText += "</a>\n"; |
659 | #endif //DESKTOP_VERSION | 659 | #endif //DESKTOP_VERSION |
660 | #else | 660 | #else |
661 | //qDebug("nokabc "); | 661 | //qDebug("nokabc "); |
662 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 662 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
663 | if (!a->name().isEmpty()) mText += a->name(); | 663 | if (!a->name().isEmpty()) mText += a->name(); |
664 | else mText += a->email(); | 664 | else mText += a->email(); |
665 | mText += "</a>\n"; | 665 | mText += "</a>\n"; |
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | 668 | ||
669 | if (!a->email().isEmpty()) { | 669 | if (!a->email().isEmpty()) { |
670 | if (iconPath) { | 670 | if (iconPath) { |
671 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 671 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
672 | if ( a->RSVP() ) { | 672 | if ( a->RSVP() ) { |
673 | ++a_count_nr; | 673 | ++a_count_nr; |
674 | mText += "<IMG src=\"" + iconPath + "\">"; | 674 | mText += "<IMG src=\"" + iconPath + "\">"; |
675 | } | 675 | } |
676 | else { | 676 | else { |
677 | ++a_count; | 677 | ++a_count; |
678 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 678 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
679 | } | 679 | } |
680 | mText += "</a>\n"; | 680 | mText += "</a>\n"; |
681 | } | 681 | } |
682 | } | 682 | } |
683 | if (a->status() != Attendee::NeedsAction ) | 683 | if (a->status() != Attendee::NeedsAction ) |
684 | mText +="[" + a->statusStr() + "] "; | 684 | mText +="[" + a->statusStr() + "] "; |
685 | if (a->role() == Attendee::Chair ) | 685 | if (a->role() == Attendee::Chair ) |
686 | mText +="(" + a->roleStr().left(1) + ".)"; | 686 | mText +="(" + a->roleStr().left(1) + ".)"; |
687 | } | 687 | } |
688 | mText.append("</li></ul>"); | 688 | mText.append("</li></ul>"); |
689 | if ( (a_count+a_count_nr) > 1 ) { | 689 | if ( (a_count+a_count_nr) > 1 ) { |
690 | mText += "<a href=\"mailto:ALL\">"; | 690 | mText += "<a href=\"mailto:ALL\">"; |
691 | mText += i18n( "Mail to all" ); | 691 | mText += i18n( "Mail to all" ); |
692 | mText += "</a> ( "; | 692 | mText += "</a> ( "; |
693 | mText += "<IMG src=\"" + iconPath + "\">"; | 693 | mText += "<IMG src=\"" + iconPath + "\">"; |
694 | mText += i18n( " and " ); | 694 | mText += i18n( " and " ); |
695 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 695 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
696 | mText += "<br>\n"; | 696 | mText += "<br>\n"; |
697 | 697 | ||
698 | 698 | ||
699 | } | 699 | } |
700 | if ( a_count_nr > 1 ) { | 700 | if ( a_count_nr > 1 ) { |
701 | mText += "<a href=\"mailto:RSVP\">"; | 701 | mText += "<a href=\"mailto:RSVP\">"; |
702 | mText += i18n( "Mail to selected" ); | 702 | mText += i18n( "Mail to selected" ); |
703 | mText += "</a> ( "; | 703 | mText += "</a> ( "; |
704 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 704 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
705 | mText += "<br>\n"; | 705 | mText += "<br>\n"; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | 708 | ||
709 | } | 709 | } |
710 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 710 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
711 | { | 711 | { |
712 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 712 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
713 | QString text_d = i18n("Journal from: "); | 713 | QString text_d = i18n("Journal from: "); |
714 | if ( !jour->summary().isEmpty() ) | 714 | if ( !jour->summary().isEmpty() ) |
715 | text_d = jour->summary(); | 715 | text_d = jour->summary(); |
716 | if (mode == 0 ) { | 716 | if (mode == 0 ) { |
717 | addTag("h2", text_d ); | 717 | addTag("h2", text_d ); |
718 | } | 718 | } |
719 | else { | 719 | else { |
720 | if ( mode == 1 ) { | 720 | if ( mode == 1 ) { |
721 | addTag("h3",i18n( "Local: " ) + text_d ); | 721 | addTag("h3",i18n( "Local: " ) + text_d ); |
722 | } else { | 722 | } else { |
723 | addTag("h3",i18n( "Remote: " ) + text_d ); | 723 | addTag("h3",i18n( "Remote: " ) + text_d ); |
724 | } | 724 | } |
725 | } | 725 | } |
726 | topLevelWidget()->setCaption(i18n("Journal viewer")); | 726 | topLevelWidget()->setCaption(i18n("Journal viewer")); |
727 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 727 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
728 | formatReadOnly(jour); | 728 | formatReadOnly(jour); |
729 | addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 729 | addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
730 | 730 | ||
731 | if (!jour->description().isEmpty()) { | 731 | if (!jour->description().isEmpty()) { |
732 | addTag("p",deTag(jour->description())); | 732 | addTag("p",deTag(jour->description())); |
733 | } | 733 | } |
734 | setText(mText); | 734 | setText(mText); |
735 | } | 735 | } |
736 | 736 | ||
737 | void KOEventViewer::formatReadOnly(Incidence *event) | 737 | void KOEventViewer::formatReadOnly(Incidence *event) |
738 | { | 738 | { |
739 | int id = event->calID(); | 739 | int id = event->calID(); |
740 | if ( id > 1 ) { | 740 | if ( id > 1 ) { |
741 | addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>"); | 741 | addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>"); |
742 | } | 742 | } |
743 | if (event->isReadOnly()) { | 743 | if (event->isReadOnly()) { |
744 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 744 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
745 | } | 745 | } |
746 | } | 746 | } |
747 | void KOEventViewer::setSyncMode( bool b ) | 747 | void KOEventViewer::setSyncMode( bool b ) |
748 | { | 748 | { |
749 | mSyncMode = b; | 749 | mSyncMode = b; |
750 | } | 750 | } |
751 | 751 | ||
752 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 752 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
753 | { | 753 | { |
754 | if ( clearV ) | 754 | if ( clearV ) |
755 | clearEvents(); | 755 | clearEvents(); |
756 | if ( mSyncMode ) { | 756 | if ( mSyncMode ) { |
757 | if ( clearV ) | 757 | if ( clearV ) |
758 | appendTodo(event,1 ); | 758 | appendTodo(event,1 ); |
759 | else | 759 | else |
760 | appendTodo(event,2); | 760 | appendTodo(event,2); |
761 | } else | 761 | } else |
762 | appendTodo(event); | 762 | appendTodo(event); |
763 | } | 763 | } |
764 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 764 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
765 | { | 765 | { |
766 | if ( clearV ) | 766 | if ( clearV ) |
767 | clearEvents(); | 767 | clearEvents(); |
768 | if ( mSyncMode ) { | 768 | if ( mSyncMode ) { |
769 | if ( clearV ) | 769 | if ( clearV ) |
770 | appendJournal(event, 1); | 770 | appendJournal(event, 1); |
771 | else | 771 | else |
772 | appendJournal(event, 2); | 772 | appendJournal(event, 2); |
773 | } else | 773 | } else |
774 | appendJournal(event); | 774 | appendJournal(event); |
775 | } | 775 | } |
776 | 776 | ||
777 | void KOEventViewer::setEvent(Event *event) | 777 | void KOEventViewer::setEvent(Event *event) |
778 | { | 778 | { |
779 | clearEvents(); | 779 | clearEvents(); |
780 | if ( mSyncMode ) | 780 | if ( mSyncMode ) |
781 | appendEvent(event, 1); | 781 | appendEvent(event, 1); |
782 | else | 782 | else |
783 | appendEvent(event); | 783 | appendEvent(event); |
784 | } | 784 | } |
785 | 785 | ||
786 | void KOEventViewer::addEvent(Event *event) | 786 | void KOEventViewer::addEvent(Event *event) |
787 | { | 787 | { |
788 | if ( mSyncMode ) | 788 | if ( mSyncMode ) |
789 | appendEvent(event, 2); | 789 | appendEvent(event, 2); |
790 | else | 790 | else |
791 | appendEvent(event); | 791 | appendEvent(event); |
792 | } | 792 | } |
793 | 793 | ||
794 | void KOEventViewer::clearEvents(bool now) | 794 | void KOEventViewer::clearEvents(bool now) |
795 | { | 795 | { |
796 | mText = ""; | 796 | mText = ""; |
797 | if (now) setText(mText); | 797 | if (now) setText(mText); |
798 | } | 798 | } |
799 | 799 | ||
800 | void KOEventViewer::addText(QString text) | 800 | void KOEventViewer::addText(QString text) |
801 | { | 801 | { |
802 | mText.append(text); | 802 | mText.append(text); |
803 | setText(mText); | 803 | setText(mText); |
804 | } | 804 | } |
805 | QString KOEventViewer::deTag(QString text) | 805 | QString KOEventViewer::deTag(QString text) |
806 | { | 806 | { |
807 | #if QT_VERSION >= 0x030000 | 807 | #if QT_VERSION >= 0x030000 |
808 | text.replace( '<' , "<" ); | 808 | text.replace( '<' , "<" ); |
809 | text.replace( '>' , ">" ); | 809 | text.replace( '>' , ">" ); |
810 | #else | 810 | #else |
811 | if ( text.find ('<') >= 0 ) { | 811 | if ( text.find ('<') >= 0 ) { |
812 | text.replace( QRegExp("<") , "<" ); | 812 | text.replace( QRegExp("<") , "<" ); |
813 | } | 813 | } |
814 | if ( text.find ('>') >= 0 ) { | 814 | if ( text.find ('>') >= 0 ) { |
815 | text.replace( QRegExp(">") , ">" ); | 815 | text.replace( QRegExp(">") , ">" ); |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | return text; | 818 | return text; |
819 | } | 819 | } |
820 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 820 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
821 | { | 821 | { |
822 | switch ( e->key() ) { | 822 | switch ( e->key() ) { |
823 | case Qt::Key_Return: | 823 | case Qt::Key_Return: |
824 | case Qt::Key_Enter : | 824 | case Qt::Key_Enter : |
825 | e->ignore(); | 825 | e->ignore(); |
826 | break; | 826 | break; |
827 | default: | 827 | default: |
828 | QTextBrowser::keyPressEvent ( e ); | 828 | QTextBrowser::keyPressEvent ( e ); |
829 | break; | 829 | break; |
830 | } | 830 | } |
831 | } | 831 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index d25f671..e7a5e0e 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,571 +1,571 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | #include <qpaintdevicemetrics.h> | 38 | #include <qpaintdevicemetrics.h> |
39 | 39 | ||
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | #include <kglobal.h> | 43 | #include <kglobal.h> |
44 | 44 | ||
45 | #include <libkdepim/kpimglobalprefs.h> | 45 | #include <libkdepim/kpimglobalprefs.h> |
46 | #include <libkcal/calendar.h> | 46 | #include <libkcal/calendar.h> |
47 | #include <libkcal/calendarlocal.h> | 47 | #include <libkcal/calendarlocal.h> |
48 | #include <libkcal/icalformat.h> | 48 | #include <libkcal/icalformat.h> |
49 | #include <libkcal/vcalformat.h> | 49 | #include <libkcal/vcalformat.h> |
50 | #include <libkcal/recurrence.h> | 50 | #include <libkcal/recurrence.h> |
51 | #include <libkcal/filestorage.h> | 51 | #include <libkcal/filestorage.h> |
52 | #include <libkdepim/categoryselectdialog.h> | 52 | #include <libkdepim/categoryselectdialog.h> |
53 | #include <libkcal/kincidenceformatter.h> | 53 | #include <libkcal/kincidenceformatter.h> |
54 | #ifndef DESKTOP_VERSION | 54 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 55 | #include <qpe/qpeapplication.h> |
56 | #else | 56 | #else |
57 | #include <qapplication.h> | 57 | #include <qapplication.h> |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #ifndef KORG_NOPRINTER | 60 | #ifndef KORG_NOPRINTER |
61 | #include "calprinter.h" | 61 | #include "calprinter.h" |
62 | #endif | 62 | #endif |
63 | #include "koglobals.h" | 63 | #include "koglobals.h" |
64 | #include "koprefs.h" | 64 | #include "koprefs.h" |
65 | #include "kfiledialog.h" | 65 | #include "kfiledialog.h" |
66 | 66 | ||
67 | #include "kolistview.h" | 67 | #include "kolistview.h" |
68 | #include "koeventviewer.h" | 68 | #include "koeventviewer.h" |
69 | 69 | ||
70 | extern QPixmap* sgListViewCompletedPix[6]; | 70 | extern QPixmap* sgListViewCompletedPix[6]; |
71 | extern QPixmap* sgListViewJournalPix; | 71 | extern QPixmap* sgListViewJournalPix; |
72 | 72 | ||
73 | class KOListViewWhatsThis :public QWhatsThis | 73 | class KOListViewWhatsThis :public QWhatsThis |
74 | { | 74 | { |
75 | public: | 75 | public: |
76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 76 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
77 | 77 | ||
78 | protected: | 78 | protected: |
79 | virtual QString text( const QPoint& p) | 79 | virtual QString text( const QPoint& p) |
80 | { | 80 | { |
81 | return _view->getWhatsThisText(p) ; | 81 | return _view->getWhatsThisText(p) ; |
82 | } | 82 | } |
83 | private: | 83 | private: |
84 | QWidget* _wid; | 84 | QWidget* _wid; |
85 | KOListView * _view; | 85 | KOListView * _view; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | 88 | ||
89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 89 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
90 | { | 90 | { |
91 | mItem = item; | 91 | mItem = item; |
92 | mDate = date; | 92 | mDate = date; |
93 | } | 93 | } |
94 | 94 | ||
95 | ListItemVisitor::~ListItemVisitor() | 95 | ListItemVisitor::~ListItemVisitor() |
96 | { | 96 | { |
97 | } | 97 | } |
98 | 98 | ||
99 | bool ListItemVisitor::visit(Event *e) | 99 | bool ListItemVisitor::visit(Event *e) |
100 | { | 100 | { |
101 | bool ok = false; | 101 | bool ok = false; |
102 | QString start, end; | 102 | QString start, end; |
103 | QDate ds, de; | 103 | QDate ds, de; |
104 | if ( e->doesRecur() ) { | 104 | if ( e->doesRecur() ) { |
105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 105 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
106 | if ( ok ) { | 106 | if ( ok ) { |
107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 107 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
108 | start = KGlobal::locale()->formatDate(ds,true); | 108 | start = KGlobal::locale()->formatDate(ds,true); |
109 | de = ds.addDays( days); | 109 | de = ds.addDays( days); |
110 | end = KGlobal::locale()->formatDate(de,true); | 110 | end = KGlobal::locale()->formatDate(de,true); |
111 | } | 111 | } |
112 | 112 | ||
113 | } | 113 | } |
114 | if ( ! ok ) { | 114 | if ( ! ok ) { |
115 | start =e->dtStartDateStr(); | 115 | start =e->dtStartDateStr(); |
116 | end = e->dtEndDateStr(); | 116 | end = e->dtEndDateStr(); |
117 | ds = e->dtStart().date(); | 117 | ds = e->dtStart().date(); |
118 | de = e->dtEnd().date(); | 118 | de = e->dtEnd().date(); |
119 | } | 119 | } |
120 | mItem->setText(0,e->summary()); | 120 | mItem->setText(0,e->summary()); |
121 | mItem->setText(1,start); | 121 | mItem->setText(1,start); |
122 | if ( e->doesFloat() ) | 122 | if ( e->doesFloat() ) |
123 | mItem->setText(2,"---"); | 123 | mItem->setText(2,"---"); |
124 | else | 124 | else |
125 | mItem->setText(2,e->dtStartTimeStr()); | 125 | mItem->setText(2,e->dtStartTimeStr()); |
126 | mItem->setText(3,end); | 126 | mItem->setText(3,end); |
127 | if ( e->doesFloat() ) | 127 | if ( e->doesFloat() ) |
128 | mItem->setText(4,"---"); | 128 | mItem->setText(4,"---"); |
129 | else | 129 | else |
130 | mItem->setText(4,e->dtEndTimeStr()); | 130 | mItem->setText(4,e->dtEndTimeStr()); |
131 | if ( e->isAlarmEnabled() ) { | 131 | if ( e->isAlarmEnabled() ) { |
132 | mItem->setText(5,e->alarms().first()->offsetText() ); | 132 | mItem->setText(5,e->alarms().first()->offsetText() ); |
133 | } else { | 133 | } else { |
134 | mItem->setText(5, i18n("No")); | 134 | mItem->setText(5, i18n("No")); |
135 | } | 135 | } |
136 | mItem->setText(6, e->recurrence()->recurrenceText()); | 136 | mItem->setText(6, e->recurrenceText()); |
137 | if( ! e->doesRecur() ) | 137 | if( ! e->doesRecur() ) |
138 | mItem->setSortKey( 6, "-" ); | 138 | mItem->setSortKey( 6, "-" ); |
139 | mItem->setText(7,"---"); | 139 | mItem->setText(7,"---"); |
140 | mItem->setText(8,"---"); | 140 | mItem->setText(8,"---"); |
141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 141 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
142 | mItem->setText(10,e->categoriesStr()); | 142 | mItem->setText(10,e->categoriesStr()); |
143 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); | 143 | mItem->setText(11, KOPrefs::instance()->calName( e->calID() )); |
144 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); | 144 | mItem->setText(12, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); |
145 | 145 | ||
146 | QString key; | 146 | QString key; |
147 | QDate d = e->lastModified().date(); | 147 | QDate d = e->lastModified().date(); |
148 | QTime t = e->lastModified().time(); | 148 | QTime t = e->lastModified().time(); |
149 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); | 149 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); |
150 | mItem->setSortKey(12,key); | 150 | mItem->setSortKey(12,key); |
151 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 151 | t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
152 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 152 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
153 | mItem->setSortKey(1,key); | 153 | mItem->setSortKey(1,key); |
154 | 154 | ||
155 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 155 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
156 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 156 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
157 | mItem->setSortKey(3,key); | 157 | mItem->setSortKey(3,key); |
158 | return true; | 158 | return true; |
159 | } | 159 | } |
160 | 160 | ||
161 | bool ListItemVisitor::visit(Todo *t) | 161 | bool ListItemVisitor::visit(Todo *t) |
162 | { | 162 | { |
163 | mItem->setText(0,t->summary()); | 163 | mItem->setText(0,t->summary()); |
164 | if ( t->isCompleted() ) { | 164 | if ( t->isCompleted() ) { |
165 | mItem->setSortKey(0,"99"+ t->summary().left(10)); | 165 | mItem->setSortKey(0,"99"+ t->summary().left(10)); |
166 | } else | 166 | } else |
167 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); | 167 | mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); |
168 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); | 168 | mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); |
169 | if (t->hasStartDate()) { | 169 | if (t->hasStartDate()) { |
170 | mItem->setText(1,t->dtStartDateStr()); | 170 | mItem->setText(1,t->dtStartDateStr()); |
171 | if (t->doesFloat()) { | 171 | if (t->doesFloat()) { |
172 | mItem->setText(2,"---"); | 172 | mItem->setText(2,"---"); |
173 | } else { | 173 | } else { |
174 | mItem->setText(2,t->dtStartTimeStr()); | 174 | mItem->setText(2,t->dtStartTimeStr()); |
175 | } | 175 | } |
176 | } else { | 176 | } else { |
177 | mItem->setText(1,"---"); | 177 | mItem->setText(1,"---"); |
178 | mItem->setText(2,"---"); | 178 | mItem->setText(2,"---"); |
179 | } | 179 | } |
180 | mItem->setText(3,"---"); | 180 | mItem->setText(3,"---"); |
181 | mItem->setText(4,"---"); | 181 | mItem->setText(4,"---"); |
182 | if ( t->isAlarmEnabled() ) { | 182 | if ( t->isAlarmEnabled() ) { |
183 | mItem->setText(5,t->alarms().first()->offsetText() ); | 183 | mItem->setText(5,t->alarms().first()->offsetText() ); |
184 | } else { | 184 | } else { |
185 | mItem->setText(5, i18n("No")); | 185 | mItem->setText(5, i18n("No")); |
186 | } | 186 | } |
187 | mItem->setText(6, t->recurrence()->recurrenceText()); | 187 | mItem->setText(6, t->recurrenceText()); |
188 | if( ! t->doesRecur() ) | 188 | if( ! t->doesRecur() ) |
189 | mItem->setSortKey( 6, "-" ); | 189 | mItem->setSortKey( 6, "-" ); |
190 | if (t->hasDueDate()) { | 190 | if (t->hasDueDate()) { |
191 | mItem->setText(7,t->dtDueDateStr()); | 191 | mItem->setText(7,t->dtDueDateStr()); |
192 | if (t->doesFloat()) { | 192 | if (t->doesFloat()) { |
193 | mItem->setText(8,"---"); | 193 | mItem->setText(8,"---"); |
194 | } else { | 194 | } else { |
195 | mItem->setText(8,t->dtDueTimeStr()); | 195 | mItem->setText(8,t->dtDueTimeStr()); |
196 | } | 196 | } |
197 | } else { | 197 | } else { |
198 | mItem->setText(7,"---"); | 198 | mItem->setText(7,"---"); |
199 | mItem->setText(8,"---"); | 199 | mItem->setText(8,"---"); |
200 | } | 200 | } |
201 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 201 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
202 | mItem->setText(10,t->categoriesStr()); | 202 | mItem->setText(10,t->categoriesStr()); |
203 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); | 203 | mItem->setText(11, KOPrefs::instance()->calName( t->calID() )); |
204 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); | 204 | mItem->setText(12, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); |
205 | QString key; | 205 | QString key; |
206 | QDate d = t->lastModified().date(); | 206 | QDate d = t->lastModified().date(); |
207 | QTime tm = t->lastModified().time(); | 207 | QTime tm = t->lastModified().time(); |
208 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 208 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
209 | mItem->setSortKey(12,key); | 209 | mItem->setSortKey(12,key); |
210 | if (t->hasDueDate()) { | 210 | if (t->hasDueDate()) { |
211 | d = t->dtDue().date(); | 211 | d = t->dtDue().date(); |
212 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 212 | tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
213 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 213 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
214 | mItem->setSortKey(7,key); | 214 | mItem->setSortKey(7,key); |
215 | } | 215 | } |
216 | if ( t->hasStartDate() ) { | 216 | if ( t->hasStartDate() ) { |
217 | d = t->dtStart().date(); | 217 | d = t->dtStart().date(); |
218 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 218 | tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
219 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 219 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
220 | mItem->setSortKey(1,key); | 220 | mItem->setSortKey(1,key); |
221 | } | 221 | } |
222 | return true; | 222 | return true; |
223 | } | 223 | } |
224 | 224 | ||
225 | bool ListItemVisitor::visit(Journal * j) | 225 | bool ListItemVisitor::visit(Journal * j) |
226 | { | 226 | { |
227 | 227 | ||
228 | QString des; | 228 | QString des; |
229 | mItem->setPixmap( 0, *sgListViewJournalPix); | 229 | mItem->setPixmap( 0, *sgListViewJournalPix); |
230 | if ( !j->summary().isEmpty() ) { | 230 | if ( !j->summary().isEmpty() ) { |
231 | des = j->summary(); | 231 | des = j->summary(); |
232 | } else { | 232 | } else { |
233 | des = j->description().left(30); | 233 | des = j->description().left(30); |
234 | des = des.simplifyWhiteSpace (); | 234 | des = des.simplifyWhiteSpace (); |
235 | des.replace (QRegExp ("\\n"),"" ); | 235 | des.replace (QRegExp ("\\n"),"" ); |
236 | des.replace (QRegExp ("\\r"),"" ); | 236 | des.replace (QRegExp ("\\r"),"" ); |
237 | } | 237 | } |
238 | mItem->setText(0,des.left(25)); | 238 | mItem->setText(0,des.left(25)); |
239 | mItem->setSortKey(0,"0"+ des.left(25)); | 239 | mItem->setSortKey(0,"0"+ des.left(25)); |
240 | mItem->setText(1,j->dtStartDateStr()); | 240 | mItem->setText(1,j->dtStartDateStr()); |
241 | mItem->setText(2,"---"); | 241 | mItem->setText(2,"---"); |
242 | mItem->setText(3,"---"); | 242 | mItem->setText(3,"---"); |
243 | mItem->setText(4,"---"); | 243 | mItem->setText(4,"---"); |
244 | mItem->setText(5,"---"); | 244 | mItem->setText(5,"---"); |
245 | mItem->setText(6,"---"); | 245 | mItem->setText(6,"---"); |
246 | mItem->setText(7,j->dtStartDateStr()); | 246 | mItem->setText(7,j->dtStartDateStr()); |
247 | mItem->setText(8,"---"); | 247 | mItem->setText(8,"---"); |
248 | mItem->setText(9,"---"); | 248 | mItem->setText(9,"---"); |
249 | mItem->setText(10,j->categoriesStr()); | 249 | mItem->setText(10,j->categoriesStr()); |
250 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); | 250 | mItem->setText(11, KOPrefs::instance()->calName( j->calID() )); |
251 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); | 251 | mItem->setText(12, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); |
252 | 252 | ||
253 | QString key; | 253 | QString key; |
254 | QDate d = j->lastModified().date(); | 254 | QDate d = j->lastModified().date(); |
255 | QTime tm = j->lastModified().time(); | 255 | QTime tm = j->lastModified().time(); |
256 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); | 256 | key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() ); |
257 | mItem->setSortKey(12,key); | 257 | mItem->setSortKey(12,key); |
258 | d = j->dtStart().date(); | 258 | d = j->dtStart().date(); |
259 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 259 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
260 | mItem->setSortKey(1,key); | 260 | mItem->setSortKey(1,key); |
261 | mItem->setSortKey(7,key); | 261 | mItem->setSortKey(7,key); |
262 | 262 | ||
263 | return true; | 263 | return true; |
264 | } | 264 | } |
265 | 265 | ||
266 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 266 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
267 | const char *name) | 267 | const char *name) |
268 | : KOEventView(calendar, parent, name) | 268 | : KOEventView(calendar, parent, name) |
269 | { | 269 | { |
270 | 270 | ||
271 | mActiveItem = 0; | 271 | mActiveItem = 0; |
272 | mForceShowCompletedTodos = false; | 272 | mForceShowCompletedTodos = false; |
273 | mListView = new KOListViewListView(this); | 273 | mListView = new KOListViewListView(this); |
274 | mListView->addColumn(i18n("Summary")); | 274 | mListView->addColumn(i18n("Summary")); |
275 | mListView->addColumn(i18n("Start Date")); | 275 | mListView->addColumn(i18n("Start Date")); |
276 | mListView->addColumn(i18n("Start Time")); | 276 | mListView->addColumn(i18n("Start Time")); |
277 | mListView->addColumn(i18n("End Date")); | 277 | mListView->addColumn(i18n("End Date")); |
278 | mListView->addColumn(i18n("End Time")); | 278 | mListView->addColumn(i18n("End Time")); |
279 | mListView->addColumn(i18n("Alarm")); // alarm set? | 279 | mListView->addColumn(i18n("Alarm")); // alarm set? |
280 | mListView->addColumn(i18n("Recurs")); // recurs? | 280 | mListView->addColumn(i18n("Recurs")); // recurs? |
281 | mListView->addColumn(i18n("Due Date")); | 281 | mListView->addColumn(i18n("Due Date")); |
282 | mListView->addColumn(i18n("Due Time")); | 282 | mListView->addColumn(i18n("Due Time")); |
283 | mListView->addColumn(i18n("Cancelled")); | 283 | mListView->addColumn(i18n("Cancelled")); |
284 | mListView->addColumn(i18n("Categories")); | 284 | mListView->addColumn(i18n("Categories")); |
285 | mListView->addColumn(i18n("Calendar")); | 285 | mListView->addColumn(i18n("Calendar")); |
286 | mListView->addColumn(i18n("Last Modified")); | 286 | mListView->addColumn(i18n("Last Modified")); |
287 | 287 | ||
288 | mListView->setColumnAlignment(0,AlignLeft); | 288 | mListView->setColumnAlignment(0,AlignLeft); |
289 | mListView->setColumnAlignment(1,AlignLeft); | 289 | mListView->setColumnAlignment(1,AlignLeft); |
290 | mListView->setColumnAlignment(2,AlignHCenter); | 290 | mListView->setColumnAlignment(2,AlignHCenter); |
291 | mListView->setColumnAlignment(3,AlignLeft); | 291 | mListView->setColumnAlignment(3,AlignLeft); |
292 | mListView->setColumnAlignment(4,AlignHCenter); | 292 | mListView->setColumnAlignment(4,AlignHCenter); |
293 | mListView->setColumnAlignment(5,AlignLeft); | 293 | mListView->setColumnAlignment(5,AlignLeft); |
294 | mListView->setColumnAlignment(6,AlignLeft); | 294 | mListView->setColumnAlignment(6,AlignLeft); |
295 | mListView->setColumnAlignment(7,AlignLeft); | 295 | mListView->setColumnAlignment(7,AlignLeft); |
296 | mListView->setColumnAlignment(8,AlignLeft); | 296 | mListView->setColumnAlignment(8,AlignLeft); |
297 | mListView->setColumnAlignment(9,AlignLeft); | 297 | mListView->setColumnAlignment(9,AlignLeft); |
298 | mListView->setColumnAlignment(10,AlignLeft); | 298 | mListView->setColumnAlignment(10,AlignLeft); |
299 | mListView->setColumnAlignment(11,AlignLeft); | 299 | mListView->setColumnAlignment(11,AlignLeft); |
300 | mListView->setColumnAlignment(12,AlignLeft); | 300 | mListView->setColumnAlignment(12,AlignLeft); |
301 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); | 301 | mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); |
302 | 302 | ||
303 | int iii = 0; | 303 | int iii = 0; |
304 | for ( iii = 0; iii< 13 ; ++iii ) | 304 | for ( iii = 0; iii< 13 ; ++iii ) |
305 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 305 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
306 | 306 | ||
307 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 307 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
308 | layoutTop->addWidget(mListView); | 308 | layoutTop->addWidget(mListView); |
309 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 309 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
310 | mPopupMenu = eventPopup(); | 310 | mPopupMenu = eventPopup(); |
311 | QPopupMenu* selPopup = new QPopupMenu ( this ); | 311 | QPopupMenu* selPopup = new QPopupMenu ( this ); |
312 | mPopupMenu->insertSeparator(); | 312 | mPopupMenu->insertSeparator(); |
313 | 313 | ||
314 | selPopup->insertItem(i18n("All"),this, | 314 | selPopup->insertItem(i18n("All"),this, |
315 | SLOT(allSelection())); | 315 | SLOT(allSelection())); |
316 | selPopup->insertItem(i18n("None"),this, | 316 | selPopup->insertItem(i18n("None"),this, |
317 | SLOT(clearSelection())); | 317 | SLOT(clearSelection())); |
318 | selPopup->insertItem(i18n("Delete selected..."),this, | 318 | selPopup->insertItem(i18n("Delete selected..."),this, |
319 | SLOT(deleteAll())); | 319 | SLOT(deleteAll())); |
320 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); | 320 | mPopupMenu->insertItem(i18n("Selection"), selPopup ); |
321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 321 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
322 | i18n("Hide all selected"),this, | 322 | i18n("Hide all selected"),this, |
323 | SLOT(hideAll()),true); | 323 | SLOT(hideAll()),true); |
324 | 324 | ||
325 | selPopup->insertSeparator(); | 325 | selPopup->insertSeparator(); |
326 | QPopupMenu * exportPO = new QPopupMenu ( this ); | 326 | QPopupMenu * exportPO = new QPopupMenu ( this ); |
327 | selPopup->insertItem( i18n("Export"), exportPO ); | 327 | selPopup->insertItem( i18n("Export"), exportPO ); |
328 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
329 | mPopupMenu->insertSeparator(); | 329 | mPopupMenu->insertSeparator(); |
330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 330 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
331 | i18n("Print complete list..."),this, | 331 | i18n("Print complete list..."),this, |
332 | SLOT(printList()),true); | 332 | SLOT(printList()),true); |
333 | #endif | 333 | #endif |
334 | mCalPopup = new QPopupMenu ( this ); | 334 | mCalPopup = new QPopupMenu ( this ); |
335 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); | 335 | selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); |
336 | 336 | ||
337 | selPopup->insertItem(i18n("Set categories")+"...",this, | 337 | selPopup->insertItem(i18n("Set categories")+"...",this, |
338 | SLOT(setCat()) ); | 338 | SLOT(setCat()) ); |
339 | selPopup->insertItem( i18n("Set alarm..."),this, | 339 | selPopup->insertItem( i18n("Set alarm..."),this, |
340 | SLOT(setAlarm())); | 340 | SLOT(setAlarm())); |
341 | #if 0 | 341 | #if 0 |
342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 342 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
343 | i18n("Set categories")+"...",this, | 343 | i18n("Set categories")+"...",this, |
344 | SLOT(setCat()),true); | 344 | SLOT(setCat()),true); |
345 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 345 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
346 | i18n("Set alarm..."),this, | 346 | i18n("Set alarm..."),this, |
347 | SLOT(setAlarm()),true); | 347 | SLOT(setAlarm()),true); |
348 | #endif | 348 | #endif |
349 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, | 349 | QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, |
350 | SLOT( populateCalPopup() )); | 350 | SLOT( populateCalPopup() )); |
351 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, | 351 | QObject::connect(mCalPopup,SIGNAL(activated( int )),this, |
352 | SLOT( setCalendar( int ) )); | 352 | SLOT( setCalendar( int ) )); |
353 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, | 353 | QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, |
354 | SLOT( catChanged( Incidence * ) )); | 354 | SLOT( catChanged( Incidence * ) )); |
355 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, | 355 | exportPO->insertItem( i18n("As iCal (ics) file..."),this, |
356 | SLOT(saveToFile())); | 356 | SLOT(saveToFile())); |
357 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, | 357 | exportPO->insertItem( i18n("As vCal (vcs) file..."),this, |
358 | SLOT(saveToFileVCS())); | 358 | SLOT(saveToFileVCS())); |
359 | exportPO->insertItem( i18n("Journal/Details..."),this, | 359 | exportPO->insertItem( i18n("Journal/Details..."),this, |
360 | SLOT(saveDescriptionToFile())); | 360 | SLOT(saveDescriptionToFile())); |
361 | // mPopupMenu->insertSeparator(); | 361 | // mPopupMenu->insertSeparator(); |
362 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 362 | // mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
363 | // i18n("Add Categ. to selected..."),this, | 363 | // i18n("Add Categ. to selected..."),this, |
364 | // SLOT(addCat()),true); | 364 | // SLOT(addCat()),true); |
365 | //mPopupMenu->insertSeparator(); | 365 | //mPopupMenu->insertSeparator(); |
366 | #ifndef DESKTOP_VERSION | 366 | #ifndef DESKTOP_VERSION |
367 | selPopup->insertSeparator(); | 367 | selPopup->insertSeparator(); |
368 | selPopup->insertItem( i18n("Beam via IR..."),this, | 368 | selPopup->insertItem( i18n("Beam via IR..."),this, |
369 | SLOT(beamSelected())); | 369 | SLOT(beamSelected())); |
370 | #if 0 | 370 | #if 0 |
371 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 371 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
372 | i18n("Beam via IR"),this, | 372 | i18n("Beam via IR"),this, |
373 | SLOT(beamSelected()),true); | 373 | SLOT(beamSelected()),true); |
374 | #endif | 374 | #endif |
375 | #endif | 375 | #endif |
376 | /* | 376 | /* |
377 | mPopupMenu = new QPopupMenu; | 377 | mPopupMenu = new QPopupMenu; |
378 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 378 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
379 | SLOT (editEvent())); | 379 | SLOT (editEvent())); |
380 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 380 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
381 | SLOT (deleteEvent())); | 381 | SLOT (deleteEvent())); |
382 | mPopupMenu->insertSeparator(); | 382 | mPopupMenu->insertSeparator(); |
383 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 383 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
384 | SLOT(showDates())); | 384 | SLOT(showDates())); |
385 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 385 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
386 | SLOT(hideDates())); | 386 | SLOT(hideDates())); |
387 | */ | 387 | */ |
388 | QObject::connect(mListView,SIGNAL( newEvent()), | 388 | QObject::connect(mListView,SIGNAL( newEvent()), |
389 | this,SIGNAL(signalNewEvent())); | 389 | this,SIGNAL(signalNewEvent())); |
390 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 390 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
391 | this,SLOT(defaultItemAction(QListViewItem *))); | 391 | this,SLOT(defaultItemAction(QListViewItem *))); |
392 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, | 392 | QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, |
393 | const QPoint &, int )), | 393 | const QPoint &, int )), |
394 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 394 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
395 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 395 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
396 | SLOT(processSelectionChange(QListViewItem *))); | 396 | SLOT(processSelectionChange(QListViewItem *))); |
397 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 397 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
398 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 398 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
399 | 399 | ||
400 | readSettings(KOGlobals::config(),"KOListView Layout"); | 400 | readSettings(KOGlobals::config(),"KOListView Layout"); |
401 | } | 401 | } |
402 | 402 | ||
403 | KOListView::~KOListView() | 403 | KOListView::~KOListView() |
404 | { | 404 | { |
405 | delete mPopupMenu; | 405 | delete mPopupMenu; |
406 | #if QT_VERSION >= 0x030000 | 406 | #if QT_VERSION >= 0x030000 |
407 | 407 | ||
408 | #else | 408 | #else |
409 | delete mKOListViewWhatsThis; | 409 | delete mKOListViewWhatsThis; |
410 | #endif | 410 | #endif |
411 | } | 411 | } |
412 | 412 | ||
413 | void KOListView::catChanged( Incidence* inc) | 413 | void KOListView::catChanged( Incidence* inc) |
414 | { | 414 | { |
415 | KOListViewItem* item = getItemForEvent(inc); | 415 | KOListViewItem* item = getItemForEvent(inc); |
416 | if (item) { | 416 | if (item) { |
417 | ListItemVisitor v(item, mStartDate ); | 417 | ListItemVisitor v(item, mStartDate ); |
418 | inc->accept(v); | 418 | inc->accept(v); |
419 | } | 419 | } |
420 | } | 420 | } |
421 | QString KOListView::getWhatsThisText(QPoint p) | 421 | QString KOListView::getWhatsThisText(QPoint p) |
422 | { | 422 | { |
423 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 423 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
424 | if ( item ) | 424 | if ( item ) |
425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 425 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
426 | KOPrefs::instance()->mWTshowDetails, | 426 | KOPrefs::instance()->mWTshowDetails, |
427 | KOPrefs::instance()->mWTshowCreated, | 427 | KOPrefs::instance()->mWTshowCreated, |
428 | KOPrefs::instance()->mWTshowChanged); | 428 | KOPrefs::instance()->mWTshowChanged); |
429 | return i18n("That is the list view" ); | 429 | return i18n("That is the list view" ); |
430 | 430 | ||
431 | } | 431 | } |
432 | 432 | ||
433 | void KOListView::setCalendar( int c ) | 433 | void KOListView::setCalendar( int c ) |
434 | { | 434 | { |
435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 435 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 436 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
437 | i18n("Continue"), i18n("Cancel"), 0, | 437 | i18n("Continue"), i18n("Cancel"), 0, |
438 | 0, 1 ); | 438 | 0, 1 ); |
439 | if ( result != 0 ) { | 439 | if ( result != 0 ) { |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | 442 | ||
443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 443 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
444 | int icount = delSel.count(); | 444 | int icount = delSel.count(); |
445 | if ( icount ) { | 445 | if ( icount ) { |
446 | Incidence *incidence = delSel.first(); | 446 | Incidence *incidence = delSel.first(); |
447 | while ( incidence ) { | 447 | while ( incidence ) { |
448 | incidence->setCalID( c ); | 448 | incidence->setCalID( c ); |
449 | KOListViewItem * item = getItemForEvent( incidence ); | 449 | KOListViewItem * item = getItemForEvent( incidence ); |
450 | if ( item ) { | 450 | if ( item ) { |
451 | ListItemVisitor v(item, mStartDate ); | 451 | ListItemVisitor v(item, mStartDate ); |
452 | incidence->accept(v); | 452 | incidence->accept(v); |
453 | } | 453 | } |
454 | incidence = delSel.next(); | 454 | incidence = delSel.next(); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 457 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
458 | KopiCalendarFile * cal = calendars.first(); | 458 | KopiCalendarFile * cal = calendars.first(); |
459 | while ( cal ) { | 459 | while ( cal ) { |
460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 460 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 461 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 462 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
463 | if ( cal->isStandard ) | 463 | if ( cal->isStandard ) |
464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 464 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
465 | cal = calendars.next(); | 465 | cal = calendars.next(); |
466 | } | 466 | } |
467 | mCalendar->setSyncEventsReadOnly(); | 467 | mCalendar->setSyncEventsReadOnly(); |
468 | mCalendar->reInitAlarmSettings(); | 468 | mCalendar->reInitAlarmSettings(); |
469 | 469 | ||
470 | } | 470 | } |
471 | void KOListView::populateCalPopup() | 471 | void KOListView::populateCalPopup() |
472 | { | 472 | { |
473 | mCalPopup->clear(); | 473 | mCalPopup->clear(); |
474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 474 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
475 | while ( kkf ) { | 475 | while ( kkf ) { |
476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 476 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 477 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
478 | mCalPopup->setItemEnabled( index, false ); | 478 | mCalPopup->setItemEnabled( index, false ); |
479 | kkf = KOPrefs::instance()->mCalendars.next(); | 479 | kkf = KOPrefs::instance()->mCalendars.next(); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | void KOListView::updateList() | 482 | void KOListView::updateList() |
483 | { | 483 | { |
484 | // qDebug(" KOListView::updateList() "); | 484 | // qDebug(" KOListView::updateList() "); |
485 | 485 | ||
486 | } | 486 | } |
487 | 487 | ||
488 | void KOListView::clearList() | 488 | void KOListView::clearList() |
489 | { | 489 | { |
490 | clear (); | 490 | clear (); |
491 | } | 491 | } |
492 | 492 | ||
493 | void KOListView::setCat() | 493 | void KOListView::setCat() |
494 | { | 494 | { |
495 | 495 | ||
496 | bool set = true; | 496 | bool set = true; |
497 | int result = KMessageBox::warningYesNoCancel(this, | 497 | int result = KMessageBox::warningYesNoCancel(this, |
498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 498 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
499 | i18n("Set categories"), | 499 | i18n("Set categories"), |
500 | i18n("Add"), | 500 | i18n("Add"), |
501 | i18n("Reset")); | 501 | i18n("Reset")); |
502 | if (result == KMessageBox::Cancel) return; | 502 | if (result == KMessageBox::Cancel) return; |
503 | if (result == KMessageBox::Yes) set = false; | 503 | if (result == KMessageBox::Yes) set = false; |
504 | setCategories( set ); | 504 | setCategories( set ); |
505 | } | 505 | } |
506 | 506 | ||
507 | void KOListView::setAlarm() | 507 | void KOListView::setAlarm() |
508 | { | 508 | { |
509 | KOAlarmPrefs kap( this); | 509 | KOAlarmPrefs kap( this); |
510 | if ( !kap.exec() ) | 510 | if ( !kap.exec() ) |
511 | return; | 511 | return; |
512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos | 512 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
513 | Incidence* inc = delSel.first(); | 513 | Incidence* inc = delSel.first(); |
514 | int count = 0; | 514 | int count = 0; |
515 | while ( inc ) { | 515 | while ( inc ) { |
516 | ++count; | 516 | ++count; |
517 | if (kap.mAlarmButton->isChecked()) { | 517 | if (kap.mAlarmButton->isChecked()) { |
518 | if (inc->alarms().count() == 0) | 518 | if (inc->alarms().count() == 0) |
519 | inc->newAlarm(); | 519 | inc->newAlarm(); |
520 | Alarm *alarm = inc->alarms().first(); | 520 | Alarm *alarm = inc->alarms().first(); |
521 | alarm->setEnabled(true); | 521 | alarm->setEnabled(true); |
522 | int j = kap.mAlarmTimeEdit->value()* -60; | 522 | int j = kap.mAlarmTimeEdit->value()* -60; |
523 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 523 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
524 | j = j * 60; | 524 | j = j * 60; |
525 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 525 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
526 | j = j * (60 * 24); | 526 | j = j * (60 * 24); |
527 | alarm->setStartOffset( j ); | 527 | alarm->setStartOffset( j ); |
528 | 528 | ||
529 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 529 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
530 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 530 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
531 | } | 531 | } |
532 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 532 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
533 | alarm->setAudioAlarm(kap.mAlarmSound); | 533 | alarm->setAudioAlarm(kap.mAlarmSound); |
534 | else | 534 | else |
535 | alarm->setType(Alarm::Invalid); | 535 | alarm->setType(Alarm::Invalid); |
536 | } else { | 536 | } else { |
537 | QPtrList<Alarm> alarms = inc->alarms(); | 537 | QPtrList<Alarm> alarms = inc->alarms(); |
538 | Alarm *alarm; | 538 | Alarm *alarm; |
539 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 539 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
540 | alarm->setEnabled(false); | 540 | alarm->setEnabled(false); |
541 | alarm->setType(Alarm::Invalid); | 541 | alarm->setType(Alarm::Invalid); |
542 | } | 542 | } |
543 | } | 543 | } |
544 | KOListViewItem* item = getItemForEvent(inc); | 544 | KOListViewItem* item = getItemForEvent(inc); |
545 | if (item) { | 545 | if (item) { |
546 | ListItemVisitor v(item, mStartDate ); | 546 | ListItemVisitor v(item, mStartDate ); |
547 | inc->accept(v); | 547 | inc->accept(v); |
548 | } | 548 | } |
549 | inc = delSel.next(); | 549 | inc = delSel.next(); |
550 | } | 550 | } |
551 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 551 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
552 | qDebug("KO: Set alarm for %d items", count); | 552 | qDebug("KO: Set alarm for %d items", count); |
553 | calendar()->reInitAlarmSettings(); | 553 | calendar()->reInitAlarmSettings(); |
554 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 554 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
555 | } | 555 | } |
556 | void KOListView::setCategories( bool removeOld ) | 556 | void KOListView::setCategories( bool removeOld ) |
557 | { | 557 | { |
558 | 558 | ||
559 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 559 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
560 | csd->setColorEnabled(); | 560 | csd->setColorEnabled(); |
561 | if (! csd->exec()) { | 561 | if (! csd->exec()) { |
562 | delete csd; | 562 | delete csd; |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | QStringList catList = csd->selectedCategories(); | 565 | QStringList catList = csd->selectedCategories(); |
566 | delete csd; | 566 | delete csd; |
567 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 567 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
568 | Incidence* inc = delSel.first(); | 568 | Incidence* inc = delSel.first(); |
569 | while ( inc ) { | 569 | while ( inc ) { |
570 | if ( removeOld ) { | 570 | if ( removeOld ) { |
571 | inc->setCategories( catList, false ); | 571 | inc->setCategories( catList, false ); |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 498d9b0..eea9a4d 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -406,1086 +406,1088 @@ void MonthViewItem::paint(QPainter *p) | |||
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->recurrence()->doesRecur() ); | 790 | item->setRecur( event->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->recurrence()->doesRecur() ); | 881 | item->setRecur( todo->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | //selection( item ); | ||
1109 | //qApp->processEvents(); | ||
1108 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1109 | Incidence *incidence = eventItem->incidence(); | 1111 | Incidence *incidence = eventItem->incidence(); |
1110 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1112 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1111 | } | 1113 | } |
1112 | 1114 | ||
1113 | void MonthViewCell::selection( QListBoxItem *item ) | 1115 | void MonthViewCell::selection( QListBoxItem *item ) |
1114 | { | 1116 | { |
1115 | if ( !item ) { | 1117 | if ( !item ) { |
1116 | emit highlightIncidence( 0 , this, 0 ); | 1118 | emit highlightIncidence( 0 , this, 0 ); |
1117 | return; | 1119 | return; |
1118 | } | 1120 | } |
1119 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1121 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1120 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1122 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1121 | mMonthView->setSelectedCell( this ); | 1123 | mMonthView->setSelectedCell( this ); |
1122 | } | 1124 | } |
1123 | 1125 | ||
1124 | void MonthViewCell::deHighLight() | 1126 | void MonthViewCell::deHighLight() |
1125 | { | 1127 | { |
1126 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1128 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1127 | while ( mitem ) { | 1129 | while ( mitem ) { |
1128 | if ( mitem->setHighlightedFalse() ) | 1130 | if ( mitem->setHighlightedFalse() ) |
1129 | updateItem ( mitem ); | 1131 | updateItem ( mitem ); |
1130 | mitem = (MonthViewItem *)mitem->next(); | 1132 | mitem = (MonthViewItem *)mitem->next(); |
1131 | } | 1133 | } |
1132 | } | 1134 | } |
1133 | // returns true if no inc found | 1135 | // returns true if no inc found |
1134 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1136 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1135 | { | 1137 | { |
1136 | 1138 | ||
1137 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1139 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1138 | while ( mitem ) { | 1140 | while ( mitem ) { |
1139 | if ( mitem->incidence() == inc ) { | 1141 | if ( mitem->incidence() == inc ) { |
1140 | if ( mitem->setHighlighted( inc ) ) | 1142 | if ( mitem->setHighlighted( inc ) ) |
1141 | updateItem ( mitem ); | 1143 | updateItem ( mitem ); |
1142 | return false; | 1144 | return false; |
1143 | } | 1145 | } |
1144 | mitem = (MonthViewItem *)mitem->next(); | 1146 | mitem = (MonthViewItem *)mitem->next(); |
1145 | } | 1147 | } |
1146 | return true; | 1148 | return true; |
1147 | } | 1149 | } |
1148 | // ******************************************************************************* | 1150 | // ******************************************************************************* |
1149 | // ******************************************************************************* | 1151 | // ******************************************************************************* |
1150 | // ******************************************************************************* | 1152 | // ******************************************************************************* |
1151 | 1153 | ||
1152 | 1154 | ||
1153 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1155 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1154 | : KOEventView( calendar, parent, name ), | 1156 | : KOEventView( calendar, parent, name ), |
1155 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1157 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1156 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1158 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1157 | { | 1159 | { |
1158 | mFlagKeyPressed = false; | 1160 | mFlagKeyPressed = false; |
1159 | mShortDayLabelsM = false; | 1161 | mShortDayLabelsM = false; |
1160 | mShortDayLabelsW = false; | 1162 | mShortDayLabelsW = false; |
1161 | skipResize = false; | 1163 | skipResize = false; |
1162 | clPending = true; | 1164 | clPending = true; |
1163 | mPopupCell = 0; | 1165 | mPopupCell = 0; |
1164 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1166 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1165 | mWidStack = new QWidgetStack( this ); | 1167 | mWidStack = new QWidgetStack( this ); |
1166 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1168 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1167 | mMonthView = new QWidget( mWidStack ); | 1169 | mMonthView = new QWidget( mWidStack ); |
1168 | mWeekView = new QWidget( mWidStack ); | 1170 | mWeekView = new QWidget( mWidStack ); |
1169 | #if QT_VERSION >= 0x030000 | 1171 | #if QT_VERSION >= 0x030000 |
1170 | mWidStack->addWidget(mMonthView ); | 1172 | mWidStack->addWidget(mMonthView ); |
1171 | mWidStack->addWidget(mWeekView ); | 1173 | mWidStack->addWidget(mWeekView ); |
1172 | #else | 1174 | #else |
1173 | mWidStack->addWidget( mMonthView, 1 ); | 1175 | mWidStack->addWidget( mMonthView, 1 ); |
1174 | mWidStack->addWidget( mWeekView , 1 ); | 1176 | mWidStack->addWidget( mWeekView , 1 ); |
1175 | #endif | 1177 | #endif |
1176 | hb->addWidget( mNavigatorBar ); | 1178 | hb->addWidget( mNavigatorBar ); |
1177 | hb->addWidget( mWidStack ); | 1179 | hb->addWidget( mWidStack ); |
1178 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1180 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1179 | updatePossible = false; | 1181 | updatePossible = false; |
1180 | //updatePossible = true; | 1182 | //updatePossible = true; |
1181 | mCells.setAutoDelete( true ); | 1183 | mCells.setAutoDelete( true ); |
1182 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1184 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1183 | mDayLabels.resize( mDaysPerWeek ); | 1185 | mDayLabels.resize( mDaysPerWeek ); |
1184 | mDayLabelsW.resize( mDaysPerWeek ); | 1186 | mDayLabelsW.resize( mDaysPerWeek ); |
1185 | QFont bfont = font(); | 1187 | QFont bfont = font(); |
1186 | if ( QApplication::desktop()->width() < 650 ) { | 1188 | if ( QApplication::desktop()->width() < 650 ) { |
1187 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1189 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1188 | } | 1190 | } |
1189 | bfont.setBold( true ); | 1191 | bfont.setBold( true ); |
1190 | int i; | 1192 | int i; |
1191 | 1193 | ||
1192 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1194 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1193 | QLabel *label = new QLabel( mMonthView ); | 1195 | QLabel *label = new QLabel( mMonthView ); |
1194 | label->setFont(bfont); | 1196 | label->setFont(bfont); |
1195 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1197 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1196 | label->setLineWidth(1); | 1198 | label->setLineWidth(1); |
1197 | label->setAlignment(AlignCenter); | 1199 | label->setAlignment(AlignCenter); |
1198 | mDayLabels.insert( i, label ); | 1200 | mDayLabels.insert( i, label ); |
1199 | label = new QLabel( mWeekView ); | 1201 | label = new QLabel( mWeekView ); |
1200 | label->setFont(bfont); | 1202 | label->setFont(bfont); |
1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1203 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1202 | label->setLineWidth(1); | 1204 | label->setLineWidth(1); |
1203 | label->setAlignment(AlignCenter); | 1205 | label->setAlignment(AlignCenter); |
1204 | mDayLabelsW.insert( i, label ); | 1206 | mDayLabelsW.insert( i, label ); |
1205 | } | 1207 | } |
1206 | 1208 | ||
1207 | bfont.setBold( false ); | 1209 | bfont.setBold( false ); |
1208 | mWeekLabels.resize( mNumWeeks+1 ); | 1210 | mWeekLabels.resize( mNumWeeks+1 ); |
1209 | mWeekLabelsW.resize( 2 ); | 1211 | mWeekLabelsW.resize( 2 ); |
1210 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1212 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1211 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1213 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1212 | label->setFocusPolicy(NoFocus); | 1214 | label->setFocusPolicy(NoFocus); |
1213 | label->setFont(bfont); | 1215 | label->setFont(bfont); |
1214 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1216 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1215 | label->setFlat(true); | 1217 | label->setFlat(true); |
1216 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1218 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1217 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1219 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1218 | //label->setLineWidth(1); | 1220 | //label->setLineWidth(1); |
1219 | //label->setAlignment(AlignCenter); | 1221 | //label->setAlignment(AlignCenter); |
1220 | mWeekLabels.insert( i, label ); | 1222 | mWeekLabels.insert( i, label ); |
1221 | } | 1223 | } |
1222 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1224 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1223 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1225 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1224 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1226 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1225 | 1227 | ||
1226 | for( i = 0; i < 1+1; i++ ) { | 1228 | for( i = 0; i < 1+1; i++ ) { |
1227 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1229 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1228 | label->setFocusPolicy(NoFocus); | 1230 | label->setFocusPolicy(NoFocus); |
1229 | label->setFont(bfont); | 1231 | label->setFont(bfont); |
1230 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1232 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1231 | label->setFlat(true); | 1233 | label->setFlat(true); |
1232 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1234 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1233 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1235 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1234 | //label->setLineWidth(1); | 1236 | //label->setLineWidth(1); |
1235 | //label->setAlignment(AlignCenter); | 1237 | //label->setAlignment(AlignCenter); |
1236 | mWeekLabelsW.insert( i, label ); | 1238 | mWeekLabelsW.insert( i, label ); |
1237 | } | 1239 | } |
1238 | mWeekLabelsW[1]->setText( i18n("W")); | 1240 | mWeekLabelsW[1]->setText( i18n("W")); |
1239 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1241 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1240 | 1242 | ||
1241 | 1243 | ||
1242 | int row, col; | 1244 | int row, col; |
1243 | mCells.resize( mNumCells ); | 1245 | mCells.resize( mNumCells ); |
1244 | for( row = 0; row < mNumWeeks; ++row ) { | 1246 | for( row = 0; row < mNumWeeks; ++row ) { |
1245 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1247 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1246 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1248 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1247 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1249 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1248 | 1250 | ||
1249 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1251 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1250 | SLOT( defaultAction( Incidence * ) ) ); | 1252 | SLOT( defaultAction( Incidence * ) ) ); |
1251 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1253 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1252 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1254 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1253 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1255 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1254 | SIGNAL( showDaySignal( QDate ) ) ); | 1256 | SIGNAL( showDaySignal( QDate ) ) ); |
1255 | connect( cell, SIGNAL( nextCell() ), | 1257 | connect( cell, SIGNAL( nextCell() ), |
1256 | SLOT( nextCell() ) ); | 1258 | SLOT( nextCell() ) ); |
1257 | connect( cell, SIGNAL( prevCell() ), | 1259 | connect( cell, SIGNAL( prevCell() ), |
1258 | SLOT( prevCell() ) ); | 1260 | SLOT( prevCell() ) ); |
1259 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1261 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1260 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1262 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1261 | } | 1263 | } |
1262 | } | 1264 | } |
1263 | mCellsW.resize( mDaysPerWeek ); | 1265 | mCellsW.resize( mDaysPerWeek ); |
1264 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1266 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1265 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1267 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1266 | mCellsW.insert( col, cell ); | 1268 | mCellsW.insert( col, cell ); |
1267 | 1269 | ||
1268 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1270 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1269 | SLOT( defaultAction( Incidence * ) ) ); | 1271 | SLOT( defaultAction( Incidence * ) ) ); |
1270 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1272 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1271 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1273 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1272 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1274 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1273 | SIGNAL( showDaySignal( QDate ) ) ); | 1275 | SIGNAL( showDaySignal( QDate ) ) ); |
1274 | connect( cell, SIGNAL( nextCell() ), | 1276 | connect( cell, SIGNAL( nextCell() ), |
1275 | SLOT( nextCell() ) ); | 1277 | SLOT( nextCell() ) ); |
1276 | connect( cell, SIGNAL( prevCell() ), | 1278 | connect( cell, SIGNAL( prevCell() ), |
1277 | SLOT( prevCell() ) ); | 1279 | SLOT( prevCell() ) ); |
1278 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1280 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1279 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1281 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1280 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1282 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1281 | } | 1283 | } |
1282 | 1284 | ||
1283 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1285 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1284 | mContextMenu = eventPopup(); | 1286 | mContextMenu = eventPopup(); |
1285 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1287 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1286 | i18n("New Event..."),this, | 1288 | i18n("New Event..."),this, |
1287 | SLOT(slotNewEvent()),false); | 1289 | SLOT(slotNewEvent()),false); |
1288 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1290 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1289 | i18n("New Todo..."),this, | 1291 | i18n("New Todo..."),this, |
1290 | SLOT(slotNewTodo()),false); | 1292 | SLOT(slotNewTodo()),false); |
1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1293 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1292 | i18n("Journal"),this, | 1294 | i18n("Journal"),this, |
1293 | SLOT(slotEditJournal()),false); | 1295 | SLOT(slotEditJournal()),false); |
1294 | 1296 | ||
1295 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1297 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1296 | SLOT( catChanged( Incidence * ) )); | 1298 | SLOT( catChanged( Incidence * ) )); |
1297 | 1299 | ||
1298 | 1300 | ||
1299 | QString pathString = ""; | 1301 | QString pathString = ""; |
1300 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1302 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1301 | if ( QApplication::desktop()->width() < 480 ) | 1303 | if ( QApplication::desktop()->width() < 480 ) |
1302 | pathString += "icons16/"; | 1304 | pathString += "icons16/"; |
1303 | } else | 1305 | } else |
1304 | pathString += "iconsmini/"; | 1306 | pathString += "iconsmini/"; |
1305 | mNewItemMenu = new QPopupMenu( this ); | 1307 | mNewItemMenu = new QPopupMenu( this ); |
1306 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1307 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1309 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1310 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1309 | 1311 | ||
1310 | // updateConfig(); //useless here... | 1312 | // updateConfig(); //useless here... |
1311 | // ... but we need mWidthLongDayLabel computed | 1313 | // ... but we need mWidthLongDayLabel computed |
1312 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1314 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1313 | mWidthLongDayLabel = 0; | 1315 | mWidthLongDayLabel = 0; |
1314 | for (int i = 0; i < 7; i++) { | 1316 | for (int i = 0; i < 7; i++) { |
1315 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1317 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1316 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1318 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1317 | } | 1319 | } |
1318 | 1320 | ||
1319 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1321 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1320 | 1322 | ||
1321 | #if 0 | 1323 | #if 0 |
1322 | if ( mShowWeekView ) | 1324 | if ( mShowWeekView ) |
1323 | mWidStack->raiseWidget( mWeekView ); | 1325 | mWidStack->raiseWidget( mWeekView ); |
1324 | else | 1326 | else |
1325 | mWidStack->raiseWidget( mMonthView ); | 1327 | mWidStack->raiseWidget( mMonthView ); |
1326 | #endif | 1328 | #endif |
1327 | 1329 | ||
1328 | emit incidenceSelected( 0 ); | 1330 | emit incidenceSelected( 0 ); |
1329 | 1331 | ||
1330 | mComputeLayoutTimer = new QTimer( this ); | 1332 | mComputeLayoutTimer = new QTimer( this ); |
1331 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1333 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1332 | 1334 | ||
1333 | 1335 | ||
1334 | #ifndef DESKTOP_VERSION | 1336 | #ifndef DESKTOP_VERSION |
1335 | resize( QApplication::desktop()->size() ); | 1337 | resize( QApplication::desktop()->size() ); |
1336 | #else | 1338 | #else |
1337 | resize(640, 480 ); | 1339 | resize(640, 480 ); |
1338 | updatePossible = true; | 1340 | updatePossible = true; |
1339 | #endif | 1341 | #endif |
1340 | computeLayout(); | 1342 | computeLayout(); |
1341 | 1343 | ||
1342 | if ( mShowWeekView ) | 1344 | if ( mShowWeekView ) |
1343 | mWidStack->raiseWidget( mWeekView ); | 1345 | mWidStack->raiseWidget( mWeekView ); |
1344 | else | 1346 | else |
1345 | mWidStack->raiseWidget( mMonthView ); | 1347 | mWidStack->raiseWidget( mMonthView ); |
1346 | } | 1348 | } |
1347 | 1349 | ||
1348 | KOMonthView::~KOMonthView() | 1350 | KOMonthView::~KOMonthView() |
1349 | { | 1351 | { |
1350 | delete mContextMenu; | 1352 | delete mContextMenu; |
1351 | } | 1353 | } |
1352 | 1354 | ||
1353 | void KOMonthView::catChanged( Incidence * ) | 1355 | void KOMonthView::catChanged( Incidence * ) |
1354 | { | 1356 | { |
1355 | updateView(); | 1357 | updateView(); |
1356 | } | 1358 | } |
1357 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1359 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1358 | { | 1360 | { |
1359 | static Incidence * lastInc = 0; | 1361 | static Incidence * lastInc = 0; |
1360 | static MonthViewCell * lastCell = 0; | 1362 | static MonthViewCell * lastCell = 0; |
1361 | 1363 | ||
1362 | if ( lastInc == inc && lastCell == mc ) | 1364 | if ( lastInc == inc && lastCell == mc ) |
1363 | return; | 1365 | return; |
1364 | lastInc = inc; | 1366 | lastInc = inc; |
1365 | lastCell = mc; | 1367 | lastCell = mc; |
1366 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1368 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1367 | 1369 | ||
1368 | bool weekview = false; | 1370 | bool weekview = false; |
1369 | uint index = 0; | 1371 | uint index = 0; |
1370 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1372 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1371 | if ( mCellsW[i] == mc ) { | 1373 | if ( mCellsW[i] == mc ) { |
1372 | weekview = true; | 1374 | weekview = true; |
1373 | index = i; | 1375 | index = i; |
1374 | break; | 1376 | break; |
1375 | } | 1377 | } |
1376 | } | 1378 | } |
1377 | QPtrVector<MonthViewCell> *cells; | 1379 | QPtrVector<MonthViewCell> *cells; |
1378 | if ( weekview ) | 1380 | if ( weekview ) |
1379 | cells = &mCellsW; | 1381 | cells = &mCellsW; |
1380 | else { | 1382 | else { |
1381 | for (uint i = 0; i < mCells.count(); ++i) { | 1383 | for (uint i = 0; i < mCells.count(); ++i) { |
1382 | if ( mCells[i] == mc ) { | 1384 | if ( mCells[i] == mc ) { |
1383 | index = i; | 1385 | index = i; |
1384 | break; | 1386 | break; |
1385 | } | 1387 | } |
1386 | } | 1388 | } |
1387 | cells = &mCells; | 1389 | cells = &mCells; |
1388 | } | 1390 | } |
1389 | for (uint i = 0; i < (*cells).count(); ++i) { | 1391 | for (uint i = 0; i < (*cells).count(); ++i) { |
1390 | (*cells)[i]->deHighLight(); | 1392 | (*cells)[i]->deHighLight(); |
1391 | } | 1393 | } |
1392 | if ( ! inc ) | 1394 | if ( ! inc ) |
1393 | return; | 1395 | return; |
1394 | 1396 | ||
1395 | uint count = (*cells).count(); | 1397 | uint count = (*cells).count(); |
1396 | bool goLeft = (mday > 1 && index > 0); | 1398 | bool goLeft = (mday > 1 && index > 0); |
1397 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1399 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1398 | for (uint iii = 1; iii < count; ++iii) { | 1400 | for (uint iii = 1; iii < count; ++iii) { |
1399 | if ( goLeft ) { | 1401 | if ( goLeft ) { |
1400 | int left = index - iii; | 1402 | int left = index - iii; |
1401 | if ( left >= 0 ) { | 1403 | if ( left >= 0 ) { |
1402 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1404 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1403 | goLeft = false; | 1405 | goLeft = false; |
1404 | } else | 1406 | } else |
1405 | goLeft = false; | 1407 | goLeft = false; |
1406 | } | 1408 | } |
1407 | if ( goRight ) { | 1409 | if ( goRight ) { |
1408 | uint right = index + iii; | 1410 | uint right = index + iii; |
1409 | if ( right < count ) { | 1411 | if ( right < count ) { |
1410 | if ( (*cells)[right]->doHighLight(inc) ) | 1412 | if ( (*cells)[right]->doHighLight(inc) ) |
1411 | goRight = false; | 1413 | goRight = false; |
1412 | 1414 | ||
1413 | } else | 1415 | } else |
1414 | goRight = false; | 1416 | goRight = false; |
1415 | } | 1417 | } |
1416 | 1418 | ||
1417 | } | 1419 | } |
1418 | #if 0 | 1420 | #if 0 |
1419 | if ( mday > 1 && index > 0 ) | 1421 | if ( mday > 1 && index > 0 ) |
1420 | for (int i = index-1; i >= 0; --i) { | 1422 | for (int i = index-1; i >= 0; --i) { |
1421 | //qDebug("index %d iii %d ", index, i); | 1423 | //qDebug("index %d iii %d ", index, i); |
1422 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1424 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1423 | break; | 1425 | break; |
1424 | } | 1426 | } |
1425 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1427 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1426 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1428 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1427 | if ( (*cells)[i]->doHighLight(inc) ) | 1429 | if ( (*cells)[i]->doHighLight(inc) ) |
1428 | break; | 1430 | break; |
1429 | } | 1431 | } |
1430 | #endif | 1432 | #endif |
1431 | 1433 | ||
1432 | } | 1434 | } |
1433 | void KOMonthView::selectInternalWeekNum ( int n ) | 1435 | void KOMonthView::selectInternalWeekNum ( int n ) |
1434 | { | 1436 | { |
1435 | switchView(); | 1437 | switchView(); |
1436 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1438 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1437 | emit selectMonth (); | 1439 | emit selectMonth (); |
1438 | else | 1440 | else |
1439 | emit selectWeekNum ( n ); | 1441 | emit selectWeekNum ( n ); |
1440 | } | 1442 | } |
1441 | 1443 | ||
1442 | int KOMonthView::currentWeek() | 1444 | int KOMonthView::currentWeek() |
1443 | { | 1445 | { |
1444 | if ( mShowWeekView ) | 1446 | if ( mShowWeekView ) |
1445 | return mWeekLabelsW[0]->getWeekNum(); | 1447 | return mWeekLabelsW[0]->getWeekNum(); |
1446 | return mWeekLabels[0]->getWeekNum(); | 1448 | return mWeekLabels[0]->getWeekNum(); |
1447 | } | 1449 | } |
1448 | void KOMonthView::switchView() | 1450 | void KOMonthView::switchView() |
1449 | { | 1451 | { |
1450 | if ( selectedCell( ) ) | 1452 | if ( selectedCell( ) ) |
1451 | selectedCell()->deselect(); | 1453 | selectedCell()->deselect(); |
1452 | mShowWeekView = !mShowWeekView; | 1454 | mShowWeekView = !mShowWeekView; |
1453 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1455 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1454 | if ( clPending ) { | 1456 | if ( clPending ) { |
1455 | computeLayout(); | 1457 | computeLayout(); |
1456 | updateConfig(); | 1458 | updateConfig(); |
1457 | } | 1459 | } |
1458 | if ( mShowWeekView ) | 1460 | if ( mShowWeekView ) |
1459 | mWidStack->raiseWidget( mWeekView ); | 1461 | mWidStack->raiseWidget( mWeekView ); |
1460 | else | 1462 | else |
1461 | mWidStack->raiseWidget( mMonthView ); | 1463 | mWidStack->raiseWidget( mMonthView ); |
1462 | clPending = false; | 1464 | clPending = false; |
1463 | } | 1465 | } |
1464 | 1466 | ||
1465 | int KOMonthView::maxDatesHint() | 1467 | int KOMonthView::maxDatesHint() |
1466 | { | 1468 | { |
1467 | return mNumCells; | 1469 | return mNumCells; |
1468 | } | 1470 | } |
1469 | 1471 | ||
1470 | int KOMonthView::currentDateCount() | 1472 | int KOMonthView::currentDateCount() |
1471 | { | 1473 | { |
1472 | return mNumCells; | 1474 | return mNumCells; |
1473 | } | 1475 | } |
1474 | 1476 | ||
1475 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1477 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1476 | { | 1478 | { |
1477 | QPtrList<Incidence> selected; | 1479 | QPtrList<Incidence> selected; |
1478 | 1480 | ||
1479 | if ( mSelectedCell ) { | 1481 | if ( mSelectedCell ) { |
1480 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1482 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1481 | if ( incidence ) selected.append( incidence ); | 1483 | if ( incidence ) selected.append( incidence ); |
1482 | } | 1484 | } |
1483 | 1485 | ||
1484 | return selected; | 1486 | return selected; |
1485 | } | 1487 | } |
1486 | 1488 | ||
1487 | DateList KOMonthView::selectedDates() | 1489 | DateList KOMonthView::selectedDates() |
1488 | { | 1490 | { |
1489 | DateList selected; | 1491 | DateList selected; |
1490 | 1492 | ||
1491 | if ( mSelectedCell ) { | 1493 | if ( mSelectedCell ) { |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 100a81b..682f83b 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,453 +1,454 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | 34 | ||
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
51 | 51 | ||
52 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
54 | 54 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 57 | { |
58 | mTodo = 0; | 58 | mTodo = 0; |
59 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
61 | init(); | 61 | init(); |
62 | if ( QApplication::desktop()->height() <= 240 ) | 62 | if ( QApplication::desktop()->height() <= 240 ) |
63 | hideButtons(); | 63 | hideButtons(); |
64 | } | 64 | } |
65 | 65 | ||
66 | KOTodoEditor::~KOTodoEditor() | 66 | KOTodoEditor::~KOTodoEditor() |
67 | { | 67 | { |
68 | emit dialogClose( mTodo ); | 68 | emit dialogClose( mTodo ); |
69 | } | 69 | } |
70 | 70 | ||
71 | void KOTodoEditor::init() | 71 | void KOTodoEditor::init() |
72 | { | 72 | { |
73 | setupGeneral(); | 73 | setupGeneral(); |
74 | setupAttendeesTab(); | 74 | setupAttendeesTab(); |
75 | setupRecurrence(); | 75 | setupRecurrence(); |
76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 76 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); | 77 | mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); |
78 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), | 78 | connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), |
79 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); | 79 | mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); |
80 | } | 80 | } |
81 | void KOTodoEditor::setupRecurrence() | 81 | void KOTodoEditor::setupRecurrence() |
82 | { | 82 | { |
83 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 83 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
84 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 84 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
85 | 85 | ||
86 | mRecurrence = new KOEditorRecurrence( topFrame ); | 86 | mRecurrence = new KOEditorRecurrence( topFrame ); |
87 | topLayout->addWidget( mRecurrence ); | 87 | topLayout->addWidget( mRecurrence ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void KOTodoEditor::setCategories( QString s ) | 90 | void KOTodoEditor::setCategories( QString s ) |
91 | { | 91 | { |
92 | mGeneral->setCategories(s); | 92 | mGeneral->setCategories(s); |
93 | } | 93 | } |
94 | void KOTodoEditor::setSecrecy( int sec ) | 94 | void KOTodoEditor::setSecrecy( int sec ) |
95 | { | 95 | { |
96 | mGeneral->setSecrecy( sec ); | 96 | mGeneral->setSecrecy( sec ); |
97 | } | 97 | } |
98 | void KOTodoEditor::reload() | 98 | void KOTodoEditor::reload() |
99 | { | 99 | { |
100 | if ( mTodo ) readTodo( mTodo ); | 100 | if ( mTodo ) readTodo( mTodo ); |
101 | } | 101 | } |
102 | 102 | ||
103 | void KOTodoEditor::setupGeneral() | 103 | void KOTodoEditor::setupGeneral() |
104 | { | 104 | { |
105 | mGeneral = new KOEditorGeneralTodo(this); | 105 | mGeneral = new KOEditorGeneralTodo(this); |
106 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 106 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
107 | 107 | ||
108 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 108 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
109 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 109 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
110 | // mGeneral,SLOT(setCategories(const QString &))); | 110 | // mGeneral,SLOT(setCategories(const QString &))); |
111 | 111 | ||
112 | if (KOPrefs::instance()->mCompactDialogs) { | 112 | if (KOPrefs::instance()->mCompactDialogs) { |
113 | QFrame *topFrame = addPage(i18n("General")); | 113 | QFrame *topFrame = addPage(i18n("General")); |
114 | 114 | ||
115 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 115 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
116 | if ( QApplication::desktop()->width() < 480 ) { | 116 | if ( QApplication::desktop()->width() < 480 ) { |
117 | topLayout->setMargin(marginHintSmall()); | 117 | topLayout->setMargin(marginHintSmall()); |
118 | topLayout->setSpacing(spacingHintSmall()); | 118 | topLayout->setSpacing(spacingHintSmall()); |
119 | } else { | 119 | } else { |
120 | topLayout->setMargin(marginHint()); | 120 | topLayout->setMargin(marginHint()); |
121 | topLayout->setSpacing(spacingHint()); | 121 | topLayout->setSpacing(spacingHint()); |
122 | } | 122 | } |
123 | topLayout->addStretch( 1 ); | 123 | topLayout->addStretch( 1 ); |
124 | mGeneral->initHeader(topFrame,topLayout); | 124 | mGeneral->initHeader(topFrame,topLayout); |
125 | topLayout->addStretch( 1 ); | 125 | topLayout->addStretch( 1 ); |
126 | mGeneral->initTime(topFrame,topLayout); | 126 | mGeneral->initTime(topFrame,topLayout); |
127 | topLayout->addStretch( 1 ); | 127 | topLayout->addStretch( 1 ); |
128 | mGeneral->initAlarm(topFrame,topLayout); | 128 | mGeneral->initAlarm(topFrame,topLayout); |
129 | topLayout->addStretch( 1 ); | 129 | topLayout->addStretch( 1 ); |
130 | mGeneral->enableAlarm( false ); | 130 | mGeneral->enableAlarm( false ); |
131 | 131 | ||
132 | 132 | ||
133 | QBoxLayout *priorityLayout; | 133 | QBoxLayout *priorityLayout; |
134 | if ( QApplication::desktop()->width() < 500 ) | 134 | if ( QApplication::desktop()->width() < 500 ) |
135 | priorityLayout = new QVBoxLayout( topLayout ); | 135 | priorityLayout = new QVBoxLayout( topLayout ); |
136 | else | 136 | else |
137 | priorityLayout = new QHBoxLayout( topLayout ); | 137 | priorityLayout = new QHBoxLayout( topLayout ); |
138 | QWidget* prioWidget = new QWidget (topFrame); | 138 | QWidget* prioWidget = new QWidget (topFrame); |
139 | priorityLayout->addWidget( prioWidget ); | 139 | priorityLayout->addWidget( prioWidget ); |
140 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 140 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
141 | 141 | ||
142 | 142 | ||
143 | QIconSet icon; | 143 | QIconSet icon; |
144 | if ( QApplication::desktop()->width() < 321 ) | 144 | if ( QApplication::desktop()->width() < 321 ) |
145 | icon = SmallIcon("fileimport16"); | 145 | icon = SmallIcon("fileimport16"); |
146 | else | 146 | else |
147 | icon = SmallIcon("fileimport"); | 147 | icon = SmallIcon("fileimport"); |
148 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 148 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
149 | loadTemplate->setIconSet (icon ) ; | 149 | loadTemplate->setIconSet (icon ) ; |
150 | int size = loadTemplate->sizeHint().height(); | 150 | int size = loadTemplate->sizeHint().height(); |
151 | loadTemplate->setFixedSize( size, size ); | 151 | loadTemplate->setFixedSize( size, size ); |
152 | if ( QApplication::desktop()->width() < 321 ) | 152 | if ( QApplication::desktop()->width() < 321 ) |
153 | icon = SmallIcon("fileexport16"); | 153 | icon = SmallIcon("fileexport16"); |
154 | else | 154 | else |
155 | icon = SmallIcon("fileexport"); | 155 | icon = SmallIcon("fileexport"); |
156 | QPushButton * saveTemplate = new QPushButton( prioWidget); | 156 | QPushButton * saveTemplate = new QPushButton( prioWidget); |
157 | saveTemplate->setIconSet (icon ) ; | 157 | saveTemplate->setIconSet (icon ) ; |
158 | saveTemplate->setFixedSize( size, size ); | 158 | saveTemplate->setFixedSize( size, size ); |
159 | 159 | ||
160 | priorityLayout2->addWidget(loadTemplate); | 160 | priorityLayout2->addWidget(loadTemplate); |
161 | priorityLayout2->addWidget(saveTemplate); | 161 | priorityLayout2->addWidget(saveTemplate); |
162 | mGeneral->initPriority(prioWidget,priorityLayout2); | 162 | mGeneral->initPriority(prioWidget,priorityLayout2); |
163 | mGeneral->initCategories( topFrame, priorityLayout ); | 163 | mGeneral->initCategories( topFrame, priorityLayout ); |
164 | topLayout->addStretch(1); | 164 | topLayout->addStretch(1); |
165 | 165 | ||
166 | QFrame *topFrame2 = addPage(i18n("Details")); | 166 | QFrame *topFrame2 = addPage(i18n("Details")); |
167 | 167 | ||
168 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 168 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
169 | topLayout2->setMargin(marginHint()); | 169 | topLayout2->setMargin(marginHint()); |
170 | topLayout2->setSpacing(spacingHint()); | 170 | topLayout2->setSpacing(spacingHint()); |
171 | 171 | ||
172 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 172 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
173 | mGeneral->initCompletion(topFrame2,completionLayout); | 173 | mGeneral->initCompletion(topFrame2,completionLayout); |
174 | 174 | ||
175 | 175 | ||
176 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 176 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
177 | mGeneral->initDescription(topFrame2,topLayout2); | 177 | mGeneral->initDescription(topFrame2,topLayout2); |
178 | 178 | ||
179 | // QHBox * hb = new QHBox ( topFrame2 ); | 179 | // QHBox * hb = new QHBox ( topFrame2 ); |
180 | // topLayout2->addWidget(hb); | 180 | // topLayout2->addWidget(hb); |
181 | // hb->setSpacing( 3 ); | 181 | // hb->setSpacing( 3 ); |
182 | 182 | ||
183 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 183 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
184 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 184 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
185 | 185 | ||
186 | } else { | 186 | } else { |
187 | QFrame *topFrame = addPage(i18n("General")); | 187 | QFrame *topFrame = addPage(i18n("General")); |
188 | 188 | ||
189 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 189 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
190 | topLayout->setSpacing(spacingHint()); | 190 | topLayout->setSpacing(spacingHint()); |
191 | 191 | ||
192 | mGeneral->initHeader(topFrame,topLayout); | 192 | mGeneral->initHeader(topFrame,topLayout); |
193 | mGeneral->initTime(topFrame,topLayout); | 193 | mGeneral->initTime(topFrame,topLayout); |
194 | mGeneral->initStatus(topFrame,topLayout); | 194 | mGeneral->initStatus(topFrame,topLayout); |
195 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 195 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
196 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 196 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
197 | mGeneral->initDescription(topFrame,topLayout); | 197 | mGeneral->initDescription(topFrame,topLayout); |
198 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 198 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
199 | mGeneral->initCategories( topFrame, detailsLayout ); | 199 | mGeneral->initCategories( topFrame, detailsLayout ); |
200 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 200 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
201 | } | 201 | } |
202 | mGeneral->finishSetup(); | 202 | mGeneral->finishSetup(); |
203 | 203 | ||
204 | } | 204 | } |
205 | 205 | ||
206 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 206 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
207 | { | 207 | { |
208 | //init(); | 208 | //init(); |
209 | 209 | ||
210 | mTodo = todo; | 210 | mTodo = todo; |
211 | readTodo(mTodo); | 211 | readTodo(mTodo); |
212 | if ( editDescription ) { | 212 | if ( editDescription ) { |
213 | showPage( 1 ); | 213 | showPage( 1 ); |
214 | mGeneral->setFocusOn( 1 ); | 214 | mGeneral->setFocusOn( 1 ); |
215 | } else { | 215 | } else { |
216 | showPage( 0 ); | 216 | showPage( 0 ); |
217 | mGeneral->setFocusOn( 2 ); | 217 | mGeneral->setFocusOn( 2 ); |
218 | } | 218 | } |
219 | checkRecurrence(); | 219 | checkRecurrence(); |
220 | } | 220 | } |
221 | 221 | ||
222 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 222 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
223 | { | 223 | { |
224 | //init(); | 224 | //init(); |
225 | 225 | ||
226 | mTodo = 0; | 226 | mTodo = 0; |
227 | setDefaults(due,relatedTodo,allDay); | 227 | setDefaults(due,relatedTodo,allDay); |
228 | } | 228 | } |
229 | 229 | ||
230 | void KOTodoEditor::loadDefaults() | 230 | void KOTodoEditor::loadDefaults() |
231 | { | 231 | { |
232 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 232 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
233 | } | 233 | } |
234 | 234 | ||
235 | bool KOTodoEditor::processInput( bool emitTime ) | 235 | bool KOTodoEditor::processInput( bool emitTime ) |
236 | { | 236 | { |
237 | if (!validateInput()) return false; | 237 | if (!validateInput()) return false; |
238 | 238 | ||
239 | Todo *todo = 0; | 239 | Todo *todo = 0; |
240 | 240 | ||
241 | if (mTodo) todo = mTodo; | 241 | if (mTodo) todo = mTodo; |
242 | else { | 242 | else { |
243 | todo = new Todo; | 243 | todo = new Todo; |
244 | todo->setOrganizer(KOPrefs::instance()->email()); | 244 | todo->setOrganizer(KOPrefs::instance()->email()); |
245 | } | 245 | } |
246 | 246 | ||
247 | writeTodo(todo); | 247 | writeTodo(todo); |
248 | if ( emitTime ) { | 248 | if ( emitTime ) { |
249 | globalFlagBlockAgenda = 1; | 249 | globalFlagBlockAgenda = 1; |
250 | emit showAgendaView( false ); | 250 | emit showAgendaView( false ); |
251 | if ( todo->hasDueDate() ) | 251 | if ( todo->hasDueDate() ) |
252 | emit jumpToTime( todo->dtDue().date() ); | 252 | emit jumpToTime( todo->dtDue().date() ); |
253 | globalFlagBlockAgenda = 2; | 253 | globalFlagBlockAgenda = 2; |
254 | } | 254 | } |
255 | if (mTodo) { | 255 | if (mTodo) { |
256 | todo->setRevision(todo->revision()+1); | 256 | todo->setRevision(todo->revision()+1); |
257 | emit todoChanged(todo); | 257 | emit todoChanged(todo); |
258 | } else { | 258 | } else { |
259 | mCalendar->addTodo(todo); | 259 | mCalendar->addTodo(todo); |
260 | mTodo = todo; | 260 | mTodo = todo; |
261 | emit todoAdded(todo); | 261 | emit todoAdded(todo); |
262 | } | 262 | } |
263 | 263 | ||
264 | return true; | 264 | return true; |
265 | } | 265 | } |
266 | 266 | ||
267 | void KOTodoEditor::deleteTodo() | 267 | void KOTodoEditor::deleteTodo() |
268 | { | 268 | { |
269 | if (mTodo) { | 269 | if (mTodo) { |
270 | if (KOPrefs::instance()->mConfirm) { | 270 | if (KOPrefs::instance()->mConfirm) { |
271 | switch (msgItemDelete()) { | 271 | switch (msgItemDelete()) { |
272 | case KMessageBox::Continue: // OK | 272 | case KMessageBox::Continue: // OK |
273 | emit todoToBeDeleted(mTodo); | 273 | emit todoToBeDeleted(mTodo); |
274 | emit dialogClose(mTodo); | 274 | emit dialogClose(mTodo); |
275 | mCalendar->deleteTodo(mTodo); | 275 | mCalendar->deleteTodo(mTodo); |
276 | emit todoDeleted(); | 276 | emit todoDeleted(); |
277 | reject(); | 277 | reject(); |
278 | break; | 278 | break; |
279 | } | 279 | } |
280 | } | 280 | } |
281 | else { | 281 | else { |
282 | emit todoToBeDeleted(mTodo); | 282 | emit todoToBeDeleted(mTodo); |
283 | emit dialogClose(mTodo); | 283 | emit dialogClose(mTodo); |
284 | mCalendar->deleteTodo(mTodo); | 284 | mCalendar->deleteTodo(mTodo); |
285 | emit todoDeleted(); | 285 | emit todoDeleted(); |
286 | reject(); | 286 | reject(); |
287 | } | 287 | } |
288 | } else { | 288 | } else { |
289 | reject(); | 289 | reject(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 293 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
294 | { | 294 | { |
295 | mRelatedTodo = relatedEvent; | 295 | mRelatedTodo = relatedEvent; |
296 | 296 | ||
297 | mGeneral->setDefaults(due,allDay); | 297 | mGeneral->setDefaults(due,allDay); |
298 | mDetails->setDefaults(); | 298 | mDetails->setDefaults(); |
299 | showPage( 0 ); | 299 | showPage( 0 ); |
300 | if ( mRelatedTodo ) { | 300 | if ( mRelatedTodo ) { |
301 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); | 301 | mGeneral->fillCalCombo(mRelatedTodo->calID() ); |
302 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 302 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
303 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 303 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
304 | if ( mRelatedTodo->priority() < 3 ) | 304 | if ( mRelatedTodo->priority() < 3 ) |
305 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 305 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
306 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 306 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
307 | int len = mRelatedTodo->summary().length(); | 307 | int len = mRelatedTodo->summary().length(); |
308 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 308 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
309 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 309 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
310 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 310 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
311 | 311 | ||
312 | } else | 312 | } else |
313 | mGeneral->setFocusOn( 2 ); | 313 | mGeneral->setFocusOn( 2 ); |
314 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 314 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
315 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); | 315 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
316 | } | 316 | } |
317 | void KOTodoEditor::checkRecurrence() | 317 | void KOTodoEditor::checkRecurrence() |
318 | { | 318 | { |
319 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 319 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
320 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 320 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
321 | 321 | ||
322 | if ( mTodo ) | 322 | if ( mTodo ) |
323 | mRecurrence->readEvent( mTodo ); | 323 | mRecurrence->readEvent( mTodo ); |
324 | else { | 324 | else { |
325 | bool time = mGeneral->mTimeButton->isChecked(); | 325 | bool time = mGeneral->mTimeButton->isChecked(); |
326 | QDateTime from,to; | 326 | QDateTime from,to; |
327 | if ( time ) { | 327 | if ( time ) { |
328 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 328 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
329 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 329 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
330 | } else { | 330 | } else { |
331 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 331 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
332 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 332 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
333 | } | 333 | } |
334 | if ( to < from ) | 334 | if ( to < from ) |
335 | to = from; | 335 | to = from; |
336 | mRecurrence->setDefaults(from,to); | 336 | mRecurrence->setDefaults(from,to); |
337 | } | 337 | } |
338 | } else { | 338 | } else { |
339 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 339 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
340 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); | 340 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | void KOTodoEditor::readTodo(Todo *todo) | 343 | void KOTodoEditor::readTodo(Todo *todo) |
344 | { | 344 | { |
345 | mGeneral->readTodo(todo); | 345 | mGeneral->readTodo(todo); |
346 | mDetails->readEvent(todo); | 346 | mDetails->readEvent(todo); |
347 | mRelatedTodo = 0;//todo->relatedTo(); | 347 | mRelatedTodo = 0;//todo->relatedTo(); |
348 | // categories | 348 | // categories |
349 | // mCategoryDialog->setSelected(todo->categories()); | 349 | // mCategoryDialog->setSelected(todo->categories()); |
350 | 350 | ||
351 | // We should handle read-only events here. | 351 | // We should handle read-only events here. |
352 | } | 352 | } |
353 | 353 | ||
354 | void KOTodoEditor::writeTodo(Todo *event) | 354 | void KOTodoEditor::writeTodo(Todo *event) |
355 | { | 355 | { |
356 | bool maybeComputeRecurrenceTime = false; | 356 | bool maybeComputeRecurrenceTime = false; |
357 | if( event->hasRecurrenceID() && event->percentComplete() < 100) | 357 | if( event->hasRecurrenceID() && event->percentComplete() < 100) |
358 | maybeComputeRecurrenceTime = true; | 358 | maybeComputeRecurrenceTime = true; |
359 | event->setHasRecurrenceID( false ); | 359 | event->setHasRecurrenceID( false ); |
360 | mGeneral->writeTodo(event); | 360 | mGeneral->writeTodo(event); |
361 | mDetails->writeEvent(event); | 361 | mDetails->writeEvent(event); |
362 | 362 | ||
363 | // set related event, i.e. parent to-do in this case. | 363 | // set related event, i.e. parent to-do in this case. |
364 | if (mRelatedTodo) { | 364 | if (mRelatedTodo) { |
365 | event->setRelatedTo(mRelatedTodo); | 365 | event->setRelatedTo(mRelatedTodo); |
366 | } | 366 | } |
367 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 367 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
368 | mRecurrence->writeEvent(event); | 368 | mRecurrence->writeEvent(event); |
369 | if ( event->doesRecur() ) { | 369 | if ( event->doesRecur() ) { |
370 | int addSec = -1 ; | 370 | int addSec = -1 ; |
371 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) | 371 | if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) |
372 | addSec = 1; | 372 | addSec = 1; |
373 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); | 373 | event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); |
374 | event->setRecurDates(); | 374 | event->setRecurDates(); |
375 | } else { | 375 | } else { |
376 | event->setHasRecurrenceID( false ); | 376 | event->setHasRecurrenceID( false ); |
377 | } | 377 | } |
378 | } else { | 378 | } else { |
379 | event->setHasRecurrenceID( false ); | 379 | event->setHasRecurrenceID( false ); |
380 | event->recurrence()->unsetRecurs(); | 380 | if ( event->doesRecur() ) |
381 | event->recurrence()->unsetRecurs(); | ||
381 | } | 382 | } |
382 | } | 383 | } |
383 | 384 | ||
384 | bool KOTodoEditor::validateInput() | 385 | bool KOTodoEditor::validateInput() |
385 | { | 386 | { |
386 | if (!mGeneral->validateInput()) return false; | 387 | if (!mGeneral->validateInput()) return false; |
387 | if (!mDetails->validateInput()) return false; | 388 | if (!mDetails->validateInput()) return false; |
388 | return true; | 389 | return true; |
389 | } | 390 | } |
390 | 391 | ||
391 | int KOTodoEditor::msgItemDelete() | 392 | int KOTodoEditor::msgItemDelete() |
392 | { | 393 | { |
393 | return KMessageBox::warningContinueCancel(this, | 394 | return KMessageBox::warningContinueCancel(this, |
394 | i18n("This item will be permanently deleted."), | 395 | i18n("This item will be permanently deleted."), |
395 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 396 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
396 | } | 397 | } |
397 | 398 | ||
398 | void KOTodoEditor::modified (int modification) | 399 | void KOTodoEditor::modified (int modification) |
399 | { | 400 | { |
400 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 401 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
401 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 402 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
402 | // mCategoryDialog->setSelected (mTodo->categories ()); | 403 | // mCategoryDialog->setSelected (mTodo->categories ()); |
403 | mGeneral->modified (mTodo, modification); | 404 | mGeneral->modified (mTodo, modification); |
404 | 405 | ||
405 | } | 406 | } |
406 | 407 | ||
407 | void KOTodoEditor::slotLoadTemplate() | 408 | void KOTodoEditor::slotLoadTemplate() |
408 | { | 409 | { |
409 | 410 | ||
410 | QString fileName =locateLocal( "templates", "todos" ); | 411 | QString fileName =locateLocal( "templates", "todos" ); |
411 | QDir t_dir; | 412 | QDir t_dir; |
412 | if ( !t_dir.exists(fileName) ) | 413 | if ( !t_dir.exists(fileName) ) |
413 | t_dir.mkdir ( fileName ); | 414 | t_dir.mkdir ( fileName ); |
414 | fileName += "/todo"; | 415 | fileName += "/todo"; |
415 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 416 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
416 | if ( fileName.length() == 0 ) | 417 | if ( fileName.length() == 0 ) |
417 | return; | 418 | return; |
418 | CalendarLocal cal; | 419 | CalendarLocal cal; |
419 | ICalFormat format; | 420 | ICalFormat format; |
420 | if ( !format.load( &cal, fileName ) ) { | 421 | if ( !format.load( &cal, fileName ) ) { |
421 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 422 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
422 | .arg( fileName ) ); | 423 | .arg( fileName ) ); |
423 | return ; | 424 | return ; |
424 | } | 425 | } |
425 | QPtrList<Todo> todos = cal.todos(); | 426 | QPtrList<Todo> todos = cal.todos(); |
426 | Todo * todo = todos.first(); | 427 | Todo * todo = todos.first(); |
427 | if ( !todo ) { | 428 | if ( !todo ) { |
428 | KMessageBox::error( this, | 429 | KMessageBox::error( this, |
429 | i18n("Template does not\ncontain a valid Todo.")); | 430 | i18n("Template does not\ncontain a valid Todo.")); |
430 | } else { | 431 | } else { |
431 | readTodo( todo ); | 432 | readTodo( todo ); |
432 | } | 433 | } |
433 | 434 | ||
434 | } | 435 | } |
435 | 436 | ||
436 | void KOTodoEditor::slotSaveTemplate() | 437 | void KOTodoEditor::slotSaveTemplate() |
437 | { | 438 | { |
438 | QString fileName =locateLocal( "templates", "todos" ); | 439 | QString fileName =locateLocal( "templates", "todos" ); |
439 | QDir t_dir; | 440 | QDir t_dir; |
440 | if ( !t_dir.exists(fileName) ) | 441 | if ( !t_dir.exists(fileName) ) |
441 | t_dir.mkdir ( fileName ); | 442 | t_dir.mkdir ( fileName ); |
442 | fileName += "/todo"; | 443 | fileName += "/todo"; |
443 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 444 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
444 | if ( fileName.length() > 0 ) | 445 | if ( fileName.length() > 0 ) |
445 | saveTemplate( fileName ); | 446 | saveTemplate( fileName ); |
446 | } | 447 | } |
447 | 448 | ||
448 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 449 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
449 | { | 450 | { |
450 | Todo *todo = new Todo; | 451 | Todo *todo = new Todo; |
451 | writeTodo( todo ); | 452 | writeTodo( todo ); |
452 | saveAsTemplate( todo, templateName ); | 453 | saveAsTemplate( todo, templateName ); |
453 | } | 454 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index fafcb58..f88403c 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -126,678 +126,678 @@ KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | |||
126 | } | 126 | } |
127 | 127 | ||
128 | KOWhatsNextView::~KOWhatsNextView() | 128 | KOWhatsNextView::~KOWhatsNextView() |
129 | { | 129 | { |
130 | } | 130 | } |
131 | 131 | ||
132 | int KOWhatsNextView::maxDatesHint() | 132 | int KOWhatsNextView::maxDatesHint() |
133 | { | 133 | { |
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
136 | 136 | ||
137 | int KOWhatsNextView::currentDateCount() | 137 | int KOWhatsNextView::currentDateCount() |
138 | { | 138 | { |
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
142 | void KOWhatsNextView::clearList() | 142 | void KOWhatsNextView::clearList() |
143 | { | 143 | { |
144 | mTimer->stop(); | 144 | mTimer->stop(); |
145 | mView->setText(" "); | 145 | mView->setText(" "); |
146 | } | 146 | } |
147 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 147 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
148 | { | 148 | { |
149 | QPtrList<Incidence> eventList; | 149 | QPtrList<Incidence> eventList; |
150 | 150 | ||
151 | return eventList; | 151 | return eventList; |
152 | } | 152 | } |
153 | 153 | ||
154 | void KOWhatsNextView::printMe() | 154 | void KOWhatsNextView::printMe() |
155 | { | 155 | { |
156 | #ifdef DESKTOP_VERSION | 156 | #ifdef DESKTOP_VERSION |
157 | mView->printMe(); | 157 | mView->printMe(); |
158 | #endif | 158 | #endif |
159 | } | 159 | } |
160 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 160 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
161 | const QDate &td) | 161 | const QDate &td) |
162 | { | 162 | { |
163 | #ifndef KORG_NOPRINTER | 163 | #ifndef KORG_NOPRINTER |
164 | calPrinter->preview(CalPrinter::Day, fd, td); | 164 | calPrinter->preview(CalPrinter::Day, fd, td); |
165 | #endif | 165 | #endif |
166 | } | 166 | } |
167 | void KOWhatsNextView::updateConfig() | 167 | void KOWhatsNextView::updateConfig() |
168 | { | 168 | { |
169 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 169 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
170 | updateView(); | 170 | updateView(); |
171 | 171 | ||
172 | } | 172 | } |
173 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 173 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
174 | { | 174 | { |
175 | //qDebug("KOWhatsNextView::showEvent "); | 175 | //qDebug("KOWhatsNextView::showEvent "); |
176 | restartTimer(); | 176 | restartTimer(); |
177 | QWidget::showEvent ( e ); | 177 | QWidget::showEvent ( e ); |
178 | } | 178 | } |
179 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 179 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
180 | { | 180 | { |
181 | //qDebug(" KOWhatsNextView::hideEvent"); | 181 | //qDebug(" KOWhatsNextView::hideEvent"); |
182 | mTimer->stop(); | 182 | mTimer->stop(); |
183 | QWidget::hideEvent ( e ); | 183 | QWidget::hideEvent ( e ); |
184 | } | 184 | } |
185 | void KOWhatsNextView::restartTimer() | 185 | void KOWhatsNextView::restartTimer() |
186 | { | 186 | { |
187 | //qDebug("KOWhatsNextView::restartTimer() "); | 187 | //qDebug("KOWhatsNextView::restartTimer() "); |
188 | mTimer->start( 300000 ); | 188 | mTimer->start( 300000 ); |
189 | //mTimer->start( 5000 ); | 189 | //mTimer->start( 5000 ); |
190 | } | 190 | } |
191 | void KOWhatsNextView::updateView() | 191 | void KOWhatsNextView::updateView() |
192 | { | 192 | { |
193 | //qDebug("KOWhatsNextView::updateView() "); | 193 | //qDebug("KOWhatsNextView::updateView() "); |
194 | if ( mTimer->isActive() ) | 194 | if ( mTimer->isActive() ) |
195 | restartTimer(); | 195 | restartTimer(); |
196 | mCurrentMaxPrio = 5; | 196 | mCurrentMaxPrio = 5; |
197 | //qDebug("KOWhatsNextView::updateView() "); | 197 | //qDebug("KOWhatsNextView::updateView() "); |
198 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 198 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
199 | KIconLoader kil("korganizer"); | 199 | KIconLoader kil("korganizer"); |
200 | QString ipath;// = new QString(); | 200 | QString ipath;// = new QString(); |
201 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 201 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
202 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 202 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
203 | mText = "<table width=\"100%\">\n"; | 203 | mText = "<table width=\"100%\">\n"; |
204 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 204 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
205 | #ifdef DESKTOP_VERSION | 205 | #ifdef DESKTOP_VERSION |
206 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 206 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
207 | #else | 207 | #else |
208 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 208 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
209 | #endif | 209 | #endif |
210 | // mText += "<img src=\""; | 210 | // mText += "<img src=\""; |
211 | // mText += ipath; | 211 | // mText += ipath; |
212 | // mText += "\">"; | 212 | // mText += "\">"; |
213 | mEventDate = QDate::currentDate(); | 213 | mEventDate = QDate::currentDate(); |
214 | #ifdef DESKTOP_VERSION | 214 | #ifdef DESKTOP_VERSION |
215 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 215 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
216 | #else | 216 | #else |
217 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 217 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
218 | #endif | 218 | #endif |
219 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 219 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
220 | int iii; | 220 | int iii; |
221 | mTodos.clear(); | 221 | mTodos.clear(); |
222 | QPtrList<Event> events; | 222 | QPtrList<Event> events; |
223 | QPtrList<Todo> todos = calendar()->todos(); | 223 | QPtrList<Todo> todos = calendar()->todos(); |
224 | Todo * todo; | 224 | Todo * todo; |
225 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 225 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
226 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 226 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
227 | bool itemAdded = false; | 227 | bool itemAdded = false; |
228 | for ( iii = 0; iii < daysToShow; ++iii ) { | 228 | for ( iii = 0; iii < daysToShow; ++iii ) { |
229 | QString date; | 229 | QString date; |
230 | itemAdded = false; | 230 | itemAdded = false; |
231 | events = calendar()->events( mEventDate, true ); | 231 | events = calendar()->events( mEventDate, true ); |
232 | 232 | ||
233 | if ( iii == 0 ) { // today !!! | 233 | if ( iii == 0 ) { // today !!! |
234 | todo = todos.first(); | 234 | todo = todos.first(); |
235 | while(todo) { | 235 | while(todo) { |
236 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 236 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
237 | if ( ! itemAdded ) { | 237 | if ( ! itemAdded ) { |
238 | appendDay ( iii, mEventDate ); | 238 | appendDay ( iii, mEventDate ); |
239 | //itemAdded = true; | 239 | //itemAdded = true; |
240 | 240 | ||
241 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 241 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
242 | appendEvent(todo, false, false, !itemAdded ); | 242 | appendEvent(todo, false, false, !itemAdded ); |
243 | itemAdded = true; | 243 | itemAdded = true; |
244 | } | 244 | } |
245 | todo = todos.next(); | 245 | todo = todos.next(); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
250 | if (events.count() > 0) { | 250 | if (events.count() > 0) { |
251 | // mText += "<p></p>"; | 251 | // mText += "<p></p>"; |
252 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 252 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
253 | // mText += "<h2>"; | 253 | // mText += "<h2>"; |
254 | //mText += " <img src=\""; | 254 | //mText += " <img src=\""; |
255 | //mText += ipath; | 255 | //mText += ipath; |
256 | //mText += "\">"; | 256 | //mText += "\">"; |
257 | if ( ! itemAdded ) { | 257 | if ( ! itemAdded ) { |
258 | appendDay ( iii, mEventDate ); | 258 | appendDay ( iii, mEventDate ); |
259 | 259 | ||
260 | } | 260 | } |
261 | // for first day (iii == 0) | 261 | // for first day (iii == 0) |
262 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 262 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
263 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 263 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
264 | // we must append it in the first successful call of appendEvent() | 264 | // we must append it in the first successful call of appendEvent() |
265 | Event *ev = events.first(); | 265 | Event *ev = events.first(); |
266 | while(ev) { | 266 | while(ev) { |
267 | //qDebug("+++++event append %s", ev->summary().latin1()); | 267 | //qDebug("+++++event append %s", ev->summary().latin1()); |
268 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 268 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
269 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 269 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
270 | itemAdded = true; | 270 | itemAdded = true; |
271 | } | 271 | } |
272 | ev = events.next(); | 272 | ev = events.next(); |
273 | } | 273 | } |
274 | 274 | ||
275 | //mText += "</table>\n"; | 275 | //mText += "</table>\n"; |
276 | } | 276 | } |
277 | 277 | ||
278 | todo = todos.first(); | 278 | todo = todos.first(); |
279 | while(todo) { | 279 | while(todo) { |
280 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 280 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
281 | if ( ! itemAdded ) { | 281 | if ( ! itemAdded ) { |
282 | appendDay ( iii, mEventDate ); | 282 | appendDay ( iii, mEventDate ); |
283 | //itemAdded = true; | 283 | //itemAdded = true; |
284 | } | 284 | } |
285 | appendEvent(todo, false , iii!= 0,!itemAdded); | 285 | appendEvent(todo, false , iii!= 0,!itemAdded); |
286 | itemAdded = true; | 286 | itemAdded = true; |
287 | } | 287 | } |
288 | todo = todos.next(); | 288 | todo = todos.next(); |
289 | } | 289 | } |
290 | if ( !itemAdded && iii == 0 ) { | 290 | if ( !itemAdded && iii == 0 ) { |
291 | // appendDay ( iii, mEventDate ); | 291 | // appendDay ( iii, mEventDate ); |
292 | //mText += "<table>"; | 292 | //mText += "<table>"; |
293 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 293 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
294 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 294 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
295 | //mText +="</table>"; | 295 | //mText +="</table>"; |
296 | } | 296 | } |
297 | if ( itemAdded ) | 297 | if ( itemAdded ) |
298 | mText += "</table>\n"; | 298 | mText += "</table>\n"; |
299 | mEventDate = mEventDate.addDays( 1 ); | 299 | mEventDate = mEventDate.addDays( 1 ); |
300 | } | 300 | } |
301 | 301 | ||
302 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 302 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
303 | if (todos.count() > 0 && topmostPrios > 0 ) { | 303 | if (todos.count() > 0 && topmostPrios > 0 ) { |
304 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 304 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
305 | // mText += "<h2>"; | 305 | // mText += "<h2>"; |
306 | //<img src=\""; | 306 | //<img src=\""; |
307 | // mText += ipath; | 307 | // mText += ipath; |
308 | // mText += "\">"; | 308 | // mText += "\">"; |
309 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 309 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
310 | 310 | ||
311 | //mText += "<ul>\n"; | 311 | //mText += "<ul>\n"; |
312 | bool gotone = false; | 312 | bool gotone = false; |
313 | int priority = 1; | 313 | int priority = 1; |
314 | int priosFound = 0; | 314 | int priosFound = 0; |
315 | #ifdef DESKTOP_VERSION | 315 | #ifdef DESKTOP_VERSION |
316 | mText +="<p></p>"; | 316 | mText +="<p></p>"; |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 319 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
320 | mText += "<ul>\n"; | 320 | mText += "<ul>\n"; |
321 | while (!gotone && priority<6) { | 321 | while (!gotone && priority<6) { |
322 | todo = todos.first(); | 322 | todo = todos.first(); |
323 | while(todo) { | 323 | while(todo) { |
324 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 324 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
325 | mCurrentMaxPrio = priority - priosFound + topmostPrios -1; | 325 | mCurrentMaxPrio = priority - priosFound + topmostPrios -1; |
326 | if ( appendTodo(todo) ) | 326 | if ( appendTodo(todo) ) |
327 | gotone = true; | 327 | gotone = true; |
328 | } | 328 | } |
329 | todo = todos.next(); | 329 | todo = todos.next(); |
330 | } | 330 | } |
331 | if ( gotone ) { | 331 | if ( gotone ) { |
332 | gotone = false; | 332 | gotone = false; |
333 | ++priosFound; | 333 | ++priosFound; |
334 | if ( priosFound == topmostPrios ) | 334 | if ( priosFound == topmostPrios ) |
335 | break; | 335 | break; |
336 | } | 336 | } |
337 | priority++; | 337 | priority++; |
338 | // kdDebug() << "adding the todos..." << endl; | 338 | // kdDebug() << "adding the todos..." << endl; |
339 | } | 339 | } |
340 | mText += "</ul>\n"; | 340 | mText += "</ul>\n"; |
341 | } | 341 | } |
342 | 342 | ||
343 | int replys = 0; | 343 | int replys = 0; |
344 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 344 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
345 | if (events.count() > 0) { | 345 | if (events.count() > 0) { |
346 | Event *ev = events.first(); | 346 | Event *ev = events.first(); |
347 | while(ev) { | 347 | while(ev) { |
348 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 348 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
349 | if (me!=0) { | 349 | if (me!=0) { |
350 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 350 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
351 | if (replys == 0) { | 351 | if (replys == 0) { |
352 | mText += "<p></p>"; | 352 | mText += "<p></p>"; |
353 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 353 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
354 | //mText += "<h2>"; | 354 | //mText += "<h2>"; |
355 | //<img src=\""; | 355 | //<img src=\""; |
356 | // mText += ipath; | 356 | // mText += ipath; |
357 | // mText += "\">"; | 357 | // mText += "\">"; |
358 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 358 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
359 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 359 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
360 | mText += "<table>\n"; | 360 | mText += "<table>\n"; |
361 | } | 361 | } |
362 | replys++; | 362 | replys++; |
363 | appendEvent(ev,true); | 363 | appendEvent(ev,true); |
364 | } | 364 | } |
365 | } | 365 | } |
366 | ev = events.next(); | 366 | ev = events.next(); |
367 | } | 367 | } |
368 | } | 368 | } |
369 | todos = calendar()->todos(); | 369 | todos = calendar()->todos(); |
370 | if (todos.count() > 0) { | 370 | if (todos.count() > 0) { |
371 | Todo *to = todos.first(); | 371 | Todo *to = todos.first(); |
372 | while(to) { | 372 | while(to) { |
373 | if ( !to->isCompleted() ){ | 373 | if ( !to->isCompleted() ){ |
374 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 374 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
375 | if (me!=0) { | 375 | if (me!=0) { |
376 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 376 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
377 | if (replys == 0) { | 377 | if (replys == 0) { |
378 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 378 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
379 | mText += "<table>\n"; | 379 | mText += "<table>\n"; |
380 | } | 380 | } |
381 | replys++; | 381 | replys++; |
382 | appendEvent(to, true); | 382 | appendEvent(to, true); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | to = todos.next(); | 386 | to = todos.next(); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | if (replys > 0 ) mText += "</table>\n"; | 389 | if (replys > 0 ) mText += "</table>\n"; |
390 | 390 | ||
391 | 391 | ||
392 | mText += "</td></tr>\n</table>\n"; | 392 | mText += "</td></tr>\n</table>\n"; |
393 | 393 | ||
394 | mView->setText(mText); | 394 | mView->setText(mText); |
395 | mView->setFocus(); | 395 | mView->setFocus(); |
396 | 396 | ||
397 | // QPixmap bPix = SmallIcon( "back" ); | 397 | // QPixmap bPix = SmallIcon( "back" ); |
398 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 398 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
399 | // QWidget* test = new QWidget(); | 399 | // QWidget* test = new QWidget(); |
400 | // test->setBackgroundMode(FixedPixmap ); | 400 | // test->setBackgroundMode(FixedPixmap ); |
401 | // test->setBackgroundPixmap ( bPix ); | 401 | // test->setBackgroundPixmap ( bPix ); |
402 | // test->resize( 300, 400 ); | 402 | // test->resize( 300, 400 ); |
403 | // test->show(); | 403 | // test->show(); |
404 | // mView->setBackgroundMode(FixedPixmap ); | 404 | // mView->setBackgroundMode(FixedPixmap ); |
405 | // mView->setBackgroundPixmap ( bPix ); | 405 | // mView->setBackgroundPixmap ( bPix ); |
406 | // qDebug("%s ",mText.latin1()); | 406 | // qDebug("%s ",mText.latin1()); |
407 | } | 407 | } |
408 | 408 | ||
409 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 409 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
410 | { | 410 | { |
411 | QString date; | 411 | QString date; |
412 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 412 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
413 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 413 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
414 | if ( i == 0 ) { | 414 | if ( i == 0 ) { |
415 | //mText += "<table>\n"; | 415 | //mText += "<table>\n"; |
416 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 416 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
417 | } | 417 | } |
418 | else if ( i == 1 ) | 418 | else if ( i == 1 ) |
419 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 419 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
420 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 420 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
421 | mText += "<h2>" + date + "</h2>\n"; | 421 | mText += "<h2>" + date + "</h2>\n"; |
422 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 422 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
423 | mText += "<table>\n"; | 423 | mText += "<table>\n"; |
424 | 424 | ||
425 | 425 | ||
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | if ( i == 0 ) { | 428 | if ( i == 0 ) { |
429 | //mText += "<table>\n"; | 429 | //mText += "<table>\n"; |
430 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 430 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
431 | } | 431 | } |
432 | 432 | ||
433 | #ifdef DESKTOP_VERSION | 433 | #ifdef DESKTOP_VERSION |
434 | else if ( i == 1 ) { | 434 | else if ( i == 1 ) { |
435 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 435 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
436 | } | 436 | } |
437 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 437 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
438 | #else | 438 | #else |
439 | else if ( i == 1 ) { | 439 | else if ( i == 1 ) { |
440 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 440 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
441 | } | 441 | } |
442 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 442 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
443 | 443 | ||
444 | #endif | 444 | #endif |
445 | mText += "<h2>" + date + "</h2>\n"; | 445 | mText += "<h2>" + date + "</h2>\n"; |
446 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 446 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
447 | mText += "<table>\n"; | 447 | mText += "<table>\n"; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
451 | 451 | ||
452 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 452 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
453 | { | 453 | { |
454 | updateView(); | 454 | updateView(); |
455 | } | 455 | } |
456 | 456 | ||
457 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 457 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
458 | { | 458 | { |
459 | } | 459 | } |
460 | 460 | ||
461 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 461 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
462 | { | 462 | { |
463 | switch(action) { | 463 | switch(action) { |
464 | case KOGlobals::EVENTADDED: | 464 | case KOGlobals::EVENTADDED: |
465 | updateView(); | 465 | updateView(); |
466 | break; | 466 | break; |
467 | case KOGlobals::EVENTEDITED: | 467 | case KOGlobals::EVENTEDITED: |
468 | updateView(); | 468 | updateView(); |
469 | break; | 469 | break; |
470 | case KOGlobals::EVENTDELETED: | 470 | case KOGlobals::EVENTDELETED: |
471 | updateView(); | 471 | updateView(); |
472 | break; | 472 | break; |
473 | default: | 473 | default: |
474 | updateView(); | 474 | updateView(); |
475 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 475 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 479 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
480 | { | 480 | { |
481 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 481 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
482 | return false; | 482 | return false; |
483 | QDateTime cdt = QDateTime::currentDateTime(); | 483 | QDateTime cdt = QDateTime::currentDateTime(); |
484 | QDateTime noc; | 484 | QDateTime noc; |
485 | QString tempText; | 485 | QString tempText; |
486 | if ( appendTable && !notRed ) { | 486 | if ( appendTable && !notRed ) { |
487 | tempText = "<table>"; | 487 | tempText = "<table>"; |
488 | } | 488 | } |
489 | bool ok = true; | 489 | bool ok = true; |
490 | if ( reply ) { | 490 | if ( reply ) { |
491 | noc = ev->getNextOccurence( cdt, &ok ); | 491 | noc = ev->getNextOccurence( cdt, &ok ); |
492 | if (! ok && ev->typeID() == eventID) | 492 | if (! ok && ev->typeID() == eventID) |
493 | return false; | 493 | return false; |
494 | } | 494 | } |
495 | bool bDay = false; | 495 | bool bDay = false; |
496 | if ( ev->isBirthday() || ev->isAnniversary() ) | 496 | if ( ev->isBirthday() || ev->isAnniversary() ) |
497 | bDay = true; | 497 | bDay = true; |
498 | tempText += "<tr><td><b>"; | 498 | tempText += "<tr><td><b>"; |
499 | if (ev->typeID() == eventID ) { | 499 | if (ev->typeID() == eventID ) { |
500 | if (reply) { | 500 | if (reply) { |
501 | if (!ev->doesFloat()) | 501 | if (!ev->doesFloat()) |
502 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 502 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
503 | else | 503 | else |
504 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 504 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
505 | 505 | ||
506 | } else { | 506 | } else { |
507 | if (!ev->doesFloat()) { | 507 | if (!ev->doesFloat()) { |
508 | Event *event = static_cast<Event *>(ev); | 508 | Event *event = static_cast<Event *>(ev); |
509 | QDateTime st,end; | 509 | QDateTime st,end; |
510 | if ( event->recurrence()->doesRecur() ) { | 510 | if ( event->doesRecur() ) { |
511 | QDate recDate= mEventDate; | 511 | QDate recDate= mEventDate; |
512 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 512 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
513 | while ( ! event->recursOn( recDate ) ) { | 513 | while ( ! event->recursOn( recDate ) ) { |
514 | recDate = recDate.addDays( -1 ); | 514 | recDate = recDate.addDays( -1 ); |
515 | 515 | ||
516 | } | 516 | } |
517 | st = QDateTime ( recDate, event->dtStart().time() ); | 517 | st = QDateTime ( recDate, event->dtStart().time() ); |
518 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 518 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
519 | } | 519 | } |
520 | else { | 520 | else { |
521 | st = event->dtStart(); | 521 | st = event->dtStart(); |
522 | end = event->dtEnd(); | 522 | end = event->dtEnd(); |
523 | } | 523 | } |
524 | 524 | ||
525 | 525 | ||
526 | QString dateText; | 526 | QString dateText; |
527 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 527 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
528 | if ( st.date() < mEventDate ) | 528 | if ( st.date() < mEventDate ) |
529 | dateText = "++:++-"; | 529 | dateText = "++:++-"; |
530 | else | 530 | else |
531 | dateText = event->dtStartTimeStr() + "-"; | 531 | dateText = event->dtStartTimeStr() + "-"; |
532 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) | 532 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) |
533 | dateText += " "; | 533 | dateText += " "; |
534 | if ( end.date() > mEventDate ) | 534 | if ( end.date() > mEventDate ) |
535 | dateText += "++:++"; | 535 | dateText += "++:++"; |
536 | else | 536 | else |
537 | dateText += event->dtEndTimeStr(); | 537 | dateText += event->dtEndTimeStr(); |
538 | if ( notRed ) | 538 | if ( notRed ) |
539 | tempText += dateText; | 539 | tempText += dateText; |
540 | else { | 540 | else { |
541 | if ( end < cdt ) { | 541 | if ( end < cdt ) { |
542 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 542 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
543 | return false; | 543 | return false; |
544 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 544 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
545 | } | 545 | } |
546 | else if ( st < cdt ) | 546 | else if ( st < cdt ) |
547 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 547 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
548 | else | 548 | else |
549 | tempText += dateText; | 549 | tempText += dateText; |
550 | 550 | ||
551 | } | 551 | } |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | if ( bDay ) { | 554 | if ( bDay ) { |
555 | 555 | ||
556 | if ( ev->isBirthday()) | 556 | if ( ev->isBirthday()) |
557 | tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; | 557 | tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; |
558 | else | 558 | else |
559 | tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; | 559 | tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; |
560 | } else { | 560 | } else { |
561 | if ( ((Event*)ev)->isMultiDay() ) { | 561 | if ( ((Event*)ev)->isMultiDay() ) { |
562 | QString dfs = KGlobal::locale()->dateFormatShort(); | 562 | QString dfs = KGlobal::locale()->dateFormatShort(); |
563 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 563 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
564 | tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtStart().date(), true, KLocale::Userdefined) + "-"; | 564 | tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtStart().date(), true, KLocale::Userdefined) + "-"; |
565 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) | 565 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) |
566 | tempText += " "; | 566 | tempText += " "; |
567 | tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtEnd().date(), true, KLocale::Userdefined); | 567 | tempText +=KGlobal::locale()->formatDate(((Event*)ev)->dtEnd().date(), true, KLocale::Userdefined); |
568 | KGlobal::locale()->setDateFormatShort(dfs); | 568 | KGlobal::locale()->setDateFormatShort(dfs); |
569 | } else { | 569 | } else { |
570 | tempText += " " ;//i18n("Allday:"); | 570 | tempText += " " ;//i18n("Allday:"); |
571 | } | 571 | } |
572 | } | 572 | } |
573 | 573 | ||
574 | } | 574 | } |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | mTodos.append( ev ); | 577 | mTodos.append( ev ); |
578 | tempText += i18n("ToDo:"); | 578 | tempText += i18n("ToDo:"); |
579 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) | 579 | if ( KOPrefs::instance()->mWhatsNextTime2Lines ) |
580 | tempText += " "; | 580 | tempText += " "; |
581 | if (reply) { | 581 | if (reply) { |
582 | tempText += " "; | 582 | tempText += " "; |
583 | if ( noc != cdt ) { | 583 | if ( noc != cdt ) { |
584 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 584 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
585 | } | 585 | } |
586 | } else { | 586 | } else { |
587 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 587 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
588 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 588 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
589 | QString dfs = KGlobal::locale()->dateFormatShort(); | 589 | QString dfs = KGlobal::locale()->dateFormatShort(); |
590 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 590 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
591 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 591 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
592 | KGlobal::locale()->setDateFormatShort(dfs); | 592 | KGlobal::locale()->setDateFormatShort(dfs); |
593 | } else { | 593 | } else { |
594 | if (!ev->doesFloat() ) | 594 | if (!ev->doesFloat() ) |
595 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 595 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
596 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 596 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
597 | 597 | ||
598 | 598 | ||
599 | } else | 599 | } else |
600 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 600 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
601 | mTodos.append( ev ); | 601 | mTodos.append( ev ); |
602 | } | 602 | } |
603 | } | 603 | } |
604 | } | 604 | } |
605 | tempText += "</b></td><td>"; | 605 | tempText += "</b></td><td>"; |
606 | bool needClose = false; | 606 | bool needClose = false; |
607 | if ( ev->cancelled() ) { | 607 | if ( ev->cancelled() ) { |
608 | tempText += "<font color=\"#F00000\">[c"; | 608 | tempText += "<font color=\"#F00000\">[c"; |
609 | needClose =true; | 609 | needClose =true; |
610 | 610 | ||
611 | } | 611 | } |
612 | if ( ev->isAlarmEnabled() && ev->alarmEnabled()) { | 612 | if ( ev->isAlarmEnabled() && ev->alarmEnabled()) { |
613 | if ( !needClose) | 613 | if ( !needClose) |
614 | tempText +="["; | 614 | tempText +="["; |
615 | tempText += "a"; | 615 | tempText += "a"; |
616 | needClose =true; | 616 | needClose =true; |
617 | 617 | ||
618 | } | 618 | } |
619 | if ( ev->description().length() > 0 ) { | 619 | if ( ev->description().length() > 0 ) { |
620 | if ( !needClose) | 620 | if ( !needClose) |
621 | tempText +="["; | 621 | tempText +="["; |
622 | tempText += "i"; | 622 | tempText += "i"; |
623 | needClose =true; | 623 | needClose =true; |
624 | } | 624 | } |
625 | if ( ev->recurrence()->doesRecur() ) { | 625 | if ( ev->doesRecur() ) { |
626 | if ( !needClose) | 626 | if ( !needClose) |
627 | tempText +="["; | 627 | tempText +="["; |
628 | tempText += "r"; | 628 | tempText += "r"; |
629 | needClose =true; | 629 | needClose =true; |
630 | } | 630 | } |
631 | if ( needClose ) { | 631 | if ( needClose ) { |
632 | tempText += "] "; | 632 | tempText += "] "; |
633 | } | 633 | } |
634 | if ( ev->cancelled() ) | 634 | if ( ev->cancelled() ) |
635 | tempText += "</font>"; | 635 | tempText += "</font>"; |
636 | tempText += "<a "; | 636 | tempText += "<a "; |
637 | if (ev->typeID() == eventID ) tempText += "href=\"event:"; | 637 | if (ev->typeID() == eventID ) tempText += "href=\"event:"; |
638 | if (ev->typeID() == todoID ) tempText += "href=\"todo:"; | 638 | if (ev->typeID() == todoID ) tempText += "href=\"todo:"; |
639 | tempText += ev->uid() + "\">"; | 639 | tempText += ev->uid() + "\">"; |
640 | if ( ev->summary().length() > 0 ) | 640 | if ( ev->summary().length() > 0 ) |
641 | tempText += ev->summary(); | 641 | tempText += ev->summary(); |
642 | else | 642 | else |
643 | tempText += i18n("-no summary-"); | 643 | tempText += i18n("-no summary-"); |
644 | if ( bDay ) { | 644 | if ( bDay ) { |
645 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); | 645 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); |
646 | if ( ok ) { | 646 | if ( ok ) { |
647 | int years = 0; | 647 | int years = 0; |
648 | if ( ev->typeID() == todoID ) { | 648 | if ( ev->typeID() == todoID ) { |
649 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); | 649 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); |
650 | } else | 650 | } else |
651 | years = noc.date().year() - ev->dtStart().date().year(); | 651 | years = noc.date().year() - ev->dtStart().date().year(); |
652 | tempText += i18n(" (%1 y.)"). arg( years ); | 652 | tempText += i18n(" (%1 y.)"). arg( years ); |
653 | } | 653 | } |
654 | } | 654 | } |
655 | 655 | ||
656 | tempText += "</a>"; | 656 | tempText += "</a>"; |
657 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 657 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
658 | if ( !ev->location().isEmpty() ) | 658 | if ( !ev->location().isEmpty() ) |
659 | tempText += " ("+ev->location() +")"; | 659 | tempText += " ("+ev->location() +")"; |
660 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 660 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
661 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 661 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
662 | tempText += "</td></tr>\n"; | 662 | tempText += "</td></tr>\n"; |
663 | mText += tempText; | 663 | mText += tempText; |
664 | return true; | 664 | return true; |
665 | } | 665 | } |
666 | 666 | ||
667 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 667 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
668 | { | 668 | { |
669 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 669 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
670 | 670 | ||
671 | mTodos.append( ev ); | 671 | mTodos.append( ev ); |
672 | if ( !isSub ) | 672 | if ( !isSub ) |
673 | mText += "<p>"; | 673 | mText += "<p>"; |
674 | else | 674 | else |
675 | mText += "<li>"; | 675 | mText += "<li>"; |
676 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 676 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
677 | 677 | ||
678 | 678 | ||
679 | mText += ind; | 679 | mText += ind; |
680 | bool needClose = false; | 680 | bool needClose = false; |
681 | if ( ev->cancelled() ) { | 681 | if ( ev->cancelled() ) { |
682 | mText += "<font color=\"#F00000\">[c"; | 682 | mText += "<font color=\"#F00000\">[c"; |
683 | needClose =true; | 683 | needClose =true; |
684 | 684 | ||
685 | } | 685 | } |
686 | if ( ev->isAlarmEnabled() && ev->alarmEnabled() ) { | 686 | if ( ev->isAlarmEnabled() && ev->alarmEnabled() ) { |
687 | if ( !needClose) | 687 | if ( !needClose) |
688 | mText +="["; | 688 | mText +="["; |
689 | mText += "a"; | 689 | mText += "a"; |
690 | needClose =true; | 690 | needClose =true; |
691 | 691 | ||
692 | } | 692 | } |
693 | 693 | ||
694 | if ( ev->description().length() > 0 ) { | 694 | if ( ev->description().length() > 0 ) { |
695 | if ( !needClose) | 695 | if ( !needClose) |
696 | mText +="["; | 696 | mText +="["; |
697 | mText += "i"; | 697 | mText += "i"; |
698 | needClose =true; | 698 | needClose =true; |
699 | } | 699 | } |
700 | if ( ev->doesRecur() ) { | 700 | if ( ev->doesRecur() ) { |
701 | if ( !needClose) | 701 | if ( !needClose) |
702 | mText +="["; | 702 | mText +="["; |
703 | mText += "r"; | 703 | mText += "r"; |
704 | needClose =true; | 704 | needClose =true; |
705 | } | 705 | } |
706 | // if ( ev->recurrence()->doesRecur() ) { | 706 | // if ( ev->recurrence()->doesRecur() ) { |
707 | // if ( !needClose) | 707 | // if ( !needClose) |
708 | // mText +="("; | 708 | // mText +="("; |
709 | // mText += "r"; | 709 | // mText += "r"; |
710 | // needClose =true; | 710 | // needClose =true; |
711 | // } | 711 | // } |
712 | if ( needClose ) | 712 | if ( needClose ) |
713 | mText += "] "; | 713 | mText += "] "; |
714 | if ( ev->cancelled() ) | 714 | if ( ev->cancelled() ) |
715 | mText += "</font>"; | 715 | mText += "</font>"; |
716 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 716 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
717 | if ( ev->summary().length() > 0 ) | 717 | if ( ev->summary().length() > 0 ) |
718 | mText += ev->summary(); | 718 | mText += ev->summary(); |
719 | else | 719 | else |
720 | mText += i18n("-no summary-"); | 720 | mText += i18n("-no summary-"); |
721 | mText += "</a>"; | 721 | mText += "</a>"; |
722 | if ( ((Todo*)ev)->hasDueDate () ) { | 722 | if ( ((Todo*)ev)->hasDueDate () ) { |
723 | QString year = ""; | 723 | QString year = ""; |
724 | int ye = ((Todo*)ev)->dtDue().date().year(); | 724 | int ye = ((Todo*)ev)->dtDue().date().year(); |
725 | if ( QDateTime::currentDateTime().date().year() != ye ) | 725 | if ( QDateTime::currentDateTime().date().year() != ye ) |
726 | year = QString::number( ye ); | 726 | year = QString::number( ye ); |
727 | QString dfs = KGlobal::locale()->dateFormatShort(); | 727 | QString dfs = KGlobal::locale()->dateFormatShort(); |
728 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 728 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
729 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 729 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
730 | KGlobal::locale()->setDateFormatShort(dfs); | 730 | KGlobal::locale()->setDateFormatShort(dfs); |
731 | } | 731 | } |
732 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 732 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
733 | if ( !ev->location().isEmpty() ) | 733 | if ( !ev->location().isEmpty() ) |
734 | mText += " ("+ev->location() +")"; | 734 | mText += " ("+ev->location() +")"; |
735 | if ( !isSub ) { | 735 | if ( !isSub ) { |
736 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 736 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
737 | mText += " ["+ev->relatedTo()->summary() +"]"; | 737 | mText += " ["+ev->relatedTo()->summary() +"]"; |
738 | mText += "</p>\n"; | 738 | mText += "</p>\n"; |
739 | } | 739 | } |
740 | else { | 740 | else { |
741 | ind += "-"; | 741 | ind += "-"; |
742 | mText += "</li>\n"; | 742 | mText += "</li>\n"; |
743 | } | 743 | } |
744 | QPtrList<Incidence> Relations = ev->relations(); | 744 | QPtrList<Incidence> Relations = ev->relations(); |
745 | Incidence *to; | 745 | Incidence *to; |
746 | for (to=Relations.first();to;to=Relations.next()) { | 746 | for (to=Relations.first();to;to=Relations.next()) { |
747 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) | 747 | if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) |
748 | appendTodo( to, ind , true ); | 748 | appendTodo( to, ind , true ); |
749 | } | 749 | } |
750 | 750 | ||
751 | return true; | 751 | return true; |
752 | } | 752 | } |
753 | 753 | ||
754 | /* | 754 | /* |
755 | void KOWhatsNextView::createEventViewer() | 755 | void KOWhatsNextView::createEventViewer() |
756 | { | 756 | { |
757 | if (!mEventViewer) { | 757 | if (!mEventViewer) { |
758 | 758 | ||
759 | mEventViewer = new KOEventViewerDialog(this); | 759 | mEventViewer = new KOEventViewerDialog(this); |
760 | } | 760 | } |
761 | } | 761 | } |
762 | */ | 762 | */ |
763 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 763 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
764 | { | 764 | { |
765 | mEventViewer = v; | 765 | mEventViewer = v; |
766 | } | 766 | } |
767 | 767 | ||
768 | // TODO: Create this function in CalendarView and remove it from here | 768 | // TODO: Create this function in CalendarView and remove it from here |
769 | void KOWhatsNextView::showIncidence(const QString &uid) | 769 | void KOWhatsNextView::showIncidence(const QString &uid) |
770 | { | 770 | { |
771 | 771 | ||
772 | if ( !mEventViewer ) { | 772 | if ( !mEventViewer ) { |
773 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 773 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
774 | return; | 774 | return; |
775 | } | 775 | } |
776 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 776 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
777 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 777 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
778 | if (uid.startsWith("event:")) { | 778 | if (uid.startsWith("event:")) { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | Event *event = calendar()->event(uid.mid(8)); | 780 | Event *event = calendar()->event(uid.mid(8)); |
781 | #else | 781 | #else |
782 | Event *event = calendar()->event(uid.mid(6)); | 782 | Event *event = calendar()->event(uid.mid(6)); |
783 | #endif | 783 | #endif |
784 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 784 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
785 | if (!event) return; | 785 | if (!event) return; |
786 | //createEventViewer(); | 786 | //createEventViewer(); |
787 | mEventViewer->setEvent(event); | 787 | mEventViewer->setEvent(event); |
788 | } else if (uid.startsWith("todo:")) { | 788 | } else if (uid.startsWith("todo:")) { |
789 | #ifdef DESKTOP_VERSION | 789 | #ifdef DESKTOP_VERSION |
790 | Todo *todo = calendar()->todo(uid.mid(7)); | 790 | Todo *todo = calendar()->todo(uid.mid(7)); |
791 | #else | 791 | #else |
792 | Todo *todo = calendar()->todo(uid.mid(5)); | 792 | Todo *todo = calendar()->todo(uid.mid(5)); |
793 | #endif | 793 | #endif |
794 | if (!todo) return; | 794 | if (!todo) return; |
795 | //createEventViewer(); | 795 | //createEventViewer(); |
796 | mEventViewer->setTodo(todo); | 796 | mEventViewer->setTodo(todo); |
797 | } else { | 797 | } else { |
798 | return; | 798 | return; |
799 | 799 | ||
800 | } | 800 | } |
801 | mEventViewer->showMe(); | 801 | mEventViewer->showMe(); |
802 | mEventViewer->raise(); | 802 | mEventViewer->raise(); |
803 | } | 803 | } |
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index ad66639..0766fd9 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -1,415 +1,416 @@ | |||
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 "event.h" | 25 | #include "event.h" |
26 | 26 | ||
27 | using namespace KCal; | 27 | using namespace KCal; |
28 | 28 | ||
29 | Event::Event() : | 29 | Event::Event() : |
30 | mHasEndDate( false ), mTransparency( Opaque ) | 30 | mHasEndDate( false ), mTransparency( Opaque ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | 33 | ||
34 | Event::Event(const Event &e) : Incidence(e) | 34 | Event::Event(const Event &e) : Incidence(e) |
35 | { | 35 | { |
36 | mDtEnd = e.mDtEnd; | 36 | mDtEnd = e.mDtEnd; |
37 | mHasEndDate = e.mHasEndDate; | 37 | mHasEndDate = e.mHasEndDate; |
38 | mTransparency = e.mTransparency; | 38 | mTransparency = e.mTransparency; |
39 | } | 39 | } |
40 | 40 | ||
41 | Event::~Event() | 41 | Event::~Event() |
42 | { | 42 | { |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence *Event::clone() | 45 | Incidence *Event::clone() |
46 | { | 46 | { |
47 | return new Event(*this); | 47 | return new Event(*this); |
48 | } | 48 | } |
49 | 49 | ||
50 | bool KCal::operator==( const Event& e1, const Event& e2 ) | 50 | bool KCal::operator==( const Event& e1, const Event& e2 ) |
51 | { | 51 | { |
52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && | 52 | return operator==( (const Incidence&)e1, (const Incidence&)e2 ) && |
53 | e1.dtEnd() == e2.dtEnd() && | 53 | e1.dtEnd() == e2.dtEnd() && |
54 | e1.hasEndDate() == e2.hasEndDate() && | 54 | e1.hasEndDate() == e2.hasEndDate() && |
55 | e1.transparency() == e2.transparency(); | 55 | e1.transparency() == e2.transparency(); |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | bool Event::contains ( Event* from ) | 59 | bool Event::contains ( Event* from ) |
60 | { | 60 | { |
61 | 61 | ||
62 | if ( !from->summary().isEmpty() ) | 62 | if ( !from->summary().isEmpty() ) |
63 | if ( !summary().startsWith( from->summary() )) | 63 | if ( !summary().startsWith( from->summary() )) |
64 | return false; | 64 | return false; |
65 | if ( from->dtStart().isValid() ) | 65 | if ( from->dtStart().isValid() ) |
66 | if (dtStart() != from->dtStart() ) | 66 | if (dtStart() != from->dtStart() ) |
67 | return false; | 67 | return false; |
68 | if ( from->dtEnd().isValid() ) | 68 | if ( from->dtEnd().isValid() ) |
69 | if ( dtEnd() != from->dtEnd() ) | 69 | if ( dtEnd() != from->dtEnd() ) |
70 | return false; | 70 | return false; |
71 | if ( !from->location().isEmpty() ) | 71 | if ( !from->location().isEmpty() ) |
72 | if ( !location().startsWith( from->location() ) ) | 72 | if ( !location().startsWith( from->location() ) ) |
73 | return false; | 73 | return false; |
74 | if ( !from->description().isEmpty() ) | 74 | if ( !from->description().isEmpty() ) |
75 | if ( !description().startsWith( from->description() )) | 75 | if ( !description().startsWith( from->description() )) |
76 | return false; | 76 | return false; |
77 | if ( from->alarms().count() ) { | 77 | if ( from->alarms().count() ) { |
78 | Alarm *a = from->alarms().first(); | 78 | Alarm *a = from->alarms().first(); |
79 | if ( a->enabled() ){ | 79 | if ( a->enabled() ){ |
80 | if ( !alarms().count() ) | 80 | if ( !alarms().count() ) |
81 | return false; | 81 | return false; |
82 | Alarm *b = alarms().first(); | 82 | Alarm *b = alarms().first(); |
83 | if( ! b->enabled() ) | 83 | if( ! b->enabled() ) |
84 | return false; | 84 | return false; |
85 | if ( ! (a->offset() == b->offset() )) | 85 | if ( ! (a->offset() == b->offset() )) |
86 | return false; | 86 | return false; |
87 | } | 87 | } |
88 | } | 88 | } |
89 | QStringList cat = categories(); | 89 | QStringList cat = categories(); |
90 | QStringList catFrom = from->categories(); | 90 | QStringList catFrom = from->categories(); |
91 | QString nCat; | 91 | QString nCat; |
92 | unsigned int iii; | 92 | unsigned int iii; |
93 | for ( iii = 0; iii < catFrom.count();++iii ) { | 93 | for ( iii = 0; iii < catFrom.count();++iii ) { |
94 | nCat = catFrom[iii]; | 94 | nCat = catFrom[iii]; |
95 | if ( !nCat.isEmpty() ) | 95 | if ( !nCat.isEmpty() ) |
96 | if ( !cat.contains( nCat )) { | 96 | if ( !cat.contains( nCat )) { |
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | } | 99 | } |
100 | if ( from->doesRecur() ) | 100 | if ( from->doesRecur() ) |
101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) | 101 | if ( from->doesRecur() != doesRecur() && ! (from->doesRecur()== Recurrence::rYearlyMonth && doesRecur()== Recurrence::rYearlyDay) ) |
102 | return false; | 102 | return false; |
103 | return true; | 103 | return true; |
104 | } | 104 | } |
105 | 105 | ||
106 | void Event::setDtEnd(const QDateTime &dtEnd) | 106 | void Event::setDtEnd(const QDateTime &dtEnd) |
107 | { | 107 | { |
108 | if (mReadOnly) return; | 108 | if (mReadOnly) return; |
109 | 109 | ||
110 | mDtEnd = getEvenTime( dtEnd ); | 110 | mDtEnd = getEvenTime( dtEnd ); |
111 | 111 | ||
112 | setHasEndDate(true); | 112 | setHasEndDate(true); |
113 | setHasDuration(false); | 113 | setHasDuration(false); |
114 | 114 | ||
115 | updated(); | 115 | updated(); |
116 | } | 116 | } |
117 | 117 | ||
118 | QDateTime Event::dtEnd() const | 118 | QDateTime Event::dtEnd() const |
119 | { | 119 | { |
120 | if (hasEndDate()) return mDtEnd; | 120 | if (hasEndDate()) return mDtEnd; |
121 | if (hasDuration()) return dtStart().addSecs(duration()); | 121 | if (hasDuration()) return dtStart().addSecs(duration()); |
122 | 122 | ||
123 | return dtStart(); | 123 | return dtStart(); |
124 | } | 124 | } |
125 | 125 | ||
126 | QString Event::dtEndTimeStr() const | 126 | QString Event::dtEndTimeStr() const |
127 | { | 127 | { |
128 | return KGlobal::locale()->formatTime(mDtEnd.time()); | 128 | return KGlobal::locale()->formatTime(mDtEnd.time()); |
129 | } | 129 | } |
130 | 130 | ||
131 | QString Event::dtEndDateStr(bool shortfmt) const | 131 | QString Event::dtEndDateStr(bool shortfmt) const |
132 | { | 132 | { |
133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); | 133 | return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); |
134 | } | 134 | } |
135 | 135 | ||
136 | QString Event::dtEndStr(bool shortfmt) const | 136 | QString Event::dtEndStr(bool shortfmt) const |
137 | { | 137 | { |
138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); | 138 | return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); |
139 | } | 139 | } |
140 | 140 | ||
141 | void Event::setHasEndDate(bool b) | 141 | void Event::setHasEndDate(bool b) |
142 | { | 142 | { |
143 | mHasEndDate = b; | 143 | mHasEndDate = b; |
144 | } | 144 | } |
145 | 145 | ||
146 | bool Event::hasEndDate() const | 146 | bool Event::hasEndDate() const |
147 | { | 147 | { |
148 | return mHasEndDate; | 148 | return mHasEndDate; |
149 | } | 149 | } |
150 | 150 | ||
151 | bool Event::isMultiDay() const | 151 | bool Event::isMultiDay() const |
152 | { | 152 | { |
153 | bool multi = !(dtStart().date() == dtEnd().date()); | 153 | bool multi = !(dtStart().date() == dtEnd().date()); |
154 | return multi; | 154 | return multi; |
155 | } | 155 | } |
156 | 156 | ||
157 | void Event::setTransparency(Event::Transparency transparency) | 157 | void Event::setTransparency(Event::Transparency transparency) |
158 | { | 158 | { |
159 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
160 | mTransparency = transparency; | 160 | mTransparency = transparency; |
161 | updated(); | 161 | updated(); |
162 | } | 162 | } |
163 | 163 | ||
164 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
165 | { | 165 | { |
166 | return mTransparency; | 166 | return mTransparency; |
167 | } | 167 | } |
168 | 168 | ||
169 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
170 | { | 170 | { |
171 | setHasEndDate(false); | 171 | setHasEndDate(false); |
172 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
173 | } | 173 | } |
174 | bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) | 174 | bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) |
175 | { | 175 | { |
176 | if ( cancelled() ) return false; | ||
176 | if ( ! doesRecur() ) { | 177 | if ( ! doesRecur() ) { |
177 | if ( doesFloat() ) { | 178 | if ( doesFloat() ) { |
178 | if ( mDtEnd.addDays( 1 ) < *startDT) | 179 | if ( mDtEnd.addDays( 1 ) < *startDT) |
179 | return false; | 180 | return false; |
180 | if ( endDT && mDtStart > * endDT) | 181 | if ( endDT && mDtStart > * endDT) |
181 | return false; | 182 | return false; |
182 | } else { | 183 | } else { |
183 | if ( mDtEnd < *startDT ) | 184 | if ( mDtEnd < *startDT ) |
184 | return false; | 185 | return false; |
185 | if ( endDT && mDtStart > * endDT) | 186 | if ( endDT && mDtStart > * endDT) |
186 | return false; | 187 | return false; |
187 | } | 188 | } |
188 | } else { | 189 | } else { |
189 | if ( endDT && mDtStart > * endDT) | 190 | if ( endDT && mDtStart > * endDT) |
190 | return false; | 191 | return false; |
191 | } | 192 | } |
192 | return true; | 193 | return true; |
193 | } | 194 | } |
194 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) | 195 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) |
195 | { | 196 | { |
196 | if ( testEvent == this ) | 197 | if ( testEvent == this ) |
197 | return false; | 198 | return false; |
198 | if ( ! doesRecur() && !testEvent->doesRecur() ) { | 199 | if ( ! doesRecur() && !testEvent->doesRecur() ) { |
199 | QDateTime te; | 200 | QDateTime te; |
200 | if ( testEvent->doesFloat() ) | 201 | if ( testEvent->doesFloat() ) |
201 | te = testEvent->mDtEnd.addDays( 1 ); | 202 | te = testEvent->mDtEnd.addDays( 1 ); |
202 | else | 203 | else |
203 | te = testEvent->mDtEnd; | 204 | te = testEvent->mDtEnd; |
204 | QDateTime e; | 205 | QDateTime e; |
205 | if ( doesFloat() ) | 206 | if ( doesFloat() ) |
206 | e = mDtEnd.addDays( 1 ); | 207 | e = mDtEnd.addDays( 1 ); |
207 | else | 208 | else |
208 | e = mDtEnd; | 209 | e = mDtEnd; |
209 | if ( mDtStart < te && testEvent->mDtStart < e ) { | 210 | if ( mDtStart < te && testEvent->mDtStart < e ) { |
210 | if ( mDtStart < testEvent->mDtStart ) | 211 | if ( mDtStart < testEvent->mDtStart ) |
211 | *overlapDT = testEvent->mDtStart; | 212 | *overlapDT = testEvent->mDtStart; |
212 | else | 213 | else |
213 | *overlapDT = mDtStart; | 214 | *overlapDT = mDtStart; |
214 | if ( startDT ) | 215 | if ( startDT ) |
215 | return (*overlapDT >= *startDT ); | 216 | return (*overlapDT >= *startDT ); |
216 | return true; | 217 | return true; |
217 | } | 218 | } |
218 | return false; | 219 | return false; |
219 | } | 220 | } |
220 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { | 221 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { |
221 | if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) { | 222 | if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) { |
222 | // no need to test. times mismatch | 223 | // no need to test. times mismatch |
223 | //fprintf(stderr,"timi "); | 224 | //fprintf(stderr,"timi "); |
224 | return false; | 225 | return false; |
225 | } | 226 | } |
226 | } | 227 | } |
227 | Event *nonRecur = 0; | 228 | Event *nonRecur = 0; |
228 | Event *recurEvent = 0; | 229 | Event *recurEvent = 0; |
229 | if ( ! doesRecur() ) { | 230 | if ( ! doesRecur() ) { |
230 | nonRecur = this; | 231 | nonRecur = this; |
231 | recurEvent = testEvent; | 232 | recurEvent = testEvent; |
232 | } | 233 | } |
233 | else if ( !testEvent->doesRecur() ) { | 234 | else if ( !testEvent->doesRecur() ) { |
234 | nonRecur = testEvent; | 235 | nonRecur = testEvent; |
235 | recurEvent = this; | 236 | recurEvent = this; |
236 | } | 237 | } |
237 | if ( nonRecur ) { | 238 | if ( nonRecur ) { |
238 | QDateTime enr; | 239 | QDateTime enr; |
239 | if ( nonRecur->doesFloat() ) | 240 | if ( nonRecur->doesFloat() ) |
240 | enr = nonRecur->mDtEnd.addDays( 1 ); | 241 | enr = nonRecur->mDtEnd.addDays( 1 ); |
241 | else | 242 | else |
242 | enr = nonRecur->mDtEnd; | 243 | enr = nonRecur->mDtEnd; |
243 | if ( enr < recurEvent->mDtStart ) | 244 | if ( enr < recurEvent->mDtStart ) |
244 | return false; | 245 | return false; |
245 | if ( startDT && enr < *startDT ) | 246 | if ( startDT && enr < *startDT ) |
246 | return false; | 247 | return false; |
247 | 248 | ||
248 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); | 249 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); |
249 | if ( recurEvent->doesFloat() ) | 250 | if ( recurEvent->doesFloat() ) |
250 | recDuration += 86400; | 251 | recDuration += 86400; |
251 | bool ok = false; | 252 | bool ok = false; |
252 | QDateTime recStart; | 253 | QDateTime recStart; |
253 | if ( startDT ) { | 254 | if ( startDT ) { |
254 | recStart = recurEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); | 255 | recStart = recurEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); |
255 | } | 256 | } |
256 | if ( recStart.isValid() ) { | 257 | if ( recStart.isValid() ) { |
257 | //qDebug("%s start at %s ", startDT-> toString().latin1(), recStart.toString().latin1()); | 258 | //qDebug("%s start at %s ", startDT-> toString().latin1(), recStart.toString().latin1()); |
258 | recStart = recStart.addSecs( -300); | 259 | recStart = recStart.addSecs( -300); |
259 | } | 260 | } |
260 | else | 261 | else |
261 | recStart = recurEvent->mDtStart.addSecs( -300); | 262 | recStart = recurEvent->mDtStart.addSecs( -300); |
262 | ok = true; | 263 | ok = true; |
263 | 264 | ||
264 | while ( ok ) { | 265 | while ( ok ) { |
265 | recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); | 266 | recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); |
266 | if ( ok ) { | 267 | if ( ok ) { |
267 | if ( recStart > enr ) | 268 | if ( recStart > enr ) |
268 | return false; | 269 | return false; |
269 | QDateTime recEnd = recStart.addSecs( recDuration ); | 270 | QDateTime recEnd = recStart.addSecs( recDuration ); |
270 | if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) { | 271 | if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) { |
271 | if ( nonRecur->mDtStart < recStart ) | 272 | if ( nonRecur->mDtStart < recStart ) |
272 | *overlapDT = recStart; | 273 | *overlapDT = recStart; |
273 | else | 274 | else |
274 | *overlapDT = nonRecur->mDtStart; | 275 | *overlapDT = nonRecur->mDtStart; |
275 | if ( startDT ) { | 276 | if ( startDT ) { |
276 | if ( *overlapDT >= *startDT ) | 277 | if ( *overlapDT >= *startDT ) |
277 | return true; | 278 | return true; |
278 | } else | 279 | } else |
279 | return true; | 280 | return true; |
280 | } | 281 | } |
281 | } | 282 | } |
282 | } | 283 | } |
283 | return false; | 284 | return false; |
284 | } | 285 | } |
285 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { | 286 | if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { |
286 | if ( recurrence()->doesRecur() == Recurrence::rWeekly && testEvent->recurrence()->doesRecur() == Recurrence::rWeekly ) { | 287 | if ( recurrence()->doesRecur() == Recurrence::rWeekly && testEvent->recurrence()->doesRecur() == Recurrence::rWeekly ) { |
287 | bool found = false; | 288 | bool found = false; |
288 | uint i; | 289 | uint i; |
289 | for ( i=0; i< recurrence()->days().size();++i ) { | 290 | for ( i=0; i< recurrence()->days().size();++i ) { |
290 | found = found || (recurrence()->days().testBit( i ) && testEvent->recurrence()->days().testBit( i ) ); | 291 | found = found || (recurrence()->days().testBit( i ) && testEvent->recurrence()->days().testBit( i ) ); |
291 | } | 292 | } |
292 | if ( ! found ) { | 293 | if ( ! found ) { |
293 | //qDebug("recurring days mismatch %s -- %s", summary().latin1(),testEvent->summary().latin1()); | 294 | //qDebug("recurring days mismatch %s -- %s", summary().latin1(),testEvent->summary().latin1()); |
294 | return false; | 295 | return false; |
295 | } | 296 | } |
296 | 297 | ||
297 | } | 298 | } |
298 | } | 299 | } |
299 | bool ok = true; | 300 | bool ok = true; |
300 | QDateTime incidenceStart;// = mDtStart; | 301 | QDateTime incidenceStart;// = mDtStart; |
301 | QDateTime testincidenceStart;// = testEvent->mDtStart; | 302 | QDateTime testincidenceStart;// = testEvent->mDtStart; |
302 | if ( startDT ) { | 303 | if ( startDT ) { |
303 | incidenceStart = recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); | 304 | incidenceStart = recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); |
304 | testincidenceStart = testEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); | 305 | testincidenceStart = testEvent->recurrence()->getPreviousDateTime( startDT->addSecs( 61 ), &ok ); |
305 | } | 306 | } |
306 | if ( !testincidenceStart.isValid() ) | 307 | if ( !testincidenceStart.isValid() ) |
307 | testincidenceStart = testEvent->mDtStart; | 308 | testincidenceStart = testEvent->mDtStart; |
308 | if ( !incidenceStart.isValid() ) | 309 | if ( !incidenceStart.isValid() ) |
309 | incidenceStart = mDtStart; | 310 | incidenceStart = mDtStart; |
310 | int duration = mDtStart.secsTo( mDtEnd ); | 311 | int duration = mDtStart.secsTo( mDtEnd ); |
311 | if ( doesFloat() ) | 312 | if ( doesFloat() ) |
312 | duration += 86400; | 313 | duration += 86400; |
313 | int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); | 314 | int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); |
314 | if ( testEvent->doesFloat() ) | 315 | if ( testEvent->doesFloat() ) |
315 | testduration += 86400; | 316 | testduration += 86400; |
316 | bool computeThis = false; | 317 | bool computeThis = false; |
317 | if ( incidenceStart < testincidenceStart ) | 318 | if ( incidenceStart < testincidenceStart ) |
318 | computeThis = true; | 319 | computeThis = true; |
319 | if ( computeThis ) | 320 | if ( computeThis ) |
320 | incidenceStart = incidenceStart.addSecs( -300 ); | 321 | incidenceStart = incidenceStart.addSecs( -300 ); |
321 | else | 322 | else |
322 | testincidenceStart = testincidenceStart.addSecs( -300 ); | 323 | testincidenceStart = testincidenceStart.addSecs( -300 ); |
323 | int count = 0; | 324 | int count = 0; |
324 | ok = true; | 325 | ok = true; |
325 | int countbreak = 2000; | 326 | int countbreak = 2000; |
326 | QDateTime stopSearch; | 327 | QDateTime stopSearch; |
327 | bool testStop = false; | 328 | bool testStop = false; |
328 | if ( startDT ) { | 329 | if ( startDT ) { |
329 | stopSearch = startDT->addDays( 365*3 ); | 330 | stopSearch = startDT->addDays( 365*3 ); |
330 | testStop = true; | 331 | testStop = true; |
331 | } | 332 | } |
332 | while ( ok ) { | 333 | while ( ok ) { |
333 | ++count; | 334 | ++count; |
334 | if ( count > countbreak ) break; | 335 | if ( count > countbreak ) break; |
335 | if ( computeThis ) { | 336 | if ( computeThis ) { |
336 | if ( testStop ) | 337 | if ( testStop ) |
337 | if ( testincidenceStart > stopSearch ) | 338 | if ( testincidenceStart > stopSearch ) |
338 | break; | 339 | break; |
339 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); | 340 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); |
340 | } | 341 | } |
341 | else { | 342 | else { |
342 | if ( testStop ) | 343 | if ( testStop ) |
343 | if ( incidenceStart > stopSearch ) | 344 | if ( incidenceStart > stopSearch ) |
344 | break; | 345 | break; |
345 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); | 346 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); |
346 | } | 347 | } |
347 | if ( ok ) { | 348 | if ( ok ) { |
348 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { | 349 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { |
349 | if ( incidenceStart < testincidenceStart ) | 350 | if ( incidenceStart < testincidenceStart ) |
350 | *overlapDT = testincidenceStart; | 351 | *overlapDT = testincidenceStart; |
351 | else | 352 | else |
352 | *overlapDT = incidenceStart; | 353 | *overlapDT = incidenceStart; |
353 | if ( startDT ) { | 354 | if ( startDT ) { |
354 | if ( *overlapDT >= *startDT ) | 355 | if ( *overlapDT >= *startDT ) |
355 | return true; | 356 | return true; |
356 | } else | 357 | } else |
357 | return true; | 358 | return true; |
358 | } | 359 | } |
359 | computeThis = ( incidenceStart < testincidenceStart ); | 360 | computeThis = ( incidenceStart < testincidenceStart ); |
360 | } | 361 | } |
361 | 362 | ||
362 | } | 363 | } |
363 | //qDebug("%d rec counter stopped at %d - %s %s", ok ,count, summary().latin1(),testEvent->summary().latin1() ); | 364 | //qDebug("%d rec counter stopped at %d - %s %s", ok ,count, summary().latin1(),testEvent->summary().latin1() ); |
364 | return false; | 365 | return false; |
365 | } | 366 | } |
366 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 367 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
367 | { | 368 | { |
368 | *ok = false; | 369 | *ok = false; |
369 | if ( !alarmEnabled() ) | 370 | if ( !alarmEnabled() ) |
370 | return QDateTime (); | 371 | return QDateTime (); |
371 | bool yes; | 372 | bool yes; |
372 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); | 373 | QDateTime incidenceStart = getNextOccurence( start_dt, &yes ); |
373 | if ( ! yes || cancelled() ) { | 374 | if ( ! yes || cancelled() ) { |
374 | *ok = false; | 375 | *ok = false; |
375 | return QDateTime (); | 376 | return QDateTime (); |
376 | } | 377 | } |
377 | 378 | ||
378 | bool enabled = false; | 379 | bool enabled = false; |
379 | Alarm* alarm; | 380 | Alarm* alarm; |
380 | int off = 0; | 381 | int off = 0; |
381 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 382 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
382 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 383 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
383 | // *ok = false; | 384 | // *ok = false; |
384 | // return incidenceStart; | 385 | // return incidenceStart; |
385 | // } | 386 | // } |
386 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 387 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
387 | if (alarm->enabled()) { | 388 | if (alarm->enabled()) { |
388 | if ( alarm->hasTime () ) { | 389 | if ( alarm->hasTime () ) { |
389 | if ( alarm->time() < alarmStart ) { | 390 | if ( alarm->time() < alarmStart ) { |
390 | alarmStart = alarm->time(); | 391 | alarmStart = alarm->time(); |
391 | enabled = true; | 392 | enabled = true; |
392 | off = alarmStart.secsTo( incidenceStart ); | 393 | off = alarmStart.secsTo( incidenceStart ); |
393 | } | 394 | } |
394 | 395 | ||
395 | } else { | 396 | } else { |
396 | int secs = alarm->startOffset().asSeconds(); | 397 | int secs = alarm->startOffset().asSeconds(); |
397 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 398 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
398 | alarmStart = incidenceStart.addSecs( secs ); | 399 | alarmStart = incidenceStart.addSecs( secs ); |
399 | enabled = true; | 400 | enabled = true; |
400 | off = -secs; | 401 | off = -secs; |
401 | } | 402 | } |
402 | } | 403 | } |
403 | } | 404 | } |
404 | } | 405 | } |
405 | if ( enabled ) { | 406 | if ( enabled ) { |
406 | if ( alarmStart > start_dt ) { | 407 | if ( alarmStart > start_dt ) { |
407 | *ok = true; | 408 | *ok = true; |
408 | * offset = off; | 409 | * offset = off; |
409 | return alarmStart; | 410 | return alarmStart; |
410 | } | 411 | } |
411 | } | 412 | } |
412 | *ok = false; | 413 | *ok = false; |
413 | return QDateTime (); | 414 | return QDateTime (); |
414 | 415 | ||
415 | } | 416 | } |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 4794bc9..f349681 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -1,770 +1,767 @@ | |||
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 <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qptrlist.h> | 23 | #include <qptrlist.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kglobal.h> | 28 | #include <kglobal.h> |
29 | 29 | ||
30 | extern "C" { | 30 | extern "C" { |
31 | #include <ical.h> | 31 | #include <ical.h> |
32 | #include <icalss.h> | 32 | #include <icalss.h> |
33 | #include <icalparser.h> | 33 | #include <icalparser.h> |
34 | #include <icalrestriction.h> | 34 | #include <icalrestriction.h> |
35 | } | 35 | } |
36 | 36 | ||
37 | #include "calendar.h" | 37 | #include "calendar.h" |
38 | #include "journal.h" | 38 | #include "journal.h" |
39 | #include "icalformat.h" | 39 | #include "icalformat.h" |
40 | #include "icalformatimpl.h" | 40 | #include "icalformatimpl.h" |
41 | #include "compat.h" | 41 | #include "compat.h" |
42 | 42 | ||
43 | #define _ICAL_VERSION "2.0" | 43 | #define _ICAL_VERSION "2.0" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | const int gSecondsPerMinute = 60; | 47 | const int gSecondsPerMinute = 60; |
48 | const int gSecondsPerHour = gSecondsPerMinute * 60; | 48 | const int gSecondsPerHour = gSecondsPerMinute * 60; |
49 | const int gSecondsPerDay = gSecondsPerHour * 24; | 49 | const int gSecondsPerDay = gSecondsPerHour * 24; |
50 | const int gSecondsPerWeek = gSecondsPerDay * 7; | 50 | const int gSecondsPerWeek = gSecondsPerDay * 7; |
51 | 51 | ||
52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : | 52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : |
53 | mParent( parent ), mCalendarVersion( 0 ) | 53 | mParent( parent ), mCalendarVersion( 0 ) |
54 | { | 54 | { |
55 | mCompat = new Compat; | 55 | mCompat = new Compat; |
56 | } | 56 | } |
57 | 57 | ||
58 | ICalFormatImpl::~ICalFormatImpl() | 58 | ICalFormatImpl::~ICalFormatImpl() |
59 | { | 59 | { |
60 | delete mCompat; | 60 | delete mCompat; |
61 | } | 61 | } |
62 | 62 | ||
63 | class ToStringVisitor : public Incidence::Visitor | 63 | class ToStringVisitor : public Incidence::Visitor |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} | 66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} |
67 | 67 | ||
68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } | 68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } |
69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } | 69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } |
70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } | 70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } |
71 | 71 | ||
72 | icalcomponent *component() { return mComponent; } | 72 | icalcomponent *component() { return mComponent; } |
73 | 73 | ||
74 | private: | 74 | private: |
75 | ICalFormatImpl *mImpl; | 75 | ICalFormatImpl *mImpl; |
76 | icalcomponent *mComponent; | 76 | icalcomponent *mComponent; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) | 79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) |
80 | { | 80 | { |
81 | ToStringVisitor v( this ); | 81 | ToStringVisitor v( this ); |
82 | incidence->accept(v); | 82 | incidence->accept(v); |
83 | return v.component(); | 83 | return v.component(); |
84 | } | 84 | } |
85 | 85 | ||
86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) | 86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) |
87 | { | 87 | { |
88 | QString tmpStr; | 88 | QString tmpStr; |
89 | QStringList tmpStrList; | 89 | QStringList tmpStrList; |
90 | 90 | ||
91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); | 91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); |
92 | 92 | ||
93 | writeIncidence(vtodo,todo); | 93 | writeIncidence(vtodo,todo); |
94 | 94 | ||
95 | // due date | 95 | // due date |
96 | if (todo->hasDueDate()) { | 96 | if (todo->hasDueDate()) { |
97 | icaltimetype due; | 97 | icaltimetype due; |
98 | if (todo->doesFloat()) { | 98 | if (todo->doesFloat()) { |
99 | due = writeICalDate(todo->dtDue().date()); | 99 | due = writeICalDate(todo->dtDue().date()); |
100 | } else { | 100 | } else { |
101 | due = writeICalDateTime(todo->dtDue()); | 101 | due = writeICalDateTime(todo->dtDue()); |
102 | } | 102 | } |
103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); | 103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); |
104 | } | 104 | } |
105 | 105 | ||
106 | // start time | 106 | // start time |
107 | if (todo->hasStartDate()) { | 107 | if (todo->hasStartDate()) { |
108 | icaltimetype start; | 108 | icaltimetype start; |
109 | if (todo->doesFloat()) { | 109 | if (todo->doesFloat()) { |
110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; | 110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; |
111 | start = writeICalDate(todo->dtStart().date()); | 111 | start = writeICalDate(todo->dtStart().date()); |
112 | } else { | 112 | } else { |
113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; | 113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; |
114 | start = writeICalDateTime(todo->dtStart()); | 114 | start = writeICalDateTime(todo->dtStart()); |
115 | } | 115 | } |
116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); | 116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); |
117 | } | 117 | } |
118 | 118 | ||
119 | // completion date | 119 | // completion date |
120 | if (todo->isCompleted()) { | 120 | if (todo->isCompleted()) { |
121 | if (!todo->hasCompletedDate()) { | 121 | if (!todo->hasCompletedDate()) { |
122 | // If todo was created by KOrganizer <2.2 it has no correct completion | 122 | // If todo was created by KOrganizer <2.2 it has no correct completion |
123 | // date. Set it to now. | 123 | // date. Set it to now. |
124 | todo->setCompleted(QDateTime::currentDateTime()); | 124 | todo->setCompleted(QDateTime::currentDateTime()); |
125 | } | 125 | } |
126 | icaltimetype completed = writeICalDateTime(todo->completed()); | 126 | icaltimetype completed = writeICalDateTime(todo->completed()); |
127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); | 127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); |
128 | } | 128 | } |
129 | 129 | ||
130 | icalcomponent_add_property(vtodo, | 130 | icalcomponent_add_property(vtodo, |
131 | icalproperty_new_percentcomplete(todo->percentComplete())); | 131 | icalproperty_new_percentcomplete(todo->percentComplete())); |
132 | 132 | ||
133 | return vtodo; | 133 | return vtodo; |
134 | } | 134 | } |
135 | 135 | ||
136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) | 136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) |
137 | { | 137 | { |
138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() | 138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() |
139 | << ")" << endl; | 139 | << ")" << endl; |
140 | 140 | ||
141 | QString tmpStr; | 141 | QString tmpStr; |
142 | QStringList tmpStrList; | 142 | QStringList tmpStrList; |
143 | 143 | ||
144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); | 144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); |
145 | 145 | ||
146 | writeIncidence(vevent,event); | 146 | writeIncidence(vevent,event); |
147 | 147 | ||
148 | // start time | 148 | // start time |
149 | icaltimetype start; | 149 | icaltimetype start; |
150 | if (event->doesFloat()) { | 150 | if (event->doesFloat()) { |
151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
152 | start = writeICalDate(event->dtStart().date()); | 152 | start = writeICalDate(event->dtStart().date()); |
153 | } else { | 153 | } else { |
154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
155 | start = writeICalDateTime(event->dtStart()); | 155 | start = writeICalDateTime(event->dtStart()); |
156 | } | 156 | } |
157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); | 157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); |
158 | 158 | ||
159 | if (event->hasEndDate()) { | 159 | if (event->hasEndDate()) { |
160 | // end time | 160 | // end time |
161 | icaltimetype end; | 161 | icaltimetype end; |
162 | if (event->doesFloat()) { | 162 | if (event->doesFloat()) { |
163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; | 163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; |
164 | // +1 day because end date is non-inclusive. | 164 | // +1 day because end date is non-inclusive. |
165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); | 165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); |
166 | } else { | 166 | } else { |
167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; | 167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; |
168 | end = writeICalDateTime(event->dtEnd()); | 168 | end = writeICalDateTime(event->dtEnd()); |
169 | } | 169 | } |
170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); | 170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); |
171 | } | 171 | } |
172 | 172 | ||
173 | // TODO: attachments, resources | 173 | // TODO: attachments, resources |
174 | #if 0 | 174 | #if 0 |
175 | // attachments | 175 | // attachments |
176 | tmpStrList = anEvent->attachments(); | 176 | tmpStrList = anEvent->attachments(); |
177 | for ( QStringList::Iterator it = tmpStrList.begin(); | 177 | for ( QStringList::Iterator it = tmpStrList.begin(); |
178 | it != tmpStrList.end(); | 178 | it != tmpStrList.end(); |
179 | ++it ) | 179 | ++it ) |
180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); | 180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); |
181 | 181 | ||
182 | // resources | 182 | // resources |
183 | tmpStrList = anEvent->resources(); | 183 | tmpStrList = anEvent->resources(); |
184 | tmpStr = tmpStrList.join(";"); | 184 | tmpStr = tmpStrList.join(";"); |
185 | if (!tmpStr.isEmpty()) | 185 | if (!tmpStr.isEmpty()) |
186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); | 186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | // Transparency | 190 | // Transparency |
191 | switch( event->transparency() ) { | 191 | switch( event->transparency() ) { |
192 | case Event::Transparent: | 192 | case Event::Transparent: |
193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); | 193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); |
194 | break; | 194 | break; |
195 | case Event::Opaque: | 195 | case Event::Opaque: |
196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); | 196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | 199 | ||
200 | return vevent; | 200 | return vevent; |
201 | } | 201 | } |
202 | 202 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, |
204 | Scheduler::Method method) | 204 | Scheduler::Method method) |
205 | { | 205 | { |
206 | 206 | ||
207 | 207 | ||
208 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); | 208 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); |
209 | 209 | ||
210 | writeIncidenceBase(vfreebusy,freebusy); | 210 | writeIncidenceBase(vfreebusy,freebusy); |
211 | 211 | ||
212 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( | 212 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( |
213 | writeICalDateTime(freebusy->dtStart()))); | 213 | writeICalDateTime(freebusy->dtStart()))); |
214 | 214 | ||
215 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( | 215 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( |
216 | writeICalDateTime(freebusy->dtEnd()))); | 216 | writeICalDateTime(freebusy->dtEnd()))); |
217 | 217 | ||
218 | if (method == Scheduler::Request) { | 218 | if (method == Scheduler::Request) { |
219 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( | 219 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( |
220 | freebusy->uid().utf8())); | 220 | freebusy->uid().utf8())); |
221 | } | 221 | } |
222 | 222 | ||
223 | //Loops through all the periods in the freebusy object | 223 | //Loops through all the periods in the freebusy object |
224 | QValueList<Period> list = freebusy->busyPeriods(); | 224 | QValueList<Period> list = freebusy->busyPeriods(); |
225 | QValueList<Period>::Iterator it; | 225 | QValueList<Period>::Iterator it; |
226 | icalperiodtype period; | 226 | icalperiodtype period; |
227 | for (it = list.begin(); it!= list.end(); ++it) { | 227 | for (it = list.begin(); it!= list.end(); ++it) { |
228 | period.start = writeICalDateTime((*it).start()); | 228 | period.start = writeICalDateTime((*it).start()); |
229 | period.end = writeICalDateTime((*it).end()); | 229 | period.end = writeICalDateTime((*it).end()); |
230 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); | 230 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); |
231 | } | 231 | } |
232 | 232 | ||
233 | return vfreebusy; | 233 | return vfreebusy; |
234 | } | 234 | } |
235 | 235 | ||
236 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 236 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) |
237 | { | 237 | { |
238 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); | 238 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); |
239 | 239 | ||
240 | writeIncidence(vjournal,journal); | 240 | writeIncidence(vjournal,journal); |
241 | 241 | ||
242 | // start time | 242 | // start time |
243 | if (journal->dtStart().isValid()) { | 243 | if (journal->dtStart().isValid()) { |
244 | icaltimetype start; | 244 | icaltimetype start; |
245 | if (journal->doesFloat()) { | 245 | if (journal->doesFloat()) { |
246 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 246 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
247 | start = writeICalDate(journal->dtStart().date()); | 247 | start = writeICalDate(journal->dtStart().date()); |
248 | } else { | 248 | } else { |
249 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 249 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
250 | start = writeICalDateTime(journal->dtStart()); | 250 | start = writeICalDateTime(journal->dtStart()); |
251 | } | 251 | } |
252 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); | 252 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); |
253 | } | 253 | } |
254 | 254 | ||
255 | return vjournal; | 255 | return vjournal; |
256 | } | 256 | } |
257 | 257 | ||
258 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 258 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) |
259 | { | 259 | { |
260 | // pilot sync stuff | 260 | // pilot sync stuff |
261 | // TODO: move this application-specific code to kpilot | 261 | // TODO: move this application-specific code to kpilot |
262 | if (incidence->pilotId()) { | 262 | if (incidence->pilotId()) { |
263 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); | 263 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); |
264 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); | 264 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); |
265 | } | 265 | } |
266 | if ( !incidence->IDStr().isEmpty()) { | 266 | if ( !incidence->IDStr().isEmpty()) { |
267 | incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); | 267 | incidence->setNonKDECustomProperty("X-KOPIEXTID",incidence->IDStr() ); |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | writeIncidenceBase(parent,incidence); | 271 | writeIncidenceBase(parent,incidence); |
272 | if (incidence->cancelled()) { | 272 | if (incidence->cancelled()) { |
273 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); | 273 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); |
274 | } | 274 | } |
275 | 275 | ||
276 | // creation date | 276 | // creation date |
277 | icalcomponent_add_property(parent,icalproperty_new_created( | 277 | icalcomponent_add_property(parent,icalproperty_new_created( |
278 | writeICalDateTime(incidence->created()))); | 278 | writeICalDateTime(incidence->created()))); |
279 | 279 | ||
280 | // unique id | 280 | // unique id |
281 | icalcomponent_add_property(parent,icalproperty_new_uid( | 281 | icalcomponent_add_property(parent,icalproperty_new_uid( |
282 | incidence->uid().utf8())); | 282 | incidence->uid().utf8())); |
283 | 283 | ||
284 | // revision | 284 | // revision |
285 | icalcomponent_add_property(parent,icalproperty_new_sequence( | 285 | icalcomponent_add_property(parent,icalproperty_new_sequence( |
286 | incidence->revision())); | 286 | incidence->revision())); |
287 | 287 | ||
288 | // last modification date | 288 | // last modification date |
289 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( | 289 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( |
290 | writeICalDateTime(incidence->lastModified()))); | 290 | writeICalDateTime(incidence->lastModified()))); |
291 | 291 | ||
292 | // description | 292 | // description |
293 | if (!incidence->description().isEmpty()) { | 293 | if (!incidence->description().isEmpty()) { |
294 | icalcomponent_add_property(parent,icalproperty_new_description( | 294 | icalcomponent_add_property(parent,icalproperty_new_description( |
295 | incidence->description().utf8())); | 295 | incidence->description().utf8())); |
296 | } | 296 | } |
297 | 297 | ||
298 | // summary | 298 | // summary |
299 | if (!incidence->summary().isEmpty()) { | 299 | if (!incidence->summary().isEmpty()) { |
300 | icalcomponent_add_property(parent,icalproperty_new_summary( | 300 | icalcomponent_add_property(parent,icalproperty_new_summary( |
301 | incidence->summary().utf8())); | 301 | incidence->summary().utf8())); |
302 | } | 302 | } |
303 | 303 | ||
304 | // location | 304 | // location |
305 | if (!incidence->location().isEmpty()) { | 305 | if (!incidence->location().isEmpty()) { |
306 | icalcomponent_add_property(parent,icalproperty_new_location( | 306 | icalcomponent_add_property(parent,icalproperty_new_location( |
307 | incidence->location().utf8())); | 307 | incidence->location().utf8())); |
308 | } | 308 | } |
309 | 309 | ||
310 | // TODO: | 310 | // TODO: |
311 | // status | 311 | // status |
312 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); | 312 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); |
313 | 313 | ||
314 | // secrecy | 314 | // secrecy |
315 | enum icalproperty_class classInt; | 315 | enum icalproperty_class classInt; |
316 | switch (incidence->secrecy()) { | 316 | switch (incidence->secrecy()) { |
317 | case Incidence::SecrecyPublic: | 317 | case Incidence::SecrecyPublic: |
318 | classInt = ICAL_CLASS_PUBLIC; | 318 | classInt = ICAL_CLASS_PUBLIC; |
319 | break; | 319 | break; |
320 | case Incidence::SecrecyConfidential: | 320 | case Incidence::SecrecyConfidential: |
321 | classInt = ICAL_CLASS_CONFIDENTIAL; | 321 | classInt = ICAL_CLASS_CONFIDENTIAL; |
322 | break; | 322 | break; |
323 | case Incidence::SecrecyPrivate: | 323 | case Incidence::SecrecyPrivate: |
324 | classInt =ICAL_CLASS_PRIVATE ; | 324 | classInt =ICAL_CLASS_PRIVATE ; |
325 | default: | 325 | default: |
326 | classInt =ICAL_CLASS_PRIVATE ; | 326 | classInt =ICAL_CLASS_PRIVATE ; |
327 | break; | 327 | break; |
328 | } | 328 | } |
329 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); | 329 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); |
330 | 330 | ||
331 | // priority | 331 | // priority |
332 | icalcomponent_add_property(parent,icalproperty_new_priority( | 332 | icalcomponent_add_property(parent,icalproperty_new_priority( |
333 | incidence->priority())); | 333 | incidence->priority())); |
334 | 334 | ||
335 | // categories | 335 | // categories |
336 | QStringList categories = incidence->categories(); | 336 | QStringList categories = incidence->categories(); |
337 | QStringList::Iterator it; | 337 | QStringList::Iterator it; |
338 | for(it = categories.begin(); it != categories.end(); ++it ) { | 338 | for(it = categories.begin(); it != categories.end(); ++it ) { |
339 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); | 339 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); |
340 | } | 340 | } |
341 | // TODO: Ensure correct concatenation of categories properties. | 341 | // TODO: Ensure correct concatenation of categories properties. |
342 | 342 | ||
343 | /* | 343 | /* |
344 | // categories | 344 | // categories |
345 | tmpStrList = incidence->getCategories(); | 345 | tmpStrList = incidence->getCategories(); |
346 | tmpStr = ""; | 346 | tmpStr = ""; |
347 | QString catStr; | 347 | QString catStr; |
348 | for ( QStringList::Iterator it = tmpStrList.begin(); | 348 | for ( QStringList::Iterator it = tmpStrList.begin(); |
349 | it != tmpStrList.end(); | 349 | it != tmpStrList.end(); |
350 | ++it ) { | 350 | ++it ) { |
351 | catStr = *it; | 351 | catStr = *it; |
352 | if (catStr[0] == ' ') | 352 | if (catStr[0] == ' ') |
353 | tmpStr += catStr.mid(1); | 353 | tmpStr += catStr.mid(1); |
354 | else | 354 | else |
355 | tmpStr += catStr; | 355 | tmpStr += catStr; |
356 | // this must be a ';' character as the vCalendar specification requires! | 356 | // this must be a ';' character as the vCalendar specification requires! |
357 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 357 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
358 | // read in. | 358 | // read in. |
359 | tmpStr += ";"; | 359 | tmpStr += ";"; |
360 | } | 360 | } |
361 | if (!tmpStr.isEmpty()) { | 361 | if (!tmpStr.isEmpty()) { |
362 | tmpStr.truncate(tmpStr.length()-1); | 362 | tmpStr.truncate(tmpStr.length()-1); |
363 | icalcomponent_add_property(parent,icalproperty_new_categories( | 363 | icalcomponent_add_property(parent,icalproperty_new_categories( |
364 | writeText(incidence->getCategories().join(";")))); | 364 | writeText(incidence->getCategories().join(";")))); |
365 | } | 365 | } |
366 | */ | 366 | */ |
367 | 367 | ||
368 | // related event | 368 | // related event |
369 | if (!incidence->relatedToUid().isEmpty()) { | 369 | if (!incidence->relatedToUid().isEmpty()) { |
370 | icalcomponent_add_property(parent,icalproperty_new_relatedto( | 370 | icalcomponent_add_property(parent,icalproperty_new_relatedto( |
371 | incidence->relatedToUid().utf8())); | 371 | incidence->relatedToUid().utf8())); |
372 | } | 372 | } |
373 | 373 | ||
374 | // recurrence rule stuff | 374 | // recurrence rule stuff |
375 | Recurrence *recur = incidence->recurrence(); | 375 | if (incidence->doesRecur()) { |
376 | if (recur->doesRecur()) { | 376 | icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence())); |
377 | 377 | // recurrence excpetion dates | |
378 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); | 378 | DateList dateList = incidence->exDates(); |
379 | } | 379 | DateList::ConstIterator exIt; |
380 | 380 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | |
381 | // recurrence excpetion dates | 381 | icalcomponent_add_property(parent,icalproperty_new_exdate( |
382 | DateList dateList = incidence->exDates(); | 382 | writeICalDate(*exIt))); |
383 | DateList::ConstIterator exIt; | 383 | } |
384 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | ||
385 | icalcomponent_add_property(parent,icalproperty_new_exdate( | ||
386 | writeICalDate(*exIt))); | ||
387 | } | 384 | } |
388 | 385 | ||
389 | // attachments | 386 | // attachments |
390 | QPtrList<Attachment> attachments = incidence->attachments(); | 387 | QPtrList<Attachment> attachments = incidence->attachments(); |
391 | for (Attachment *at = attachments.first(); at; at = attachments.next()) | 388 | for (Attachment *at = attachments.first(); at; at = attachments.next()) |
392 | icalcomponent_add_property(parent,writeAttachment(at)); | 389 | icalcomponent_add_property(parent,writeAttachment(at)); |
393 | 390 | ||
394 | // alarms | 391 | // alarms |
395 | QPtrList<Alarm> alarms = incidence->alarms(); | 392 | QPtrList<Alarm> alarms = incidence->alarms(); |
396 | Alarm* alarm; | 393 | Alarm* alarm; |
397 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 394 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
398 | if (alarm->enabled()) { | 395 | if (alarm->enabled()) { |
399 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; | 396 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; |
400 | icalcomponent_add_component(parent,writeAlarm(alarm)); | 397 | icalcomponent_add_component(parent,writeAlarm(alarm)); |
401 | } | 398 | } |
402 | } | 399 | } |
403 | if( incidence->hasRecurrenceID() ) { | 400 | if( incidence->hasRecurrenceID() ) { |
404 | icalcomponent_add_property(parent, | 401 | icalcomponent_add_property(parent, |
405 | icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); | 402 | icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); |
406 | } | 403 | } |
407 | // duration | 404 | // duration |
408 | 405 | ||
409 | // turned off as it always is set to PTS0 (and must not occur together with DTEND | 406 | // turned off as it always is set to PTS0 (and must not occur together with DTEND |
410 | 407 | ||
411 | if (incidence->hasDuration()) { | 408 | if (incidence->hasDuration()) { |
412 | icaldurationtype duration; | 409 | icaldurationtype duration; |
413 | duration = writeICalDuration(incidence->duration()); | 410 | duration = writeICalDuration(incidence->duration()); |
414 | icalcomponent_add_property(parent,icalproperty_new_duration(duration)); | 411 | icalcomponent_add_property(parent,icalproperty_new_duration(duration)); |
415 | } | 412 | } |
416 | } | 413 | } |
417 | 414 | ||
418 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 415 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
419 | { | 416 | { |
420 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( | 417 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( |
421 | writeICalDateTime(QDateTime::currentDateTime()))); | 418 | writeICalDateTime(QDateTime::currentDateTime()))); |
422 | 419 | ||
423 | // organizer stuff | 420 | // organizer stuff |
424 | icalcomponent_add_property(parent,icalproperty_new_organizer( | 421 | icalcomponent_add_property(parent,icalproperty_new_organizer( |
425 | ("MAILTO:" + incidenceBase->organizer()).utf8())); | 422 | ("MAILTO:" + incidenceBase->organizer()).utf8())); |
426 | 423 | ||
427 | // attendees | 424 | // attendees |
428 | if (incidenceBase->attendeeCount() != 0) { | 425 | if (incidenceBase->attendeeCount() != 0) { |
429 | QPtrList<Attendee> al = incidenceBase->attendees(); | 426 | QPtrList<Attendee> al = incidenceBase->attendees(); |
430 | QPtrListIterator<Attendee> ai(al); | 427 | QPtrListIterator<Attendee> ai(al); |
431 | for (; ai.current(); ++ai) { | 428 | for (; ai.current(); ++ai) { |
432 | icalcomponent_add_property(parent,writeAttendee(ai.current())); | 429 | icalcomponent_add_property(parent,writeAttendee(ai.current())); |
433 | } | 430 | } |
434 | } | 431 | } |
435 | 432 | ||
436 | // custom properties | 433 | // custom properties |
437 | writeCustomProperties(parent, incidenceBase); | 434 | writeCustomProperties(parent, incidenceBase); |
438 | } | 435 | } |
439 | 436 | ||
440 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) | 437 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) |
441 | { | 438 | { |
442 | QMap<QCString, QString> custom = properties->customProperties(); | 439 | QMap<QCString, QString> custom = properties->customProperties(); |
443 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 440 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
444 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 441 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
445 | icalproperty_set_x_name(p,c.key()); | 442 | icalproperty_set_x_name(p,c.key()); |
446 | icalcomponent_add_property(parent,p); | 443 | icalcomponent_add_property(parent,p); |
447 | } | 444 | } |
448 | } | 445 | } |
449 | 446 | ||
450 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | 447 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) |
451 | { | 448 | { |
452 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); | 449 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); |
453 | 450 | ||
454 | if (!attendee->name().isEmpty()) { | 451 | if (!attendee->name().isEmpty()) { |
455 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); | 452 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); |
456 | } | 453 | } |
457 | 454 | ||
458 | 455 | ||
459 | icalproperty_add_parameter(p,icalparameter_new_rsvp( | 456 | icalproperty_add_parameter(p,icalparameter_new_rsvp( |
460 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); | 457 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); |
461 | 458 | ||
462 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | 459 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; |
463 | switch (attendee->status()) { | 460 | switch (attendee->status()) { |
464 | default: | 461 | default: |
465 | case Attendee::NeedsAction: | 462 | case Attendee::NeedsAction: |
466 | status = ICAL_PARTSTAT_NEEDSACTION; | 463 | status = ICAL_PARTSTAT_NEEDSACTION; |
467 | break; | 464 | break; |
468 | case Attendee::Accepted: | 465 | case Attendee::Accepted: |
469 | status = ICAL_PARTSTAT_ACCEPTED; | 466 | status = ICAL_PARTSTAT_ACCEPTED; |
470 | break; | 467 | break; |
471 | case Attendee::Declined: | 468 | case Attendee::Declined: |
472 | status = ICAL_PARTSTAT_DECLINED; | 469 | status = ICAL_PARTSTAT_DECLINED; |
473 | break; | 470 | break; |
474 | case Attendee::Tentative: | 471 | case Attendee::Tentative: |
475 | status = ICAL_PARTSTAT_TENTATIVE; | 472 | status = ICAL_PARTSTAT_TENTATIVE; |
476 | break; | 473 | break; |
477 | case Attendee::Delegated: | 474 | case Attendee::Delegated: |
478 | status = ICAL_PARTSTAT_DELEGATED; | 475 | status = ICAL_PARTSTAT_DELEGATED; |
479 | break; | 476 | break; |
480 | case Attendee::Completed: | 477 | case Attendee::Completed: |
481 | status = ICAL_PARTSTAT_COMPLETED; | 478 | status = ICAL_PARTSTAT_COMPLETED; |
482 | break; | 479 | break; |
483 | case Attendee::InProcess: | 480 | case Attendee::InProcess: |
484 | status = ICAL_PARTSTAT_INPROCESS; | 481 | status = ICAL_PARTSTAT_INPROCESS; |
485 | break; | 482 | break; |
486 | } | 483 | } |
487 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); | 484 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); |
488 | 485 | ||
489 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 486 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; |
490 | switch (attendee->role()) { | 487 | switch (attendee->role()) { |
491 | case Attendee::Chair: | 488 | case Attendee::Chair: |
492 | role = ICAL_ROLE_CHAIR; | 489 | role = ICAL_ROLE_CHAIR; |
493 | break; | 490 | break; |
494 | default: | 491 | default: |
495 | case Attendee::ReqParticipant: | 492 | case Attendee::ReqParticipant: |
496 | role = ICAL_ROLE_REQPARTICIPANT; | 493 | role = ICAL_ROLE_REQPARTICIPANT; |
497 | break; | 494 | break; |
498 | case Attendee::OptParticipant: | 495 | case Attendee::OptParticipant: |
499 | role = ICAL_ROLE_OPTPARTICIPANT; | 496 | role = ICAL_ROLE_OPTPARTICIPANT; |
500 | break; | 497 | break; |
501 | case Attendee::NonParticipant: | 498 | case Attendee::NonParticipant: |
502 | role = ICAL_ROLE_NONPARTICIPANT; | 499 | role = ICAL_ROLE_NONPARTICIPANT; |
503 | break; | 500 | break; |
504 | } | 501 | } |
505 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 502 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
506 | 503 | ||
507 | if (!attendee->uid().isEmpty()) { | 504 | if (!attendee->uid().isEmpty()) { |
508 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 505 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
509 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 506 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
510 | icalproperty_add_parameter(p,icalparameter_uid); | 507 | icalproperty_add_parameter(p,icalparameter_uid); |
511 | } | 508 | } |
512 | 509 | ||
513 | return p; | 510 | return p; |
514 | } | 511 | } |
515 | 512 | ||
516 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 513 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
517 | { | 514 | { |
518 | #if 0 | 515 | #if 0 |
519 | icalattachtype* attach = icalattachtype_new(); | 516 | icalattachtype* attach = icalattachtype_new(); |
520 | if (att->isURI()) | 517 | if (att->isURI()) |
521 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 518 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
522 | else | 519 | else |
523 | icalattachtype_set_base64(attach, att->data(), 0); | 520 | icalattachtype_set_base64(attach, att->data(), 0); |
524 | #endif | 521 | #endif |
525 | icalattach *attach; | 522 | icalattach *attach; |
526 | if (att->isURI()) | 523 | if (att->isURI()) |
527 | attach = icalattach_new_from_url( att->uri().utf8().data()); | 524 | attach = icalattach_new_from_url( att->uri().utf8().data()); |
528 | else | 525 | else |
529 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | 526 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); |
530 | icalproperty *p = icalproperty_new_attach(attach); | 527 | icalproperty *p = icalproperty_new_attach(attach); |
531 | if (!att->mimeType().isEmpty()) | 528 | if (!att->mimeType().isEmpty()) |
532 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 529 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
533 | 530 | ||
534 | if (att->isBinary()) { | 531 | if (att->isBinary()) { |
535 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 532 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
536 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 533 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
537 | } | 534 | } |
538 | return p; | 535 | return p; |
539 | } | 536 | } |
540 | 537 | ||
541 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 538 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
542 | { | 539 | { |
543 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 540 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
544 | 541 | ||
545 | icalrecurrencetype r; | 542 | icalrecurrencetype r; |
546 | 543 | ||
547 | icalrecurrencetype_clear(&r); | 544 | icalrecurrencetype_clear(&r); |
548 | 545 | ||
549 | int index = 0; | 546 | int index = 0; |
550 | int index2 = 0; | 547 | int index2 = 0; |
551 | 548 | ||
552 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 549 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
553 | QPtrList<int> tmpDays; | 550 | QPtrList<int> tmpDays; |
554 | int *tmpDay; | 551 | int *tmpDay; |
555 | Recurrence::rMonthPos *tmpPos; | 552 | Recurrence::rMonthPos *tmpPos; |
556 | bool datetime = false; | 553 | bool datetime = false; |
557 | int day; | 554 | int day; |
558 | int i; | 555 | int i; |
559 | 556 | ||
560 | switch(recur->doesRecur()) { | 557 | switch(recur->doesRecur()) { |
561 | case Recurrence::rMinutely: | 558 | case Recurrence::rMinutely: |
562 | r.freq = ICAL_MINUTELY_RECURRENCE; | 559 | r.freq = ICAL_MINUTELY_RECURRENCE; |
563 | datetime = true; | 560 | datetime = true; |
564 | break; | 561 | break; |
565 | case Recurrence::rHourly: | 562 | case Recurrence::rHourly: |
566 | r.freq = ICAL_HOURLY_RECURRENCE; | 563 | r.freq = ICAL_HOURLY_RECURRENCE; |
567 | datetime = true; | 564 | datetime = true; |
568 | break; | 565 | break; |
569 | case Recurrence::rDaily: | 566 | case Recurrence::rDaily: |
570 | r.freq = ICAL_DAILY_RECURRENCE; | 567 | r.freq = ICAL_DAILY_RECURRENCE; |
571 | break; | 568 | break; |
572 | case Recurrence::rWeekly: | 569 | case Recurrence::rWeekly: |
573 | r.freq = ICAL_WEEKLY_RECURRENCE; | 570 | r.freq = ICAL_WEEKLY_RECURRENCE; |
574 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); | 571 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); |
575 | for (i = 0; i < 7; i++) { | 572 | for (i = 0; i < 7; i++) { |
576 | if (recur->days().testBit(i)) { | 573 | if (recur->days().testBit(i)) { |
577 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 574 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
578 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); | 575 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); |
579 | } | 576 | } |
580 | } | 577 | } |
581 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 578 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
582 | break; | 579 | break; |
583 | case Recurrence::rMonthlyPos: | 580 | case Recurrence::rMonthlyPos: |
584 | r.freq = ICAL_MONTHLY_RECURRENCE; | 581 | r.freq = ICAL_MONTHLY_RECURRENCE; |
585 | 582 | ||
586 | tmpPositions = recur->monthPositions(); | 583 | tmpPositions = recur->monthPositions(); |
587 | for (tmpPos = tmpPositions.first(); | 584 | for (tmpPos = tmpPositions.first(); |
588 | tmpPos; | 585 | tmpPos; |
589 | tmpPos = tmpPositions.next()) { | 586 | tmpPos = tmpPositions.next()) { |
590 | for (i = 0; i < 7; i++) { | 587 | for (i = 0; i < 7; i++) { |
591 | if (tmpPos->rDays.testBit(i)) { | 588 | if (tmpPos->rDays.testBit(i)) { |
592 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 589 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
593 | day += tmpPos->rPos*8; | 590 | day += tmpPos->rPos*8; |
594 | if (tmpPos->negative) day = -day; | 591 | if (tmpPos->negative) day = -day; |
595 | r.by_day[index++] = day; | 592 | r.by_day[index++] = day; |
596 | } | 593 | } |
597 | } | 594 | } |
598 | } | 595 | } |
599 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 596 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
600 | break; | 597 | break; |
601 | case Recurrence::rMonthlyDay: | 598 | case Recurrence::rMonthlyDay: |
602 | r.freq = ICAL_MONTHLY_RECURRENCE; | 599 | r.freq = ICAL_MONTHLY_RECURRENCE; |
603 | 600 | ||
604 | tmpDays = recur->monthDays(); | 601 | tmpDays = recur->monthDays(); |
605 | for (tmpDay = tmpDays.first(); | 602 | for (tmpDay = tmpDays.first(); |
606 | tmpDay; | 603 | tmpDay; |
607 | tmpDay = tmpDays.next()) { | 604 | tmpDay = tmpDays.next()) { |
608 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); | 605 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); |
609 | } | 606 | } |
610 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 607 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
611 | break; | 608 | break; |
612 | case Recurrence::rYearlyMonth: | 609 | case Recurrence::rYearlyMonth: |
613 | case Recurrence::rYearlyPos: | 610 | case Recurrence::rYearlyPos: |
614 | r.freq = ICAL_YEARLY_RECURRENCE; | 611 | r.freq = ICAL_YEARLY_RECURRENCE; |
615 | 612 | ||
616 | tmpDays = recur->yearNums(); | 613 | tmpDays = recur->yearNums(); |
617 | for (tmpDay = tmpDays.first(); | 614 | for (tmpDay = tmpDays.first(); |
618 | tmpDay; | 615 | tmpDay; |
619 | tmpDay = tmpDays.next()) { | 616 | tmpDay = tmpDays.next()) { |
620 | r.by_month[index++] = *tmpDay; | 617 | r.by_month[index++] = *tmpDay; |
621 | } | 618 | } |
622 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; | 619 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; |
623 | if (recur->doesRecur() == Recurrence::rYearlyPos) { | 620 | if (recur->doesRecur() == Recurrence::rYearlyPos) { |
624 | tmpPositions = recur->monthPositions(); | 621 | tmpPositions = recur->monthPositions(); |
625 | for (tmpPos = tmpPositions.first(); | 622 | for (tmpPos = tmpPositions.first(); |
626 | tmpPos; | 623 | tmpPos; |
627 | tmpPos = tmpPositions.next()) { | 624 | tmpPos = tmpPositions.next()) { |
628 | for (i = 0; i < 7; i++) { | 625 | for (i = 0; i < 7; i++) { |
629 | if (tmpPos->rDays.testBit(i)) { | 626 | if (tmpPos->rDays.testBit(i)) { |
630 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 627 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
631 | day += tmpPos->rPos*8; | 628 | day += tmpPos->rPos*8; |
632 | if (tmpPos->negative) day = -day; | 629 | if (tmpPos->negative) day = -day; |
633 | r.by_day[index2++] = day; | 630 | r.by_day[index2++] = day; |
634 | } | 631 | } |
635 | } | 632 | } |
636 | } | 633 | } |
637 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; | 634 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; |
638 | } | 635 | } |
639 | break; | 636 | break; |
640 | case Recurrence::rYearlyDay: | 637 | case Recurrence::rYearlyDay: |
641 | r.freq = ICAL_YEARLY_RECURRENCE; | 638 | r.freq = ICAL_YEARLY_RECURRENCE; |
642 | 639 | ||
643 | tmpDays = recur->yearNums(); | 640 | tmpDays = recur->yearNums(); |
644 | for (tmpDay = tmpDays.first(); | 641 | for (tmpDay = tmpDays.first(); |
645 | tmpDay; | 642 | tmpDay; |
646 | tmpDay = tmpDays.next()) { | 643 | tmpDay = tmpDays.next()) { |
647 | r.by_year_day[index++] = *tmpDay; | 644 | r.by_year_day[index++] = *tmpDay; |
648 | } | 645 | } |
649 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 646 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
650 | break; | 647 | break; |
651 | default: | 648 | default: |
652 | r.freq = ICAL_NO_RECURRENCE; | 649 | r.freq = ICAL_NO_RECURRENCE; |
653 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; | 650 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; |
654 | break; | 651 | break; |
655 | } | 652 | } |
656 | 653 | ||
657 | r.interval = recur->frequency(); | 654 | r.interval = recur->frequency(); |
658 | 655 | ||
659 | if (recur->duration() > 0) { | 656 | if (recur->duration() > 0) { |
660 | r.count = recur->duration(); | 657 | r.count = recur->duration(); |
661 | } else if (recur->duration() == -1) { | 658 | } else if (recur->duration() == -1) { |
662 | r.count = 0; | 659 | r.count = 0; |
663 | } else { | 660 | } else { |
664 | if (datetime) | 661 | if (datetime) |
665 | r.until = writeICalDateTime(recur->endDateTime()); | 662 | r.until = writeICalDateTime(recur->endDateTime()); |
666 | else | 663 | else |
667 | r.until = writeICalDate(recur->endDate()); | 664 | r.until = writeICalDate(recur->endDate()); |
668 | } | 665 | } |
669 | 666 | ||
670 | // Debug output | 667 | // Debug output |
671 | #if 0 | 668 | #if 0 |
672 | const char *str = icalrecurrencetype_as_string(&r); | 669 | const char *str = icalrecurrencetype_as_string(&r); |
673 | if (str) { | 670 | if (str) { |
674 | kdDebug(5800) << " String: " << str << endl; | 671 | kdDebug(5800) << " String: " << str << endl; |
675 | } else { | 672 | } else { |
676 | kdDebug(5800) << " No String" << endl; | 673 | kdDebug(5800) << " No String" << endl; |
677 | } | 674 | } |
678 | #endif | 675 | #endif |
679 | 676 | ||
680 | return icalproperty_new_rrule(r); | 677 | return icalproperty_new_rrule(r); |
681 | } | 678 | } |
682 | 679 | ||
683 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | 680 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) |
684 | { | 681 | { |
685 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); | 682 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); |
686 | 683 | ||
687 | icalproperty_action action; | 684 | icalproperty_action action; |
688 | icalattach *attach = 0; | 685 | icalattach *attach = 0; |
689 | 686 | ||
690 | switch (alarm->type()) { | 687 | switch (alarm->type()) { |
691 | case Alarm::Procedure: | 688 | case Alarm::Procedure: |
692 | action = ICAL_ACTION_PROCEDURE; | 689 | action = ICAL_ACTION_PROCEDURE; |
693 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); | 690 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); |
694 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 691 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
695 | if (!alarm->programArguments().isEmpty()) { | 692 | if (!alarm->programArguments().isEmpty()) { |
696 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); | 693 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); |
697 | } | 694 | } |
698 | icalattach_unref( attach ); | 695 | icalattach_unref( attach ); |
699 | break; | 696 | break; |
700 | case Alarm::Audio: | 697 | case Alarm::Audio: |
701 | action = ICAL_ACTION_AUDIO; | 698 | action = ICAL_ACTION_AUDIO; |
702 | if (!alarm->audioFile().isEmpty()) { | 699 | if (!alarm->audioFile().isEmpty()) { |
703 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); | 700 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); |
704 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 701 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
705 | icalattach_unref( attach ); | 702 | icalattach_unref( attach ); |
706 | } | 703 | } |
707 | break; | 704 | break; |
708 | case Alarm::Email: { | 705 | case Alarm::Email: { |
709 | action = ICAL_ACTION_EMAIL; | 706 | action = ICAL_ACTION_EMAIL; |
710 | QValueList<Person> addresses = alarm->mailAddresses(); | 707 | QValueList<Person> addresses = alarm->mailAddresses(); |
711 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { | 708 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { |
712 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); | 709 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); |
713 | if (!(*ad).name().isEmpty()) { | 710 | if (!(*ad).name().isEmpty()) { |
714 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); | 711 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); |
715 | } | 712 | } |
716 | icalcomponent_add_property(a,p); | 713 | icalcomponent_add_property(a,p); |
717 | } | 714 | } |
718 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); | 715 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); |
719 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 716 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
720 | QStringList attachments = alarm->mailAttachments(); | 717 | QStringList attachments = alarm->mailAttachments(); |
721 | if (attachments.count() > 0) { | 718 | if (attachments.count() > 0) { |
722 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { | 719 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { |
723 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); | 720 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); |
724 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 721 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
725 | icalattach_unref( attach ); | 722 | icalattach_unref( attach ); |
726 | } | 723 | } |
727 | } | 724 | } |
728 | break; | 725 | break; |
729 | } | 726 | } |
730 | case Alarm::Display: | 727 | case Alarm::Display: |
731 | action = ICAL_ACTION_DISPLAY; | 728 | action = ICAL_ACTION_DISPLAY; |
732 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 729 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
733 | break; | 730 | break; |
734 | case Alarm::Invalid: | 731 | case Alarm::Invalid: |
735 | default: | 732 | default: |
736 | kdDebug(5800) << "Unknown type of alarm" << endl; | 733 | kdDebug(5800) << "Unknown type of alarm" << endl; |
737 | action = ICAL_ACTION_NONE; | 734 | action = ICAL_ACTION_NONE; |
738 | break; | 735 | break; |
739 | } | 736 | } |
740 | icalcomponent_add_property(a,icalproperty_new_action(action)); | 737 | icalcomponent_add_property(a,icalproperty_new_action(action)); |
741 | 738 | ||
742 | // Trigger time | 739 | // Trigger time |
743 | icaltriggertype trigger; | 740 | icaltriggertype trigger; |
744 | if ( alarm->hasTime() ) { | 741 | if ( alarm->hasTime() ) { |
745 | trigger.time = writeICalDateTime(alarm->time()); | 742 | trigger.time = writeICalDateTime(alarm->time()); |
746 | trigger.duration = icaldurationtype_null_duration(); | 743 | trigger.duration = icaldurationtype_null_duration(); |
747 | } else { | 744 | } else { |
748 | trigger.time = icaltime_null_time(); | 745 | trigger.time = icaltime_null_time(); |
749 | Duration offset; | 746 | Duration offset; |
750 | if ( alarm->hasStartOffset() ) | 747 | if ( alarm->hasStartOffset() ) |
751 | offset = alarm->startOffset(); | 748 | offset = alarm->startOffset(); |
752 | else | 749 | else |
753 | offset = alarm->endOffset(); | 750 | offset = alarm->endOffset(); |
754 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); | 751 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); |
755 | } | 752 | } |
756 | icalproperty *p = icalproperty_new_trigger(trigger); | 753 | icalproperty *p = icalproperty_new_trigger(trigger); |
757 | if ( alarm->hasEndOffset() ) | 754 | if ( alarm->hasEndOffset() ) |
758 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); | 755 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); |
759 | icalcomponent_add_property(a,p); | 756 | icalcomponent_add_property(a,p); |
760 | 757 | ||
761 | // Repeat count and duration | 758 | // Repeat count and duration |
762 | if (alarm->repeatCount()) { | 759 | if (alarm->repeatCount()) { |
763 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); | 760 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); |
764 | icalcomponent_add_property(a,icalproperty_new_duration( | 761 | icalcomponent_add_property(a,icalproperty_new_duration( |
765 | icaldurationtype_from_int(alarm->snoozeTime()*60))); | 762 | icaldurationtype_from_int(alarm->snoozeTime()*60))); |
766 | } | 763 | } |
767 | 764 | ||
768 | // Custom properties | 765 | // Custom properties |
769 | QMap<QCString, QString> custom = alarm->customProperties(); | 766 | QMap<QCString, QString> custom = alarm->customProperties(); |
770 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 767 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
@@ -914,769 +911,770 @@ Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | |||
914 | 911 | ||
915 | // resources | 912 | // resources |
916 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 913 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
917 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 914 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
918 | deleteStr(s); | 915 | deleteStr(s); |
919 | tmpStrList.clear(); | 916 | tmpStrList.clear(); |
920 | index1 = 0; | 917 | index1 = 0; |
921 | index2 = 0; | 918 | index2 = 0; |
922 | QString resource; | 919 | QString resource; |
923 | while ((index2 = resources.find(';', index1)) != -1) { | 920 | while ((index2 = resources.find(';', index1)) != -1) { |
924 | resource = resources.mid(index1, (index2 - index1)); | 921 | resource = resources.mid(index1, (index2 - index1)); |
925 | tmpStrList.append(resource); | 922 | tmpStrList.append(resource); |
926 | index1 = index2; | 923 | index1 = index2; |
927 | } | 924 | } |
928 | anEvent->setResources(tmpStrList); | 925 | anEvent->setResources(tmpStrList); |
929 | } | 926 | } |
930 | #endif | 927 | #endif |
931 | 928 | ||
932 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) | 929 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) |
933 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 930 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
934 | mEventsRelate.append(event); | 931 | mEventsRelate.append(event); |
935 | break; | 932 | break; |
936 | 933 | ||
937 | case ICAL_TRANSP_PROPERTY: // Transparency | 934 | case ICAL_TRANSP_PROPERTY: // Transparency |
938 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) | 935 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) |
939 | event->setTransparency( Event::Transparent ); | 936 | event->setTransparency( Event::Transparent ); |
940 | else | 937 | else |
941 | event->setTransparency( Event::Opaque ); | 938 | event->setTransparency( Event::Opaque ); |
942 | break; | 939 | break; |
943 | 940 | ||
944 | default: | 941 | default: |
945 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind | 942 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind |
946 | // << endl; | 943 | // << endl; |
947 | break; | 944 | break; |
948 | } | 945 | } |
949 | 946 | ||
950 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); | 947 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); |
951 | } | 948 | } |
952 | 949 | ||
953 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); | 950 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); |
954 | if (!msade.isNull()) { | 951 | if (!msade.isNull()) { |
955 | bool floats = (msade == QString::fromLatin1("TRUE")); | 952 | bool floats = (msade == QString::fromLatin1("TRUE")); |
956 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; | 953 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; |
957 | event->setFloats(floats); | 954 | event->setFloats(floats); |
958 | if (floats) { | 955 | if (floats) { |
959 | QDateTime endDate = event->dtEnd(); | 956 | QDateTime endDate = event->dtEnd(); |
960 | event->setDtEnd(endDate.addDays(-1)); | 957 | event->setDtEnd(endDate.addDays(-1)); |
961 | } | 958 | } |
962 | } | 959 | } |
963 | 960 | ||
964 | // some stupid vCal exporters ignore the standard and use Description | 961 | // some stupid vCal exporters ignore the standard and use Description |
965 | // instead of Summary for the default field. Correct for this. | 962 | // instead of Summary for the default field. Correct for this. |
966 | if (event->summary().isEmpty() && | 963 | if (event->summary().isEmpty() && |
967 | !(event->description().isEmpty())) { | 964 | !(event->description().isEmpty())) { |
968 | QString tmpStr = event->description().simplifyWhiteSpace(); | 965 | QString tmpStr = event->description().simplifyWhiteSpace(); |
969 | event->setDescription(""); | 966 | event->setDescription(""); |
970 | event->setSummary(tmpStr); | 967 | event->setSummary(tmpStr); |
971 | } | 968 | } |
972 | 969 | ||
973 | return event; | 970 | return event; |
974 | } | 971 | } |
975 | 972 | ||
976 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) | 973 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) |
977 | { | 974 | { |
978 | FreeBusy *freebusy = new FreeBusy; | 975 | FreeBusy *freebusy = new FreeBusy; |
979 | 976 | ||
980 | readIncidenceBase(vfreebusy,freebusy); | 977 | readIncidenceBase(vfreebusy,freebusy); |
981 | 978 | ||
982 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); | 979 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); |
983 | 980 | ||
984 | icaltimetype icaltime; | 981 | icaltimetype icaltime; |
985 | icalperiodtype icalperiod; | 982 | icalperiodtype icalperiod; |
986 | QDateTime period_start, period_end; | 983 | QDateTime period_start, period_end; |
987 | 984 | ||
988 | while (p) { | 985 | while (p) { |
989 | icalproperty_kind kind = icalproperty_isa(p); | 986 | icalproperty_kind kind = icalproperty_isa(p); |
990 | switch (kind) { | 987 | switch (kind) { |
991 | 988 | ||
992 | case ICAL_DTSTART_PROPERTY: // start date and time | 989 | case ICAL_DTSTART_PROPERTY: // start date and time |
993 | icaltime = icalproperty_get_dtstart(p); | 990 | icaltime = icalproperty_get_dtstart(p); |
994 | freebusy->setDtStart(readICalDateTime(icaltime)); | 991 | freebusy->setDtStart(readICalDateTime(icaltime)); |
995 | break; | 992 | break; |
996 | 993 | ||
997 | case ICAL_DTEND_PROPERTY: // start End Date and Time | 994 | case ICAL_DTEND_PROPERTY: // start End Date and Time |
998 | icaltime = icalproperty_get_dtend(p); | 995 | icaltime = icalproperty_get_dtend(p); |
999 | freebusy->setDtEnd(readICalDateTime(icaltime)); | 996 | freebusy->setDtEnd(readICalDateTime(icaltime)); |
1000 | break; | 997 | break; |
1001 | 998 | ||
1002 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times | 999 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times |
1003 | icalperiod = icalproperty_get_freebusy(p); | 1000 | icalperiod = icalproperty_get_freebusy(p); |
1004 | period_start = readICalDateTime(icalperiod.start); | 1001 | period_start = readICalDateTime(icalperiod.start); |
1005 | period_end = readICalDateTime(icalperiod.end); | 1002 | period_end = readICalDateTime(icalperiod.end); |
1006 | freebusy->addPeriod(period_start, period_end); | 1003 | freebusy->addPeriod(period_start, period_end); |
1007 | break; | 1004 | break; |
1008 | 1005 | ||
1009 | default: | 1006 | default: |
1010 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1007 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1011 | << endl; | 1008 | << endl; |
1012 | break; | 1009 | break; |
1013 | } | 1010 | } |
1014 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); | 1011 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); |
1015 | } | 1012 | } |
1016 | 1013 | ||
1017 | return freebusy; | 1014 | return freebusy; |
1018 | } | 1015 | } |
1019 | 1016 | ||
1020 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) | 1017 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) |
1021 | { | 1018 | { |
1022 | Journal *journal = new Journal; | 1019 | Journal *journal = new Journal; |
1023 | 1020 | ||
1024 | readIncidence(vjournal,journal); | 1021 | readIncidence(vjournal,journal); |
1025 | 1022 | ||
1026 | if ( !journal->dtStart().isValid() && journal->created().isValid() ) { | 1023 | if ( !journal->dtStart().isValid() && journal->created().isValid() ) { |
1027 | journal->setDtStart( journal->created() ); | 1024 | journal->setDtStart( journal->created() ); |
1028 | } | 1025 | } |
1029 | return journal; | 1026 | return journal; |
1030 | } | 1027 | } |
1031 | 1028 | ||
1032 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | 1029 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) |
1033 | { | 1030 | { |
1034 | icalparameter *p = 0; | 1031 | icalparameter *p = 0; |
1035 | 1032 | ||
1036 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | 1033 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); |
1037 | 1034 | ||
1038 | QString name; | 1035 | QString name; |
1039 | QString uid = QString::null; | 1036 | QString uid = QString::null; |
1040 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); | 1037 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); |
1041 | if (p) { | 1038 | if (p) { |
1042 | name = QString::fromUtf8(icalparameter_get_cn(p)); | 1039 | name = QString::fromUtf8(icalparameter_get_cn(p)); |
1043 | } else { | 1040 | } else { |
1044 | } | 1041 | } |
1045 | 1042 | ||
1046 | bool rsvp=false; | 1043 | bool rsvp=false; |
1047 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); | 1044 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); |
1048 | if (p) { | 1045 | if (p) { |
1049 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); | 1046 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); |
1050 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; | 1047 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; |
1051 | } | 1048 | } |
1052 | 1049 | ||
1053 | Attendee::PartStat status = Attendee::NeedsAction; | 1050 | Attendee::PartStat status = Attendee::NeedsAction; |
1054 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); | 1051 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); |
1055 | if (p) { | 1052 | if (p) { |
1056 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); | 1053 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); |
1057 | switch(partStatParameter) { | 1054 | switch(partStatParameter) { |
1058 | default: | 1055 | default: |
1059 | case ICAL_PARTSTAT_NEEDSACTION: | 1056 | case ICAL_PARTSTAT_NEEDSACTION: |
1060 | status = Attendee::NeedsAction; | 1057 | status = Attendee::NeedsAction; |
1061 | break; | 1058 | break; |
1062 | case ICAL_PARTSTAT_ACCEPTED: | 1059 | case ICAL_PARTSTAT_ACCEPTED: |
1063 | status = Attendee::Accepted; | 1060 | status = Attendee::Accepted; |
1064 | break; | 1061 | break; |
1065 | case ICAL_PARTSTAT_DECLINED: | 1062 | case ICAL_PARTSTAT_DECLINED: |
1066 | status = Attendee::Declined; | 1063 | status = Attendee::Declined; |
1067 | break; | 1064 | break; |
1068 | case ICAL_PARTSTAT_TENTATIVE: | 1065 | case ICAL_PARTSTAT_TENTATIVE: |
1069 | status = Attendee::Tentative; | 1066 | status = Attendee::Tentative; |
1070 | break; | 1067 | break; |
1071 | case ICAL_PARTSTAT_DELEGATED: | 1068 | case ICAL_PARTSTAT_DELEGATED: |
1072 | status = Attendee::Delegated; | 1069 | status = Attendee::Delegated; |
1073 | break; | 1070 | break; |
1074 | case ICAL_PARTSTAT_COMPLETED: | 1071 | case ICAL_PARTSTAT_COMPLETED: |
1075 | status = Attendee::Completed; | 1072 | status = Attendee::Completed; |
1076 | break; | 1073 | break; |
1077 | case ICAL_PARTSTAT_INPROCESS: | 1074 | case ICAL_PARTSTAT_INPROCESS: |
1078 | status = Attendee::InProcess; | 1075 | status = Attendee::InProcess; |
1079 | break; | 1076 | break; |
1080 | } | 1077 | } |
1081 | } | 1078 | } |
1082 | 1079 | ||
1083 | Attendee::Role role = Attendee::ReqParticipant; | 1080 | Attendee::Role role = Attendee::ReqParticipant; |
1084 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); | 1081 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); |
1085 | if (p) { | 1082 | if (p) { |
1086 | icalparameter_role roleParameter = icalparameter_get_role(p); | 1083 | icalparameter_role roleParameter = icalparameter_get_role(p); |
1087 | switch(roleParameter) { | 1084 | switch(roleParameter) { |
1088 | case ICAL_ROLE_CHAIR: | 1085 | case ICAL_ROLE_CHAIR: |
1089 | role = Attendee::Chair; | 1086 | role = Attendee::Chair; |
1090 | break; | 1087 | break; |
1091 | default: | 1088 | default: |
1092 | case ICAL_ROLE_REQPARTICIPANT: | 1089 | case ICAL_ROLE_REQPARTICIPANT: |
1093 | role = Attendee::ReqParticipant; | 1090 | role = Attendee::ReqParticipant; |
1094 | break; | 1091 | break; |
1095 | case ICAL_ROLE_OPTPARTICIPANT: | 1092 | case ICAL_ROLE_OPTPARTICIPANT: |
1096 | role = Attendee::OptParticipant; | 1093 | role = Attendee::OptParticipant; |
1097 | break; | 1094 | break; |
1098 | case ICAL_ROLE_NONPARTICIPANT: | 1095 | case ICAL_ROLE_NONPARTICIPANT: |
1099 | role = Attendee::NonParticipant; | 1096 | role = Attendee::NonParticipant; |
1100 | break; | 1097 | break; |
1101 | } | 1098 | } |
1102 | } | 1099 | } |
1103 | 1100 | ||
1104 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); | 1101 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); |
1105 | uid = icalparameter_get_xvalue(p); | 1102 | uid = icalparameter_get_xvalue(p); |
1106 | // This should be added, but there seems to be a libical bug here. | 1103 | // This should be added, but there seems to be a libical bug here. |
1107 | /*while (p) { | 1104 | /*while (p) { |
1108 | // if (icalparameter_get_xname(p) == "X-UID") { | 1105 | // if (icalparameter_get_xname(p) == "X-UID") { |
1109 | uid = icalparameter_get_xvalue(p); | 1106 | uid = icalparameter_get_xvalue(p); |
1110 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); | 1107 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); |
1111 | } */ | 1108 | } */ |
1112 | 1109 | ||
1113 | return new Attendee( name, email, rsvp, status, role, uid ); | 1110 | return new Attendee( name, email, rsvp, status, role, uid ); |
1114 | } | 1111 | } |
1115 | 1112 | ||
1116 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | 1113 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) |
1117 | { | 1114 | { |
1118 | icalattach *a = icalproperty_get_attach(attach); | 1115 | icalattach *a = icalproperty_get_attach(attach); |
1119 | icalparameter_value v = ICAL_VALUE_NONE; | 1116 | icalparameter_value v = ICAL_VALUE_NONE; |
1120 | icalparameter_encoding e = ICAL_ENCODING_NONE; | 1117 | icalparameter_encoding e = ICAL_ENCODING_NONE; |
1121 | 1118 | ||
1122 | Attachment *attachment = 0; | 1119 | Attachment *attachment = 0; |
1123 | /* | 1120 | /* |
1124 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); | 1121 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); |
1125 | if (vp) | 1122 | if (vp) |
1126 | v = icalparameter_get_value(vp); | 1123 | v = icalparameter_get_value(vp); |
1127 | 1124 | ||
1128 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); | 1125 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); |
1129 | if (ep) | 1126 | if (ep) |
1130 | e = icalparameter_get_encoding(ep); | 1127 | e = icalparameter_get_encoding(ep); |
1131 | */ | 1128 | */ |
1132 | int isurl = icalattach_get_is_url (a); | 1129 | int isurl = icalattach_get_is_url (a); |
1133 | if (isurl == 0) | 1130 | if (isurl == 0) |
1134 | attachment = new Attachment((const char*)icalattach_get_data(a)); | 1131 | attachment = new Attachment((const char*)icalattach_get_data(a)); |
1135 | else { | 1132 | else { |
1136 | attachment = new Attachment(QString(icalattach_get_url(a))); | 1133 | attachment = new Attachment(QString(icalattach_get_url(a))); |
1137 | } | 1134 | } |
1138 | 1135 | ||
1139 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); | 1136 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); |
1140 | if (p) | 1137 | if (p) |
1141 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); | 1138 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); |
1142 | 1139 | ||
1143 | return attachment; | 1140 | return attachment; |
1144 | } | 1141 | } |
1145 | #include <qtextcodec.h> | 1142 | #include <qtextcodec.h> |
1146 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | 1143 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) |
1147 | { | 1144 | { |
1148 | readIncidenceBase(parent,incidence); | 1145 | readIncidenceBase(parent,incidence); |
1149 | 1146 | ||
1150 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1147 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1151 | bool readrec = false; | 1148 | bool readrec = false; |
1152 | const char *text; | 1149 | const char *text; |
1153 | int intvalue; | 1150 | int intvalue; |
1154 | icaltimetype icaltime; | 1151 | icaltimetype icaltime; |
1155 | icaldurationtype icalduration; | 1152 | icaldurationtype icalduration; |
1156 | struct icalrecurrencetype rectype; | 1153 | struct icalrecurrencetype rectype; |
1157 | QStringList categories; | 1154 | QStringList categories; |
1158 | 1155 | ||
1159 | while (p) { | 1156 | while (p) { |
1160 | icalproperty_kind kind = icalproperty_isa(p); | 1157 | icalproperty_kind kind = icalproperty_isa(p); |
1161 | switch (kind) { | 1158 | switch (kind) { |
1162 | 1159 | ||
1163 | case ICAL_CREATED_PROPERTY: | 1160 | case ICAL_CREATED_PROPERTY: |
1164 | icaltime = icalproperty_get_created(p); | 1161 | icaltime = icalproperty_get_created(p); |
1165 | incidence->setCreated(readICalDateTime(icaltime)); | 1162 | incidence->setCreated(readICalDateTime(icaltime)); |
1166 | break; | 1163 | break; |
1167 | 1164 | ||
1168 | case ICAL_SEQUENCE_PROPERTY: // sequence | 1165 | case ICAL_SEQUENCE_PROPERTY: // sequence |
1169 | intvalue = icalproperty_get_sequence(p); | 1166 | intvalue = icalproperty_get_sequence(p); |
1170 | incidence->setRevision(intvalue); | 1167 | incidence->setRevision(intvalue); |
1171 | break; | 1168 | break; |
1172 | 1169 | ||
1173 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date | 1170 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date |
1174 | icaltime = icalproperty_get_lastmodified(p); | 1171 | icaltime = icalproperty_get_lastmodified(p); |
1175 | incidence->setLastModified(readICalDateTime(icaltime)); | 1172 | incidence->setLastModified(readICalDateTime(icaltime)); |
1176 | break; | 1173 | break; |
1177 | 1174 | ||
1178 | case ICAL_DTSTART_PROPERTY: // start date and time | 1175 | case ICAL_DTSTART_PROPERTY: // start date and time |
1179 | icaltime = icalproperty_get_dtstart(p); | 1176 | icaltime = icalproperty_get_dtstart(p); |
1180 | if (icaltime.is_date) { | 1177 | if (icaltime.is_date) { |
1181 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 1178 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
1182 | incidence->setFloats(true); | 1179 | incidence->setFloats(true); |
1183 | } else { | 1180 | } else { |
1184 | incidence->setDtStart(readICalDateTime(icaltime)); | 1181 | incidence->setDtStart(readICalDateTime(icaltime)); |
1185 | } | 1182 | } |
1186 | break; | 1183 | break; |
1187 | 1184 | ||
1188 | case ICAL_DURATION_PROPERTY: // start date and time | 1185 | case ICAL_DURATION_PROPERTY: // start date and time |
1189 | icalduration = icalproperty_get_duration(p); | 1186 | icalduration = icalproperty_get_duration(p); |
1190 | incidence->setDuration(readICalDuration(icalduration)); | 1187 | incidence->setDuration(readICalDuration(icalduration)); |
1191 | break; | 1188 | break; |
1192 | 1189 | ||
1193 | case ICAL_DESCRIPTION_PROPERTY: // description | 1190 | case ICAL_DESCRIPTION_PROPERTY: // description |
1194 | text = icalproperty_get_description(p); | 1191 | text = icalproperty_get_description(p); |
1195 | incidence->setDescription(QString::fromUtf8(text)); | 1192 | incidence->setDescription(QString::fromUtf8(text)); |
1196 | break; | 1193 | break; |
1197 | 1194 | ||
1198 | case ICAL_SUMMARY_PROPERTY: // summary | 1195 | case ICAL_SUMMARY_PROPERTY: // summary |
1199 | { | 1196 | { |
1200 | text = icalproperty_get_summary(p); | 1197 | text = icalproperty_get_summary(p); |
1201 | incidence->setSummary(QString::fromUtf8(text)); | 1198 | incidence->setSummary(QString::fromUtf8(text)); |
1202 | } | 1199 | } |
1203 | break; | 1200 | break; |
1204 | case ICAL_STATUS_PROPERTY: // summary | 1201 | case ICAL_STATUS_PROPERTY: // summary |
1205 | { | 1202 | { |
1206 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) | 1203 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) |
1207 | incidence->setCancelled( true ); | 1204 | incidence->setCancelled( true ); |
1208 | } | 1205 | } |
1209 | break; | 1206 | break; |
1210 | 1207 | ||
1211 | case ICAL_LOCATION_PROPERTY: // location | 1208 | case ICAL_LOCATION_PROPERTY: // location |
1212 | text = icalproperty_get_location(p); | 1209 | text = icalproperty_get_location(p); |
1213 | incidence->setLocation(QString::fromUtf8(text)); | 1210 | incidence->setLocation(QString::fromUtf8(text)); |
1214 | break; | 1211 | break; |
1215 | 1212 | ||
1216 | case ICAL_RECURRENCEID_PROPERTY: | 1213 | case ICAL_RECURRENCEID_PROPERTY: |
1217 | icaltime = icalproperty_get_recurrenceid(p); | 1214 | icaltime = icalproperty_get_recurrenceid(p); |
1218 | incidence->setRecurrenceID( readICalDateTime(icaltime) ); | 1215 | incidence->setRecurrenceID( readICalDateTime(icaltime) ); |
1219 | //qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); | 1216 | //qDebug(" RecurrenceID %s",incidence->recurrenceID().toString().latin1() ); |
1220 | break; | 1217 | break; |
1221 | #if 0 | 1218 | #if 0 |
1222 | // status | 1219 | // status |
1223 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { | 1220 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { |
1224 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); | 1221 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); |
1225 | deleteStr(s); | 1222 | deleteStr(s); |
1226 | } | 1223 | } |
1227 | else | 1224 | else |
1228 | incidence->setStatus("NEEDS ACTION"); | 1225 | incidence->setStatus("NEEDS ACTION"); |
1229 | #endif | 1226 | #endif |
1230 | 1227 | ||
1231 | case ICAL_PRIORITY_PROPERTY: // priority | 1228 | case ICAL_PRIORITY_PROPERTY: // priority |
1232 | intvalue = icalproperty_get_priority(p); | 1229 | intvalue = icalproperty_get_priority(p); |
1233 | incidence->setPriority(intvalue); | 1230 | incidence->setPriority(intvalue); |
1234 | break; | 1231 | break; |
1235 | 1232 | ||
1236 | case ICAL_CATEGORIES_PROPERTY: // categories | 1233 | case ICAL_CATEGORIES_PROPERTY: // categories |
1237 | text = icalproperty_get_categories(p); | 1234 | text = icalproperty_get_categories(p); |
1238 | categories.append(QString::fromUtf8(text)); | 1235 | categories.append(QString::fromUtf8(text)); |
1239 | break; | 1236 | break; |
1240 | //******************************************* | 1237 | //******************************************* |
1241 | case ICAL_RRULE_PROPERTY: | 1238 | case ICAL_RRULE_PROPERTY: |
1242 | // we do need (maybe )start datetime of incidence for recurrence | 1239 | // we do need (maybe )start datetime of incidence for recurrence |
1243 | // such that we can read recurrence only after we read incidence completely | 1240 | // such that we can read recurrence only after we read incidence completely |
1244 | readrec = true; | 1241 | readrec = true; |
1245 | rectype = icalproperty_get_rrule(p); | 1242 | rectype = icalproperty_get_rrule(p); |
1246 | break; | 1243 | break; |
1247 | 1244 | ||
1248 | case ICAL_EXDATE_PROPERTY: | 1245 | case ICAL_EXDATE_PROPERTY: |
1249 | icaltime = icalproperty_get_exdate(p); | 1246 | icaltime = icalproperty_get_exdate(p); |
1250 | incidence->addExDate(readICalDate(icaltime)); | 1247 | incidence->addExDate(readICalDate(icaltime)); |
1251 | break; | 1248 | break; |
1252 | 1249 | ||
1253 | case ICAL_CLASS_PROPERTY: { | 1250 | case ICAL_CLASS_PROPERTY: { |
1254 | int inttext = icalproperty_get_class(p); | 1251 | int inttext = icalproperty_get_class(p); |
1255 | if (inttext == ICAL_CLASS_PUBLIC ) { | 1252 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1256 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1253 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1257 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { | 1254 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1258 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1255 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1259 | } else { | 1256 | } else { |
1260 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1257 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1261 | } | 1258 | } |
1262 | } | 1259 | } |
1263 | break; | 1260 | break; |
1264 | 1261 | ||
1265 | case ICAL_ATTACH_PROPERTY: // attachments | 1262 | case ICAL_ATTACH_PROPERTY: // attachments |
1266 | incidence->addAttachment(readAttachment(p)); | 1263 | incidence->addAttachment(readAttachment(p)); |
1267 | break; | 1264 | break; |
1268 | 1265 | ||
1269 | default: | 1266 | default: |
1270 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1267 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1271 | // << endl; | 1268 | // << endl; |
1272 | break; | 1269 | break; |
1273 | } | 1270 | } |
1274 | 1271 | ||
1275 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1272 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1276 | } | 1273 | } |
1277 | if ( readrec ) { | 1274 | if ( readrec ) { |
1278 | readRecurrenceRule(rectype,incidence); | 1275 | readRecurrenceRule(rectype,incidence); |
1279 | } | 1276 | } |
1280 | // kpilot stuff | 1277 | // kpilot stuff |
1281 | // TODO: move this application-specific code to kpilot | 1278 | // TODO: move this application-specific code to kpilot |
1282 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1279 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1283 | if (!kp.isNull()) { | 1280 | if (!kp.isNull()) { |
1284 | incidence->setPilotId(kp.toInt()); | 1281 | incidence->setPilotId(kp.toInt()); |
1285 | } | 1282 | } |
1286 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1283 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
1287 | if (!kp.isNull()) { | 1284 | if (!kp.isNull()) { |
1288 | incidence->setSyncStatus(kp.toInt()); | 1285 | incidence->setSyncStatus(kp.toInt()); |
1289 | } | 1286 | } |
1290 | 1287 | ||
1291 | 1288 | ||
1292 | kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); | 1289 | kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); |
1293 | if (!kp.isNull()) { | 1290 | if (!kp.isNull()) { |
1294 | incidence->setIDStr(kp); | 1291 | incidence->setIDStr(kp); |
1295 | } | 1292 | } |
1296 | 1293 | ||
1297 | // Cancel backwards compatibility mode for subsequent changes by the application | 1294 | // Cancel backwards compatibility mode for subsequent changes by the application |
1298 | incidence->recurrence()->setCompatVersion(); | 1295 | if ( readrec ) |
1296 | incidence->recurrence()->setCompatVersion(); | ||
1299 | 1297 | ||
1300 | // add categories | 1298 | // add categories |
1301 | incidence->setCategories(categories); | 1299 | incidence->setCategories(categories); |
1302 | 1300 | ||
1303 | // iterate through all alarms | 1301 | // iterate through all alarms |
1304 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1302 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1305 | alarm; | 1303 | alarm; |
1306 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1304 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1307 | readAlarm(alarm,incidence); | 1305 | readAlarm(alarm,incidence); |
1308 | } | 1306 | } |
1309 | } | 1307 | } |
1310 | 1308 | ||
1311 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1309 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1312 | { | 1310 | { |
1313 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1311 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1314 | 1312 | ||
1315 | while (p) { | 1313 | while (p) { |
1316 | icalproperty_kind kind = icalproperty_isa(p); | 1314 | icalproperty_kind kind = icalproperty_isa(p); |
1317 | switch (kind) { | 1315 | switch (kind) { |
1318 | 1316 | ||
1319 | case ICAL_UID_PROPERTY: // unique id | 1317 | case ICAL_UID_PROPERTY: // unique id |
1320 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1318 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1321 | break; | 1319 | break; |
1322 | 1320 | ||
1323 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1321 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1324 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1322 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1325 | break; | 1323 | break; |
1326 | 1324 | ||
1327 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1325 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1328 | incidenceBase->addAttendee(readAttendee(p)); | 1326 | incidenceBase->addAttendee(readAttendee(p)); |
1329 | break; | 1327 | break; |
1330 | 1328 | ||
1331 | default: | 1329 | default: |
1332 | break; | 1330 | break; |
1333 | } | 1331 | } |
1334 | 1332 | ||
1335 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1333 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1336 | } | 1334 | } |
1337 | 1335 | ||
1338 | // custom properties | 1336 | // custom properties |
1339 | readCustomProperties(parent, incidenceBase); | 1337 | readCustomProperties(parent, incidenceBase); |
1340 | } | 1338 | } |
1341 | 1339 | ||
1342 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1340 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1343 | { | 1341 | { |
1344 | QMap<QCString, QString> customProperties; | 1342 | QMap<QCString, QString> customProperties; |
1345 | 1343 | ||
1346 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1344 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1347 | 1345 | ||
1348 | while (p) { | 1346 | while (p) { |
1349 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1347 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1350 | customProperties[icalproperty_get_x_name(p)] = value; | 1348 | customProperties[icalproperty_get_x_name(p)] = value; |
1351 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | 1349 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); |
1352 | 1350 | ||
1353 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1351 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1354 | } | 1352 | } |
1355 | 1353 | ||
1356 | properties->setCustomProperties(customProperties); | 1354 | properties->setCustomProperties(customProperties); |
1357 | } | 1355 | } |
1358 | 1356 | ||
1359 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1357 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1360 | { | 1358 | { |
1361 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1359 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1362 | 1360 | ||
1363 | Recurrence *recur = incidence->recurrence(); | 1361 | Recurrence *recur = incidence->recurrence(); |
1364 | recur->setCompatVersion(mCalendarVersion); | 1362 | recur->setCompatVersion(mCalendarVersion); |
1365 | recur->unsetRecurs(); | 1363 | recur->unsetRecurs(); |
1366 | 1364 | ||
1367 | struct icalrecurrencetype r = rrule; | 1365 | struct icalrecurrencetype r = rrule; |
1368 | 1366 | ||
1369 | dumpIcalRecurrence(r); | 1367 | dumpIcalRecurrence(r); |
1370 | readRecurrence( r, recur, incidence); | 1368 | readRecurrence( r, recur, incidence); |
1371 | } | 1369 | } |
1372 | 1370 | ||
1373 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1371 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1374 | { | 1372 | { |
1375 | int wkst; | 1373 | int wkst; |
1376 | int index = 0; | 1374 | int index = 0; |
1377 | short day = 0; | 1375 | short day = 0; |
1378 | QBitArray qba(7); | 1376 | QBitArray qba(7); |
1379 | int frequ = r.freq; | 1377 | int frequ = r.freq; |
1380 | int interv = r.interval; | 1378 | int interv = r.interval; |
1381 | // preprocessing for odd recurrence definitions | 1379 | // preprocessing for odd recurrence definitions |
1382 | 1380 | ||
1383 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { | 1381 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { |
1384 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1382 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1385 | interv = 12; | 1383 | interv = 12; |
1386 | } | 1384 | } |
1387 | } | 1385 | } |
1388 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { | 1386 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { |
1389 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1387 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1390 | frequ = ICAL_MONTHLY_RECURRENCE; | 1388 | frequ = ICAL_MONTHLY_RECURRENCE; |
1391 | interv = 12* r.interval; | 1389 | interv = 12* r.interval; |
1392 | } | 1390 | } |
1393 | } | 1391 | } |
1394 | 1392 | ||
1395 | switch (frequ) { | 1393 | switch (frequ) { |
1396 | case ICAL_MINUTELY_RECURRENCE: | 1394 | case ICAL_MINUTELY_RECURRENCE: |
1397 | if (!icaltime_is_null_time(r.until)) { | 1395 | if (!icaltime_is_null_time(r.until)) { |
1398 | recur->setMinutely(interv,readICalDateTime(r.until)); | 1396 | recur->setMinutely(interv,readICalDateTime(r.until)); |
1399 | } else { | 1397 | } else { |
1400 | if (r.count == 0) | 1398 | if (r.count == 0) |
1401 | recur->setMinutely(interv,-1); | 1399 | recur->setMinutely(interv,-1); |
1402 | else | 1400 | else |
1403 | recur->setMinutely(interv,r.count); | 1401 | recur->setMinutely(interv,r.count); |
1404 | } | 1402 | } |
1405 | break; | 1403 | break; |
1406 | case ICAL_HOURLY_RECURRENCE: | 1404 | case ICAL_HOURLY_RECURRENCE: |
1407 | if (!icaltime_is_null_time(r.until)) { | 1405 | if (!icaltime_is_null_time(r.until)) { |
1408 | recur->setHourly(interv,readICalDateTime(r.until)); | 1406 | recur->setHourly(interv,readICalDateTime(r.until)); |
1409 | } else { | 1407 | } else { |
1410 | if (r.count == 0) | 1408 | if (r.count == 0) |
1411 | recur->setHourly(interv,-1); | 1409 | recur->setHourly(interv,-1); |
1412 | else | 1410 | else |
1413 | recur->setHourly(interv,r.count); | 1411 | recur->setHourly(interv,r.count); |
1414 | } | 1412 | } |
1415 | break; | 1413 | break; |
1416 | case ICAL_DAILY_RECURRENCE: | 1414 | case ICAL_DAILY_RECURRENCE: |
1417 | if (!icaltime_is_null_time(r.until)) { | 1415 | if (!icaltime_is_null_time(r.until)) { |
1418 | recur->setDaily(interv,readICalDate(r.until)); | 1416 | recur->setDaily(interv,readICalDate(r.until)); |
1419 | } else { | 1417 | } else { |
1420 | if (r.count == 0) | 1418 | if (r.count == 0) |
1421 | recur->setDaily(interv,-1); | 1419 | recur->setDaily(interv,-1); |
1422 | else | 1420 | else |
1423 | recur->setDaily(interv,r.count); | 1421 | recur->setDaily(interv,r.count); |
1424 | } | 1422 | } |
1425 | break; | 1423 | break; |
1426 | case ICAL_WEEKLY_RECURRENCE: | 1424 | case ICAL_WEEKLY_RECURRENCE: |
1427 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; | 1425 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; |
1428 | wkst = (r.week_start + 5)%7 + 1; | 1426 | wkst = (r.week_start + 5)%7 + 1; |
1429 | if (!icaltime_is_null_time(r.until)) { | 1427 | if (!icaltime_is_null_time(r.until)) { |
1430 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); | 1428 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); |
1431 | } else { | 1429 | } else { |
1432 | if (r.count == 0) | 1430 | if (r.count == 0) |
1433 | recur->setWeekly(interv,qba,-1,wkst); | 1431 | recur->setWeekly(interv,qba,-1,wkst); |
1434 | else | 1432 | else |
1435 | recur->setWeekly(interv,qba,r.count,wkst); | 1433 | recur->setWeekly(interv,qba,r.count,wkst); |
1436 | } | 1434 | } |
1437 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { | 1435 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { |
1438 | int wday = incidence->dtStart().date().dayOfWeek ()-1; | 1436 | int wday = incidence->dtStart().date().dayOfWeek ()-1; |
1439 | //qDebug("weekly error found "); | 1437 | //qDebug("weekly error found "); |
1440 | qba.setBit(wday); | 1438 | qba.setBit(wday); |
1441 | } else { | 1439 | } else { |
1442 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1440 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1443 | // kdDebug(5800) << " " << day << endl; | 1441 | // kdDebug(5800) << " " << day << endl; |
1444 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1442 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1445 | } | 1443 | } |
1446 | } | 1444 | } |
1447 | break; | 1445 | break; |
1448 | case ICAL_MONTHLY_RECURRENCE: | 1446 | case ICAL_MONTHLY_RECURRENCE: |
1449 | 1447 | ||
1450 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1448 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1451 | if (!icaltime_is_null_time(r.until)) { | 1449 | if (!icaltime_is_null_time(r.until)) { |
1452 | recur->setMonthly(Recurrence::rMonthlyPos,interv, | 1450 | recur->setMonthly(Recurrence::rMonthlyPos,interv, |
1453 | readICalDate(r.until)); | 1451 | readICalDate(r.until)); |
1454 | } else { | 1452 | } else { |
1455 | if (r.count == 0) | 1453 | if (r.count == 0) |
1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); | 1454 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); |
1457 | else | 1455 | else |
1458 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); | 1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); |
1459 | } | 1457 | } |
1460 | bool useSetPos = false; | 1458 | bool useSetPos = false; |
1461 | short pos = 0; | 1459 | short pos = 0; |
1462 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1460 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1463 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1461 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1464 | pos = icalrecurrencetype_day_position(day); | 1462 | pos = icalrecurrencetype_day_position(day); |
1465 | if (pos) { | 1463 | if (pos) { |
1466 | day = icalrecurrencetype_day_day_of_week(day); | 1464 | day = icalrecurrencetype_day_day_of_week(day); |
1467 | QBitArray ba(7); // don't wipe qba | 1465 | QBitArray ba(7); // don't wipe qba |
1468 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1466 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1469 | recur->addMonthlyPos(pos,ba); | 1467 | recur->addMonthlyPos(pos,ba); |
1470 | } else { | 1468 | } else { |
1471 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1469 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1472 | useSetPos = true; | 1470 | useSetPos = true; |
1473 | } | 1471 | } |
1474 | } | 1472 | } |
1475 | if (useSetPos) { | 1473 | if (useSetPos) { |
1476 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1474 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1477 | recur->addMonthlyPos(r.by_set_pos[0],qba); | 1475 | recur->addMonthlyPos(r.by_set_pos[0],qba); |
1478 | } | 1476 | } |
1479 | } | 1477 | } |
1480 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1478 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1481 | if (!icaltime_is_null_time(r.until)) { | 1479 | if (!icaltime_is_null_time(r.until)) { |
1482 | recur->setMonthly(Recurrence::rMonthlyDay,interv, | 1480 | recur->setMonthly(Recurrence::rMonthlyDay,interv, |
1483 | readICalDate(r.until)); | 1481 | readICalDate(r.until)); |
1484 | } else { | 1482 | } else { |
1485 | if (r.count == 0) | 1483 | if (r.count == 0) |
1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); | 1484 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); |
1487 | else | 1485 | else |
1488 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); | 1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); |
1489 | } | 1487 | } |
1490 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1488 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1491 | // kdDebug(5800) << "----b " << day << endl; | 1489 | // kdDebug(5800) << "----b " << day << endl; |
1492 | recur->addMonthlyDay(day); | 1490 | recur->addMonthlyDay(day); |
1493 | } | 1491 | } |
1494 | } | 1492 | } |
1495 | break; | 1493 | break; |
1496 | case ICAL_YEARLY_RECURRENCE: | 1494 | case ICAL_YEARLY_RECURRENCE: |
1497 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1495 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1498 | //qDebug(" YEARLY DAY OF YEAR"); | 1496 | //qDebug(" YEARLY DAY OF YEAR"); |
1499 | if (!icaltime_is_null_time(r.until)) { | 1497 | if (!icaltime_is_null_time(r.until)) { |
1500 | recur->setYearly(Recurrence::rYearlyDay,interv, | 1498 | recur->setYearly(Recurrence::rYearlyDay,interv, |
1501 | readICalDate(r.until)); | 1499 | readICalDate(r.until)); |
1502 | } else { | 1500 | } else { |
1503 | if (r.count == 0) | 1501 | if (r.count == 0) |
1504 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); | 1502 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); |
1505 | else | 1503 | else |
1506 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); | 1504 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); |
1507 | } | 1505 | } |
1508 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1506 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1509 | recur->addYearlyNum(day); | 1507 | recur->addYearlyNum(day); |
1510 | } | 1508 | } |
1511 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { | 1509 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { |
1512 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1510 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1513 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | 1511 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); |
1514 | if (!icaltime_is_null_time(r.until)) { | 1512 | if (!icaltime_is_null_time(r.until)) { |
1515 | recur->setYearly(Recurrence::rYearlyPos,interv, | 1513 | recur->setYearly(Recurrence::rYearlyPos,interv, |
1516 | readICalDate(r.until)); | 1514 | readICalDate(r.until)); |
1517 | } else { | 1515 | } else { |
1518 | if (r.count == 0) | 1516 | if (r.count == 0) |
1519 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); | 1517 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); |
1520 | else | 1518 | else |
1521 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); | 1519 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); |
1522 | } | 1520 | } |
1523 | bool useSetPos = false; | 1521 | bool useSetPos = false; |
1524 | short pos = 0; | 1522 | short pos = 0; |
1525 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1523 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1526 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1524 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1527 | pos = icalrecurrencetype_day_position(day); | 1525 | pos = icalrecurrencetype_day_position(day); |
1528 | if (pos) { | 1526 | if (pos) { |
1529 | day = icalrecurrencetype_day_day_of_week(day); | 1527 | day = icalrecurrencetype_day_day_of_week(day); |
1530 | QBitArray ba(7); // don't wipe qba | 1528 | QBitArray ba(7); // don't wipe qba |
1531 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1529 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1532 | recur->addYearlyMonthPos(pos,ba); | 1530 | recur->addYearlyMonthPos(pos,ba); |
1533 | } else { | 1531 | } else { |
1534 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1532 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1535 | useSetPos = true; | 1533 | useSetPos = true; |
1536 | } | 1534 | } |
1537 | } | 1535 | } |
1538 | if (useSetPos) { | 1536 | if (useSetPos) { |
1539 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1537 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1540 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); | 1538 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); |
1541 | } | 1539 | } |
1542 | } | 1540 | } |
1543 | } else { | 1541 | } else { |
1544 | //qDebug("YEARLY MONTH "); | 1542 | //qDebug("YEARLY MONTH "); |
1545 | if (!icaltime_is_null_time(r.until)) { | 1543 | if (!icaltime_is_null_time(r.until)) { |
1546 | recur->setYearly(Recurrence::rYearlyMonth,interv, | 1544 | recur->setYearly(Recurrence::rYearlyMonth,interv, |
1547 | readICalDate(r.until)); | 1545 | readICalDate(r.until)); |
1548 | } else { | 1546 | } else { |
1549 | if (r.count == 0) | 1547 | if (r.count == 0) |
1550 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); | 1548 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); |
1551 | else | 1549 | else |
1552 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); | 1550 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); |
1553 | } | 1551 | } |
1554 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1552 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1555 | index = 0; | 1553 | index = 0; |
1556 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1554 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1557 | recur->addYearlyNum(day); | 1555 | recur->addYearlyNum(day); |
1558 | } | 1556 | } |
1559 | } else { | 1557 | } else { |
1560 | recur->addYearlyNum(incidence->dtStart().date().month()); | 1558 | recur->addYearlyNum(incidence->dtStart().date().month()); |
1561 | } | 1559 | } |
1562 | } | 1560 | } |
1563 | 1561 | ||
1564 | } | 1562 | } |
1565 | break; | 1563 | break; |
1566 | default: | 1564 | default: |
1567 | ; | 1565 | ; |
1568 | break; | 1566 | break; |
1569 | } | 1567 | } |
1570 | } | 1568 | } |
1571 | 1569 | ||
1572 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | 1570 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) |
1573 | { | 1571 | { |
1574 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; | 1572 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; |
1575 | 1573 | ||
1576 | Alarm* ialarm = incidence->newAlarm(); | 1574 | Alarm* ialarm = incidence->newAlarm(); |
1577 | ialarm->setRepeatCount(0); | 1575 | ialarm->setRepeatCount(0); |
1578 | ialarm->setEnabled(true); | 1576 | ialarm->setEnabled(true); |
1579 | 1577 | ||
1580 | // Determine the alarm's action type | 1578 | // Determine the alarm's action type |
1581 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); | 1579 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); |
1582 | if ( !p ) { | 1580 | if ( !p ) { |
1583 | return; | 1581 | return; |
1584 | } | 1582 | } |
1585 | 1583 | ||
1586 | icalproperty_action action = icalproperty_get_action(p); | 1584 | icalproperty_action action = icalproperty_get_action(p); |
1587 | Alarm::Type type = Alarm::Display; | 1585 | Alarm::Type type = Alarm::Display; |
1588 | switch ( action ) { | 1586 | switch ( action ) { |
1589 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; | 1587 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; |
1590 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; | 1588 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; |
1591 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; | 1589 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; |
1592 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; | 1590 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; |
1593 | default: | 1591 | default: |
1594 | ; | 1592 | ; |
1595 | return; | 1593 | return; |
1596 | } | 1594 | } |
1597 | ialarm->setType(type); | 1595 | ialarm->setType(type); |
1598 | 1596 | ||
1599 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); | 1597 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); |
1600 | while (p) { | 1598 | while (p) { |
1601 | icalproperty_kind kind = icalproperty_isa(p); | 1599 | icalproperty_kind kind = icalproperty_isa(p); |
1602 | 1600 | ||
1603 | switch (kind) { | 1601 | switch (kind) { |
1604 | case ICAL_TRIGGER_PROPERTY: { | 1602 | case ICAL_TRIGGER_PROPERTY: { |
1605 | icaltriggertype trigger = icalproperty_get_trigger(p); | 1603 | icaltriggertype trigger = icalproperty_get_trigger(p); |
1606 | if (icaltime_is_null_time(trigger.time)) { | 1604 | if (icaltime_is_null_time(trigger.time)) { |
1607 | if (icaldurationtype_is_null_duration(trigger.duration)) { | 1605 | if (icaldurationtype_is_null_duration(trigger.duration)) { |
1608 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; | 1606 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; |
1609 | } else { | 1607 | } else { |
1610 | Duration duration = icaldurationtype_as_int( trigger.duration ); | 1608 | Duration duration = icaldurationtype_as_int( trigger.duration ); |
1611 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); | 1609 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); |
1612 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) | 1610 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) |
1613 | ialarm->setEndOffset(duration); | 1611 | ialarm->setEndOffset(duration); |
1614 | else | 1612 | else |
1615 | ialarm->setStartOffset(duration); | 1613 | ialarm->setStartOffset(duration); |
1616 | } | 1614 | } |
1617 | } else { | 1615 | } else { |
1618 | ialarm->setTime(readICalDateTime(trigger.time)); | 1616 | ialarm->setTime(readICalDateTime(trigger.time)); |
1619 | } | 1617 | } |
1620 | break; | 1618 | break; |
1621 | } | 1619 | } |
1622 | case ICAL_DURATION_PROPERTY: { | 1620 | case ICAL_DURATION_PROPERTY: { |
1623 | icaldurationtype duration = icalproperty_get_duration(p); | 1621 | icaldurationtype duration = icalproperty_get_duration(p); |
1624 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); | 1622 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); |
1625 | break; | 1623 | break; |
1626 | } | 1624 | } |
1627 | case ICAL_REPEAT_PROPERTY: | 1625 | case ICAL_REPEAT_PROPERTY: |
1628 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); | 1626 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); |
1629 | break; | 1627 | break; |
1630 | 1628 | ||
1631 | // Only in DISPLAY and EMAIL and PROCEDURE alarms | 1629 | // Only in DISPLAY and EMAIL and PROCEDURE alarms |
1632 | case ICAL_DESCRIPTION_PROPERTY: { | 1630 | case ICAL_DESCRIPTION_PROPERTY: { |
1633 | QString description = QString::fromUtf8(icalproperty_get_description(p)); | 1631 | QString description = QString::fromUtf8(icalproperty_get_description(p)); |
1634 | switch ( action ) { | 1632 | switch ( action ) { |
1635 | case ICAL_ACTION_DISPLAY: | 1633 | case ICAL_ACTION_DISPLAY: |
1636 | ialarm->setText( description ); | 1634 | ialarm->setText( description ); |
1637 | break; | 1635 | break; |
1638 | case ICAL_ACTION_PROCEDURE: | 1636 | case ICAL_ACTION_PROCEDURE: |
1639 | ialarm->setProgramArguments( description ); | 1637 | ialarm->setProgramArguments( description ); |
1640 | break; | 1638 | break; |
1641 | case ICAL_ACTION_EMAIL: | 1639 | case ICAL_ACTION_EMAIL: |
1642 | ialarm->setMailText( description ); | 1640 | ialarm->setMailText( description ); |
1643 | break; | 1641 | break; |
1644 | default: | 1642 | default: |
1645 | break; | 1643 | break; |
1646 | } | 1644 | } |
1647 | break; | 1645 | break; |
1648 | } | 1646 | } |
1649 | // Only in EMAIL alarm | 1647 | // Only in EMAIL alarm |
1650 | case ICAL_SUMMARY_PROPERTY: | 1648 | case ICAL_SUMMARY_PROPERTY: |
1651 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); | 1649 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); |
1652 | break; | 1650 | break; |
1653 | 1651 | ||
1654 | // Only in EMAIL alarm | 1652 | // Only in EMAIL alarm |
1655 | case ICAL_ATTENDEE_PROPERTY: { | 1653 | case ICAL_ATTENDEE_PROPERTY: { |
1656 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); | 1654 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); |
1657 | QString name; | 1655 | QString name; |
1658 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); | 1656 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); |
1659 | if (param) { | 1657 | if (param) { |
1660 | name = QString::fromUtf8(icalparameter_get_cn(param)); | 1658 | name = QString::fromUtf8(icalparameter_get_cn(param)); |
1661 | } | 1659 | } |
1662 | ialarm->addMailAddress(Person(name, email)); | 1660 | ialarm->addMailAddress(Person(name, email)); |
1663 | break; | 1661 | break; |
1664 | } | 1662 | } |
1665 | // Only in AUDIO and EMAIL and PROCEDURE alarms | 1663 | // Only in AUDIO and EMAIL and PROCEDURE alarms |
1666 | case ICAL_ATTACH_PROPERTY: { | 1664 | case ICAL_ATTACH_PROPERTY: { |
1667 | icalattach *attach = icalproperty_get_attach(p); | 1665 | icalattach *attach = icalproperty_get_attach(p); |
1668 | QString url = QFile::decodeName(icalattach_get_url(attach)); | 1666 | QString url = QFile::decodeName(icalattach_get_url(attach)); |
1669 | switch ( action ) { | 1667 | switch ( action ) { |
1670 | case ICAL_ACTION_AUDIO: | 1668 | case ICAL_ACTION_AUDIO: |
1671 | ialarm->setAudioFile( url ); | 1669 | ialarm->setAudioFile( url ); |
1672 | break; | 1670 | break; |
1673 | case ICAL_ACTION_PROCEDURE: | 1671 | case ICAL_ACTION_PROCEDURE: |
1674 | ialarm->setProgramFile( url ); | 1672 | ialarm->setProgramFile( url ); |
1675 | break; | 1673 | break; |
1676 | case ICAL_ACTION_EMAIL: | 1674 | case ICAL_ACTION_EMAIL: |
1677 | ialarm->addMailAttachment( url ); | 1675 | ialarm->addMailAttachment( url ); |
1678 | break; | 1676 | break; |
1679 | default: | 1677 | default: |
1680 | break; | 1678 | break; |
1681 | } | 1679 | } |
1682 | break; | 1680 | break; |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index e4bcc5e..4643a3a 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,780 +1,811 @@ | |||
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 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::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 = 0;//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; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | mAttachments = i.mAttachments; |
63 | mResources = i.mResources; | 63 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 64 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 65 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 66 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 67 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 68 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 69 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 70 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 71 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 72 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 73 | b->setParent( this ); |
74 | mAlarms.append( b ); | 74 | mAlarms.append( b ); |
75 | 75 | ||
76 | ++it; | 76 | ++it; |
77 | } | 77 | } |
78 | mAlarms.setAutoDelete(true); | 78 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 79 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 80 | mRecurrenceID = i.mRecurrenceID; |
81 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 81 | if ( i.mRecurrence ) |
82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | ||
83 | else | ||
84 | mRecurrence = 0; | ||
82 | mHoliday = i.mHoliday ; | 85 | mHoliday = i.mHoliday ; |
83 | mBirthday = i.mBirthday; | 86 | mBirthday = i.mBirthday; |
84 | mAnniversary = i.mAnniversary; | 87 | mAnniversary = i.mAnniversary; |
85 | } | 88 | } |
86 | 89 | ||
87 | Incidence::~Incidence() | 90 | Incidence::~Incidence() |
88 | { | 91 | { |
89 | 92 | ||
90 | Incidence *ev; | 93 | Incidence *ev; |
91 | QPtrList<Incidence> Relations = relations(); | 94 | QPtrList<Incidence> Relations = relations(); |
92 | for (ev=Relations.first();ev;ev=Relations.next()) { | 95 | for (ev=Relations.first();ev;ev=Relations.next()) { |
93 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 96 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
94 | } | 97 | } |
95 | if (relatedTo()) relatedTo()->removeRelation(this); | 98 | if (relatedTo()) relatedTo()->removeRelation(this); |
96 | delete mRecurrence; | 99 | if ( mRecurrence ) |
100 | delete mRecurrence; | ||
97 | 101 | ||
98 | } | 102 | } |
99 | 103 | ||
100 | bool Incidence::isHoliday() const | 104 | bool Incidence::isHoliday() const |
101 | { | 105 | { |
102 | return mHoliday; | 106 | return mHoliday; |
103 | } | 107 | } |
104 | bool Incidence::isBirthday() const | 108 | bool Incidence::isBirthday() const |
105 | { | 109 | { |
106 | 110 | ||
107 | return mBirthday ; | 111 | return mBirthday ; |
108 | } | 112 | } |
109 | bool Incidence::isAnniversary() const | 113 | bool Incidence::isAnniversary() const |
110 | { | 114 | { |
111 | return mAnniversary ; | 115 | return mAnniversary ; |
112 | 116 | ||
113 | } | 117 | } |
114 | 118 | ||
115 | bool Incidence::hasRecurrenceID() const | 119 | bool Incidence::hasRecurrenceID() const |
116 | { | 120 | { |
117 | return mHasRecurrenceID; | 121 | return mHasRecurrenceID; |
118 | } | 122 | } |
119 | 123 | ||
120 | void Incidence::setHasRecurrenceID( bool b ) | 124 | void Incidence::setHasRecurrenceID( bool b ) |
121 | { | 125 | { |
122 | mHasRecurrenceID = b; | 126 | mHasRecurrenceID = b; |
123 | } | 127 | } |
124 | 128 | ||
125 | void Incidence::setRecurrenceID(QDateTime d) | 129 | void Incidence::setRecurrenceID(QDateTime d) |
126 | { | 130 | { |
127 | mRecurrenceID = d; | 131 | mRecurrenceID = d; |
128 | mHasRecurrenceID = true; | 132 | mHasRecurrenceID = true; |
129 | updated(); | 133 | updated(); |
130 | } | 134 | } |
131 | QDateTime Incidence::recurrenceID () const | 135 | QDateTime Incidence::recurrenceID () const |
132 | { | 136 | { |
133 | return mRecurrenceID; | 137 | return mRecurrenceID; |
134 | } | 138 | } |
135 | 139 | ||
136 | bool Incidence::cancelled() const | 140 | bool Incidence::cancelled() const |
137 | { | 141 | { |
138 | return mCancelled; | 142 | return mCancelled; |
139 | } | 143 | } |
140 | void Incidence::setCancelled( bool b ) | 144 | void Incidence::setCancelled( bool b ) |
141 | { | 145 | { |
142 | mCancelled = b; | 146 | mCancelled = b; |
143 | updated(); | 147 | updated(); |
144 | } | 148 | } |
145 | bool Incidence::hasStartDate() const | 149 | bool Incidence::hasStartDate() const |
146 | { | 150 | { |
147 | return mHasStartDate; | 151 | return mHasStartDate; |
148 | } | 152 | } |
149 | 153 | ||
150 | void Incidence::setHasStartDate(bool f) | 154 | void Incidence::setHasStartDate(bool f) |
151 | { | 155 | { |
152 | if (mReadOnly) return; | 156 | if (mReadOnly) return; |
153 | mHasStartDate = f; | 157 | mHasStartDate = f; |
154 | updated(); | 158 | updated(); |
155 | } | 159 | } |
156 | 160 | ||
157 | // A string comparison that considers that null and empty are the same | 161 | // A string comparison that considers that null and empty are the same |
158 | static bool stringCompare( const QString& s1, const QString& s2 ) | 162 | static bool stringCompare( const QString& s1, const QString& s2 ) |
159 | { | 163 | { |
160 | if ( s1.isEmpty() && s2.isEmpty() ) | 164 | if ( s1.isEmpty() && s2.isEmpty() ) |
161 | return true; | 165 | return true; |
162 | return s1 == s2; | 166 | return s1 == s2; |
163 | } | 167 | } |
164 | 168 | ||
165 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 169 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
166 | { | 170 | { |
167 | 171 | ||
168 | if( i1.alarms().count() != i2.alarms().count() ) { | 172 | if( i1.alarms().count() != i2.alarms().count() ) { |
169 | return false; // no need to check further | 173 | return false; // no need to check further |
170 | } | 174 | } |
171 | if ( i1.alarms().count() > 0 ) { | 175 | if ( i1.alarms().count() > 0 ) { |
172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 176 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
173 | { | 177 | { |
174 | qDebug("alarm not equal "); | 178 | qDebug("alarm not equal "); |
175 | return false; | 179 | return false; |
176 | } | 180 | } |
177 | } | 181 | } |
178 | #if 0 | 182 | #if 0 |
179 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 183 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
180 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 184 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 185 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
182 | if( *a1.current() == *a2.current() ) { | 186 | if( *a1.current() == *a2.current() ) { |
183 | continue; | 187 | continue; |
184 | } | 188 | } |
185 | else { | 189 | else { |
186 | return false; | 190 | return false; |
187 | } | 191 | } |
188 | } | 192 | } |
189 | #endif | 193 | #endif |
190 | 194 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 195 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 196 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 197 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 198 | return false; |
195 | } | 199 | } |
196 | 200 | ||
197 | } else { | 201 | } else { |
198 | return false; | 202 | return false; |
199 | } | 203 | } |
200 | 204 | ||
201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 205 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
202 | return false; | 206 | return false; |
203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 207 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
204 | if ( i1.hasStartDate() ) { | 208 | if ( i1.hasStartDate() ) { |
205 | if ( i1.dtStart() != i2.dtStart() ) | 209 | if ( i1.dtStart() != i2.dtStart() ) |
206 | return false; | 210 | return false; |
207 | } | 211 | } |
208 | } else { | 212 | } else { |
209 | return false; | 213 | return false; |
210 | } | 214 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 215 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { |
212 | qDebug("recurrence is NOT equal "); | 216 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { |
213 | return false; | 217 | //qDebug("recurrence is NOT equal "); |
218 | return false; | ||
219 | } | ||
220 | } else { | ||
221 | // one ( or both ) recurrence is 0 | ||
222 | if ( i1.mRecurrence == 0 ) { | ||
223 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) | ||
224 | return false; | ||
225 | } else { | ||
226 | // i1.mRecurrence != 0 | ||
227 | // i2.mRecurrence == 0 | ||
228 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) | ||
229 | return false; | ||
230 | } | ||
214 | } | 231 | } |
232 | |||
215 | return | 233 | return |
216 | // i1.created() == i2.created() && | 234 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 235 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 236 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 237 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 238 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 239 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 240 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 241 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 242 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 243 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 244 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 245 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 246 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 247 | stringCompare( i1.location(), i2.location() ); |
230 | } | 248 | } |
231 | 249 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 250 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 251 | { |
234 | Incidence* newInc = clone(); | 252 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 253 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 254 | if ( doesRecur() ) { |
237 | addExDate( d ); | 255 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 256 | newInc->recurrence()->unsetRecurs(); |
239 | if ( typeID() == eventID ) { | 257 | if ( typeID() == eventID ) { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 258 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 259 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 260 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 261 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 262 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 263 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 264 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 265 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 266 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 267 | ((Todo*)this)->setRecurDates(); |
250 | } | 268 | } |
251 | newInc->setExDates( DateList () ); | 269 | newInc->setExDates( DateList () ); |
252 | } | 270 | } |
253 | return newInc; | 271 | return newInc; |
254 | } | 272 | } |
255 | 273 | ||
256 | void Incidence::recreate() | 274 | void Incidence::recreate() |
257 | { | 275 | { |
258 | setCreated(QDateTime::currentDateTime()); | 276 | setCreated(QDateTime::currentDateTime()); |
259 | 277 | ||
260 | setUid(CalFormat::createUniqueId()); | 278 | setUid(CalFormat::createUniqueId()); |
261 | 279 | ||
262 | setRevision(0); | 280 | setRevision(0); |
263 | setIDStr( ":" ); | 281 | setIDStr( ":" ); |
264 | setLastModified(QDateTime::currentDateTime()); | 282 | setLastModified(QDateTime::currentDateTime()); |
265 | } | 283 | } |
266 | void Incidence::cloneRelations( Incidence * newInc ) | 284 | void Incidence::cloneRelations( Incidence * newInc ) |
267 | { | 285 | { |
268 | // newInc is already a clone of this incidence | 286 | // newInc is already a clone of this incidence |
269 | Incidence * inc; | 287 | Incidence * inc; |
270 | Incidence * cloneInc; | 288 | Incidence * cloneInc; |
271 | QPtrList<Incidence> Relations = relations(); | 289 | QPtrList<Incidence> Relations = relations(); |
272 | for (inc=Relations.first();inc;inc=Relations.next()) { | 290 | for (inc=Relations.first();inc;inc=Relations.next()) { |
273 | cloneInc = inc->clone(); | 291 | cloneInc = inc->clone(); |
274 | cloneInc->recreate(); | 292 | cloneInc->recreate(); |
275 | cloneInc->setRelatedTo( newInc ); | 293 | cloneInc->setRelatedTo( newInc ); |
276 | inc->cloneRelations( cloneInc ); | 294 | inc->cloneRelations( cloneInc ); |
277 | } | 295 | } |
278 | } | 296 | } |
279 | void Incidence::setReadOnly( bool readOnly ) | 297 | void Incidence::setReadOnly( bool readOnly ) |
280 | { | 298 | { |
281 | IncidenceBase::setReadOnly( readOnly ); | 299 | IncidenceBase::setReadOnly( readOnly ); |
282 | recurrence()->setRecurReadOnly( readOnly); | 300 | if ( mRecurrence ) |
301 | mRecurrence->setRecurReadOnly( readOnly); | ||
283 | } | 302 | } |
284 | void Incidence::setLastModifiedSubInvalid() | 303 | void Incidence::setLastModifiedSubInvalid() |
285 | { | 304 | { |
286 | mLastModifiedSub = QDateTime(); | 305 | mLastModifiedSub = QDateTime(); |
287 | if ( mRelatedTo ) | 306 | if ( mRelatedTo ) |
288 | mRelatedTo->setLastModifiedSubInvalid(); | 307 | mRelatedTo->setLastModifiedSubInvalid(); |
289 | } | 308 | } |
290 | QDateTime Incidence::lastModifiedSub() | 309 | QDateTime Incidence::lastModifiedSub() |
291 | { | 310 | { |
292 | if ( !mRelations.count() ) | 311 | if ( !mRelations.count() ) |
293 | return lastModified(); | 312 | return lastModified(); |
294 | if ( mLastModifiedSub.isValid() ) | 313 | if ( mLastModifiedSub.isValid() ) |
295 | return mLastModifiedSub; | 314 | return mLastModifiedSub; |
296 | mLastModifiedSub = lastModified(); | 315 | mLastModifiedSub = lastModified(); |
297 | Incidence * inc; | 316 | Incidence * inc; |
298 | QPtrList<Incidence> Relations = relations(); | 317 | QPtrList<Incidence> Relations = relations(); |
299 | for (inc=Relations.first();inc;inc=Relations.next()) { | 318 | for (inc=Relations.first();inc;inc=Relations.next()) { |
300 | if ( inc->lastModifiedSub() > mLastModifiedSub ) | 319 | if ( inc->lastModifiedSub() > mLastModifiedSub ) |
301 | mLastModifiedSub = inc->lastModifiedSub(); | 320 | mLastModifiedSub = inc->lastModifiedSub(); |
302 | } | 321 | } |
303 | return mLastModifiedSub; | 322 | return mLastModifiedSub; |
304 | } | 323 | } |
305 | void Incidence::setCreated(QDateTime created) | 324 | void Incidence::setCreated(QDateTime created) |
306 | { | 325 | { |
307 | if (mReadOnly) return; | 326 | if (mReadOnly) return; |
308 | mCreated = getEvenTime(created); | 327 | mCreated = getEvenTime(created); |
309 | } | 328 | } |
310 | 329 | ||
311 | QDateTime Incidence::created() const | 330 | QDateTime Incidence::created() const |
312 | { | 331 | { |
313 | return mCreated; | 332 | return mCreated; |
314 | } | 333 | } |
315 | 334 | ||
316 | void Incidence::setRevision(int rev) | 335 | void Incidence::setRevision(int rev) |
317 | { | 336 | { |
318 | if (mReadOnly) return; | 337 | if (mReadOnly) return; |
319 | mRevision = rev; | 338 | mRevision = rev; |
320 | 339 | ||
321 | updated(); | 340 | updated(); |
322 | } | 341 | } |
323 | 342 | ||
324 | int Incidence::revision() const | 343 | int Incidence::revision() const |
325 | { | 344 | { |
326 | return mRevision; | 345 | return mRevision; |
327 | } | 346 | } |
328 | 347 | ||
329 | void Incidence::setDtStart(const QDateTime &dtStart) | 348 | void Incidence::setDtStart(const QDateTime &dtStart) |
330 | { | 349 | { |
331 | 350 | ||
332 | QDateTime dt = getEvenTime(dtStart); | 351 | QDateTime dt = getEvenTime(dtStart); |
333 | recurrence()->setRecurStart( dt); | 352 | |
353 | if ( mRecurrence ) | ||
354 | mRecurrence->setRecurStart( dt); | ||
334 | IncidenceBase::setDtStart( dt ); | 355 | IncidenceBase::setDtStart( dt ); |
335 | } | 356 | } |
336 | 357 | ||
337 | void Incidence::setDescription(const QString &description) | 358 | void Incidence::setDescription(const QString &description) |
338 | { | 359 | { |
339 | if (mReadOnly) return; | 360 | if (mReadOnly) return; |
340 | mDescription = description; | 361 | mDescription = description; |
341 | updated(); | 362 | updated(); |
342 | } | 363 | } |
343 | 364 | ||
344 | QString Incidence::description() const | 365 | QString Incidence::description() const |
345 | { | 366 | { |
346 | return mDescription; | 367 | return mDescription; |
347 | } | 368 | } |
348 | 369 | ||
349 | 370 | ||
350 | void Incidence::setSummary(const QString &summary) | 371 | void Incidence::setSummary(const QString &summary) |
351 | { | 372 | { |
352 | if (mReadOnly) return; | 373 | if (mReadOnly) return; |
353 | mSummary = summary; | 374 | mSummary = summary; |
354 | updated(); | 375 | updated(); |
355 | } | 376 | } |
356 | 377 | ||
357 | QString Incidence::summary() const | 378 | QString Incidence::summary() const |
358 | { | 379 | { |
359 | return mSummary; | 380 | return mSummary; |
360 | } | 381 | } |
361 | void Incidence::checkCategories() | 382 | void Incidence::checkCategories() |
362 | { | 383 | { |
363 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 384 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
364 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 385 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
365 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 386 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
366 | } | 387 | } |
367 | 388 | ||
368 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 389 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
369 | { | 390 | { |
370 | if (mReadOnly) return; | 391 | if (mReadOnly) return; |
371 | int i; | 392 | int i; |
372 | for( i = 0; i < categories.count(); ++i ) { | 393 | for( i = 0; i < categories.count(); ++i ) { |
373 | if ( !mCategories.contains (categories[i])) | 394 | if ( !mCategories.contains (categories[i])) |
374 | mCategories.append( categories[i] ); | 395 | mCategories.append( categories[i] ); |
375 | } | 396 | } |
376 | checkCategories(); | 397 | checkCategories(); |
377 | updated(); | 398 | updated(); |
378 | if ( addToRelations ) { | 399 | if ( addToRelations ) { |
379 | Incidence * inc; | 400 | Incidence * inc; |
380 | QPtrList<Incidence> Relations = relations(); | 401 | QPtrList<Incidence> Relations = relations(); |
381 | for (inc=Relations.first();inc;inc=Relations.next()) { | 402 | for (inc=Relations.first();inc;inc=Relations.next()) { |
382 | inc->addCategories( categories, true ); | 403 | inc->addCategories( categories, true ); |
383 | } | 404 | } |
384 | } | 405 | } |
385 | } | 406 | } |
386 | 407 | ||
387 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 408 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
388 | { | 409 | { |
389 | if (mReadOnly) return; | 410 | if (mReadOnly) return; |
390 | mCategories = categories; | 411 | mCategories = categories; |
391 | checkCategories(); | 412 | checkCategories(); |
392 | updated(); | 413 | updated(); |
393 | if ( setForRelations ) { | 414 | if ( setForRelations ) { |
394 | Incidence * inc; | 415 | Incidence * inc; |
395 | QPtrList<Incidence> Relations = relations(); | 416 | QPtrList<Incidence> Relations = relations(); |
396 | for (inc=Relations.first();inc;inc=Relations.next()) { | 417 | for (inc=Relations.first();inc;inc=Relations.next()) { |
397 | inc->setCategories( categories, true ); | 418 | inc->setCategories( categories, true ); |
398 | } | 419 | } |
399 | } | 420 | } |
400 | } | 421 | } |
401 | 422 | ||
402 | // TODO: remove setCategories(QString) function | 423 | // TODO: remove setCategories(QString) function |
403 | void Incidence::setCategories(const QString &catStr) | 424 | void Incidence::setCategories(const QString &catStr) |
404 | { | 425 | { |
405 | if (mReadOnly) return; | 426 | if (mReadOnly) return; |
406 | mCategories.clear(); | 427 | mCategories.clear(); |
407 | 428 | ||
408 | if (catStr.isEmpty()) return; | 429 | if (catStr.isEmpty()) return; |
409 | 430 | ||
410 | mCategories = QStringList::split(",",catStr); | 431 | mCategories = QStringList::split(",",catStr); |
411 | 432 | ||
412 | QStringList::Iterator it; | 433 | QStringList::Iterator it; |
413 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 434 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
414 | *it = (*it).stripWhiteSpace(); | 435 | *it = (*it).stripWhiteSpace(); |
415 | } | 436 | } |
416 | checkCategories(); | 437 | checkCategories(); |
417 | updated(); | 438 | updated(); |
418 | } | 439 | } |
419 | // using this makes filtering 3 times faster | 440 | // using this makes filtering 3 times faster |
420 | QStringList* Incidence::categoriesP() | 441 | QStringList* Incidence::categoriesP() |
421 | { | 442 | { |
422 | return &mCategories; | 443 | return &mCategories; |
423 | } | 444 | } |
424 | 445 | ||
425 | QStringList Incidence::categories() const | 446 | QStringList Incidence::categories() const |
426 | { | 447 | { |
427 | return mCategories; | 448 | return mCategories; |
428 | } | 449 | } |
429 | 450 | ||
430 | QString Incidence::categoriesStr() | 451 | QString Incidence::categoriesStr() |
431 | { | 452 | { |
432 | return mCategories.join(","); | 453 | return mCategories.join(","); |
433 | } | 454 | } |
434 | QString Incidence::categoriesStrWithSpace() | 455 | QString Incidence::categoriesStrWithSpace() |
435 | { | 456 | { |
436 | return mCategories.join(", "); | 457 | return mCategories.join(", "); |
437 | } | 458 | } |
438 | 459 | ||
439 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 460 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
440 | { | 461 | { |
441 | if (mReadOnly) return; | 462 | if (mReadOnly) return; |
442 | mRelatedToUid = relatedToUid; | 463 | mRelatedToUid = relatedToUid; |
443 | } | 464 | } |
444 | 465 | ||
445 | QString Incidence::relatedToUid() const | 466 | QString Incidence::relatedToUid() const |
446 | { | 467 | { |
447 | return mRelatedToUid; | 468 | return mRelatedToUid; |
448 | } | 469 | } |
449 | 470 | ||
450 | void Incidence::setRelatedTo(Incidence *relatedTo) | 471 | void Incidence::setRelatedTo(Incidence *relatedTo) |
451 | { | 472 | { |
452 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 473 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
453 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 474 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
454 | if (mReadOnly || mRelatedTo == relatedTo) return; | 475 | if (mReadOnly || mRelatedTo == relatedTo) return; |
455 | if(mRelatedTo) { | 476 | if(mRelatedTo) { |
456 | // updated(); | 477 | // updated(); |
457 | mRelatedTo->removeRelation(this); | 478 | mRelatedTo->removeRelation(this); |
458 | } | 479 | } |
459 | mRelatedTo = relatedTo; | 480 | mRelatedTo = relatedTo; |
460 | if (mRelatedTo) { | 481 | if (mRelatedTo) { |
461 | mRelatedTo->addRelation(this); | 482 | mRelatedTo->addRelation(this); |
462 | mRelatedToUid = mRelatedTo->uid(); | 483 | mRelatedToUid = mRelatedTo->uid(); |
463 | } else { | 484 | } else { |
464 | mRelatedToUid = ""; | 485 | mRelatedToUid = ""; |
465 | } | 486 | } |
466 | } | 487 | } |
467 | 488 | ||
468 | Incidence *Incidence::relatedTo() const | 489 | Incidence *Incidence::relatedTo() const |
469 | { | 490 | { |
470 | return mRelatedTo; | 491 | return mRelatedTo; |
471 | } | 492 | } |
472 | 493 | ||
473 | QPtrList<Incidence> Incidence::relations() const | 494 | QPtrList<Incidence> Incidence::relations() const |
474 | { | 495 | { |
475 | return mRelations; | 496 | return mRelations; |
476 | } | 497 | } |
477 | 498 | ||
478 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 499 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
479 | { | 500 | { |
480 | Incidence* inc; | 501 | Incidence* inc; |
481 | QPtrList<Incidence> Relations = relations(); | 502 | QPtrList<Incidence> Relations = relations(); |
482 | for (inc=Relations.first();inc;inc=Relations.next()) { | 503 | for (inc=Relations.first();inc;inc=Relations.next()) { |
483 | inc->addRelationsToList( rel ); | 504 | inc->addRelationsToList( rel ); |
484 | } | 505 | } |
485 | if ( rel->findRef( this ) == -1 ) | 506 | if ( rel->findRef( this ) == -1 ) |
486 | rel->append( this ); | 507 | rel->append( this ); |
487 | } | 508 | } |
488 | 509 | ||
489 | void Incidence::addRelation(Incidence *event) | 510 | void Incidence::addRelation(Incidence *event) |
490 | { | 511 | { |
491 | setLastModifiedSubInvalid(); | 512 | setLastModifiedSubInvalid(); |
492 | if( mRelations.findRef( event ) == -1 ) { | 513 | if( mRelations.findRef( event ) == -1 ) { |
493 | mRelations.append(event); | 514 | mRelations.append(event); |
494 | //updated(); | 515 | //updated(); |
495 | } | 516 | } |
496 | } | 517 | } |
497 | 518 | ||
498 | void Incidence::removeRelation(Incidence *event) | 519 | void Incidence::removeRelation(Incidence *event) |
499 | { | 520 | { |
500 | setLastModifiedSubInvalid(); | 521 | setLastModifiedSubInvalid(); |
501 | mRelations.removeRef(event); | 522 | mRelations.removeRef(event); |
502 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 523 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
503 | } | 524 | } |
504 | 525 | ||
505 | bool Incidence::recursOn(const QDate &qd) const | 526 | bool Incidence::recursOn(const QDate &qd) const |
506 | { | 527 | { |
507 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 528 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
508 | else return false; | 529 | else return false; |
509 | } | 530 | } |
510 | 531 | ||
511 | void Incidence::setExDates(const DateList &exDates) | 532 | void Incidence::setExDates(const DateList &exDates) |
512 | { | 533 | { |
513 | if (mReadOnly) return; | 534 | if (mReadOnly) return; |
514 | mExDates = exDates; | 535 | mExDates = exDates; |
515 | |||
516 | recurrence()->setRecurExDatesCount(mExDates.count()); | 536 | recurrence()->setRecurExDatesCount(mExDates.count()); |
517 | 537 | ||
518 | updated(); | 538 | updated(); |
519 | } | 539 | } |
520 | 540 | ||
521 | void Incidence::addExDate(const QDate &date) | 541 | void Incidence::addExDate(const QDate &date) |
522 | { | 542 | { |
523 | if (mReadOnly) return; | 543 | if (mReadOnly) return; |
524 | mExDates.append(date); | 544 | mExDates.append(date); |
525 | 545 | ||
526 | recurrence()->setRecurExDatesCount(mExDates.count()); | 546 | recurrence()->setRecurExDatesCount(mExDates.count()); |
527 | 547 | ||
528 | updated(); | 548 | updated(); |
529 | } | 549 | } |
530 | 550 | ||
531 | DateList Incidence::exDates() const | 551 | DateList Incidence::exDates() const |
532 | { | 552 | { |
533 | return mExDates; | 553 | return mExDates; |
534 | } | 554 | } |
535 | 555 | ||
536 | bool Incidence::isException(const QDate &date) const | 556 | bool Incidence::isException(const QDate &date) const |
537 | { | 557 | { |
538 | DateList::ConstIterator it; | 558 | DateList::ConstIterator it; |
539 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 559 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
540 | if ( (*it) == date ) { | 560 | if ( (*it) == date ) { |
541 | return true; | 561 | return true; |
542 | } | 562 | } |
543 | } | 563 | } |
544 | 564 | ||
545 | return false; | 565 | return false; |
546 | } | 566 | } |
547 | 567 | ||
548 | void Incidence::addAttachment(Attachment *attachment) | 568 | void Incidence::addAttachment(Attachment *attachment) |
549 | { | 569 | { |
550 | if (mReadOnly || !attachment) return; | 570 | if (mReadOnly || !attachment) return; |
551 | mAttachments.append(attachment); | 571 | mAttachments.append(attachment); |
552 | updated(); | 572 | updated(); |
553 | } | 573 | } |
554 | 574 | ||
555 | void Incidence::deleteAttachment(Attachment *attachment) | 575 | void Incidence::deleteAttachment(Attachment *attachment) |
556 | { | 576 | { |
557 | mAttachments.removeRef(attachment); | 577 | mAttachments.removeRef(attachment); |
558 | } | 578 | } |
559 | 579 | ||
560 | void Incidence::deleteAttachments(const QString& mime) | 580 | void Incidence::deleteAttachments(const QString& mime) |
561 | { | 581 | { |
562 | Attachment *at = mAttachments.first(); | 582 | Attachment *at = mAttachments.first(); |
563 | while (at) { | 583 | while (at) { |
564 | if (at->mimeType() == mime) | 584 | if (at->mimeType() == mime) |
565 | mAttachments.remove(); | 585 | mAttachments.remove(); |
566 | else | 586 | else |
567 | at = mAttachments.next(); | 587 | at = mAttachments.next(); |
568 | } | 588 | } |
569 | } | 589 | } |
570 | 590 | ||
571 | QPtrList<Attachment> Incidence::attachments() const | 591 | QPtrList<Attachment> Incidence::attachments() const |
572 | { | 592 | { |
573 | return mAttachments; | 593 | return mAttachments; |
574 | } | 594 | } |
575 | 595 | ||
576 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 596 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
577 | { | 597 | { |
578 | QPtrList<Attachment> attachments; | 598 | QPtrList<Attachment> attachments; |
579 | QPtrListIterator<Attachment> it( mAttachments ); | 599 | QPtrListIterator<Attachment> it( mAttachments ); |
580 | Attachment *at; | 600 | Attachment *at; |
581 | while ( (at = it.current()) ) { | 601 | while ( (at = it.current()) ) { |
582 | if (at->mimeType() == mime) | 602 | if (at->mimeType() == mime) |
583 | attachments.append(at); | 603 | attachments.append(at); |
584 | ++it; | 604 | ++it; |
585 | } | 605 | } |
586 | 606 | ||
587 | return attachments; | 607 | return attachments; |
588 | } | 608 | } |
589 | 609 | ||
590 | void Incidence::setResources(const QStringList &resources) | 610 | void Incidence::setResources(const QStringList &resources) |
591 | { | 611 | { |
592 | if (mReadOnly) return; | 612 | if (mReadOnly) return; |
593 | mResources = resources; | 613 | mResources = resources; |
594 | updated(); | 614 | updated(); |
595 | } | 615 | } |
596 | 616 | ||
597 | QStringList Incidence::resources() const | 617 | QStringList Incidence::resources() const |
598 | { | 618 | { |
599 | return mResources; | 619 | return mResources; |
600 | } | 620 | } |
601 | 621 | ||
602 | 622 | ||
603 | void Incidence::setPriority(int priority) | 623 | void Incidence::setPriority(int priority) |
604 | { | 624 | { |
605 | if (mReadOnly) return; | 625 | if (mReadOnly) return; |
606 | mPriority = priority; | 626 | mPriority = priority; |
607 | updated(); | 627 | updated(); |
608 | } | 628 | } |
609 | 629 | ||
610 | int Incidence::priority() const | 630 | int Incidence::priority() const |
611 | { | 631 | { |
612 | return mPriority; | 632 | return mPriority; |
613 | } | 633 | } |
614 | 634 | ||
615 | void Incidence::setSecrecy(int sec) | 635 | void Incidence::setSecrecy(int sec) |
616 | { | 636 | { |
617 | if (mReadOnly) return; | 637 | if (mReadOnly) return; |
618 | mSecrecy = sec; | 638 | mSecrecy = sec; |
619 | updated(); | 639 | updated(); |
620 | } | 640 | } |
621 | 641 | ||
622 | int Incidence::secrecy() const | 642 | int Incidence::secrecy() const |
623 | { | 643 | { |
624 | return mSecrecy; | 644 | return mSecrecy; |
625 | } | 645 | } |
626 | 646 | ||
627 | QString Incidence::secrecyStr() const | 647 | QString Incidence::secrecyStr() const |
628 | { | 648 | { |
629 | return secrecyName(mSecrecy); | 649 | return secrecyName(mSecrecy); |
630 | } | 650 | } |
631 | 651 | ||
632 | QString Incidence::secrecyName(int secrecy) | 652 | QString Incidence::secrecyName(int secrecy) |
633 | { | 653 | { |
634 | switch (secrecy) { | 654 | switch (secrecy) { |
635 | case SecrecyPublic: | 655 | case SecrecyPublic: |
636 | return i18n("Public"); | 656 | return i18n("Public"); |
637 | break; | 657 | break; |
638 | case SecrecyPrivate: | 658 | case SecrecyPrivate: |
639 | return i18n("Private"); | 659 | return i18n("Private"); |
640 | break; | 660 | break; |
641 | case SecrecyConfidential: | 661 | case SecrecyConfidential: |
642 | return i18n("Confidential"); | 662 | return i18n("Confidential"); |
643 | break; | 663 | break; |
644 | default: | 664 | default: |
645 | return i18n("Undefined"); | 665 | return i18n("Undefined"); |
646 | break; | 666 | break; |
647 | } | 667 | } |
648 | } | 668 | } |
649 | 669 | ||
650 | QStringList Incidence::secrecyList() | 670 | QStringList Incidence::secrecyList() |
651 | { | 671 | { |
652 | QStringList list; | 672 | QStringList list; |
653 | list << secrecyName(SecrecyPublic); | 673 | list << secrecyName(SecrecyPublic); |
654 | list << secrecyName(SecrecyPrivate); | 674 | list << secrecyName(SecrecyPrivate); |
655 | list << secrecyName(SecrecyConfidential); | 675 | list << secrecyName(SecrecyConfidential); |
656 | 676 | ||
657 | return list; | 677 | return list; |
658 | } | 678 | } |
659 | 679 | ||
660 | 680 | ||
661 | QPtrList<Alarm> Incidence::alarms() const | 681 | QPtrList<Alarm> Incidence::alarms() const |
662 | { | 682 | { |
663 | return mAlarms; | 683 | return mAlarms; |
664 | } | 684 | } |
665 | 685 | ||
666 | Alarm* Incidence::newAlarm() | 686 | Alarm* Incidence::newAlarm() |
667 | { | 687 | { |
668 | Alarm* alarm = new Alarm(this); | 688 | Alarm* alarm = new Alarm(this); |
669 | mAlarms.append(alarm); | 689 | mAlarms.append(alarm); |
670 | // updated(); | 690 | // updated(); |
671 | return alarm; | 691 | return alarm; |
672 | } | 692 | } |
673 | 693 | ||
674 | void Incidence::addAlarm(Alarm *alarm) | 694 | void Incidence::addAlarm(Alarm *alarm) |
675 | { | 695 | { |
676 | mAlarms.append(alarm); | 696 | mAlarms.append(alarm); |
677 | updated(); | 697 | updated(); |
678 | } | 698 | } |
679 | 699 | ||
680 | void Incidence::removeAlarm(Alarm *alarm) | 700 | void Incidence::removeAlarm(Alarm *alarm) |
681 | { | 701 | { |
682 | mAlarms.removeRef(alarm); | 702 | mAlarms.removeRef(alarm); |
683 | updated(); | 703 | updated(); |
684 | } | 704 | } |
685 | 705 | ||
686 | void Incidence::clearAlarms() | 706 | void Incidence::clearAlarms() |
687 | { | 707 | { |
688 | mAlarms.clear(); | 708 | mAlarms.clear(); |
689 | updated(); | 709 | updated(); |
690 | } | 710 | } |
691 | 711 | ||
692 | bool Incidence::isAlarmEnabled() const | 712 | bool Incidence::isAlarmEnabled() const |
693 | { | 713 | { |
694 | Alarm* alarm; | 714 | Alarm* alarm; |
695 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 715 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
696 | if (alarm->enabled()) | 716 | if (alarm->enabled()) |
697 | return true; | 717 | return true; |
698 | } | 718 | } |
699 | return false; | 719 | return false; |
700 | } | 720 | } |
701 | 721 | #include <stdlib.h> | |
702 | Recurrence *Incidence::recurrence() const | 722 | Recurrence *Incidence::recurrence() |
703 | { | 723 | { |
724 | if ( ! mRecurrence ) { | ||
725 | mRecurrence = new Recurrence(this); | ||
726 | qDebug("creating new recurence "); | ||
727 | //abort(); | ||
728 | } | ||
704 | return mRecurrence; | 729 | return mRecurrence; |
705 | } | 730 | } |
706 | void Incidence::setRecurrence( Recurrence * r) | 731 | void Incidence::setRecurrence( Recurrence * r) |
707 | { | 732 | { |
708 | delete mRecurrence; | 733 | if ( mRecurrence ) |
709 | mRecurrence = r; | 734 | delete mRecurrence; |
735 | mRecurrence = r; | ||
710 | } | 736 | } |
711 | 737 | ||
712 | void Incidence::setLocation(const QString &location) | 738 | void Incidence::setLocation(const QString &location) |
713 | { | 739 | { |
714 | if (mReadOnly) return; | 740 | if (mReadOnly) return; |
715 | mLocation = location; | 741 | mLocation = location; |
716 | updated(); | 742 | updated(); |
717 | } | 743 | } |
718 | 744 | ||
719 | QString Incidence::location() const | 745 | QString Incidence::location() const |
720 | { | 746 | { |
721 | return mLocation; | 747 | return mLocation; |
722 | } | 748 | } |
749 | QString Incidence::recurrenceText() const | ||
750 | { | ||
751 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | ||
752 | return i18n("No"); | ||
753 | } | ||
723 | 754 | ||
724 | ushort Incidence::doesRecur() const | 755 | ushort Incidence::doesRecur() const |
725 | { | 756 | { |
726 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 757 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
727 | else return Recurrence::rNone; | 758 | else return Recurrence::rNone; |
728 | } | 759 | } |
729 | 760 | ||
730 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 761 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
731 | { | 762 | { |
732 | QDateTime incidenceStart = dt; | 763 | QDateTime incidenceStart = dt; |
733 | *ok = false; | 764 | *ok = false; |
734 | if ( doesRecur() ) { | 765 | if ( doesRecur() ) { |
735 | bool last; | 766 | bool last; |
736 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 767 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); |
737 | int count = 0; | 768 | int count = 0; |
738 | if ( !last ) { | 769 | if ( !last ) { |
739 | while ( !last ) { | 770 | while ( !last ) { |
740 | ++count; | 771 | ++count; |
741 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 772 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); |
742 | if ( recursOn( incidenceStart.date() ) ) { | 773 | if ( recursOn( incidenceStart.date() ) ) { |
743 | last = true; // exit while llop | 774 | last = true; // exit while llop |
744 | } else { | 775 | } else { |
745 | if ( last ) { // no alarm on last recurrence | 776 | if ( last ) { // no alarm on last recurrence |
746 | return QDateTime (); | 777 | return QDateTime (); |
747 | } | 778 | } |
748 | int year = incidenceStart.date().year(); | 779 | int year = incidenceStart.date().year(); |
749 | // workaround for bug in recurrence | 780 | // workaround for bug in recurrence |
750 | if ( count == 100 || year < 1000 || year > 5000 ) { | 781 | if ( count == 100 || year < 1000 || year > 5000 ) { |
751 | return QDateTime (); | 782 | return QDateTime (); |
752 | } | 783 | } |
753 | incidenceStart = incidenceStart.addSecs( 1 ); | 784 | incidenceStart = incidenceStart.addSecs( 1 ); |
754 | } | 785 | } |
755 | } | 786 | } |
756 | } else { | 787 | } else { |
757 | return QDateTime (); | 788 | return QDateTime (); |
758 | } | 789 | } |
759 | } else { | 790 | } else { |
760 | if ( hasStartDate () ) { | 791 | if ( hasStartDate () ) { |
761 | incidenceStart = dtStart(); | 792 | incidenceStart = dtStart(); |
762 | } | 793 | } |
763 | if ( typeID() == todoID ) { | 794 | if ( typeID() == todoID ) { |
764 | if ( ((Todo*)this)->hasDueDate() ) | 795 | if ( ((Todo*)this)->hasDueDate() ) |
765 | incidenceStart = ((Todo*)this)->dtDue(); | 796 | incidenceStart = ((Todo*)this)->dtDue(); |
766 | } | 797 | } |
767 | } | 798 | } |
768 | if ( incidenceStart > dt ) | 799 | if ( incidenceStart > dt ) |
769 | *ok = true; | 800 | *ok = true; |
770 | return incidenceStart; | 801 | return incidenceStart; |
771 | } | 802 | } |
772 | QDateTime Incidence::dtStart() const | 803 | QDateTime Incidence::dtStart() const |
773 | { | 804 | { |
774 | if ( doesRecur() ) { | 805 | if ( doesRecur() ) { |
775 | if ( typeID() == todoID ) { | 806 | if ( typeID() == todoID ) { |
776 | ((Todo*)this)->checkSetCompletedFalse(); | 807 | ((Todo*)this)->checkSetCompletedFalse(); |
777 | } | 808 | } |
778 | } | 809 | } |
779 | return mDtStart; | 810 | return mDtStart; |
780 | } | 811 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index d4af9f0..8519f01 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -1,321 +1,322 @@ | |||
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 INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_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 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | virtual void cloneRelations( Incidence * ); | 115 | virtual void cloneRelations( Incidence * ); |
116 | void addRelationsToList(QPtrList<Incidence> *rel); | 116 | void addRelationsToList(QPtrList<Incidence> *rel); |
117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; | 117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; |
118 | void setReadOnly( bool ); | 118 | void setReadOnly( bool ); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Recreate event. The event is made a new unique event, but already stored | 121 | Recreate event. The event is made a new unique event, but already stored |
122 | event information is preserved. Sets uniquie id, creation date, last | 122 | event information is preserved. Sets uniquie id, creation date, last |
123 | modification date and revision number. | 123 | modification date and revision number. |
124 | */ | 124 | */ |
125 | void recreate(); | 125 | void recreate(); |
126 | Incidence* recreateCloneException(QDate); | 126 | Incidence* recreateCloneException(QDate); |
127 | 127 | ||
128 | /** set creation date */ | 128 | /** set creation date */ |
129 | void setCreated(QDateTime); | 129 | void setCreated(QDateTime); |
130 | /** return time and date of creation. */ | 130 | /** return time and date of creation. */ |
131 | QDateTime created() const; | 131 | QDateTime created() const; |
132 | 132 | ||
133 | /** set the number of revisions this event has seen */ | 133 | /** set the number of revisions this event has seen */ |
134 | void setRevision(int rev); | 134 | void setRevision(int rev); |
135 | /** return the number of revisions this event has seen */ | 135 | /** return the number of revisions this event has seen */ |
136 | int revision() const; | 136 | int revision() const; |
137 | 137 | ||
138 | /** Set starting date/time. */ | 138 | /** Set starting date/time. */ |
139 | virtual void setDtStart(const QDateTime &dtStart); | 139 | virtual void setDtStart(const QDateTime &dtStart); |
140 | /** Return the incidence's ending date/time as a QDateTime. */ | 140 | /** Return the incidence's ending date/time as a QDateTime. */ |
141 | virtual QDateTime dtEnd() const { return QDateTime(); } | 141 | virtual QDateTime dtEnd() const { return QDateTime(); } |
142 | 142 | ||
143 | /** sets the event's lengthy description. */ | 143 | /** sets the event's lengthy description. */ |
144 | void setDescription(const QString &description); | 144 | void setDescription(const QString &description); |
145 | /** returns a reference to the event's description. */ | 145 | /** returns a reference to the event's description. */ |
146 | QString description() const; | 146 | QString description() const; |
147 | 147 | ||
148 | /** sets the event's short summary. */ | 148 | /** sets the event's short summary. */ |
149 | void setSummary(const QString &summary); | 149 | void setSummary(const QString &summary); |
150 | /** returns a reference to the event's summary. */ | 150 | /** returns a reference to the event's summary. */ |
151 | QString summary() const; | 151 | QString summary() const; |
152 | 152 | ||
153 | /** set event's applicable categories */ | 153 | /** set event's applicable categories */ |
154 | void setCategories(const QStringList &categories, bool setForRelations = false); | 154 | void setCategories(const QStringList &categories, bool setForRelations = false); |
155 | void addCategories(const QStringList &categories, bool addToRelations = false); | 155 | void addCategories(const QStringList &categories, bool addToRelations = false); |
156 | /** set event's categories based on a comma delimited string */ | 156 | /** set event's categories based on a comma delimited string */ |
157 | void setCategories(const QString &catStr); | 157 | void setCategories(const QString &catStr); |
158 | /** return categories in a list */ | 158 | /** return categories in a list */ |
159 | QStringList categories() const; | 159 | QStringList categories() const; |
160 | QStringList* categoriesP(); | 160 | QStringList* categoriesP(); |
161 | /** return categories as a comma separated string */ | 161 | /** return categories as a comma separated string */ |
162 | QString categoriesStr(); | 162 | QString categoriesStr(); |
163 | QString categoriesStrWithSpace(); | 163 | QString categoriesStrWithSpace(); |
164 | 164 | ||
165 | /** point at some other event to which the event relates. This function should | 165 | /** point at some other event to which the event relates. This function should |
166 | * only be used when constructing a calendar before the related Event | 166 | * only be used when constructing a calendar before the related Event |
167 | * exists. */ | 167 | * exists. */ |
168 | void setRelatedToUid(const QString &); | 168 | void setRelatedToUid(const QString &); |
169 | /** what event does this one relate to? This function should | 169 | /** what event does this one relate to? This function should |
170 | * only be used when constructing a calendar before the related Event | 170 | * only be used when constructing a calendar before the related Event |
171 | * exists. */ | 171 | * exists. */ |
172 | QString relatedToUid() const; | 172 | QString relatedToUid() const; |
173 | /** point at some other event to which the event relates */ | 173 | /** point at some other event to which the event relates */ |
174 | void setRelatedTo(Incidence *relatedTo); | 174 | void setRelatedTo(Incidence *relatedTo); |
175 | /** what event does this one relate to? */ | 175 | /** what event does this one relate to? */ |
176 | Incidence *relatedTo() const; | 176 | Incidence *relatedTo() const; |
177 | /** All events that are related to this event */ | 177 | /** All events that are related to this event */ |
178 | QPtrList<Incidence> relations() const; | 178 | QPtrList<Incidence> relations() const; |
179 | /** Add an event which is related to this event */ | 179 | /** Add an event which is related to this event */ |
180 | void addRelation(Incidence *); | 180 | void addRelation(Incidence *); |
181 | /** Remove event that is related to this event */ | 181 | /** Remove event that is related to this event */ |
182 | void removeRelation(Incidence *); | 182 | void removeRelation(Incidence *); |
183 | 183 | ||
184 | /** returns the list of dates which are exceptions to the recurrence rule */ | 184 | /** returns the list of dates which are exceptions to the recurrence rule */ |
185 | DateList exDates() const; | 185 | DateList exDates() const; |
186 | /** sets the list of dates which are exceptions to the recurrence rule */ | 186 | /** sets the list of dates which are exceptions to the recurrence rule */ |
187 | void setExDates(const DateList &_exDates); | 187 | void setExDates(const DateList &_exDates); |
188 | void setExDates(const char *dates); | 188 | void setExDates(const char *dates); |
189 | /** Add a date to the list of exceptions of the recurrence rule. */ | 189 | /** Add a date to the list of exceptions of the recurrence rule. */ |
190 | void addExDate(const QDate &date); | 190 | void addExDate(const QDate &date); |
191 | 191 | ||
192 | /** returns true if there is an exception for this date in the recurrence | 192 | /** returns true if there is an exception for this date in the recurrence |
193 | rule set, or false otherwise. */ | 193 | rule set, or false otherwise. */ |
194 | bool isException(const QDate &qd) const; | 194 | bool isException(const QDate &qd) const; |
195 | 195 | ||
196 | /** add attachment to this event */ | 196 | /** add attachment to this event */ |
197 | void addAttachment(Attachment *attachment); | 197 | void addAttachment(Attachment *attachment); |
198 | /** remove and delete a specific attachment */ | 198 | /** remove and delete a specific attachment */ |
199 | void deleteAttachment(Attachment *attachment); | 199 | void deleteAttachment(Attachment *attachment); |
200 | /** remove and delete all attachments with this mime type */ | 200 | /** remove and delete all attachments with this mime type */ |
201 | void deleteAttachments(const QString& mime); | 201 | void deleteAttachments(const QString& mime); |
202 | /** return list of all associated attachments */ | 202 | /** return list of all associated attachments */ |
203 | QPtrList<Attachment> attachments() const; | 203 | QPtrList<Attachment> attachments() const; |
204 | /** find a list of attachments with this mime type */ | 204 | /** find a list of attachments with this mime type */ |
205 | QPtrList<Attachment> attachments(const QString& mime) const; | 205 | QPtrList<Attachment> attachments(const QString& mime) const; |
206 | 206 | ||
207 | /** sets the event's status the value specified. See the enumeration | 207 | /** sets the event's status the value specified. See the enumeration |
208 | * above for possible values. */ | 208 | * above for possible values. */ |
209 | void setSecrecy(int); | 209 | void setSecrecy(int); |
210 | /** return the event's secrecy. */ | 210 | /** return the event's secrecy. */ |
211 | int secrecy() const; | 211 | int secrecy() const; |
212 | /** return the event's secrecy in string format. */ | 212 | /** return the event's secrecy in string format. */ |
213 | QString secrecyStr() const; | 213 | QString secrecyStr() const; |
214 | /** return list of all availbale secrecy classes */ | 214 | /** return list of all availbale secrecy classes */ |
215 | static QStringList secrecyList(); | 215 | static QStringList secrecyList(); |
216 | /** return human-readable name of secrecy class */ | 216 | /** return human-readable name of secrecy class */ |
217 | static QString secrecyName(int); | 217 | static QString secrecyName(int); |
218 | 218 | ||
219 | /** returns TRUE if the date specified is one on which the event will | 219 | /** returns TRUE if the date specified is one on which the event will |
220 | * recur. */ | 220 | * recur. */ |
221 | bool recursOn(const QDate &qd) const; | 221 | bool recursOn(const QDate &qd) const; |
222 | 222 | ||
223 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 223 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
224 | 224 | ||
225 | /** set resources used, such as Office, Car, etc. */ | 225 | /** set resources used, such as Office, Car, etc. */ |
226 | void setResources(const QStringList &resources); | 226 | void setResources(const QStringList &resources); |
227 | /** return list of current resources */ | 227 | /** return list of current resources */ |
228 | QStringList resources() const; | 228 | QStringList resources() const; |
229 | 229 | ||
230 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ | 230 | /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ |
231 | void setPriority(int priority); | 231 | void setPriority(int priority); |
232 | /** get the event's priority */ | 232 | /** get the event's priority */ |
233 | int priority() const; | 233 | int priority() const; |
234 | 234 | ||
235 | /** All alarms that are associated with this incidence */ | 235 | /** All alarms that are associated with this incidence */ |
236 | QPtrList<Alarm> alarms() const; | 236 | QPtrList<Alarm> alarms() const; |
237 | /** Create a new alarm which is associated with this incidence */ | 237 | /** Create a new alarm which is associated with this incidence */ |
238 | Alarm* newAlarm(); | 238 | Alarm* newAlarm(); |
239 | /** Add an alarm which is associated with this incidence */ | 239 | /** Add an alarm which is associated with this incidence */ |
240 | void addAlarm(Alarm*); | 240 | void addAlarm(Alarm*); |
241 | /** Remove an alarm that is associated with this incidence */ | 241 | /** Remove an alarm that is associated with this incidence */ |
242 | void removeAlarm(Alarm*); | 242 | void removeAlarm(Alarm*); |
243 | /** Remove all alarms that are associated with this incidence */ | 243 | /** Remove all alarms that are associated with this incidence */ |
244 | void clearAlarms(); | 244 | void clearAlarms(); |
245 | /** return whether any alarm associated with this incidence is enabled */ | 245 | /** return whether any alarm associated with this incidence is enabled */ |
246 | bool isAlarmEnabled() const; | 246 | bool isAlarmEnabled() const; |
247 | 247 | ||
248 | /** | 248 | /** |
249 | Return the recurrence rule associated with this incidence. If there is | 249 | Return the recurrence rule associated with this incidence. If there is |
250 | none, returns an appropriate (non-0) object. | 250 | none, returns an appropriate (non-0) object. |
251 | */ | 251 | */ |
252 | Recurrence *recurrence() const; | 252 | Recurrence *recurrence(); |
253 | void setRecurrence(Recurrence * r); | 253 | void setRecurrence(Recurrence * r); |
254 | /** | 254 | /** |
255 | Forward to Recurrence::doesRecur(). | 255 | Forward to Recurrence::doesRecur(). |
256 | */ | 256 | */ |
257 | ushort doesRecur() const; | 257 | ushort doesRecur() const; |
258 | 258 | ||
259 | /** set the event's/todo's location. Do _not_ use it with journal */ | 259 | /** set the event's/todo's location. Do _not_ use it with journal */ |
260 | void setLocation(const QString &location); | 260 | void setLocation(const QString &location); |
261 | /** return the event's/todo's location. Do _not_ use it with journal */ | 261 | /** return the event's/todo's location. Do _not_ use it with journal */ |
262 | QString location() const; | 262 | QString location() const; |
263 | /** returns TRUE or FALSE depending on whether the todo has a start date */ | 263 | /** returns TRUE or FALSE depending on whether the todo has a start date */ |
264 | bool hasStartDate() const; | 264 | bool hasStartDate() const; |
265 | /** sets the event's hasStartDate value. */ | 265 | /** sets the event's hasStartDate value. */ |
266 | void setHasStartDate(bool f); | 266 | void setHasStartDate(bool f); |
267 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; | 267 | QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; |
268 | bool cancelled() const; | 268 | bool cancelled() const; |
269 | void setCancelled( bool b ); | 269 | void setCancelled( bool b ); |
270 | 270 | ||
271 | bool hasRecurrenceID() const; | 271 | bool hasRecurrenceID() const; |
272 | void setHasRecurrenceID( bool b ); | 272 | void setHasRecurrenceID( bool b ); |
273 | 273 | ||
274 | void setRecurrenceID(QDateTime); | 274 | void setRecurrenceID(QDateTime); |
275 | QDateTime recurrenceID () const; | 275 | QDateTime recurrenceID () const; |
276 | QDateTime dtStart() const; | 276 | QDateTime dtStart() const; |
277 | bool isHoliday() const; | 277 | bool isHoliday() const; |
278 | bool isBirthday() const; | 278 | bool isBirthday() const; |
279 | bool isAnniversary() const; | 279 | bool isAnniversary() const; |
280 | QDateTime lastModifiedSub(); | 280 | QDateTime lastModifiedSub(); |
281 | QString recurrenceText() const; | ||
281 | void setLastModifiedSubInvalid(); | 282 | void setLastModifiedSubInvalid(); |
282 | 283 | ||
283 | 284 | ||
285 | Recurrence *mRecurrence; | ||
284 | protected: | 286 | protected: |
285 | QPtrList<Alarm> mAlarms; | 287 | QPtrList<Alarm> mAlarms; |
286 | QPtrList<Incidence> mRelations; | 288 | QPtrList<Incidence> mRelations; |
287 | QDateTime mRecurrenceID; | 289 | QDateTime mRecurrenceID; |
288 | bool mHasRecurrenceID; | 290 | bool mHasRecurrenceID; |
289 | private: | 291 | private: |
290 | void checkCategories(); | 292 | void checkCategories(); |
291 | bool mHoliday, mBirthday, mAnniversary; | 293 | bool mHoliday, mBirthday, mAnniversary; |
292 | int mRevision; | 294 | int mRevision; |
293 | bool mCancelled; | 295 | bool mCancelled; |
294 | 296 | ||
295 | // base components of jounal, event and todo | 297 | // base components of jounal, event and todo |
296 | QDateTime mCreated; | 298 | QDateTime mCreated; |
297 | QDateTime mLastModifiedSub; | 299 | QDateTime mLastModifiedSub; |
298 | QString mDescription; | 300 | QString mDescription; |
299 | QString mSummary; | 301 | QString mSummary; |
300 | QStringList mCategories; | 302 | QStringList mCategories; |
301 | Incidence *mRelatedTo; | 303 | Incidence *mRelatedTo; |
302 | QString mRelatedToUid; | 304 | QString mRelatedToUid; |
303 | DateList mExDates; | 305 | DateList mExDates; |
304 | QPtrList<Attachment> mAttachments; | 306 | QPtrList<Attachment> mAttachments; |
305 | QStringList mResources; | 307 | QStringList mResources; |
306 | bool mHasStartDate; // if todo has associated start date | 308 | bool mHasStartDate; // if todo has associated start date |
307 | 309 | ||
308 | int mSecrecy; | 310 | int mSecrecy; |
309 | int mPriority; // 1 = highest, 2 = less, etc. | 311 | int mPriority; // 1 = highest, 2 = less, etc. |
310 | 312 | ||
311 | //QPtrList<Alarm> mAlarms; | 313 | //QPtrList<Alarm> mAlarms; |
312 | Recurrence *mRecurrence; | ||
313 | 314 | ||
314 | QString mLocation; | 315 | QString mLocation; |
315 | }; | 316 | }; |
316 | 317 | ||
317 | bool operator==( const Incidence&, const Incidence& ); | 318 | bool operator==( const Incidence&, const Incidence& ); |
318 | 319 | ||
319 | } | 320 | } |
320 | 321 | ||
321 | #endif | 322 | #endif |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 9359fad..f8f40f1 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,425 +1,425 @@ | |||
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 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString 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->typeID() == eventID ) | 24 | if ( inc->typeID() == eventID ) |
25 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
26 | else if ( inc->typeID() == todoID ) | 26 | else if ( inc->typeID() == todoID ) |
27 | setTodo((Todo *) inc ); | 27 | setTodo((Todo *) inc ); |
28 | return mText; | 28 | return mText; |
29 | } | 29 | } |
30 | 30 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* 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 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~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 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void 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 | formatReadOnly(event); | 55 | formatReadOnly(event); |
56 | } | 56 | } |
57 | else { | 57 | else { |
58 | if ( mColorMode == 1 ) { | 58 | if ( mColorMode == 1 ) { |
59 | mText +="<font color=\"#00A000\">"; | 59 | mText +="<font color=\"#00A000\">"; |
60 | } | 60 | } |
61 | if ( mColorMode == 2 ) { | 61 | if ( mColorMode == 2 ) { |
62 | mText +="<font color=\"#C00000\">"; | 62 | mText +="<font color=\"#C00000\">"; |
63 | } | 63 | } |
64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
65 | if ( mode == 1 ) { | 65 | if ( mode == 1 ) { |
66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
67 | } else { | 67 | } else { |
68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
69 | } | 69 | } |
70 | formatReadOnly(event); | 70 | formatReadOnly(event); |
71 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 71 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
72 | if ( mColorMode ) | 72 | if ( mColorMode ) |
73 | mText += "</font>"; | 73 | mText += "</font>"; |
74 | } | 74 | } |
75 | if (event->cancelled ()) { | 75 | if (event->cancelled ()) { |
76 | mText +="<font color=\"#B00000\">"; | 76 | mText +="<font color=\"#B00000\">"; |
77 | addTag("i",i18n("This event has been cancelled!")); | 77 | addTag("i",i18n("This event has been cancelled!")); |
78 | mText.append("<br>"); | 78 | mText.append("<br>"); |
79 | mText += "</font>"; | 79 | mText += "</font>"; |
80 | } | 80 | } |
81 | if (event->doesFloat()) { | 81 | if (event->doesFloat()) { |
82 | if (event->isMultiDay()) { | 82 | if (event->isMultiDay()) { |
83 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 83 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
84 | .arg(event->dtStartDateStr(shortDate)) | 84 | .arg(event->dtStartDateStr(shortDate)) |
85 | .arg(event->dtEndDateStr(shortDate))); | 85 | .arg(event->dtEndDateStr(shortDate))); |
86 | } else { | 86 | } else { |
87 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 87 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
88 | } | 88 | } |
89 | } else { | 89 | } else { |
90 | if (event->isMultiDay()) { | 90 | if (event->isMultiDay()) { |
91 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 91 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
92 | .arg(event->dtStartStr( shortDate))); | 92 | .arg(event->dtStartStr( shortDate))); |
93 | mText.append(i18n("<p><b>To:</b> %1</p>") | 93 | mText.append(i18n("<p><b>To:</b> %1</p>") |
94 | .arg(event->dtEndStr(shortDate))); | 94 | .arg(event->dtEndStr(shortDate))); |
95 | } else { | 95 | } else { |
96 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 96 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
97 | .arg(event->dtStartTimeStr()) | 97 | .arg(event->dtStartTimeStr()) |
98 | .arg(event->dtEndTimeStr())); | 98 | .arg(event->dtEndTimeStr())); |
99 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 99 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
100 | .arg(event->dtStartDateStr( shortDate ))); | 100 | .arg(event->dtStartDateStr( shortDate ))); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | if (!event->location().isEmpty()) { | 103 | if (!event->location().isEmpty()) { |
104 | addTag("b",i18n("Location: ")); | 104 | addTag("b",i18n("Location: ")); |
105 | mText.append(deTag(event->location())+"<br>"); | 105 | mText.append(deTag(event->location())+"<br>"); |
106 | } | 106 | } |
107 | 107 | ||
108 | if (event->recurrence()->doesRecur()) { | 108 | if (event->doesRecur()) { |
109 | 109 | ||
110 | QString recurText = event->recurrence()->recurrenceText(); | 110 | QString recurText = event->recurrence()->recurrenceText(); |
111 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 111 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
112 | 112 | ||
113 | bool ok; | 113 | bool ok; |
114 | QDate start = QDate::currentDate(); | 114 | QDate start = QDate::currentDate(); |
115 | QDateTime next; | 115 | QDateTime next; |
116 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 116 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
117 | if ( ok ) { | 117 | if ( ok ) { |
118 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 118 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
119 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 119 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
120 | 120 | ||
121 | } else { | 121 | } else { |
122 | bool last; | 122 | bool last; |
123 | QDate nextd; | 123 | QDate nextd; |
124 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 124 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
125 | if ( last ) { | 125 | if ( last ) { |
126 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 126 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
127 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 127 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
128 | } | 128 | } |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | 132 | ||
133 | if (event->isAlarmEnabled()) { | 133 | if (event->isAlarmEnabled()) { |
134 | Alarm *alarm =event->alarms().first() ; | 134 | Alarm *alarm =event->alarms().first() ; |
135 | QDateTime t = alarm->time(); | 135 | QDateTime t = alarm->time(); |
136 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 136 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
137 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 137 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
138 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 138 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
139 | //addTag("p",s); | 139 | //addTag("p",s); |
140 | } | 140 | } |
141 | 141 | ||
142 | 142 | ||
143 | 143 | ||
144 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 144 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
145 | // mText.append(event->secrecyStr()+"<br>"); | 145 | // mText.append(event->secrecyStr()+"<br>"); |
146 | formatCategories(event); | 146 | formatCategories(event); |
147 | 147 | ||
148 | formatAttendees(event); | 148 | formatAttendees(event); |
149 | 149 | ||
150 | if ( mCreated ) { | 150 | if ( mCreated ) { |
151 | #ifdef DESKTOP_VERSION | 151 | #ifdef DESKTOP_VERSION |
152 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 152 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
153 | #else | 153 | #else |
154 | addTag("p",i18n("<b>Created: ") +" </b>"); | 154 | addTag("p",i18n("<b>Created: ") +" </b>"); |
155 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 155 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
156 | #endif | 156 | #endif |
157 | 157 | ||
158 | } | 158 | } |
159 | if ( mModified ) { | 159 | if ( mModified ) { |
160 | #ifdef DESKTOP_VERSION | 160 | #ifdef DESKTOP_VERSION |
161 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 161 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
162 | #else | 162 | #else |
163 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 163 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
164 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 164 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | } | 167 | } |
168 | if ( mDetails ) { | 168 | if ( mDetails ) { |
169 | if (!event->description().isEmpty()) { | 169 | if (!event->description().isEmpty()) { |
170 | addTag("p",i18n("<b>Details: </b>")); | 170 | addTag("p",i18n("<b>Details: </b>")); |
171 | addTag("p",deTag(event->description())); | 171 | addTag("p",deTag(event->description())); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | void KIncidenceFormatter::setTodo(Todo *event ) | 177 | void KIncidenceFormatter::setTodo(Todo *event ) |
178 | { | 178 | { |
179 | int mode = 0; | 179 | int mode = 0; |
180 | mCurrentIncidence = event; | 180 | mCurrentIncidence = event; |
181 | bool shortDate = true; | 181 | bool shortDate = true; |
182 | if (mode == 0 ) { | 182 | if (mode == 0 ) { |
183 | addTag("h3",deTag(event->summary())); | 183 | addTag("h3",deTag(event->summary())); |
184 | formatReadOnly(event); | 184 | formatReadOnly(event); |
185 | } | 185 | } |
186 | else { | 186 | else { |
187 | if ( mColorMode == 1 ) { | 187 | if ( mColorMode == 1 ) { |
188 | mText +="<font color=\"#00A000\">"; | 188 | mText +="<font color=\"#00A000\">"; |
189 | } | 189 | } |
190 | if ( mColorMode == 2 ) { | 190 | if ( mColorMode == 2 ) { |
191 | mText +="<font color=\"#B00000\">"; | 191 | mText +="<font color=\"#B00000\">"; |
192 | } | 192 | } |
193 | if ( mode == 1 ) { | 193 | if ( mode == 1 ) { |
194 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 194 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
195 | } else { | 195 | } else { |
196 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 196 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
197 | } | 197 | } |
198 | formatReadOnly(event); | 198 | formatReadOnly(event); |
199 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 199 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
200 | if ( mColorMode ) | 200 | if ( mColorMode ) |
201 | mText += "</font>"; | 201 | mText += "</font>"; |
202 | } | 202 | } |
203 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 203 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
204 | mText +="<font color=\"#B00000\">"; | 204 | mText +="<font color=\"#B00000\">"; |
205 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 205 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
206 | mText += "</font>"; | 206 | mText += "</font>"; |
207 | } else { | 207 | } else { |
208 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 208 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
209 | .arg(event->percentComplete())); | 209 | .arg(event->percentComplete())); |
210 | } | 210 | } |
211 | if (event->cancelled ()) { | 211 | if (event->cancelled ()) { |
212 | mText +="<font color=\"#B00000\">"; | 212 | mText +="<font color=\"#B00000\">"; |
213 | addTag("i",i18n("This todo has been cancelled!")); | 213 | addTag("i",i18n("This todo has been cancelled!")); |
214 | mText.append("<br>"); | 214 | mText.append("<br>"); |
215 | mText += "</font>"; | 215 | mText += "</font>"; |
216 | } | 216 | } |
217 | 217 | ||
218 | 218 | ||
219 | if (event->recurrence()->doesRecur()) { | 219 | if (event->doesRecur()) { |
220 | 220 | ||
221 | QString recurText = event->recurrence()->recurrenceText(); | 221 | QString recurText = event->recurrence()->recurrenceText(); |
222 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 222 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
223 | } | 223 | } |
224 | 224 | ||
225 | if (event->hasStartDate()) { | 225 | if (event->hasStartDate()) { |
226 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 226 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | if (event->hasDueDate()) { | 230 | if (event->hasDueDate()) { |
231 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 231 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
232 | } | 232 | } |
233 | 233 | ||
234 | if (!event->location().isEmpty()) { | 234 | if (!event->location().isEmpty()) { |
235 | addTag("b",i18n("Location: ")); | 235 | addTag("b",i18n("Location: ")); |
236 | mText.append(deTag(event->location())+"<br>"); | 236 | mText.append(deTag(event->location())+"<br>"); |
237 | } | 237 | } |
238 | 238 | ||
239 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 239 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
240 | .arg(QString::number(event->priority()))); | 240 | .arg(QString::number(event->priority()))); |
241 | 241 | ||
242 | if (event->isAlarmEnabled()) { | 242 | if (event->isAlarmEnabled()) { |
243 | Alarm *alarm =event->alarms().first() ; | 243 | Alarm *alarm =event->alarms().first() ; |
244 | QDateTime t = alarm->time(); | 244 | QDateTime t = alarm->time(); |
245 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 245 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
246 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 246 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
247 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 247 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
248 | //addTag("p",s); | 248 | //addTag("p",s); |
249 | } | 249 | } |
250 | 250 | ||
251 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 251 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
252 | formatCategories(event); | 252 | formatCategories(event); |
253 | 253 | ||
254 | formatAttendees(event); | 254 | formatAttendees(event); |
255 | if ( mCreated ) { | 255 | if ( mCreated ) { |
256 | #ifdef DESKTOP_VERSION | 256 | #ifdef DESKTOP_VERSION |
257 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 257 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
258 | #else | 258 | #else |
259 | addTag("p",i18n("<b>Created: ") +" </b>"); | 259 | addTag("p",i18n("<b>Created: ") +" </b>"); |
260 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 260 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
261 | #endif | 261 | #endif |
262 | 262 | ||
263 | } | 263 | } |
264 | if ( mModified ) { | 264 | if ( mModified ) { |
265 | #ifdef DESKTOP_VERSION | 265 | #ifdef DESKTOP_VERSION |
266 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 266 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
267 | #else | 267 | #else |
268 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 268 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
269 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 269 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
270 | #endif | 270 | #endif |
271 | 271 | ||
272 | } | 272 | } |
273 | if ( mDetails ) { | 273 | if ( mDetails ) { |
274 | if (!event->description().isEmpty()) { | 274 | if (!event->description().isEmpty()) { |
275 | addTag("p",i18n("<b>Details: </b>")); | 275 | addTag("p",i18n("<b>Details: </b>")); |
276 | addTag("p",deTag(event->description())); | 276 | addTag("p",deTag(event->description())); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | void KIncidenceFormatter::setJournal(Journal* ) | 281 | void KIncidenceFormatter::setJournal(Journal* ) |
282 | { | 282 | { |
283 | 283 | ||
284 | } | 284 | } |
285 | 285 | ||
286 | void KIncidenceFormatter::formatCategories(Incidence *event) | 286 | void KIncidenceFormatter::formatCategories(Incidence *event) |
287 | { | 287 | { |
288 | if (!event->categoriesStr().isEmpty()) { | 288 | if (!event->categoriesStr().isEmpty()) { |
289 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); | 289 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); |
290 | //mText.append(event->categoriesStr()); | 290 | //mText.append(event->categoriesStr()); |
291 | } | 291 | } |
292 | } | 292 | } |
293 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 293 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
294 | { | 294 | { |
295 | int number=text.contains("\n"); | 295 | int number=text.contains("\n"); |
296 | QString str = "<" + tag + ">"; | 296 | QString str = "<" + tag + ">"; |
297 | QString tmpText=text; | 297 | QString tmpText=text; |
298 | QString tmpStr=str; | 298 | QString tmpStr=str; |
299 | if(number !=-1) | 299 | if(number !=-1) |
300 | { | 300 | { |
301 | if (number > 0) { | 301 | if (number > 0) { |
302 | int pos=0; | 302 | int pos=0; |
303 | QString tmp; | 303 | QString tmp; |
304 | for(int i=0;i<=number;i++) { | 304 | for(int i=0;i<=number;i++) { |
305 | pos=tmpText.find("\n"); | 305 | pos=tmpText.find("\n"); |
306 | tmp=tmpText.left(pos); | 306 | tmp=tmpText.left(pos); |
307 | tmpText=tmpText.right(tmpText.length()-pos-1); | 307 | tmpText=tmpText.right(tmpText.length()-pos-1); |
308 | tmpStr+=tmp+"<br>"; | 308 | tmpStr+=tmp+"<br>"; |
309 | } | 309 | } |
310 | } | 310 | } |
311 | else tmpStr += tmpText; | 311 | else tmpStr += tmpText; |
312 | tmpStr+="</" + tag + ">"; | 312 | tmpStr+="</" + tag + ">"; |
313 | mText.append(tmpStr); | 313 | mText.append(tmpStr); |
314 | } | 314 | } |
315 | else | 315 | else |
316 | { | 316 | { |
317 | str += text + "</" + tag + ">"; | 317 | str += text + "</" + tag + ">"; |
318 | mText.append(str); | 318 | mText.append(str); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 322 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
323 | { | 323 | { |
324 | QPtrList<Attendee> attendees = event->attendees(); | 324 | QPtrList<Attendee> attendees = event->attendees(); |
325 | if (attendees.count()) { | 325 | if (attendees.count()) { |
326 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 326 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
327 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 327 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
328 | addTag("h3",i18n("Organizer")); | 328 | addTag("h3",i18n("Organizer")); |
329 | mText.append("<ul><li>"); | 329 | mText.append("<ul><li>"); |
330 | #if 0 | 330 | #if 0 |
331 | //ndef KORG_NOKABC | 331 | //ndef KORG_NOKABC |
332 | 332 | ||
333 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 333 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
334 | KABC::Addressee::List addressList; | 334 | KABC::Addressee::List addressList; |
335 | addressList = add_book->findByEmail(event->organizer()); | 335 | addressList = add_book->findByEmail(event->organizer()); |
336 | KABC::Addressee o = addressList.first(); | 336 | KABC::Addressee o = addressList.first(); |
337 | if (!o.isEmpty() && addressList.size()<2) { | 337 | if (!o.isEmpty() && addressList.size()<2) { |
338 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 338 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
339 | mText += o.formattedName(); | 339 | mText += o.formattedName(); |
340 | mText += "</a>\n"; | 340 | mText += "</a>\n"; |
341 | } else { | 341 | } else { |
342 | mText.append(event->organizer()); | 342 | mText.append(event->organizer()); |
343 | } | 343 | } |
344 | #else | 344 | #else |
345 | mText.append(event->organizer()); | 345 | mText.append(event->organizer()); |
346 | #endif | 346 | #endif |
347 | if (iconPath) { | 347 | if (iconPath) { |
348 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 348 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
349 | mText += "<IMG src=\"" + iconPath + "\">"; | 349 | mText += "<IMG src=\"" + iconPath + "\">"; |
350 | mText += "</a>\n"; | 350 | mText += "</a>\n"; |
351 | } | 351 | } |
352 | mText.append("</li></ul>"); | 352 | mText.append("</li></ul>"); |
353 | 353 | ||
354 | addTag("h3",i18n("Attendees")); | 354 | addTag("h3",i18n("Attendees")); |
355 | Attendee *a; | 355 | Attendee *a; |
356 | mText.append("<ul>"); | 356 | mText.append("<ul>"); |
357 | for(a=attendees.first();a;a=attendees.next()) { | 357 | for(a=attendees.first();a;a=attendees.next()) { |
358 | #if 0 | 358 | #if 0 |
359 | //ndef KORG_NOKABC | 359 | //ndef KORG_NOKABC |
360 | if (a->name().isEmpty()) { | 360 | if (a->name().isEmpty()) { |
361 | addressList = add_book->findByEmail(a->email()); | 361 | addressList = add_book->findByEmail(a->email()); |
362 | KABC::Addressee o = addressList.first(); | 362 | KABC::Addressee o = addressList.first(); |
363 | if (!o.isEmpty() && addressList.size()<2) { | 363 | if (!o.isEmpty() && addressList.size()<2) { |
364 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 364 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
365 | mText += o.formattedName(); | 365 | mText += o.formattedName(); |
366 | mText += "</a>\n"; | 366 | mText += "</a>\n"; |
367 | } else { | 367 | } else { |
368 | mText += "<li>"; | 368 | mText += "<li>"; |
369 | mText.append(a->email()); | 369 | mText.append(a->email()); |
370 | mText += "\n"; | 370 | mText += "\n"; |
371 | } | 371 | } |
372 | } else { | 372 | } else { |
373 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 373 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
374 | if (!a->name().isEmpty()) mText += a->name(); | 374 | if (!a->name().isEmpty()) mText += a->name(); |
375 | else mText += a->email(); | 375 | else mText += a->email(); |
376 | mText += "</a>\n"; | 376 | mText += "</a>\n"; |
377 | } | 377 | } |
378 | #else | 378 | #else |
379 | //qDebug("nokabc "); | 379 | //qDebug("nokabc "); |
380 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 380 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
381 | if (!a->name().isEmpty()) mText += a->name(); | 381 | if (!a->name().isEmpty()) mText += a->name(); |
382 | else mText += a->email(); | 382 | else mText += a->email(); |
383 | mText += "</a>\n"; | 383 | mText += "</a>\n"; |
384 | #endif | 384 | #endif |
385 | 385 | ||
386 | if (!a->email().isEmpty()) { | 386 | if (!a->email().isEmpty()) { |
387 | if (iconPath) { | 387 | if (iconPath) { |
388 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 388 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
389 | if ( a->RSVP() ) | 389 | if ( a->RSVP() ) |
390 | mText += "<IMG src=\"" + iconPath + "\">"; | 390 | mText += "<IMG src=\"" + iconPath + "\">"; |
391 | else | 391 | else |
392 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 392 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
393 | mText += "</a>\n"; | 393 | mText += "</a>\n"; |
394 | } | 394 | } |
395 | } | 395 | } |
396 | if (a->status() != Attendee::NeedsAction ) | 396 | if (a->status() != Attendee::NeedsAction ) |
397 | mText +="[" + a->statusStr() + "] "; | 397 | mText +="[" + a->statusStr() + "] "; |
398 | if (a->role() == Attendee::Chair ) | 398 | if (a->role() == Attendee::Chair ) |
399 | mText +="(" + a->roleStr().left(1) + ".)"; | 399 | mText +="(" + a->roleStr().left(1) + ".)"; |
400 | } | 400 | } |
401 | mText.append("</li></ul>"); | 401 | mText.append("</li></ul>"); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | 404 | ||
405 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 405 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
406 | { | 406 | { |
407 | if (event->isReadOnly()) { | 407 | if (event->isReadOnly()) { |
408 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 408 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | QString KIncidenceFormatter::deTag(QString text) | 411 | QString KIncidenceFormatter::deTag(QString text) |
412 | { | 412 | { |
413 | #if QT_VERSION >= 0x030000 | 413 | #if QT_VERSION >= 0x030000 |
414 | text.replace( '<' , "<" ); | 414 | text.replace( '<' , "<" ); |
415 | text.replace( '>' , ">" ); | 415 | text.replace( '>' , ">" ); |
416 | #else | 416 | #else |
417 | if ( text.find ('<') >= 0 ) { | 417 | if ( text.find ('<') >= 0 ) { |
418 | text.replace( QRegExp("<") , "<" ); | 418 | text.replace( QRegExp("<") , "<" ); |
419 | } | 419 | } |
420 | if ( text.find ('>') >= 0 ) { | 420 | if ( text.find ('>') >= 0 ) { |
421 | text.replace( QRegExp(">") , ">" ); | 421 | text.replace( QRegExp(">") , ">" ); |
422 | } | 422 | } |
423 | #endif | 423 | #endif |
424 | return text; | 424 | return text; |
425 | } | 425 | } |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 8efc1ea..2e19740 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -11,836 +11,836 @@ | |||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
34 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | 36 | ||
37 | #include "vcc.h" | 37 | #include "vcc.h" |
38 | #include "vobject.h" | 38 | #include "vobject.h" |
39 | 39 | ||
40 | #include "vcaldrag.h" | 40 | #include "vcaldrag.h" |
41 | #include "calendar.h" | 41 | #include "calendar.h" |
42 | 42 | ||
43 | #include "vcalformat.h" | 43 | #include "vcalformat.h" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
48 | { | 48 | { |
49 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | 50 | useLocalTime = false; |
51 | } | 51 | } |
52 | 52 | ||
53 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
54 | { | 54 | { |
55 | } | 55 | } |
56 | 56 | ||
57 | void VCalFormat::setLocalTime ( bool b ) | 57 | void VCalFormat::setLocalTime ( bool b ) |
58 | { | 58 | { |
59 | useLocalTime = b; | 59 | useLocalTime = b; |
60 | } | 60 | } |
61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 61 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
62 | { | 62 | { |
63 | mCalendar = calendar; | 63 | mCalendar = calendar; |
64 | clearException(); | 64 | clearException(); |
65 | if ( ! useLocalTime ) | 65 | if ( ! useLocalTime ) |
66 | useLocalTime = mCalendar->isLocalTime(); | 66 | useLocalTime = mCalendar->isLocalTime(); |
67 | VObject *vcal = 0; | 67 | VObject *vcal = 0; |
68 | 68 | ||
69 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 69 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
70 | // a vcard... | 70 | // a vcard... |
71 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 71 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
72 | 72 | ||
73 | if (!vcal) { | 73 | if (!vcal) { |
74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 74 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
75 | return FALSE; | 75 | return FALSE; |
76 | } | 76 | } |
77 | 77 | ||
78 | // any other top-level calendar stuff should be added/initialized here | 78 | // any other top-level calendar stuff should be added/initialized here |
79 | 79 | ||
80 | // put all vobjects into their proper places | 80 | // put all vobjects into their proper places |
81 | populate(vcal); | 81 | populate(vcal); |
82 | 82 | ||
83 | // clean up from vcal API stuff | 83 | // clean up from vcal API stuff |
84 | cleanVObjects(vcal); | 84 | cleanVObjects(vcal); |
85 | cleanStrTbl(); | 85 | cleanStrTbl(); |
86 | 86 | ||
87 | return true; | 87 | return true; |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 91 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
92 | { | 92 | { |
93 | mCalendar = calendar; | 93 | mCalendar = calendar; |
94 | if ( ! useLocalTime ) | 94 | if ( ! useLocalTime ) |
95 | useLocalTime = mCalendar->isLocalTime(); | 95 | useLocalTime = mCalendar->isLocalTime(); |
96 | 96 | ||
97 | QString tmpStr; | 97 | QString tmpStr; |
98 | VObject *vcal, *vo; | 98 | VObject *vcal, *vo; |
99 | 99 | ||
100 | 100 | ||
101 | vcal = newVObject(VCCalProp); | 101 | vcal = newVObject(VCCalProp); |
102 | 102 | ||
103 | // addPropValue(vcal,VCLocationProp, "0.0"); | 103 | // addPropValue(vcal,VCLocationProp, "0.0"); |
104 | addPropValue(vcal,VCProdIdProp, productId()); | 104 | addPropValue(vcal,VCProdIdProp, productId()); |
105 | tmpStr = mCalendar->getTimeZoneStr(); | 105 | tmpStr = mCalendar->getTimeZoneStr(); |
106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 106 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 107 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 108 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
109 | 109 | ||
110 | // TODO STUFF | 110 | // TODO STUFF |
111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 111 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
112 | QPtrListIterator<Todo> qlt(todoList); | 112 | QPtrListIterator<Todo> qlt(todoList); |
113 | for (; qlt.current(); ++qlt) { | 113 | for (; qlt.current(); ++qlt) { |
114 | vo = eventToVTodo(qlt.current()); | 114 | vo = eventToVTodo(qlt.current()); |
115 | addVObjectProp(vcal, vo); | 115 | addVObjectProp(vcal, vo); |
116 | } | 116 | } |
117 | 117 | ||
118 | // EVENT STUFF | 118 | // EVENT STUFF |
119 | QPtrList<Event> events = mCalendar->rawEvents(); | 119 | QPtrList<Event> events = mCalendar->rawEvents(); |
120 | Event *ev; | 120 | Event *ev; |
121 | for(ev=events.first();ev;ev=events.next()) { | 121 | for(ev=events.first();ev;ev=events.next()) { |
122 | vo = eventToVEvent(ev); | 122 | vo = eventToVEvent(ev); |
123 | addVObjectProp(vcal, vo); | 123 | addVObjectProp(vcal, vo); |
124 | } | 124 | } |
125 | 125 | ||
126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 126 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
127 | cleanVObjects(vcal); | 127 | cleanVObjects(vcal); |
128 | cleanStrTbl(); | 128 | cleanStrTbl(); |
129 | 129 | ||
130 | if (QFile::exists(fileName)) { | 130 | if (QFile::exists(fileName)) { |
131 | return true; | 131 | return true; |
132 | } else { | 132 | } else { |
133 | return false; // error | 133 | return false; // error |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 137 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
138 | { | 138 | { |
139 | // TODO: Factor out VCalFormat::fromString() | 139 | // TODO: Factor out VCalFormat::fromString() |
140 | 140 | ||
141 | QCString data = text.utf8(); | 141 | QCString data = text.utf8(); |
142 | 142 | ||
143 | if ( !data.size() ) return false; | 143 | if ( !data.size() ) return false; |
144 | 144 | ||
145 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 145 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
146 | if ( !vcal ) return false; | 146 | if ( !vcal ) return false; |
147 | 147 | ||
148 | VObjectIterator i; | 148 | VObjectIterator i; |
149 | VObject *curvo; | 149 | VObject *curvo; |
150 | initPropIterator( &i, vcal ); | 150 | initPropIterator( &i, vcal ); |
151 | 151 | ||
152 | // we only take the first object. TODO: parse all incidences. | 152 | // we only take the first object. TODO: parse all incidences. |
153 | do { | 153 | do { |
154 | curvo = nextVObject( &i ); | 154 | curvo = nextVObject( &i ); |
155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 155 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 156 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
157 | 157 | ||
158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 158 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
159 | Event *event = VEventToEvent( curvo ); | 159 | Event *event = VEventToEvent( curvo ); |
160 | calendar->addEvent( event ); | 160 | calendar->addEvent( event ); |
161 | } else { | 161 | } else { |
162 | qDebug("VCalFormat::fromString(): Unknown object type. "); | 162 | qDebug("VCalFormat::fromString(): Unknown object type. "); |
163 | deleteVObject( vcal ); | 163 | deleteVObject( vcal ); |
164 | return false; | 164 | return false; |
165 | } | 165 | } |
166 | 166 | ||
167 | deleteVObject( vcal ); | 167 | deleteVObject( vcal ); |
168 | 168 | ||
169 | return true; | 169 | return true; |
170 | } | 170 | } |
171 | 171 | ||
172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) | 172 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
173 | { | 173 | { |
174 | 174 | ||
175 | if ( !event ) return QString::null; | 175 | if ( !event ) return QString::null; |
176 | bool useL = useLocalTime; | 176 | bool useL = useLocalTime; |
177 | useLocalTime = useLocal; | 177 | useLocalTime = useLocal; |
178 | mCalendar = calendar; | 178 | mCalendar = calendar; |
179 | VObject *vevent = eventToVEvent( event ); | 179 | VObject *vevent = eventToVEvent( event ); |
180 | char *buf = writeMemVObject( 0, 0, vevent ); | 180 | char *buf = writeMemVObject( 0, 0, vevent ); |
181 | QString result( buf ); | 181 | QString result( buf ); |
182 | cleanVObject( vevent ); | 182 | cleanVObject( vevent ); |
183 | useLocalTime = useL; | 183 | useLocalTime = useL; |
184 | return result; | 184 | return result; |
185 | } | 185 | } |
186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) | 186 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
187 | { | 187 | { |
188 | 188 | ||
189 | if ( !todo ) return QString::null; | 189 | if ( !todo ) return QString::null; |
190 | bool useL = useLocalTime; | 190 | bool useL = useLocalTime; |
191 | useLocalTime = useLocal; | 191 | useLocalTime = useLocal; |
192 | mCalendar = calendar; | 192 | mCalendar = calendar; |
193 | VObject *vevent = eventToVTodo( todo ); | 193 | VObject *vevent = eventToVTodo( todo ); |
194 | char *buf = writeMemVObject( 0, 0, vevent ); | 194 | char *buf = writeMemVObject( 0, 0, vevent ); |
195 | QString result( buf ); | 195 | QString result( buf ); |
196 | cleanVObject( vevent ); | 196 | cleanVObject( vevent ); |
197 | useLocalTime = useL; | 197 | useLocalTime = useL; |
198 | return result; | 198 | return result; |
199 | } | 199 | } |
200 | 200 | ||
201 | QString VCalFormat::toString( Calendar *calendar ) | 201 | QString VCalFormat::toString( Calendar *calendar ) |
202 | { | 202 | { |
203 | // TODO: Factor out VCalFormat::asString() | 203 | // TODO: Factor out VCalFormat::asString() |
204 | 204 | ||
205 | VObject *vcal = newVObject(VCCalProp); | 205 | VObject *vcal = newVObject(VCCalProp); |
206 | 206 | ||
207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 207 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
208 | QString tmpStr = mCalendar->getTimeZoneStr(); | 208 | QString tmpStr = mCalendar->getTimeZoneStr(); |
209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 209 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 210 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
211 | 211 | ||
212 | // TODO: Use all data. | 212 | // TODO: Use all data. |
213 | QPtrList<Event> events = calendar->events(); | 213 | QPtrList<Event> events = calendar->events(); |
214 | Event *event = events.first(); | 214 | Event *event = events.first(); |
215 | if ( !event ) return QString::null; | 215 | if ( !event ) return QString::null; |
216 | 216 | ||
217 | VObject *vevent = eventToVEvent( event ); | 217 | VObject *vevent = eventToVEvent( event ); |
218 | 218 | ||
219 | addVObjectProp( vcal, vevent ); | 219 | addVObjectProp( vcal, vevent ); |
220 | 220 | ||
221 | char *buf = writeMemVObject( 0, 0, vcal ); | 221 | char *buf = writeMemVObject( 0, 0, vcal ); |
222 | 222 | ||
223 | QString result( buf ); | 223 | QString result( buf ); |
224 | 224 | ||
225 | cleanVObject( vcal ); | 225 | cleanVObject( vcal ); |
226 | 226 | ||
227 | return result; | 227 | return result; |
228 | } | 228 | } |
229 | 229 | ||
230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 230 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
231 | { | 231 | { |
232 | VObject *vtodo; | 232 | VObject *vtodo; |
233 | QString tmpStr; | 233 | QString tmpStr; |
234 | 234 | ||
235 | 235 | ||
236 | vtodo = newVObject(VCTodoProp); | 236 | vtodo = newVObject(VCTodoProp); |
237 | 237 | ||
238 | // due date | 238 | // due date |
239 | if (anEvent->hasDueDate()) { | 239 | if (anEvent->hasDueDate()) { |
240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 240 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
241 | !anEvent->doesFloat()); | 241 | !anEvent->doesFloat()); |
242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 242 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
243 | } | 243 | } |
244 | 244 | ||
245 | // start date | 245 | // start date |
246 | if (anEvent->hasStartDate()) { | 246 | if (anEvent->hasStartDate()) { |
247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 247 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
248 | !anEvent->doesFloat()); | 248 | !anEvent->doesFloat()); |
249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 249 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
250 | } | 250 | } |
251 | 251 | ||
252 | // creation date | 252 | // creation date |
253 | tmpStr = qDateTimeToISO(anEvent->created()); | 253 | tmpStr = qDateTimeToISO(anEvent->created()); |
254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 254 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
255 | 255 | ||
256 | // unique id | 256 | // unique id |
257 | addPropValue(vtodo, VCUniqueStringProp, | 257 | addPropValue(vtodo, VCUniqueStringProp, |
258 | anEvent->uid().local8Bit()); | 258 | anEvent->uid().local8Bit()); |
259 | 259 | ||
260 | // revision | 260 | // revision |
261 | tmpStr.sprintf("%i", anEvent->revision()); | 261 | tmpStr.sprintf("%i", anEvent->revision()); |
262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 262 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
263 | 263 | ||
264 | // last modification date | 264 | // last modification date |
265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 265 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 266 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
267 | 267 | ||
268 | // organizer stuff | 268 | // organizer stuff |
269 | tmpStr = "MAILTO:" + anEvent->organizer(); | 269 | tmpStr = "MAILTO:" + anEvent->organizer(); |
270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 270 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
271 | 271 | ||
272 | // attendees | 272 | // attendees |
273 | if (anEvent->attendeeCount() != 0) { | 273 | if (anEvent->attendeeCount() != 0) { |
274 | QPtrList<Attendee> al = anEvent->attendees(); | 274 | QPtrList<Attendee> al = anEvent->attendees(); |
275 | QPtrListIterator<Attendee> ai(al); | 275 | QPtrListIterator<Attendee> ai(al); |
276 | Attendee *curAttendee; | 276 | Attendee *curAttendee; |
277 | 277 | ||
278 | for (; ai.current(); ++ai) { | 278 | for (; ai.current(); ++ai) { |
279 | curAttendee = ai.current(); | 279 | curAttendee = ai.current(); |
280 | if (!curAttendee->email().isEmpty() && | 280 | if (!curAttendee->email().isEmpty() && |
281 | !curAttendee->name().isEmpty()) | 281 | !curAttendee->name().isEmpty()) |
282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 282 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
283 | curAttendee->email() + ">"; | 283 | curAttendee->email() + ">"; |
284 | else if (curAttendee->name().isEmpty()) | 284 | else if (curAttendee->name().isEmpty()) |
285 | tmpStr = "MAILTO: " + curAttendee->email(); | 285 | tmpStr = "MAILTO: " + curAttendee->email(); |
286 | else if (curAttendee->email().isEmpty()) | 286 | else if (curAttendee->email().isEmpty()) |
287 | tmpStr = "MAILTO: " + curAttendee->name(); | 287 | tmpStr = "MAILTO: " + curAttendee->name(); |
288 | else if (curAttendee->name().isEmpty() && | 288 | else if (curAttendee->name().isEmpty() && |
289 | curAttendee->email().isEmpty()) | 289 | curAttendee->email().isEmpty()) |
290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 290 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 291 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
292 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); | 292 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
293 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 293 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
294 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 294 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | // description BL: | 298 | // description BL: |
299 | if (!anEvent->description().isEmpty()) { | 299 | if (!anEvent->description().isEmpty()) { |
300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 300 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
301 | anEvent->description().local8Bit()); | 301 | anEvent->description().local8Bit()); |
302 | if (anEvent->description().find('\n') != -1) | 302 | if (anEvent->description().find('\n') != -1) |
303 | addProp(d, VCQuotedPrintableProp); | 303 | addProp(d, VCQuotedPrintableProp); |
304 | } | 304 | } |
305 | 305 | ||
306 | // summary | 306 | // summary |
307 | if (!anEvent->summary().isEmpty()) | 307 | if (!anEvent->summary().isEmpty()) |
308 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 308 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
309 | 309 | ||
310 | if (!anEvent->location().isEmpty()) | 310 | if (!anEvent->location().isEmpty()) |
311 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 311 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
312 | 312 | ||
313 | // completed | 313 | // completed |
314 | // status | 314 | // status |
315 | // backward compatibility, KOrganizer used to interpret only these two values | 315 | // backward compatibility, KOrganizer used to interpret only these two values |
316 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 316 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
317 | "NEEDS_ACTION"); | 317 | "NEEDS_ACTION"); |
318 | // completion date | 318 | // completion date |
319 | if (anEvent->hasCompletedDate()) { | 319 | if (anEvent->hasCompletedDate()) { |
320 | tmpStr = qDateTimeToISO(anEvent->completed()); | 320 | tmpStr = qDateTimeToISO(anEvent->completed()); |
321 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 321 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
322 | } | 322 | } |
323 | 323 | ||
324 | // priority | 324 | // priority |
325 | tmpStr.sprintf("%i",anEvent->priority()); | 325 | tmpStr.sprintf("%i",anEvent->priority()); |
326 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 326 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
327 | 327 | ||
328 | // related event | 328 | // related event |
329 | if (anEvent->relatedToUid()) { | 329 | if (anEvent->relatedToUid()) { |
330 | addPropValue(vtodo, VCRelatedToProp, | 330 | addPropValue(vtodo, VCRelatedToProp, |
331 | anEvent->relatedToUid().local8Bit()); | 331 | anEvent->relatedToUid().local8Bit()); |
332 | } | 332 | } |
333 | 333 | ||
334 | // categories | 334 | // categories |
335 | QStringList tmpStrList = anEvent->categories(); | 335 | QStringList tmpStrList = anEvent->categories(); |
336 | tmpStr = ""; | 336 | tmpStr = ""; |
337 | QString catStr; | 337 | QString catStr; |
338 | for ( QStringList::Iterator it = tmpStrList.begin(); | 338 | for ( QStringList::Iterator it = tmpStrList.begin(); |
339 | it != tmpStrList.end(); | 339 | it != tmpStrList.end(); |
340 | ++it ) { | 340 | ++it ) { |
341 | catStr = *it; | 341 | catStr = *it; |
342 | if (catStr[0] == ' ') | 342 | if (catStr[0] == ' ') |
343 | tmpStr += catStr.mid(1); | 343 | tmpStr += catStr.mid(1); |
344 | else | 344 | else |
345 | tmpStr += catStr; | 345 | tmpStr += catStr; |
346 | // this must be a ';' character as the vCalendar specification requires! | 346 | // this must be a ';' character as the vCalendar specification requires! |
347 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 347 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
348 | // read in. | 348 | // read in. |
349 | tmpStr += ";"; | 349 | tmpStr += ";"; |
350 | } | 350 | } |
351 | if (!tmpStr.isEmpty()) { | 351 | if (!tmpStr.isEmpty()) { |
352 | tmpStr.truncate(tmpStr.length()-1); | 352 | tmpStr.truncate(tmpStr.length()-1); |
353 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 353 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
354 | } | 354 | } |
355 | 355 | ||
356 | // alarm stuff | 356 | // alarm stuff |
357 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 357 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
358 | QPtrList<Alarm> alarms = anEvent->alarms(); | 358 | QPtrList<Alarm> alarms = anEvent->alarms(); |
359 | Alarm* alarm; | 359 | Alarm* alarm; |
360 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 360 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
361 | if (alarm->enabled()) { | 361 | if (alarm->enabled()) { |
362 | VObject *a; | 362 | VObject *a; |
363 | tmpStr = qDateTimeToISO(alarm->time()); | 363 | tmpStr = qDateTimeToISO(alarm->time()); |
364 | if (alarm->type() == Alarm::Audio) { | 364 | if (alarm->type() == Alarm::Audio) { |
365 | a = addProp(vtodo, VCAAlarmProp); | 365 | a = addProp(vtodo, VCAAlarmProp); |
366 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 366 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
367 | addPropValue(a, VCRepeatCountProp, "1"); | 367 | addPropValue(a, VCRepeatCountProp, "1"); |
368 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 368 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
369 | } | 369 | } |
370 | else if (alarm->type() == Alarm::Procedure) { | 370 | else if (alarm->type() == Alarm::Procedure) { |
371 | a = addProp(vtodo, VCPAlarmProp); | 371 | a = addProp(vtodo, VCPAlarmProp); |
372 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 372 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
373 | addPropValue(a, VCRepeatCountProp, "1"); | 373 | addPropValue(a, VCRepeatCountProp, "1"); |
374 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 374 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
375 | } else { | 375 | } else { |
376 | a = addProp(vtodo, VCDAlarmProp); | 376 | a = addProp(vtodo, VCDAlarmProp); |
377 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 377 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
378 | addPropValue(a, VCRepeatCountProp, "1"); | 378 | addPropValue(a, VCRepeatCountProp, "1"); |
379 | addPropValue(a, VCDisplayStringProp, "beep!"); | 379 | addPropValue(a, VCDisplayStringProp, "beep!"); |
380 | } | 380 | } |
381 | } | 381 | } |
382 | } | 382 | } |
383 | 383 | ||
384 | if (anEvent->pilotId()) { | 384 | if (anEvent->pilotId()) { |
385 | // pilot sync stuff | 385 | // pilot sync stuff |
386 | tmpStr.sprintf("%i",anEvent->pilotId()); | 386 | tmpStr.sprintf("%i",anEvent->pilotId()); |
387 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 387 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
388 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 388 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
389 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 389 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
390 | } | 390 | } |
391 | 391 | ||
392 | return vtodo; | 392 | return vtodo; |
393 | } | 393 | } |
394 | 394 | ||
395 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 395 | VObject* VCalFormat::eventToVEvent(Event *anEvent) |
396 | { | 396 | { |
397 | VObject *vevent; | 397 | VObject *vevent; |
398 | QString tmpStr; | 398 | QString tmpStr; |
399 | 399 | ||
400 | vevent = newVObject(VCEventProp); | 400 | vevent = newVObject(VCEventProp); |
401 | 401 | ||
402 | // start and end time | 402 | // start and end time |
403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 403 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
404 | !anEvent->doesFloat()); | 404 | !anEvent->doesFloat()); |
405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 405 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
406 | 406 | ||
407 | // events that have time associated but take up no time should | 407 | // events that have time associated but take up no time should |
408 | // not have both DTSTART and DTEND. | 408 | // not have both DTSTART and DTEND. |
409 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 409 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 410 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
411 | !anEvent->doesFloat()); | 411 | !anEvent->doesFloat()); |
412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 412 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
413 | } | 413 | } |
414 | 414 | ||
415 | // creation date | 415 | // creation date |
416 | tmpStr = qDateTimeToISO(anEvent->created()); | 416 | tmpStr = qDateTimeToISO(anEvent->created()); |
417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 417 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
418 | 418 | ||
419 | // unique id | 419 | // unique id |
420 | addPropValue(vevent, VCUniqueStringProp, | 420 | addPropValue(vevent, VCUniqueStringProp, |
421 | anEvent->uid().local8Bit()); | 421 | anEvent->uid().local8Bit()); |
422 | 422 | ||
423 | // revision | 423 | // revision |
424 | tmpStr.sprintf("%i", anEvent->revision()); | 424 | tmpStr.sprintf("%i", anEvent->revision()); |
425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 425 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
426 | 426 | ||
427 | // last modification date | 427 | // last modification date |
428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 428 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 429 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
430 | 430 | ||
431 | // attendee and organizer stuff | 431 | // attendee and organizer stuff |
432 | tmpStr = "MAILTO:" + anEvent->organizer(); | 432 | tmpStr = "MAILTO:" + anEvent->organizer(); |
433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 433 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
434 | 434 | ||
435 | if (anEvent->attendeeCount() != 0) { | 435 | if (anEvent->attendeeCount() != 0) { |
436 | QPtrList<Attendee> al = anEvent->attendees(); | 436 | QPtrList<Attendee> al = anEvent->attendees(); |
437 | QPtrListIterator<Attendee> ai(al); | 437 | QPtrListIterator<Attendee> ai(al); |
438 | Attendee *curAttendee; | 438 | Attendee *curAttendee; |
439 | 439 | ||
440 | // TODO: Put this functionality into Attendee class | 440 | // TODO: Put this functionality into Attendee class |
441 | for (; ai.current(); ++ai) { | 441 | for (; ai.current(); ++ai) { |
442 | curAttendee = ai.current(); | 442 | curAttendee = ai.current(); |
443 | if (!curAttendee->email().isEmpty() && | 443 | if (!curAttendee->email().isEmpty() && |
444 | !curAttendee->name().isEmpty()) | 444 | !curAttendee->name().isEmpty()) |
445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 445 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
446 | curAttendee->email() + ">"; | 446 | curAttendee->email() + ">"; |
447 | else if (curAttendee->name().isEmpty()) | 447 | else if (curAttendee->name().isEmpty()) |
448 | tmpStr = "MAILTO: " + curAttendee->email(); | 448 | tmpStr = "MAILTO: " + curAttendee->email(); |
449 | else if (curAttendee->email().isEmpty()) | 449 | else if (curAttendee->email().isEmpty()) |
450 | tmpStr = "MAILTO: " + curAttendee->name(); | 450 | tmpStr = "MAILTO: " + curAttendee->name(); |
451 | else if (curAttendee->name().isEmpty() && | 451 | else if (curAttendee->name().isEmpty() && |
452 | curAttendee->email().isEmpty()) | 452 | curAttendee->email().isEmpty()) |
453 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 453 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 454 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
455 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); | 455 | addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); |
456 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 456 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
457 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 457 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
458 | } | 458 | } |
459 | } | 459 | } |
460 | 460 | ||
461 | // recurrence rule stuff | 461 | // recurrence rule stuff |
462 | if (anEvent->recurrence()->doesRecur()) { | 462 | if (anEvent->doesRecur()) { |
463 | // some more variables | 463 | // some more variables |
464 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 464 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
465 | QPtrList<int> tmpDays; | 465 | QPtrList<int> tmpDays; |
466 | int *tmpDay; | 466 | int *tmpDay; |
467 | Recurrence::rMonthPos *tmpPos; | 467 | Recurrence::rMonthPos *tmpPos; |
468 | QString tmpStr2; | 468 | QString tmpStr2; |
469 | int i; | 469 | int i; |
470 | 470 | ||
471 | switch(anEvent->recurrence()->doesRecur()) { | 471 | switch(anEvent->recurrence()->doesRecur()) { |
472 | case Recurrence::rDaily: | 472 | case Recurrence::rDaily: |
473 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 473 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
474 | // if (anEvent->rDuration > 0) | 474 | // if (anEvent->rDuration > 0) |
475 | //tmpStr += "#"; | 475 | //tmpStr += "#"; |
476 | break; | 476 | break; |
477 | case Recurrence::rWeekly: | 477 | case Recurrence::rWeekly: |
478 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 478 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
479 | for (i = 0; i < 7; i++) { | 479 | for (i = 0; i < 7; i++) { |
480 | if (anEvent->recurrence()->days().testBit(i)) | 480 | if (anEvent->recurrence()->days().testBit(i)) |
481 | tmpStr += dayFromNum(i); | 481 | tmpStr += dayFromNum(i); |
482 | } | 482 | } |
483 | break; | 483 | break; |
484 | case Recurrence::rMonthlyPos: | 484 | case Recurrence::rMonthlyPos: |
485 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 485 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
486 | // write out all rMonthPos's | 486 | // write out all rMonthPos's |
487 | tmpPositions = anEvent->recurrence()->monthPositions(); | 487 | tmpPositions = anEvent->recurrence()->monthPositions(); |
488 | for (tmpPos = tmpPositions.first(); | 488 | for (tmpPos = tmpPositions.first(); |
489 | tmpPos; | 489 | tmpPos; |
490 | tmpPos = tmpPositions.next()) { | 490 | tmpPos = tmpPositions.next()) { |
491 | 491 | ||
492 | tmpStr2.sprintf("%i", tmpPos->rPos); | 492 | tmpStr2.sprintf("%i", tmpPos->rPos); |
493 | if (tmpPos->negative) | 493 | if (tmpPos->negative) |
494 | tmpStr2 += "- "; | 494 | tmpStr2 += "- "; |
495 | else | 495 | else |
496 | tmpStr2 += "+ "; | 496 | tmpStr2 += "+ "; |
497 | tmpStr += tmpStr2; | 497 | tmpStr += tmpStr2; |
498 | for (i = 0; i < 7; i++) { | 498 | for (i = 0; i < 7; i++) { |
499 | if (tmpPos->rDays.testBit(i)) | 499 | if (tmpPos->rDays.testBit(i)) |
500 | tmpStr += dayFromNum(i); | 500 | tmpStr += dayFromNum(i); |
501 | } | 501 | } |
502 | } // loop for all rMonthPos's | 502 | } // loop for all rMonthPos's |
503 | break; | 503 | break; |
504 | case Recurrence::rMonthlyDay: | 504 | case Recurrence::rMonthlyDay: |
505 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 505 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
506 | // write out all rMonthDays; | 506 | // write out all rMonthDays; |
507 | tmpDays = anEvent->recurrence()->monthDays(); | 507 | tmpDays = anEvent->recurrence()->monthDays(); |
508 | for (tmpDay = tmpDays.first(); | 508 | for (tmpDay = tmpDays.first(); |
509 | tmpDay; | 509 | tmpDay; |
510 | tmpDay = tmpDays.next()) { | 510 | tmpDay = tmpDays.next()) { |
511 | tmpStr2.sprintf("%i ", *tmpDay); | 511 | tmpStr2.sprintf("%i ", *tmpDay); |
512 | tmpStr += tmpStr2; | 512 | tmpStr += tmpStr2; |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | case Recurrence::rYearlyMonth: | 515 | case Recurrence::rYearlyMonth: |
516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 516 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
517 | // write out all the rYearNums; | 517 | // write out all the rYearNums; |
518 | tmpDays = anEvent->recurrence()->yearNums(); | 518 | tmpDays = anEvent->recurrence()->yearNums(); |
519 | for (tmpDay = tmpDays.first(); | 519 | for (tmpDay = tmpDays.first(); |
520 | tmpDay; | 520 | tmpDay; |
521 | tmpDay = tmpDays.next()) { | 521 | tmpDay = tmpDays.next()) { |
522 | tmpStr2.sprintf("%i ", *tmpDay); | 522 | tmpStr2.sprintf("%i ", *tmpDay); |
523 | tmpStr += tmpStr2; | 523 | tmpStr += tmpStr2; |
524 | } | 524 | } |
525 | break; | 525 | break; |
526 | case Recurrence::rYearlyDay: | 526 | case Recurrence::rYearlyDay: |
527 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 527 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
528 | // write out all the rYearNums; | 528 | // write out all the rYearNums; |
529 | tmpDays = anEvent->recurrence()->yearNums(); | 529 | tmpDays = anEvent->recurrence()->yearNums(); |
530 | for (tmpDay = tmpDays.first(); | 530 | for (tmpDay = tmpDays.first(); |
531 | tmpDay; | 531 | tmpDay; |
532 | tmpDay = tmpDays.next()) { | 532 | tmpDay = tmpDays.next()) { |
533 | tmpStr2.sprintf("%i ", *tmpDay); | 533 | tmpStr2.sprintf("%i ", *tmpDay); |
534 | tmpStr += tmpStr2; | 534 | tmpStr += tmpStr2; |
535 | } | 535 | } |
536 | break; | 536 | break; |
537 | default: | 537 | default: |
538 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 538 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
539 | break; | 539 | break; |
540 | } // switch | 540 | } // switch |
541 | 541 | ||
542 | if (anEvent->recurrence()->duration() > 0) { | 542 | if (anEvent->recurrence()->duration() > 0) { |
543 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 543 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
544 | tmpStr += tmpStr2; | 544 | tmpStr += tmpStr2; |
545 | } else if (anEvent->recurrence()->duration() == -1) { | 545 | } else if (anEvent->recurrence()->duration() == -1) { |
546 | tmpStr += "#0"; // defined as repeat forever | 546 | tmpStr += "#0"; // defined as repeat forever |
547 | } else { | 547 | } else { |
548 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 548 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
549 | } | 549 | } |
550 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 550 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
551 | 551 | ||
552 | } // event repeats | 552 | } // event repeats |
553 | 553 | ||
554 | // exceptions to recurrence | 554 | // exceptions to recurrence |
555 | DateList dateList = anEvent->exDates(); | 555 | DateList dateList = anEvent->exDates(); |
556 | DateList::ConstIterator it; | 556 | DateList::ConstIterator it; |
557 | QString tmpStr2; | 557 | QString tmpStr2; |
558 | 558 | ||
559 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 559 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
560 | tmpStr = qDateToISO(*it) + ";"; | 560 | tmpStr = qDateToISO(*it) + ";"; |
561 | tmpStr2 += tmpStr; | 561 | tmpStr2 += tmpStr; |
562 | } | 562 | } |
563 | if (!tmpStr2.isEmpty()) { | 563 | if (!tmpStr2.isEmpty()) { |
564 | tmpStr2.truncate(tmpStr2.length()-1); | 564 | tmpStr2.truncate(tmpStr2.length()-1); |
565 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 565 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
566 | } | 566 | } |
567 | 567 | ||
568 | // description | 568 | // description |
569 | if (!anEvent->description().isEmpty()) { | 569 | if (!anEvent->description().isEmpty()) { |
570 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 570 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
571 | anEvent->description().local8Bit()); | 571 | anEvent->description().local8Bit()); |
572 | if (anEvent->description().find('\n') != -1) | 572 | if (anEvent->description().find('\n') != -1) |
573 | addProp(d, VCQuotedPrintableProp); | 573 | addProp(d, VCQuotedPrintableProp); |
574 | } | 574 | } |
575 | 575 | ||
576 | // summary | 576 | // summary |
577 | if (!anEvent->summary().isEmpty()) | 577 | if (!anEvent->summary().isEmpty()) |
578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 578 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
579 | 579 | ||
580 | if (!anEvent->location().isEmpty()) | 580 | if (!anEvent->location().isEmpty()) |
581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 581 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
582 | 582 | ||
583 | // status | 583 | // status |
584 | // TODO: define Event status | 584 | // TODO: define Event status |
585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 585 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
586 | 586 | ||
587 | // secrecy | 587 | // secrecy |
588 | const char *text = 0; | 588 | const char *text = 0; |
589 | switch (anEvent->secrecy()) { | 589 | switch (anEvent->secrecy()) { |
590 | case Incidence::SecrecyPublic: | 590 | case Incidence::SecrecyPublic: |
591 | text = "PUBLIC"; | 591 | text = "PUBLIC"; |
592 | break; | 592 | break; |
593 | case Incidence::SecrecyPrivate: | 593 | case Incidence::SecrecyPrivate: |
594 | text = "PRIVATE"; | 594 | text = "PRIVATE"; |
595 | break; | 595 | break; |
596 | case Incidence::SecrecyConfidential: | 596 | case Incidence::SecrecyConfidential: |
597 | text = "CONFIDENTIAL"; | 597 | text = "CONFIDENTIAL"; |
598 | break; | 598 | break; |
599 | } | 599 | } |
600 | if (text) { | 600 | if (text) { |
601 | addPropValue(vevent, VCClassProp, text); | 601 | addPropValue(vevent, VCClassProp, text); |
602 | } | 602 | } |
603 | 603 | ||
604 | // categories | 604 | // categories |
605 | QStringList tmpStrList = anEvent->categories(); | 605 | QStringList tmpStrList = anEvent->categories(); |
606 | tmpStr = ""; | 606 | tmpStr = ""; |
607 | QString catStr; | 607 | QString catStr; |
608 | for ( QStringList::Iterator it = tmpStrList.begin(); | 608 | for ( QStringList::Iterator it = tmpStrList.begin(); |
609 | it != tmpStrList.end(); | 609 | it != tmpStrList.end(); |
610 | ++it ) { | 610 | ++it ) { |
611 | catStr = *it; | 611 | catStr = *it; |
612 | if (catStr[0] == ' ') | 612 | if (catStr[0] == ' ') |
613 | tmpStr += catStr.mid(1); | 613 | tmpStr += catStr.mid(1); |
614 | else | 614 | else |
615 | tmpStr += catStr; | 615 | tmpStr += catStr; |
616 | // this must be a ';' character as the vCalendar specification requires! | 616 | // this must be a ';' character as the vCalendar specification requires! |
617 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 617 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
618 | // read in. | 618 | // read in. |
619 | tmpStr += ";"; | 619 | tmpStr += ";"; |
620 | } | 620 | } |
621 | if (!tmpStr.isEmpty()) { | 621 | if (!tmpStr.isEmpty()) { |
622 | tmpStr.truncate(tmpStr.length()-1); | 622 | tmpStr.truncate(tmpStr.length()-1); |
623 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 623 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
624 | } | 624 | } |
625 | 625 | ||
626 | // attachments | 626 | // attachments |
627 | // TODO: handle binary attachments! | 627 | // TODO: handle binary attachments! |
628 | QPtrList<Attachment> attachments = anEvent->attachments(); | 628 | QPtrList<Attachment> attachments = anEvent->attachments(); |
629 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 629 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
630 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 630 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
631 | 631 | ||
632 | // resources | 632 | // resources |
633 | tmpStrList = anEvent->resources(); | 633 | tmpStrList = anEvent->resources(); |
634 | tmpStr = tmpStrList.join(";"); | 634 | tmpStr = tmpStrList.join(";"); |
635 | if (!tmpStr.isEmpty()) | 635 | if (!tmpStr.isEmpty()) |
636 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 636 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
637 | 637 | ||
638 | // alarm stuff | 638 | // alarm stuff |
639 | QPtrList<Alarm> alarms = anEvent->alarms(); | 639 | QPtrList<Alarm> alarms = anEvent->alarms(); |
640 | Alarm* alarm; | 640 | Alarm* alarm; |
641 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 641 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
642 | if (alarm->enabled()) { | 642 | if (alarm->enabled()) { |
643 | VObject *a ; | 643 | VObject *a ; |
644 | tmpStr = qDateTimeToISO(alarm->time()); | 644 | tmpStr = qDateTimeToISO(alarm->time()); |
645 | if (alarm->type() == Alarm::Audio) { | 645 | if (alarm->type() == Alarm::Audio) { |
646 | a = addProp(vevent, VCAAlarmProp); | 646 | a = addProp(vevent, VCAAlarmProp); |
647 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 647 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
648 | addPropValue(a, VCRepeatCountProp, "1"); | 648 | addPropValue(a, VCRepeatCountProp, "1"); |
649 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 649 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
650 | } | 650 | } |
651 | if (alarm->type() == Alarm::Procedure) { | 651 | if (alarm->type() == Alarm::Procedure) { |
652 | a = addProp(vevent, VCPAlarmProp); | 652 | a = addProp(vevent, VCPAlarmProp); |
653 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 653 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
654 | addPropValue(a, VCRepeatCountProp, "1"); | 654 | addPropValue(a, VCRepeatCountProp, "1"); |
655 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 655 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
656 | } else { | 656 | } else { |
657 | a = addProp(vevent, VCDAlarmProp); | 657 | a = addProp(vevent, VCDAlarmProp); |
658 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 658 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
659 | addPropValue(a, VCRepeatCountProp, "1"); | 659 | addPropValue(a, VCRepeatCountProp, "1"); |
660 | addPropValue(a, VCDisplayStringProp, "beep!"); | 660 | addPropValue(a, VCDisplayStringProp, "beep!"); |
661 | 661 | ||
662 | } | 662 | } |
663 | } | 663 | } |
664 | } | 664 | } |
665 | 665 | ||
666 | // priority | 666 | // priority |
667 | tmpStr.sprintf("%i",anEvent->priority()); | 667 | tmpStr.sprintf("%i",anEvent->priority()); |
668 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 668 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
669 | 669 | ||
670 | // transparency | 670 | // transparency |
671 | tmpStr.sprintf("%i",anEvent->transparency()); | 671 | tmpStr.sprintf("%i",anEvent->transparency()); |
672 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 672 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
673 | 673 | ||
674 | // related event | 674 | // related event |
675 | if (anEvent->relatedToUid()) { | 675 | if (anEvent->relatedToUid()) { |
676 | addPropValue(vevent, VCRelatedToProp, | 676 | addPropValue(vevent, VCRelatedToProp, |
677 | anEvent->relatedToUid().local8Bit()); | 677 | anEvent->relatedToUid().local8Bit()); |
678 | } | 678 | } |
679 | 679 | ||
680 | if (anEvent->pilotId()) { | 680 | if (anEvent->pilotId()) { |
681 | // pilot sync stuff | 681 | // pilot sync stuff |
682 | tmpStr.sprintf("%i",anEvent->pilotId()); | 682 | tmpStr.sprintf("%i",anEvent->pilotId()); |
683 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 683 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
684 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 684 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
685 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 685 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
686 | } | 686 | } |
687 | 687 | ||
688 | return vevent; | 688 | return vevent; |
689 | } | 689 | } |
690 | 690 | ||
691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 691 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
692 | { | 692 | { |
693 | VObject *vo; | 693 | VObject *vo; |
694 | VObjectIterator voi; | 694 | VObjectIterator voi; |
695 | char *s; | 695 | char *s; |
696 | 696 | ||
697 | Todo *anEvent = new Todo; | 697 | Todo *anEvent = new Todo; |
698 | 698 | ||
699 | // creation date | 699 | // creation date |
700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 700 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 701 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
702 | deleteStr(s); | 702 | deleteStr(s); |
703 | } | 703 | } |
704 | 704 | ||
705 | // unique id | 705 | // unique id |
706 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 706 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
707 | // while the UID property is preferred, it is not required. We'll use the | 707 | // while the UID property is preferred, it is not required. We'll use the |
708 | // default Event UID if none is given. | 708 | // default Event UID if none is given. |
709 | if (vo) { | 709 | if (vo) { |
710 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 710 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
711 | deleteStr(s); | 711 | deleteStr(s); |
712 | } | 712 | } |
713 | 713 | ||
714 | // last modification date | 714 | // last modification date |
715 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 715 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
716 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 716 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
717 | deleteStr(s); | 717 | deleteStr(s); |
718 | } | 718 | } |
719 | else | 719 | else |
720 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 720 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
721 | QTime::currentTime())); | 721 | QTime::currentTime())); |
722 | 722 | ||
723 | // organizer | 723 | // organizer |
724 | // if our extension property for the event's ORGANIZER exists, add it. | 724 | // if our extension property for the event's ORGANIZER exists, add it. |
725 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 725 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
726 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 726 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
727 | deleteStr(s); | 727 | deleteStr(s); |
728 | } else { | 728 | } else { |
729 | anEvent->setOrganizer(mCalendar->getEmail()); | 729 | anEvent->setOrganizer(mCalendar->getEmail()); |
730 | } | 730 | } |
731 | 731 | ||
732 | // attendees. | 732 | // attendees. |
733 | initPropIterator(&voi, vtodo); | 733 | initPropIterator(&voi, vtodo); |
734 | while (moreIteration(&voi)) { | 734 | while (moreIteration(&voi)) { |
735 | vo = nextVObject(&voi); | 735 | vo = nextVObject(&voi); |
736 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 736 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
737 | Attendee *a; | 737 | Attendee *a; |
738 | VObject *vp; | 738 | VObject *vp; |
739 | s = fakeCString(vObjectUStringZValue(vo)); | 739 | s = fakeCString(vObjectUStringZValue(vo)); |
740 | QString tmpStr = QString::fromLocal8Bit(s); | 740 | QString tmpStr = QString::fromLocal8Bit(s); |
741 | deleteStr(s); | 741 | deleteStr(s); |
742 | tmpStr = tmpStr.simplifyWhiteSpace(); | 742 | tmpStr = tmpStr.simplifyWhiteSpace(); |
743 | int emailPos1, emailPos2; | 743 | int emailPos1, emailPos2; |
744 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 744 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
745 | // both email address and name | 745 | // both email address and name |
746 | emailPos2 = tmpStr.findRev('>'); | 746 | emailPos2 = tmpStr.findRev('>'); |
747 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 747 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
748 | tmpStr.mid(emailPos1 + 1, | 748 | tmpStr.mid(emailPos1 + 1, |
749 | emailPos2 - (emailPos1 + 1))); | 749 | emailPos2 - (emailPos1 + 1))); |
750 | } else if (tmpStr.find('@') > 0) { | 750 | } else if (tmpStr.find('@') > 0) { |
751 | // just an email address | 751 | // just an email address |
752 | a = new Attendee(0, tmpStr); | 752 | a = new Attendee(0, tmpStr); |
753 | } else { | 753 | } else { |
754 | // just a name | 754 | // just a name |
755 | // QString email = tmpStr.replace( QRegExp(" "), "." ); | 755 | // QString email = tmpStr.replace( QRegExp(" "), "." ); |
756 | a = new Attendee(tmpStr,0); | 756 | a = new Attendee(tmpStr,0); |
757 | } | 757 | } |
758 | // is there a Role property? | 758 | // is there a Role property? |
759 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) | 759 | if ((vp = isAPropertyOf(vo, VCRoleProp)) != 0) |
760 | a->setRole(readRole(vObjectStringZValue(vp))); | 760 | a->setRole(readRole(vObjectStringZValue(vp))); |
761 | // is there an RSVP property? | 761 | // is there an RSVP property? |
762 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 762 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
763 | a->setRSVP(vObjectStringZValue(vp)); | 763 | a->setRSVP(vObjectStringZValue(vp)); |
764 | // is there a status property? | 764 | // is there a status property? |
765 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 765 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
766 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 766 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
767 | // add the attendee | 767 | // add the attendee |
768 | anEvent->addAttendee(a); | 768 | anEvent->addAttendee(a); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | // description for todo | 772 | // description for todo |
773 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 773 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
774 | s = fakeCString(vObjectUStringZValue(vo)); | 774 | s = fakeCString(vObjectUStringZValue(vo)); |
775 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 775 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
776 | deleteStr(s); | 776 | deleteStr(s); |
777 | } | 777 | } |
778 | 778 | ||
779 | // summary | 779 | // summary |
780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 780 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
781 | s = fakeCString(vObjectUStringZValue(vo)); | 781 | s = fakeCString(vObjectUStringZValue(vo)); |
782 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 782 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
783 | deleteStr(s); | 783 | deleteStr(s); |
784 | } | 784 | } |
785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 785 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
786 | s = fakeCString(vObjectUStringZValue(vo)); | 786 | s = fakeCString(vObjectUStringZValue(vo)); |
787 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 787 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
788 | deleteStr(s); | 788 | deleteStr(s); |
789 | } | 789 | } |
790 | 790 | ||
791 | 791 | ||
792 | // completed | 792 | // completed |
793 | // was: status | 793 | // was: status |
794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 794 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
795 | s = fakeCString(vObjectUStringZValue(vo)); | 795 | s = fakeCString(vObjectUStringZValue(vo)); |
796 | if (strcmp(s,"COMPLETED") == 0) { | 796 | if (strcmp(s,"COMPLETED") == 0) { |
797 | anEvent->setCompleted(true); | 797 | anEvent->setCompleted(true); |
798 | } else { | 798 | } else { |
799 | anEvent->setCompleted(false); | 799 | anEvent->setCompleted(false); |
800 | } | 800 | } |
801 | deleteStr(s); | 801 | deleteStr(s); |
802 | } | 802 | } |
803 | else | 803 | else |
804 | anEvent->setCompleted(false); | 804 | anEvent->setCompleted(false); |
805 | 805 | ||
806 | // completion date | 806 | // completion date |
807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 807 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 808 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
809 | deleteStr(s); | 809 | deleteStr(s); |
810 | } | 810 | } |
811 | 811 | ||
812 | // priority | 812 | // priority |
813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 813 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 814 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
815 | deleteStr(s); | 815 | deleteStr(s); |
816 | } | 816 | } |
817 | 817 | ||
818 | // due date | 818 | // due date |
819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 819 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 820 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
821 | deleteStr(s); | 821 | deleteStr(s); |
822 | anEvent->setHasDueDate(true); | 822 | anEvent->setHasDueDate(true); |
823 | } else { | 823 | } else { |
824 | anEvent->setHasDueDate(false); | 824 | anEvent->setHasDueDate(false); |
825 | } | 825 | } |
826 | 826 | ||
827 | // start time | 827 | // start time |
828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 828 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 829 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
830 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 830 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
831 | deleteStr(s); | 831 | deleteStr(s); |
832 | anEvent->setHasStartDate(true); | 832 | anEvent->setHasStartDate(true); |
833 | } else { | 833 | } else { |
834 | anEvent->setHasStartDate(false); | 834 | anEvent->setHasStartDate(false); |
835 | } | 835 | } |
836 | 836 | ||
837 | /* alarm stuff */ | 837 | /* alarm stuff */ |
838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 838 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 839 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
840 | Alarm* alarm = anEvent->newAlarm(); | 840 | Alarm* alarm = anEvent->newAlarm(); |
841 | VObject *a; | 841 | VObject *a; |
842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 842 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 843 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
844 | deleteStr(s); | 844 | deleteStr(s); |
845 | } | 845 | } |
846 | alarm->setEnabled(true); | 846 | alarm->setEnabled(true); |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index c7df017..6dae3d2 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -1,113 +1,113 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef _VCALFORMAT_H | 22 | #ifndef _VCALFORMAT_H |
23 | #define _VCALFORMAT_H | 23 | #define _VCALFORMAT_H |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #define _VCAL_VERSION "1.0" | 27 | #define _VCAL_VERSION "1.0" |
28 | 28 | ||
29 | class VObject; | 29 | class VObject; |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the vCalendar format. It provides methods for | 34 | This class implements the vCalendar format. It provides methods for |
35 | loading/saving/converting vCalendar format data into the internal KOrganizer | 35 | loading/saving/converting vCalendar format data into the internal KOrganizer |
36 | representation as Calendar and Events. | 36 | representation as Calendar and Events. |
37 | 37 | ||
38 | @short vCalendar format implementation | 38 | @short vCalendar format implementation |
39 | */ | 39 | */ |
40 | class VCalFormat : public CalFormat { | 40 | class VCalFormat : public CalFormat { |
41 | public: | 41 | public: |
42 | VCalFormat(); | 42 | VCalFormat(); |
43 | virtual ~VCalFormat(); | 43 | virtual ~VCalFormat(); |
44 | 44 | ||
45 | /** loads a calendar on disk in vCalendar format into the current calendar. | 45 | /** loads a calendar on disk in vCalendar format into the current calendar. |
46 | * any information already present is lost. Returns TRUE if successful, | 46 | * any information already present is lost. Returns TRUE if successful, |
47 | * else returns FALSE. | 47 | * else returns FALSE. |
48 | * @param fileName the name of the calendar on disk. | 48 | * @param fileName the name of the calendar on disk. |
49 | */ | 49 | */ |
50 | bool load(Calendar *,const QString &fileName ); | 50 | bool load(Calendar *,const QString &fileName ); |
51 | /** writes out the calendar to disk in vCalendar format. Returns true if | 51 | /** writes out the calendar to disk in vCalendar format. Returns true if |
52 | * successful and false on error. | 52 | * successful and false on error. |
53 | * @param fileName the name of the file | 53 | * @param fileName the name of the file |
54 | */ | 54 | */ |
55 | bool save(Calendar *,const QString &fileName ); | 55 | bool save(Calendar *,const QString &fileName ); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | Parse string and populate calendar with that information. | 58 | Parse string and populate calendar with that information. |
59 | */ | 59 | */ |
60 | bool fromString( Calendar *, const QString & ); | 60 | bool fromString( Calendar *, const QString & ); |
61 | /** | 61 | /** |
62 | Return calendar information as string. | 62 | Return calendar information as string. |
63 | */ | 63 | */ |
64 | void setLocalTime ( bool ); | 64 | void setLocalTime ( bool ); |
65 | QString toString( Calendar * ); | 65 | QString toString( Calendar * ); |
66 | QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); | 66 | QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); |
67 | QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); | 67 | QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); |
68 | 68 | ||
69 | protected: | 69 | protected: |
70 | /** translates a VObject of the TODO type into a Event */ | 70 | /** translates a VObject of the TODO type into a Event */ |
71 | Todo *VTodoToEvent(VObject *vtodo); | 71 | Todo *VTodoToEvent(VObject *vtodo); |
72 | /** translates a VObject into a Event and returns a pointer to it. */ | 72 | /** translates a VObject into a Event and returns a pointer to it. */ |
73 | Event *VEventToEvent(VObject *vevent); | 73 | Event *VEventToEvent(VObject *vevent); |
74 | /** translate a Event into a VTodo-type VObject and return pointer */ | 74 | /** translate a Event into a VTodo-type VObject and return pointer */ |
75 | VObject *eventToVTodo(const Todo *anEvent); | 75 | VObject *eventToVTodo(const Todo *anEvent); |
76 | /** translate a Event into a VObject and returns a pointer to it. */ | 76 | /** translate a Event into a VObject and returns a pointer to it. */ |
77 | VObject* eventToVEvent(const Event *anEvent); | 77 | VObject* eventToVEvent(Event *anEvent); |
78 | 78 | ||
79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ | 79 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |
80 | QString qDateToISO(const QDate &); | 80 | QString qDateToISO(const QDate &); |
81 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ | 81 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ |
82 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); | 82 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); |
83 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a | 83 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a |
84 | * valid QDateTime. */ | 84 | * valid QDateTime. */ |
85 | QDateTime ISOToQDateTime(const QString & dtStr); | 85 | QDateTime ISOToQDateTime(const QString & dtStr); |
86 | /** takes a string in the format YYYYMMDD and returns a | 86 | /** takes a string in the format YYYYMMDD and returns a |
87 | * valid QDate. */ | 87 | * valid QDate. */ |
88 | QDate ISOToQDate(const QString & dtStr); | 88 | QDate ISOToQDate(const QString & dtStr); |
89 | /** takes a vCalendar tree of VObjects, and puts all of them that have | 89 | /** takes a vCalendar tree of VObjects, and puts all of them that have |
90 | * the "event" property into the dictionary, todos in the todo-list, etc. */ | 90 | * the "event" property into the dictionary, todos in the todo-list, etc. */ |
91 | void populate(VObject *vcal); | 91 | void populate(VObject *vcal); |
92 | 92 | ||
93 | /** takes a number 0 - 6 and returns the two letter string of that day, | 93 | /** takes a number 0 - 6 and returns the two letter string of that day, |
94 | * i.e. MO, TU, WE, etc. */ | 94 | * i.e. MO, TU, WE, etc. */ |
95 | const char *dayFromNum(int day); | 95 | const char *dayFromNum(int day); |
96 | /** the reverse of the above function. */ | 96 | /** the reverse of the above function. */ |
97 | int numFromDay(const QString &day); | 97 | int numFromDay(const QString &day); |
98 | Attendee::Role VCalFormat::readRole(const char *s) const; | 98 | Attendee::Role VCalFormat::readRole(const char *s) const; |
99 | QCString writeRole(Attendee::Role role) const; | 99 | QCString writeRole(Attendee::Role role) const; |
100 | Attendee::PartStat readStatus(const char *s) const; | 100 | Attendee::PartStat readStatus(const char *s) const; |
101 | QCString writeStatus(Attendee::PartStat status) const; | 101 | QCString writeStatus(Attendee::PartStat status) const; |
102 | 102 | ||
103 | private: | 103 | private: |
104 | Calendar *mCalendar; | 104 | Calendar *mCalendar; |
105 | bool useLocalTime; | 105 | bool useLocalTime; |
106 | 106 | ||
107 | QPtrList<Event> mEventsRelate; // events with relations | 107 | QPtrList<Event> mEventsRelate; // events with relations |
108 | QPtrList<Todo> mTodosRelate; // todos with relations | 108 | QPtrList<Todo> mTodosRelate; // todos with relations |
109 | }; | 109 | }; |
110 | 110 | ||
111 | } | 111 | } |
112 | 112 | ||
113 | #endif | 113 | #endif |