summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp28
-rw-r--r--korganizer/koagendaview.cpp27
-rw-r--r--korganizer/mainwindow.cpp8
3 files changed, 43 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 73aa733..a330414 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -3304,779 +3304,801 @@ void CalendarView::schedule_counter(Incidence *incidence)
3304 schedule(Scheduler::Counter,incidence); 3304 schedule(Scheduler::Counter,incidence);
3305} 3305}
3306 3306
3307void CalendarView::schedule_declinecounter(Incidence *incidence) 3307void CalendarView::schedule_declinecounter(Incidence *incidence)
3308{ 3308{
3309 schedule(Scheduler::Declinecounter,incidence); 3309 schedule(Scheduler::Declinecounter,incidence);
3310} 3310}
3311 3311
3312void CalendarView::schedule_publish_freebusy(int daysToPublish) 3312void CalendarView::schedule_publish_freebusy(int daysToPublish)
3313{ 3313{
3314 QDateTime start = QDateTime::currentDateTime(); 3314 QDateTime start = QDateTime::currentDateTime();
3315 QDateTime end = start.addDays(daysToPublish); 3315 QDateTime end = start.addDays(daysToPublish);
3316 3316
3317 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3317 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3318 freebusy->setOrganizer(KOPrefs::instance()->email()); 3318 freebusy->setOrganizer(KOPrefs::instance()->email());
3319 3319
3320 3320
3321 PublishDialog *publishdlg = new PublishDialog(); 3321 PublishDialog *publishdlg = new PublishDialog();
3322 if ( publishdlg->exec() == QDialog::Accepted ) { 3322 if ( publishdlg->exec() == QDialog::Accepted ) {
3323 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3323 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3324 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3324 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3325 delete(freebusy); 3325 delete(freebusy);
3326 } 3326 }
3327 } 3327 }
3328 delete publishdlg; 3328 delete publishdlg;
3329} 3329}
3330 3330
3331void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3331void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3332{ 3332{
3333 Event *event = 0; 3333 Event *event = 0;
3334 Todo *todo = 0; 3334 Todo *todo = 0;
3335 3335
3336 if (incidence == 0) { 3336 if (incidence == 0) {
3337 incidence = mViewManager->currentView()->selectedIncidences().first(); 3337 incidence = mViewManager->currentView()->selectedIncidences().first();
3338 if (incidence == 0) { 3338 if (incidence == 0) {
3339 incidence = mTodoList->selectedIncidences().first(); 3339 incidence = mTodoList->selectedIncidences().first();
3340 } 3340 }
3341 } 3341 }
3342 if ( incidence && incidence->type() == "Event" ) { 3342 if ( incidence && incidence->type() == "Event" ) {
3343 event = static_cast<Event *>(incidence); 3343 event = static_cast<Event *>(incidence);
3344 } 3344 }
3345 if ( incidence && incidence->type() == "Todo" ) { 3345 if ( incidence && incidence->type() == "Todo" ) {
3346 todo = static_cast<Todo *>(incidence); 3346 todo = static_cast<Todo *>(incidence);
3347 } 3347 }
3348 3348
3349 if (!event && !todo) { 3349 if (!event && !todo) {
3350 KMessageBox::sorry(this,i18n("No event selected.")); 3350 KMessageBox::sorry(this,i18n("No event selected."));
3351 return; 3351 return;
3352 } 3352 }
3353 3353
3354 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3354 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3355 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3355 KMessageBox::sorry(this,i18n("The event has no attendees."));
3356 return; 3356 return;
3357 } 3357 }
3358 3358
3359 Event *ev = 0; 3359 Event *ev = 0;
3360 if (event) ev = new Event(*event); 3360 if (event) ev = new Event(*event);
3361 Todo *to = 0; 3361 Todo *to = 0;
3362 if (todo) to = new Todo(*todo); 3362 if (todo) to = new Todo(*todo);
3363 3363
3364 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3364 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3365 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3365 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3366 if (!me) { 3366 if (!me) {
3367 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3367 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3368 return; 3368 return;
3369 } 3369 }
3370 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3370 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3371 StatusDialog *statdlg = new StatusDialog(this); 3371 StatusDialog *statdlg = new StatusDialog(this);
3372 if (!statdlg->exec()==QDialog::Accepted) return; 3372 if (!statdlg->exec()==QDialog::Accepted) return;
3373 me->setStatus( statdlg->status() ); 3373 me->setStatus( statdlg->status() );
3374 delete(statdlg); 3374 delete(statdlg);
3375 } 3375 }
3376 Attendee *menew = new Attendee(*me); 3376 Attendee *menew = new Attendee(*me);
3377 if (ev) { 3377 if (ev) {
3378 ev->clearAttendees(); 3378 ev->clearAttendees();
3379 ev->addAttendee(menew,false); 3379 ev->addAttendee(menew,false);
3380 } else { 3380 } else {
3381 if (to) { 3381 if (to) {
3382 todo->clearAttendees(); 3382 todo->clearAttendees();
3383 todo->addAttendee(menew,false); 3383 todo->addAttendee(menew,false);
3384 } 3384 }
3385 } 3385 }
3386 } 3386 }
3387 3387
3388 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3388 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3389 if (ev) { 3389 if (ev) {
3390 if ( !dlg->addMessage(ev,method) ) delete(ev); 3390 if ( !dlg->addMessage(ev,method) ) delete(ev);
3391 } else { 3391 } else {
3392 if (to) { 3392 if (to) {
3393 if ( !dlg->addMessage(to,method) ) delete(to); 3393 if ( !dlg->addMessage(to,method) ) delete(to);
3394 } 3394 }
3395 } 3395 }
3396} 3396}
3397 3397
3398void CalendarView::openAddressbook() 3398void CalendarView::openAddressbook()
3399{ 3399{
3400 KRun::runCommand("kaddressbook"); 3400 KRun::runCommand("kaddressbook");
3401} 3401}
3402 3402
3403void CalendarView::setModified(bool modified) 3403void CalendarView::setModified(bool modified)
3404{ 3404{
3405 if ( modified ) 3405 if ( modified )
3406 emit signalmodified(); 3406 emit signalmodified();
3407 if (mModified != modified) { 3407 if (mModified != modified) {
3408 mModified = modified; 3408 mModified = modified;
3409 emit modifiedChanged(mModified); 3409 emit modifiedChanged(mModified);
3410 } 3410 }
3411} 3411}
3412 3412
3413bool CalendarView::isReadOnly() 3413bool CalendarView::isReadOnly()
3414{ 3414{
3415 return mReadOnly; 3415 return mReadOnly;
3416} 3416}
3417 3417
3418void CalendarView::setReadOnly(bool readOnly) 3418void CalendarView::setReadOnly(bool readOnly)
3419{ 3419{
3420 if (mReadOnly != readOnly) { 3420 if (mReadOnly != readOnly) {
3421 mReadOnly = readOnly; 3421 mReadOnly = readOnly;
3422 emit readOnlyChanged(mReadOnly); 3422 emit readOnlyChanged(mReadOnly);
3423 } 3423 }
3424} 3424}
3425 3425
3426bool CalendarView::isModified() 3426bool CalendarView::isModified()
3427{ 3427{
3428 return mModified; 3428 return mModified;
3429} 3429}
3430 3430
3431void CalendarView::printSetup() 3431void CalendarView::printSetup()
3432{ 3432{
3433#ifndef KORG_NOPRINTER 3433#ifndef KORG_NOPRINTER
3434 createPrinter(); 3434 createPrinter();
3435 3435
3436 mCalPrinter->setupPrinter(); 3436 mCalPrinter->setupPrinter();
3437#endif 3437#endif
3438} 3438}
3439 3439
3440void CalendarView::print() 3440void CalendarView::print()
3441{ 3441{
3442#ifndef KORG_NOPRINTER 3442#ifndef KORG_NOPRINTER
3443 createPrinter(); 3443 createPrinter();
3444 3444
3445 DateList tmpDateList = mNavigator->selectedDates(); 3445 DateList tmpDateList = mNavigator->selectedDates();
3446 mCalPrinter->print(CalPrinter::Month, 3446 mCalPrinter->print(CalPrinter::Month,
3447 tmpDateList.first(), tmpDateList.last()); 3447 tmpDateList.first(), tmpDateList.last());
3448#endif 3448#endif
3449} 3449}
3450 3450
3451void CalendarView::printPreview() 3451void CalendarView::printPreview()
3452{ 3452{
3453#ifndef KORG_NOPRINTER 3453#ifndef KORG_NOPRINTER
3454 kdDebug() << "CalendarView::printPreview()" << endl; 3454 kdDebug() << "CalendarView::printPreview()" << endl;
3455 3455
3456 createPrinter(); 3456 createPrinter();
3457 3457
3458 DateList tmpDateList = mNavigator->selectedDates(); 3458 DateList tmpDateList = mNavigator->selectedDates();
3459 3459
3460 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3460 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3461 tmpDateList.last()); 3461 tmpDateList.last());
3462#endif 3462#endif
3463} 3463}
3464 3464
3465void CalendarView::exportICalendar() 3465void CalendarView::exportICalendar()
3466{ 3466{
3467 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3467 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3468 3468
3469 // Force correct extension 3469 // Force correct extension
3470 if (filename.right(4) != ".ics") filename += ".ics"; 3470 if (filename.right(4) != ".ics") filename += ".ics";
3471 3471
3472 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3472 FileStorage storage( mCalendar, filename, new ICalFormat() );
3473 storage.save(); 3473 storage.save();
3474} 3474}
3475 3475
3476bool CalendarView::exportVCalendar( QString filename ) 3476bool CalendarView::exportVCalendar( QString filename )
3477{ 3477{
3478 if (mCalendar->journals().count() > 0) { 3478 if (mCalendar->journals().count() > 0) {
3479 int result = KMessageBox::warningContinueCancel(this, 3479 int result = KMessageBox::warningContinueCancel(this,
3480 i18n("The journal entries can not be\nexported to a vCalendar file."), 3480 i18n("The journal entries can not be\nexported to a vCalendar file."),
3481 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3481 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3482 true); 3482 true);
3483 if (result != KMessageBox::Continue) return false; 3483 if (result != KMessageBox::Continue) return false;
3484 } 3484 }
3485 3485
3486 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3486 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3487 3487
3488 // Force correct extension 3488 // Force correct extension
3489 if (filename.right(4) != ".vcs") filename += ".vcs"; 3489 if (filename.right(4) != ".vcs") filename += ".vcs";
3490 3490
3491 FileStorage storage( mCalendar, filename, new VCalFormat ); 3491 FileStorage storage( mCalendar, filename, new VCalFormat );
3492 return storage.save(); 3492 return storage.save();
3493 3493
3494} 3494}
3495 3495
3496void CalendarView::eventUpdated(Incidence *) 3496void CalendarView::eventUpdated(Incidence *)
3497{ 3497{
3498 setModified(); 3498 setModified();
3499 // Don't call updateView here. The code, which has caused the update of the 3499 // Don't call updateView here. The code, which has caused the update of the
3500 // event is responsible for updating the view. 3500 // event is responsible for updating the view.
3501 // updateView(); 3501 // updateView();
3502} 3502}
3503 3503
3504void CalendarView::adaptNavigationUnits() 3504void CalendarView::adaptNavigationUnits()
3505{ 3505{
3506 if (mViewManager->currentView()->isEventView()) { 3506 if (mViewManager->currentView()->isEventView()) {
3507 int days = mViewManager->currentView()->currentDateCount(); 3507 int days = mViewManager->currentView()->currentDateCount();
3508 if (days == 1) { 3508 if (days == 1) {
3509 emit changeNavStringPrev(i18n("&Previous Day")); 3509 emit changeNavStringPrev(i18n("&Previous Day"));
3510 emit changeNavStringNext(i18n("&Next Day")); 3510 emit changeNavStringNext(i18n("&Next Day"));
3511 } else { 3511 } else {
3512 emit changeNavStringPrev(i18n("&Previous Week")); 3512 emit changeNavStringPrev(i18n("&Previous Week"));
3513 emit changeNavStringNext(i18n("&Next Week")); 3513 emit changeNavStringNext(i18n("&Next Week"));
3514 } 3514 }
3515 } 3515 }
3516} 3516}
3517 3517
3518void CalendarView::processMainViewSelection( Incidence *incidence ) 3518void CalendarView::processMainViewSelection( Incidence *incidence )
3519{ 3519{
3520 if ( incidence ) mTodoList->clearSelection(); 3520 if ( incidence ) mTodoList->clearSelection();
3521 processIncidenceSelection( incidence ); 3521 processIncidenceSelection( incidence );
3522} 3522}
3523 3523
3524void CalendarView::processTodoListSelection( Incidence *incidence ) 3524void CalendarView::processTodoListSelection( Incidence *incidence )
3525{ 3525{
3526 if ( incidence && mViewManager->currentView() ) { 3526 if ( incidence && mViewManager->currentView() ) {
3527 mViewManager->currentView()->clearSelection(); 3527 mViewManager->currentView()->clearSelection();
3528 } 3528 }
3529 processIncidenceSelection( incidence ); 3529 processIncidenceSelection( incidence );
3530} 3530}
3531 3531
3532void CalendarView::processIncidenceSelection( Incidence *incidence ) 3532void CalendarView::processIncidenceSelection( Incidence *incidence )
3533{ 3533{
3534 if ( incidence == mSelectedIncidence ) return; 3534 if ( incidence == mSelectedIncidence ) return;
3535 3535
3536 mSelectedIncidence = incidence; 3536 mSelectedIncidence = incidence;
3537 3537
3538 emit incidenceSelected( mSelectedIncidence ); 3538 emit incidenceSelected( mSelectedIncidence );
3539 3539
3540 if ( incidence && incidence->type() == "Event" ) { 3540 if ( incidence && incidence->type() == "Event" ) {
3541 Event *event = static_cast<Event *>( incidence ); 3541 Event *event = static_cast<Event *>( incidence );
3542 if ( event->organizer() == KOPrefs::instance()->email() ) { 3542 if ( event->organizer() == KOPrefs::instance()->email() ) {
3543 emit organizerEventsSelected( true ); 3543 emit organizerEventsSelected( true );
3544 } else { 3544 } else {
3545 emit organizerEventsSelected(false); 3545 emit organizerEventsSelected(false);
3546 } 3546 }
3547 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3547 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3548 KOPrefs::instance()->email() ) ) { 3548 KOPrefs::instance()->email() ) ) {
3549 emit groupEventsSelected( true ); 3549 emit groupEventsSelected( true );
3550 } else { 3550 } else {
3551 emit groupEventsSelected(false); 3551 emit groupEventsSelected(false);
3552 } 3552 }
3553 return; 3553 return;
3554 } else { 3554 } else {
3555 if ( incidence && incidence->type() == "Todo" ) { 3555 if ( incidence && incidence->type() == "Todo" ) {
3556 emit todoSelected( true ); 3556 emit todoSelected( true );
3557 Todo *event = static_cast<Todo *>( incidence ); 3557 Todo *event = static_cast<Todo *>( incidence );
3558 if ( event->organizer() == KOPrefs::instance()->email() ) { 3558 if ( event->organizer() == KOPrefs::instance()->email() ) {
3559 emit organizerEventsSelected( true ); 3559 emit organizerEventsSelected( true );
3560 } else { 3560 } else {
3561 emit organizerEventsSelected(false); 3561 emit organizerEventsSelected(false);
3562 } 3562 }
3563 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3563 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3564 KOPrefs::instance()->email() ) ) { 3564 KOPrefs::instance()->email() ) ) {
3565 emit groupEventsSelected( true ); 3565 emit groupEventsSelected( true );
3566 } else { 3566 } else {
3567 emit groupEventsSelected(false); 3567 emit groupEventsSelected(false);
3568 } 3568 }
3569 return; 3569 return;
3570 } else { 3570 } else {
3571 emit todoSelected( false ); 3571 emit todoSelected( false );
3572 emit organizerEventsSelected(false); 3572 emit organizerEventsSelected(false);
3573 emit groupEventsSelected(false); 3573 emit groupEventsSelected(false);
3574 } 3574 }
3575 return; 3575 return;
3576 } 3576 }
3577 3577
3578 /* if ( incidence && incidence->type() == "Todo" ) { 3578 /* if ( incidence && incidence->type() == "Todo" ) {
3579 emit todoSelected( true ); 3579 emit todoSelected( true );
3580 } else { 3580 } else {
3581 emit todoSelected( false ); 3581 emit todoSelected( false );
3582 }*/ 3582 }*/
3583} 3583}
3584 3584
3585 3585
3586void CalendarView::checkClipboard() 3586void CalendarView::checkClipboard()
3587{ 3587{
3588#ifndef KORG_NODND 3588#ifndef KORG_NODND
3589 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3589 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3590 emit pasteEnabled(true); 3590 emit pasteEnabled(true);
3591 } else { 3591 } else {
3592 emit pasteEnabled(false); 3592 emit pasteEnabled(false);
3593 } 3593 }
3594#endif 3594#endif
3595} 3595}
3596 3596
3597void CalendarView::showDates(const DateList &selectedDates) 3597void CalendarView::showDates(const DateList &selectedDates)
3598{ 3598{
3599 // kdDebug() << "CalendarView::selectDates()" << endl; 3599 // kdDebug() << "CalendarView::selectDates()" << endl;
3600 3600
3601 3601
3602 if ( !mBlockShowDates ) { 3602 if ( !mBlockShowDates ) {
3603 if ( mViewManager->currentView() ) { 3603 if ( mViewManager->currentView() ) {
3604 updateView( selectedDates.first(), selectedDates.last() ); 3604 updateView( selectedDates.first(), selectedDates.last() );
3605 } else { 3605 } else {
3606 mViewManager->showAgendaView(); 3606 mViewManager->showAgendaView();
3607 } 3607 }
3608 } 3608 }
3609 3609
3610 QDate date = selectedDates.first(); 3610 QDate date = selectedDates.first();
3611 if ( ! date.isValid() ) { 3611 if ( ! date.isValid() ) {
3612 topLevelWidget()->setCaption(""); 3612 topLevelWidget()->setCaption("");
3613 return; 3613 return;
3614 } 3614 }
3615 3615
3616 QString selDates; 3616 QString selDates;
3617 selDates = KGlobal::locale()->formatDate( date, true); 3617 selDates = KGlobal::locale()->formatDate( date, true);
3618 if (selectedDates.first() < selectedDates.last() ) 3618 if (selectedDates.first() < selectedDates.last() )
3619 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3619 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3620 else { 3620 else {
3621 QString addString; 3621 QString addString;
3622 if ( date == QDateTime::currentDateTime().date() ) 3622 if ( date == QDateTime::currentDateTime().date() )
3623 addString = i18n("Today"); 3623 addString = i18n("Today");
3624 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3624 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3625 addString = i18n("Tomorrow"); 3625 addString = i18n("Tomorrow");
3626 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3626 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3627 addString = i18n("Yesterday"); 3627 addString = i18n("Yesterday");
3628 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3628 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3629 addString = i18n("Day before yesterday"); 3629 addString = i18n("Day before yesterday");
3630 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3630 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3631 addString = i18n("Day after tomorrow"); 3631 addString = i18n("Day after tomorrow");
3632 if ( !addString.isEmpty() ) { 3632 if ( !addString.isEmpty() ) {
3633 topLevelWidget()->setCaption( addString+", " + selDates ); 3633 topLevelWidget()->setCaption( addString+", " + selDates );
3634 return; 3634 return;
3635 } 3635 }
3636 } 3636 }
3637 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3637 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3638 3638
3639} 3639}
3640 3640
3641QPtrList<CalFilter> CalendarView::filters() 3641QPtrList<CalFilter> CalendarView::filters()
3642{ 3642{
3643 return mFilters; 3643 return mFilters;
3644 3644
3645} 3645}
3646void CalendarView::editFilters() 3646void CalendarView::editFilters()
3647{ 3647{
3648 // kdDebug() << "CalendarView::editFilters()" << endl; 3648 // kdDebug() << "CalendarView::editFilters()" << endl;
3649 3649
3650 CalFilter *filter = mFilters.first(); 3650 CalFilter *filter = mFilters.first();
3651 while(filter) { 3651 while(filter) {
3652 kdDebug() << " Filter: " << filter->name() << endl; 3652 kdDebug() << " Filter: " << filter->name() << endl;
3653 filter = mFilters.next(); 3653 filter = mFilters.next();
3654 } 3654 }
3655 3655
3656 mDialogManager->showFilterEditDialog(&mFilters); 3656 mDialogManager->showFilterEditDialog(&mFilters);
3657} 3657}
3658void CalendarView::toggleFilter() 3658void CalendarView::toggleFilter()
3659{ 3659{
3660 showFilter(! mFilterView->isVisible()); 3660 showFilter(! mFilterView->isVisible());
3661} 3661}
3662 3662
3663KOFilterView *CalendarView::filterView() 3663KOFilterView *CalendarView::filterView()
3664{ 3664{
3665 return mFilterView; 3665 return mFilterView;
3666} 3666}
3667void CalendarView::selectFilter( int fil ) 3667void CalendarView::selectFilter( int fil )
3668{ 3668{
3669 mFilterView->setSelectedFilter( fil ); 3669 mFilterView->setSelectedFilter( fil );
3670} 3670}
3671void CalendarView::showFilter(bool visible) 3671void CalendarView::showFilter(bool visible)
3672{ 3672{
3673 if (visible) mFilterView->show(); 3673 if (visible) mFilterView->show();
3674 else mFilterView->hide(); 3674 else mFilterView->hide();
3675} 3675}
3676void CalendarView::toggleFilerEnabled( ) 3676void CalendarView::toggleFilerEnabled( )
3677{ 3677{
3678 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3678 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3679 if ( !mFilterView->filtersEnabled() ) 3679 if ( !mFilterView->filtersEnabled() )
3680 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3680 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3681 3681
3682} 3682}
3683void CalendarView::updateFilter() 3683void CalendarView::updateFilter()
3684{ 3684{
3685 CalFilter *filter = mFilterView->selectedFilter(); 3685 CalFilter *filter = mFilterView->selectedFilter();
3686 if (filter) { 3686 if (filter) {
3687 QString mess; 3687 QString mess;
3688 if (mFilterView->filtersEnabled()) { 3688 if (mFilterView->filtersEnabled()) {
3689 mess = i18n("Filter selected: ")+filter->name(); 3689 mess = i18n("Filter selected: ")+filter->name();
3690 filter->setEnabled(true); 3690 filter->setEnabled(true);
3691 } 3691 }
3692 else filter->setEnabled(false); 3692 else filter->setEnabled(false);
3693 mCalendar->setFilter(filter); 3693 mCalendar->setFilter(filter);
3694 updateView(); 3694 updateView();
3695 if ( !mess.isEmpty() ) 3695 if ( !mess.isEmpty() )
3696 topLevelWidget()->setCaption( mess ); 3696 topLevelWidget()->setCaption( mess );
3697 3697
3698 } 3698 }
3699} 3699}
3700 3700
3701void CalendarView::filterEdited() 3701void CalendarView::filterEdited()
3702{ 3702{
3703 mFilterView->updateFilters(); 3703 mFilterView->updateFilters();
3704 updateFilter(); 3704 updateFilter();
3705 writeSettings(); 3705 writeSettings();
3706} 3706}
3707 3707
3708 3708
3709void CalendarView::takeOverEvent() 3709void CalendarView::takeOverEvent()
3710{ 3710{
3711 Incidence *incidence = currentSelection(); 3711 Incidence *incidence = currentSelection();
3712 3712
3713 if (!incidence) return; 3713 if (!incidence) return;
3714 3714
3715 incidence->setOrganizer(KOPrefs::instance()->email()); 3715 incidence->setOrganizer(KOPrefs::instance()->email());
3716 incidence->recreate(); 3716 incidence->recreate();
3717 incidence->setReadOnly(false); 3717 incidence->setReadOnly(false);
3718 3718
3719 updateView(); 3719 updateView();
3720} 3720}
3721 3721
3722void CalendarView::takeOverCalendar() 3722void CalendarView::takeOverCalendar()
3723{ 3723{
3724 // TODO: Create Calendar::allIncidences() function and use it here 3724 // TODO: Create Calendar::allIncidences() function and use it here
3725 3725
3726 QPtrList<Event> events = mCalendar->events(); 3726 QPtrList<Event> events = mCalendar->events();
3727 for(uint i=0; i<events.count(); ++i) { 3727 for(uint i=0; i<events.count(); ++i) {
3728 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3728 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3729 events.at(i)->recreate(); 3729 events.at(i)->recreate();
3730 events.at(i)->setReadOnly(false); 3730 events.at(i)->setReadOnly(false);
3731 } 3731 }
3732 3732
3733 QPtrList<Todo> todos = mCalendar->todos(); 3733 QPtrList<Todo> todos = mCalendar->todos();
3734 for(uint i=0; i<todos.count(); ++i) { 3734 for(uint i=0; i<todos.count(); ++i) {
3735 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3735 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3736 todos.at(i)->recreate(); 3736 todos.at(i)->recreate();
3737 todos.at(i)->setReadOnly(false); 3737 todos.at(i)->setReadOnly(false);
3738 } 3738 }
3739 3739
3740 QPtrList<Journal> journals = mCalendar->journals(); 3740 QPtrList<Journal> journals = mCalendar->journals();
3741 for(uint i=0; i<journals.count(); ++i) { 3741 for(uint i=0; i<journals.count(); ++i) {
3742 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3742 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3743 journals.at(i)->recreate(); 3743 journals.at(i)->recreate();
3744 journals.at(i)->setReadOnly(false); 3744 journals.at(i)->setReadOnly(false);
3745 } 3745 }
3746 3746
3747 updateView(); 3747 updateView();
3748} 3748}
3749 3749
3750void CalendarView::showIntro() 3750void CalendarView::showIntro()
3751{ 3751{
3752 kdDebug() << "To be implemented." << endl; 3752 kdDebug() << "To be implemented." << endl;
3753} 3753}
3754 3754
3755QWidgetStack *CalendarView::viewStack() 3755QWidgetStack *CalendarView::viewStack()
3756{ 3756{
3757 return mRightFrame; 3757 return mRightFrame;
3758} 3758}
3759 3759
3760QWidget *CalendarView::leftFrame() 3760QWidget *CalendarView::leftFrame()
3761{ 3761{
3762 return ( QWidget *)mLeftFrame; 3762 return ( QWidget *)mLeftFrame;
3763} 3763}
3764 3764
3765DateNavigator *CalendarView::dateNavigator() 3765DateNavigator *CalendarView::dateNavigator()
3766{ 3766{
3767 return mNavigator; 3767 return mNavigator;
3768} 3768}
3769 3769
3770KDateNavigator* CalendarView::dateNavigatorWidget() 3770KDateNavigator* CalendarView::dateNavigatorWidget()
3771{ 3771{
3772 return mDateNavigator->navigatorView(); 3772 return mDateNavigator->navigatorView();
3773} 3773}
3774void CalendarView::toggleDateNavigatorWidget() 3774void CalendarView::toggleDateNavigatorWidget()
3775{ 3775{
3776 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3776 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3777 3777
3778 if (!KOPrefs::instance()->mShowDateNavigator ) 3778 if (!KOPrefs::instance()->mShowDateNavigator )
3779 mDateNavigator->hide(); 3779 mDateNavigator->hide();
3780 else 3780 else
3781 mDateNavigator->show(); 3781 mDateNavigator->show();
3782} 3782}
3783void CalendarView::addView(KOrg::BaseView *view) 3783void CalendarView::addView(KOrg::BaseView *view)
3784{ 3784{
3785 mViewManager->addView(view); 3785 mViewManager->addView(view);
3786} 3786}
3787 3787
3788void CalendarView::showView(KOrg::BaseView *view) 3788void CalendarView::showView(KOrg::BaseView *view)
3789{ 3789{
3790 mViewManager->showView(view, mLeftFrame->isVisible()); 3790 mViewManager->showView(view, mLeftFrame->isVisible());
3791} 3791}
3792 3792
3793Incidence *CalendarView::currentSelection() 3793Incidence *CalendarView::currentSelection()
3794{ 3794{
3795 return mViewManager->currentSelection(); 3795 return mViewManager->currentSelection();
3796} 3796}
3797void CalendarView::toggleAllDaySize() 3797void CalendarView::toggleAllDaySize()
3798{ 3798{
3799 /* 3799 /*
3800 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3800 if ( KOPrefs::instance()->mAllDaySize > 47 )
3801 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3801 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3802 else 3802 else
3803 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3803 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3804 */ 3804 */
3805 viewManager()->agendaView()->toggleAllDay(); 3805 viewManager()->agendaView()->toggleAllDay();
3806} 3806}
3807void CalendarView::toggleExpand() 3807void CalendarView::toggleExpand()
3808{ 3808{
3809 // if ( mLeftFrame->isHidden() ) { 3809 // if ( mLeftFrame->isHidden() ) {
3810 // mLeftFrame->show(); 3810 // mLeftFrame->show();
3811 // emit calendarViewExpanded( false ); 3811 // emit calendarViewExpanded( false );
3812 // } else { 3812 // } else {
3813 // mLeftFrame->hide(); 3813 // mLeftFrame->hide();
3814 // emit calendarViewExpanded( true ); 3814 // emit calendarViewExpanded( true );
3815 // } 3815 // }
3816 //qDebug(" CalendarView::toggleExpand()"); 3816 //qDebug(" CalendarView::toggleExpand()");
3817 globalFlagBlockAgenda = 1; 3817 globalFlagBlockAgenda = 1;
3818 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3818 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3819 globalFlagBlockAgenda = 5; 3819 globalFlagBlockAgenda = 5;
3820 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3820 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3821 //mViewManager->showView( 0, true ); 3821 //mViewManager->showView( 0, true );
3822} 3822}
3823 3823
3824void CalendarView::calendarModified( bool modified, Calendar * ) 3824void CalendarView::calendarModified( bool modified, Calendar * )
3825{ 3825{
3826 setModified( modified ); 3826 setModified( modified );
3827} 3827}
3828 3828
3829Todo *CalendarView::selectedTodo() 3829Todo *CalendarView::selectedTodo()
3830{ 3830{
3831 Incidence *incidence = currentSelection(); 3831 Incidence *incidence = currentSelection();
3832 if ( incidence && incidence->type() == "Todo" ) { 3832 if ( incidence && incidence->type() == "Todo" ) {
3833 return static_cast<Todo *>( incidence ); 3833 return static_cast<Todo *>( incidence );
3834 } 3834 }
3835 3835
3836 incidence = mTodoList->selectedIncidences().first(); 3836 incidence = mTodoList->selectedIncidences().first();
3837 if ( incidence && incidence->type() == "Todo" ) { 3837 if ( incidence && incidence->type() == "Todo" ) {
3838 return static_cast<Todo *>( incidence ); 3838 return static_cast<Todo *>( incidence );
3839 } 3839 }
3840 3840
3841 return 0; 3841 return 0;
3842} 3842}
3843 3843
3844void CalendarView::dialogClosing(Incidence *in) 3844void CalendarView::dialogClosing(Incidence *in)
3845{ 3845{
3846 // mDialogList.remove(in); 3846 // mDialogList.remove(in);
3847} 3847}
3848 3848
3849void CalendarView::showIncidence() 3849void CalendarView::showIncidence()
3850{ 3850{
3851 mViewerCallerIsSearchDialog = false; 3851 mViewerCallerIsSearchDialog = false;
3852 Incidence *incidence = currentSelection(); 3852 Incidence *incidence = currentSelection();
3853 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3853 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3854 if ( incidence ) { 3854 if ( incidence ) {
3855 ShowIncidenceVisitor v; 3855 ShowIncidenceVisitor v;
3856 v.act( incidence, this ); 3856 v.act( incidence, this );
3857 } 3857 }
3858} 3858}
3859void CalendarView::editIncidenceDescription() 3859void CalendarView::editIncidenceDescription()
3860{ 3860{
3861 mFlagEditDescription = true; 3861 mFlagEditDescription = true;
3862 editIncidence(); 3862 editIncidence();
3863 mFlagEditDescription = false; 3863 mFlagEditDescription = false;
3864} 3864}
3865void CalendarView::editIncidence() 3865void CalendarView::editIncidence()
3866{ 3866{
3867 // qDebug("editIncidence() "); 3867 // qDebug("editIncidence() ");
3868 Incidence *incidence = currentSelection(); 3868 Incidence *incidence = currentSelection();
3869 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3869 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3870 if ( incidence ) { 3870 if ( incidence ) {
3871 EditIncidenceVisitor v; 3871 EditIncidenceVisitor v;
3872 v.act( incidence, this ); 3872 v.act( incidence, this );
3873 } 3873 }
3874} 3874}
3875 3875
3876void CalendarView::deleteIncidence() 3876void CalendarView::deleteIncidence()
3877{ 3877{
3878 Incidence *incidence = currentSelection(); 3878 Incidence *incidence = currentSelection();
3879 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3879 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3880 if ( incidence ) { 3880 if ( incidence ) {
3881 deleteIncidence(incidence); 3881 deleteIncidence(incidence);
3882 } 3882 }
3883} 3883}
3884 3884
3885void CalendarView::showIncidence(Incidence *incidence) 3885void CalendarView::showIncidence(Incidence *incidence)
3886{ 3886{
3887 mViewerCallerIsSearchDialog = false; 3887 mViewerCallerIsSearchDialog = false;
3888 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3888 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3889 if ( sender() && mDialogManager->getSearchDialog() ) { 3889 if ( sender() && mDialogManager->getSearchDialog() ) {
3890 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3890 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3891 mViewerCallerIsSearchDialog = true; 3891 mViewerCallerIsSearchDialog = true;
3892 } 3892 }
3893 } 3893 }
3894 if ( incidence ) { 3894 if ( incidence ) {
3895 ShowIncidenceVisitor v; 3895 ShowIncidenceVisitor v;
3896 v.act( incidence, this ); 3896 v.act( incidence, this );
3897 } 3897 }
3898} 3898}
3899 3899
3900void CalendarView::editIncidence(Incidence *incidence) 3900void CalendarView::editIncidence(Incidence *incidence)
3901{ 3901{
3902 if ( incidence ) { 3902 if ( incidence ) {
3903 3903
3904 EditIncidenceVisitor v; 3904 EditIncidenceVisitor v;
3905 v.act( incidence, this ); 3905 v.act( incidence, this );
3906 3906
3907 } 3907 }
3908} 3908}
3909 3909
3910void CalendarView::deleteIncidence(Incidence *incidence) 3910void CalendarView::deleteIncidence(Incidence *incidence)
3911{ 3911{
3912 //qDebug(" CalendarView::deleteIncidence "); 3912 //qDebug(" CalendarView::deleteIncidence ");
3913 if ( incidence ) { 3913 if ( incidence ) {
3914 DeleteIncidenceVisitor v; 3914 DeleteIncidenceVisitor v;
3915 v.act( incidence, this ); 3915 v.act( incidence, this );
3916 } 3916 }
3917} 3917}
3918 3918
3919 3919
3920void CalendarView::lookForOutgoingMessages() 3920void CalendarView::lookForOutgoingMessages()
3921{ 3921{
3922 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3922 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3923 ogd->loadMessages(); 3923 ogd->loadMessages();
3924} 3924}
3925 3925
3926void CalendarView::lookForIncomingMessages() 3926void CalendarView::lookForIncomingMessages()
3927{ 3927{
3928 IncomingDialog *icd = mDialogManager->incomingDialog(); 3928 IncomingDialog *icd = mDialogManager->incomingDialog();
3929 icd->retrieve(); 3929 icd->retrieve();
3930} 3930}
3931 3931
3932bool CalendarView::removeCompletedSubTodos( Todo* t ) 3932bool CalendarView::removeCompletedSubTodos( Todo* t )
3933{ 3933{
3934 bool deleteTodo = true; 3934 bool deleteTodo = true;
3935 QPtrList<Incidence> subTodos; 3935 QPtrList<Incidence> subTodos;
3936 Incidence *aTodo; 3936 Incidence *aTodo;
3937 subTodos = t->relations(); 3937 subTodos = t->relations();
3938 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3938 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3939 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3939 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3940 deleteTodo = false; 3940 deleteTodo = false;
3941 } 3941 }
3942 if ( deleteTodo ) { 3942 if ( deleteTodo ) {
3943 if ( t->isCompleted() && !t->doesRecur()) { 3943 if ( t->isCompleted() && !t->doesRecur()) {
3944 checkExternalId( t ); 3944 checkExternalId( t );
3945 mCalendar->deleteTodo( t ); 3945 mCalendar->deleteTodo( t );
3946 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3946 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3947 } 3947 }
3948 else 3948 else
3949 deleteTodo = false; 3949 deleteTodo = false;
3950 } 3950 }
3951 return deleteTodo; 3951 return deleteTodo;
3952 3952
3953} 3953}
3954void CalendarView::purgeCompleted() 3954void CalendarView::purgeCompleted()
3955{ 3955{
3956 int result = KMessageBox::warningContinueCancel(this, 3956 int result = KMessageBox::warningContinueCancel(this,
3957 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3957 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3958 3958
3959 if (result == KMessageBox::Continue) { 3959 if (result == KMessageBox::Continue) {
3960 3960
3961 QPtrList<Todo> todoCal; 3961 QPtrList<Todo> todoCal;
3962 QPtrList<Todo> rootTodos; 3962 QPtrList<Todo> rootTodos;
3963 //QPtrList<Incidence> rel; 3963 //QPtrList<Incidence> rel;
3964 Todo *aTodo;//, *rTodo; 3964 Todo *aTodo;//, *rTodo;
3965 Incidence *rIncidence; 3965 Incidence *rIncidence;
3966 bool childDelete = false; 3966 bool childDelete = false;
3967 bool deletedOne = true; 3967 bool deletedOne = true;
3968 todoCal = calendar()->todos(); 3968 todoCal = calendar()->todos();
3969 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3969 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3970 if ( !aTodo->relatedTo() ) 3970 if ( !aTodo->relatedTo() )
3971 rootTodos.append( aTodo ); 3971 rootTodos.append( aTodo );
3972 } 3972 }
3973 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3973 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3974 removeCompletedSubTodos( aTodo ); 3974 removeCompletedSubTodos( aTodo );
3975 } 3975 }
3976 3976
3977 updateView(); 3977 updateView();
3978 } 3978 }
3979} 3979}
3980 3980
3981void CalendarView::slotCalendarChanged() 3981void CalendarView::slotCalendarChanged()
3982{ 3982{
3983 ; 3983 ;
3984} 3984}
3985 3985
3986void CalendarView::keyPressEvent ( QKeyEvent *e) 3986void CalendarView::keyPressEvent ( QKeyEvent *e)
3987{ 3987{
3988 //qDebug(" alendarView::keyPressEvent "); 3988 //qDebug(" alendarView::keyPressEvent ");
3989 e->ignore(); 3989 e->ignore();
3990} 3990}
3991 3991
3992 3992
3993bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3993bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3994{ 3994{
3995 // mSyncManager = manager; 3995 // mSyncManager = manager;
3996 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3996 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3997 qDebug("KO: SyncKDE request detected!"); 3997 qDebug("KO: SyncKDE request detected!");
3998 } 3998 }
3999 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3999 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4000 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4000 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4001 return syncCalendar( filename, mode ); 4001 return syncCalendar( filename, mode );
4002} 4002}
4003bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4003bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4004{ 4004{
4005 //mSyncManager = manager; 4005 //mSyncManager = manager;
4006 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4006 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4007 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4007 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4008 if ( resource == "sharp" ) 4008 if ( resource == "sharp" )
4009 syncExternal( 0 ); 4009 syncExternal( 0 );
4010 if ( resource == "phone" ) 4010 if ( resource == "phone" )
4011 syncExternal( 1 ); 4011 syncExternal( 1 );
4012 // pending setmodified 4012 // pending setmodified
4013 return true; 4013 return true;
4014} 4014}
4015void CalendarView::setSyncManager(KSyncManager* manager) 4015void CalendarView::setSyncManager(KSyncManager* manager)
4016{ 4016{
4017 mSyncManager = manager; 4017 mSyncManager = manager;
4018} 4018}
4019 4019
4020void CalendarView::removeSyncInfo( QString syncProfile) 4020void CalendarView::removeSyncInfo( QString syncProfile)
4021{ 4021{
4022 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4022 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4023 mCalendar->removeSyncInfo( syncProfile ); 4023 mCalendar->removeSyncInfo( syncProfile );
4024 4024
4025} 4025}
4026 4026
4027void CalendarView::undo_delete() 4027void CalendarView::undo_delete()
4028{ 4028{
4029 //qDebug("undo_delete() "); 4029 //qDebug("undo_delete() ");
4030 Incidence* undo = mCalendar->undoIncidence(); 4030 Incidence* undo = mCalendar->undoIncidence();
4031 if ( !undo ) { 4031 if ( !undo ) {
4032 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4032 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4033 i18n("KO/Pi")); 4033 i18n("KO/Pi"));
4034 return; 4034 return;
4035 } 4035 }
4036 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4036 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4037 i18n("\nAre you sure you want\nto restore this?"), 4037 i18n("\nAre you sure you want\nto restore this?"),
4038 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4038 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4039 mCalendar->undoDeleteIncidence(); 4039 mCalendar->undoDeleteIncidence();
4040 updateView(); 4040 updateView();
4041 } 4041 }
4042} 4042}
4043 4043
4044void CalendarView::slotViewerClosed() 4044void CalendarView::slotViewerClosed()
4045{ 4045{
4046 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4046 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4047} 4047}
4048 4048
4049void CalendarView::resetFocus() 4049void CalendarView::resetFocus()
4050{ 4050{
4051 if ( mViewerCallerIsSearchDialog ) { 4051 if ( mViewerCallerIsSearchDialog ) {
4052 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4052 if ( mDialogManager->getSearchDialog()->isVisible() ){
4053 mDialogManager->getSearchDialog()->raise(); 4053 mDialogManager->getSearchDialog()->raise();
4054 mDialogManager->getSearchDialog()->setActiveWindow(); 4054 mDialogManager->getSearchDialog()->setActiveWindow();
4055 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4055 mDialogManager->getSearchDialog()->listview()->resetFocus();
4056 } else 4056 } else
4057 mViewerCallerIsSearchDialog = false; 4057 mViewerCallerIsSearchDialog = false;
4058 } 4058 }
4059 if ( !mViewerCallerIsSearchDialog ) { 4059 if ( !mViewerCallerIsSearchDialog ) {
4060 //mViewManager->currentView()->setFocus(); 4060 //mViewManager->currentView()->setFocus();
4061 //qDebug("sssssssssssssssset focus "); 4061 //qDebug("sssssssssssssssset focus ");
4062 topLevelWidget()->raise(); 4062 topLevelWidget()->raise();
4063 setActiveWindow(); 4063 setActiveWindow();
4064 //setFocus(); 4064 //setFocus();
4065 } 4065 }
4066 mViewerCallerIsSearchDialog = false; 4066 mViewerCallerIsSearchDialog = false;
4067} 4067}
4068 4068
4069void CalendarView::showNextAlarms() 4069void CalendarView::showNextAlarms()
4070{ 4070{
4071 QString message; 4071 QString message;
4072 if ( mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4072 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4073 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4073 QString sum = mCalendar->nextSummary(); 4074 QString sum = mCalendar->nextSummary();
4074 QDateTime nextA = mNextAlarmDateTime; 4075 QDateTime nextA = mNextAlarmDateTime;
4075 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4076 QDateTime cur = QDateTime::currentDateTime();
4076 message = i18n("The next alarm is on:\n%1\nat: %2\n\n%3\n(%4)").arg( KGlobal::locale()->formatDate(nextA.date() , false)).arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4077 int secs = cur.secsTo( nextA );
4078 int min = secs /60;
4079 int hours = min /60;
4080 min = min % 60;
4081 int days = hours /24;
4082 hours = hours % 24;
4083
4084 message = i18n("The next alarm is in:\n");
4085 if ( days > 1 )
4086 message += i18n("%1 days\n").arg( days );
4087 else if ( days == 1 )
4088 message += i18n("1 day\n");
4089 if ( hours > 1 )
4090 message += i18n("%1 hours\n").arg( hours );
4091 else if ( hours == 1 )
4092 message += i18n("1 hour\n");
4093 if ( min > 1 )
4094 message += i18n("%1 minutes\n").arg( min );
4095 else if ( min == 1 )
4096 message += i18n("1 minute\n");
4097
4098 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4077 } else { 4099 } else {
4078 message = i18n("There is no next alarm."); 4100 message = i18n("There is no next alarm.");
4079 4101
4080 } 4102 }
4081 KMessageBox::information( this, message); 4103 KMessageBox::information( this, message);
4082} 4104}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 18f242c..f6f390b 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1593 +1,1590 @@
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 mRows = rows; 84 mRows = rows;
85 85
86 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
87 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
88 88
89 enableClipper(true); 89 enableClipper(true);
90 90
91 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
92 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
93 93
94 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
95 95
96 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
97} 97}
98 98
99void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
100{ 100{
101 mCellHeight = height; 101 mCellHeight = height;
102} 102}
103 103
104/* 104/*
105 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
106 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
107*/ 107*/
108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
109{ 109{
110 110
111 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
112 // return; 112 // return;
113 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
114 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
115 // code assumes the latter... 115 // code assumes the latter...
116 116
117 // now, for a workaround... 117 // now, for a workaround...
118 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
119 cx = contentsX() + 2; 119 cx = contentsX() + 2;
120 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
121 // end of workaround 121 // end of workaround
122 122
123 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
124 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
125 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
126 QString hour; 126 QString hour;
127 QString suffix; 127 QString suffix;
128 QString fullTime;
129 int tW = fm.width("24:00i"); 128 int tW = fm.width("24:00i");
130 int timeHeight = fm.height(); 129 int timeHeight = fm.height();
131 //timeHeight -= (timeHeight/4-2); 130 //timeHeight -= (timeHeight/4-2);
132 int borderWidth = 0; 131 int borderWidth = 0;
133 QFont nFont = p->font(); 132 QFont nFont = p->font();
134 133
135 if (!KGlobal::locale()->use12Clock()) 134 if (!KGlobal::locale()->use12Clock())
136 suffix = "00"; 135 suffix = "00";
137 else 136 else
138 borderWidth = 0; 137 borderWidth = 0;
139 if ( timeHeight > mCellHeight ) { 138 if ( timeHeight > mCellHeight ) {
140 timeHeight = mCellHeight-1; 139 timeHeight = mCellHeight-1;
141 int pointS = nFont.pointSize(); 140 int pointS = nFont.pointSize();
142 while ( pointS > 4 ) { 141 while ( pointS > 4 ) {
143 nFont.setPointSize( pointS ); 142 nFont.setPointSize( pointS );
144 fm = QFontMetrics( nFont ); 143 fm = QFontMetrics( nFont );
145 if ( fm.height() < mCellHeight ) 144 if ( fm.height() < mCellHeight )
146 break; 145 break;
147 -- pointS; 146 -- pointS;
148 } 147 }
149 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
150 borderWidth = 4; 149 borderWidth = 4;
151 timeHeight = fm.height(); 150 timeHeight = fm.height();
152 } 151 }
153 timeHeight -= (timeHeight/4-2); 152 timeHeight -= (timeHeight/4-2);
154 QFont sFont = nFont; 153 QFont sFont = nFont;
155 sFont.setPointSize( sFont.pointSize()/2+2 ); 154 sFont.setPointSize( sFont.pointSize()/2+2 );
156 QFontMetrics fmS( sFont ); 155 QFontMetrics fmS( sFont );
157 int sHei = fmS.height(); 156 int sHei = fmS.height();
158 157 sHei -= (sHei/4-2);
158 int startW = this->width() - frameWidth();
159 while (y < cy + ch) { 159 while (y < cy + ch) {
160 p->drawLine(cx,y,cx+tW,y); 160 p->drawLine(cx,y,cx+tW,y);
161 hour.setNum(cell); 161 hour.setNum(cell);
162 162
163 // handle 24h and am/pm time formats 163 // handle 24h and am/pm time formats
164 if (KGlobal::locale()->use12Clock()) { 164 if (KGlobal::locale()->use12Clock()) {
165 if (cell > 11) suffix = "pm"; 165 if (cell > 11) suffix = "pm";
166 else 166 else
167 suffix = "am"; 167 suffix = "am";
168 if (cell == 0) hour.setNum(12); 168 if (cell == 0) hour.setNum(12);
169 if (cell > 12) hour.setNum(cell - 12); 169 if (cell > 12) hour.setNum(cell - 12);
170 } 170 }
171 171
172 // create string in format of "XX:XX" or "XXpm/am"
173 fullTime = hour;// + suffix;
174
175 // center and draw the time label 172 // center and draw the time label
176 int timeWidth = fm.width(fullTime+"i"); 173 int timeWidth = fm.width(hour+"i");
177 int tw2 = fm.width(suffix); 174 int tw2 = fm.width(suffix);
178 int offset = this->width() - timeWidth - tw2; 175 int offset = startW - timeWidth - tw2 ;
179 p->setFont( nFont ); 176 p->setFont( nFont );
180 p->drawText(cx - borderWidth + offset, y+ timeHeight, fullTime); 177 p->drawText(cx - borderWidth + offset, y+ timeHeight, hour);
181 p->setFont( sFont ); 178 p->setFont( sFont );
182 offset += timeWidth; 179 offset = startW - tw2-1;
183 p->drawText(cx - borderWidth + offset, y+ sHei, suffix); 180 p->drawText(cx - borderWidth + offset, y+ sHei, suffix);
184 181
185 // increment indices 182 // increment indices
186 y += mCellHeight; 183 y += mCellHeight;
187 cell++; 184 cell++;
188 } 185 }
189} 186}
190 187
191/** 188/**
192 Calculates the minimum width. 189 Calculates the minimum width.
193*/ 190*/
194int TimeLabels::minimumWidth() const 191int TimeLabels::minimumWidth() const
195{ 192{
196 return mMiniWidth; 193 return mMiniWidth;
197} 194}
198 195
199/** updates widget's internal state */ 196/** updates widget's internal state */
200void TimeLabels::updateConfig() 197void TimeLabels::updateConfig()
201{ 198{
202 // set the font 199 // set the font
203 // config->setGroup("Fonts"); 200 // config->setGroup("Fonts");
204 // QFont font = config->readFontEntry("TimeBar Font"); 201 // QFont font = config->readFontEntry("TimeBar Font");
205 setFont(KOPrefs::instance()->mTimeBarFont); 202 setFont(KOPrefs::instance()->mTimeBarFont);
206 mMiniWidth = fontMetrics().width("88:88") + 2 ; 203 QString test = "88:88";
204 if (KGlobal::locale()->use12Clock())
205 test += "i";
206 mMiniWidth = fontMetrics().width(test) + frameWidth()*2 +1 ;
207 // update geometry restrictions based on new settings 207 // update geometry restrictions based on new settings
208 setFixedWidth(minimumWidth()); 208 setFixedWidth(minimumWidth());
209 209
210 // update HourSize 210 // update HourSize
211 mCellHeight = KOPrefs::instance()->mHourSize*4; 211 mCellHeight = KOPrefs::instance()->mHourSize*4;
212 resizeContents(50,mRows * mCellHeight); 212 resizeContents(50,mRows * mCellHeight);
213} 213}
214 214
215/** update time label positions */ 215/** update time label positions */
216void TimeLabels::positionChanged() 216void TimeLabels::positionChanged()
217{ 217{
218 int adjustment = mAgenda->contentsY(); 218 int adjustment = mAgenda->contentsY();
219 setContentsPos(0, adjustment); 219 setContentsPos(0, adjustment);
220} 220}
221 221
222/** */ 222/** */
223void TimeLabels::setAgenda(KOAgenda* agenda) 223void TimeLabels::setAgenda(KOAgenda* agenda)
224{ 224{
225 mAgenda = agenda; 225 mAgenda = agenda;
226} 226}
227 227
228void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 228void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
229{ 229{
230 mMouseDownY = e->pos().y(); 230 mMouseDownY = e->pos().y();
231 mOrgCap = topLevelWidget()->caption(); 231 mOrgCap = topLevelWidget()->caption();
232} 232}
233 233
234void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 234void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
235{ 235{
236 int diff = mMouseDownY - e->pos().y(); 236 int diff = mMouseDownY - e->pos().y();
237 if ( diff < 10 && diff > -10 ) 237 if ( diff < 10 && diff > -10 )
238 return; 238 return;
239 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 239 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
240 if ( tSize < 4 ) 240 if ( tSize < 4 )
241 tSize = 4; 241 tSize = 4;
242 if ( tSize > 22 ) 242 if ( tSize > 22 )
243 tSize = 22; 243 tSize = 22;
244 tSize = (tSize-2)/2; 244 tSize = (tSize-2)/2;
245 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 245 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
246 246
247} 247}
248void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 248void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
249{ 249{
250 topLevelWidget()->setCaption( mOrgCap ); 250 topLevelWidget()->setCaption( mOrgCap );
251 int diff = mMouseDownY - e->pos().y(); 251 int diff = mMouseDownY - e->pos().y();
252 if ( diff < 10 && diff > -10 ) 252 if ( diff < 10 && diff > -10 )
253 return; 253 return;
254 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 254 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
255 if ( tSize < 4 ) 255 if ( tSize < 4 )
256 tSize = 4; 256 tSize = 4;
257 if ( tSize > 22 ) 257 if ( tSize > 22 )
258 tSize = 22; 258 tSize = 22;
259 tSize = (tSize/2)*2; 259 tSize = (tSize/2)*2;
260 if ( tSize == KOPrefs::instance()->mHourSize ) 260 if ( tSize == KOPrefs::instance()->mHourSize )
261 return; 261 return;
262 KOPrefs::instance()->mHourSize = tSize; 262 KOPrefs::instance()->mHourSize = tSize;
263 emit scaleChanged(); 263 emit scaleChanged();
264} 264}
265 265
266/** This is called in response to repaint() */ 266/** This is called in response to repaint() */
267void TimeLabels::paintEvent(QPaintEvent*) 267void TimeLabels::paintEvent(QPaintEvent*)
268{ 268{
269 269
270 // kdDebug() << "paintevent..." << endl; 270 // kdDebug() << "paintevent..." << endl;
271 // this is another hack! 271 // this is another hack!
272 // QPainter painter(this); 272 // QPainter painter(this);
273 //QString c 273 //QString c
274 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 274 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
275} 275}
276 276
277//////////////////////////////////////////////////////////////////////////// 277////////////////////////////////////////////////////////////////////////////
278 278
279EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 279EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
280 : QFrame(parent,name) 280 : QFrame(parent,name)
281{ 281{
282 mColumns = 1; 282 mColumns = 1;
283 mTopBox = 0; 283 mTopBox = 0;
284 mLocation = loc; 284 mLocation = loc;
285 mTopLayout = 0; 285 mTopLayout = 0;
286 mPaintWidget = 0; 286 mPaintWidget = 0;
287 mXOffset = 0; 287 mXOffset = 0;
288 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 288 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
289 else mPixmap = SmallIcon("1downarrow"); 289 else mPixmap = SmallIcon("1downarrow");
290 mEnabled.resize(mColumns); 290 mEnabled.resize(mColumns);
291 mEnabled.fill( false ); 291 mEnabled.fill( false );
292 setMinimumHeight(mPixmap.height()); 292 setMinimumHeight(mPixmap.height());
293} 293}
294 294
295EventIndicator::~EventIndicator() 295EventIndicator::~EventIndicator()
296{ 296{
297} 297}
298 298
299void EventIndicator::drawContents(QPainter *p) 299void EventIndicator::drawContents(QPainter *p)
300{ 300{
301 301
302 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 302 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
303 KDGanttSplitterHandle* han = 0; 303 KDGanttSplitterHandle* han = 0;
304 if ( mPaintWidget ) 304 if ( mPaintWidget )
305 han = mPaintWidget->firstHandle(); 305 han = mPaintWidget->firstHandle();
306 if ( ! han ) { 306 if ( ! han ) {
307 int i; 307 int i;
308 for(i=0;i<mColumns;++i) { 308 for(i=0;i<mColumns;++i) {
309 if (mEnabled[i]) { 309 if (mEnabled[i]) {
310 int cellWidth = contentsRect().right()/mColumns; 310 int cellWidth = contentsRect().right()/mColumns;
311 int xOffset = KOGlobals::self()->reverseLayout() ? 311 int xOffset = KOGlobals::self()->reverseLayout() ?
312 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 312 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
313 i*cellWidth + (cellWidth -mPixmap.width()) /2; 313 i*cellWidth + (cellWidth -mPixmap.width()) /2;
314 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 314 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
315 } 315 }
316 } 316 }
317 } else { 317 } else {
318 han->repaint(); 318 han->repaint();
319 //mPaintWidget->setBackgroundColor( red ); 319 //mPaintWidget->setBackgroundColor( red );
320 320
321 QPainter pa( han ); 321 QPainter pa( han );
322 int i; 322 int i;
323 bool setColor = false; 323 bool setColor = false;
324 for(i=0;i<mColumns;++i) { 324 for(i=0;i<mColumns;++i) {
325 if (mEnabled[i]) { 325 if (mEnabled[i]) {
326 setColor = true; 326 setColor = true;
327 327
328 int cellWidth = contentsRect().right()/mColumns; 328 int cellWidth = contentsRect().right()/mColumns;
329 int xOffset = KOGlobals::self()->reverseLayout() ? 329 int xOffset = KOGlobals::self()->reverseLayout() ?
330 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 330 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
331 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 331 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
332 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 332 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
333 //qDebug("222draw pix %d ",xOffset ); 333 //qDebug("222draw pix %d ",xOffset );
334 334
335 } 335 }
336 336
337 } 337 }
338 pa.end(); 338 pa.end();
339 339
340 } 340 }
341} 341}
342 342
343void EventIndicator::setXOffset( int x ) 343void EventIndicator::setXOffset( int x )
344{ 344{
345 mXOffset = x; 345 mXOffset = x;
346} 346}
347void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 347void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
348{ 348{
349 mPaintWidget = w; 349 mPaintWidget = w;
350 setMaximumHeight(0); 350 setMaximumHeight(0);
351 setMinimumHeight(0); 351 setMinimumHeight(0);
352} 352}
353void EventIndicator::changeColumns(int columns) 353void EventIndicator::changeColumns(int columns)
354{ 354{
355 mColumns = columns; 355 mColumns = columns;
356 mEnabled.resize(mColumns); 356 mEnabled.resize(mColumns);
357 357
358 update(); 358 update();
359} 359}
360 360
361void EventIndicator::enableColumn(int column, bool enable) 361void EventIndicator::enableColumn(int column, bool enable)
362{ 362{
363 mEnabled[column] = enable; 363 mEnabled[column] = enable;
364} 364}
365 365
366 366
367//////////////////////////////////////////////////////////////////////////// 367////////////////////////////////////////////////////////////////////////////
368//////////////////////////////////////////////////////////////////////////// 368////////////////////////////////////////////////////////////////////////////
369//////////////////////////////////////////////////////////////////////////// 369////////////////////////////////////////////////////////////////////////////
370 370
371KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 371KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
372 KOEventView (cal,parent,name) 372 KOEventView (cal,parent,name)
373{ 373{
374 mBlockUpdating = true; 374 mBlockUpdating = true;
375 mStartHour = 8; 375 mStartHour = 8;
376 mSelectedDates.append(QDate::currentDate()); 376 mSelectedDates.append(QDate::currentDate());
377 377
378 mLayoutDayLabels = 0; 378 mLayoutDayLabels = 0;
379 mDayLabelsFrame = 0; 379 mDayLabelsFrame = 0;
380 mDayLabels = 0; 380 mDayLabels = 0;
381 bool isRTL = KOGlobals::self()->reverseLayout(); 381 bool isRTL = KOGlobals::self()->reverseLayout();
382 QPixmap expandPix; 382 QPixmap expandPix;
383 if ( KOPrefs::instance()->mVerticalScreen ) { 383 if ( KOPrefs::instance()->mVerticalScreen ) {
384 expandPix = SmallIcon( "1updownarrow" ); 384 expandPix = SmallIcon( "1updownarrow" );
385 } else { 385 } else {
386 expandPix = SmallIcon("1leftrightarrow" ); 386 expandPix = SmallIcon("1leftrightarrow" );
387 } 387 }
388 388
389 QBoxLayout *topLayout = new QVBoxLayout(this); 389 QBoxLayout *topLayout = new QVBoxLayout(this);
390 390
391 // Create day name labels for agenda columns 391 // Create day name labels for agenda columns
392 // Create agenda splitter 392 // Create agenda splitter
393 393
394 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 394 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
395 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 395 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
396 topLayout->addWidget( mSplitterAgenda ); 396 topLayout->addWidget( mSplitterAgenda );
397 mAllDayFrame = new QHBox(mSplitterAgenda); 397 mAllDayFrame = new QHBox(mSplitterAgenda);
398 mAllDayFrame->setFocusPolicy(NoFocus); 398 mAllDayFrame->setFocusPolicy(NoFocus);
399 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 399 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
400 agendaFrame->setFocusPolicy(NoFocus); 400 agendaFrame->setFocusPolicy(NoFocus);
401 401
402 // Create all-day agenda widget 402 // Create all-day agenda widget
403 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 403 mDummyAllDayLeft = new QVBox( mAllDayFrame );
404 404
405 mExpandButton = new QPushButton(mDummyAllDayLeft); 405 mExpandButton = new QPushButton(mDummyAllDayLeft);
406 mExpandButton->setPixmap( expandPix ); 406 mExpandButton->setPixmap( expandPix );
407 int widebut = mExpandButton->sizeHint().width()+4; 407 int widebut = mExpandButton->sizeHint().width()+4;
408 int heibut = mExpandButton->sizeHint().height()+4; 408 int heibut = mExpandButton->sizeHint().height()+4;
409 if ( heibut > widebut ) 409 if ( heibut > widebut )
410 widebut = heibut ; 410 widebut = heibut ;
411 if ( QApplication::desktop()->width() < 480 ) 411 if ( QApplication::desktop()->width() < 480 )
412 widebut = widebut*3/2; 412 widebut = widebut*3/2;
413 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 413 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
414 // QSizePolicy::Fixed ) ); 414 // QSizePolicy::Fixed ) );
415 mExpandButton->setFixedSize( widebut, widebut); 415 mExpandButton->setFixedSize( widebut, widebut);
416 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 416 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
417 mExpandButton->setFocusPolicy(NoFocus); 417 mExpandButton->setFocusPolicy(NoFocus);
418 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 418 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
419 mAllDayAgenda->setFocusPolicy(NoFocus); 419 mAllDayAgenda->setFocusPolicy(NoFocus);
420 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 420 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
421 421
422 // Create event context menu for all day agenda 422 // Create event context menu for all day agenda
423 mAllDayAgendaPopup = eventPopup(); 423 mAllDayAgendaPopup = eventPopup();
424 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 424 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
425 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 425 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
426 426
427 // Create agenda frame 427 // Create agenda frame
428 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 428 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
429 // QHBox *agendaFrame = new QHBox(splitterAgenda); 429 // QHBox *agendaFrame = new QHBox(splitterAgenda);
430 430
431 // create event indicator bars 431 // create event indicator bars
432 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 432 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
433#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
434 // FIX 434 // FIX
435 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 435 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
436#endif 436#endif
437 mDayLabelsFrame = new QHBox(agendaFrame); 437 mDayLabelsFrame = new QHBox(agendaFrame);
438 //topLayout->addWidget(mDayLabelsFrame); 438 //topLayout->addWidget(mDayLabelsFrame);
439 mDayLabels = new QFrame (mDayLabelsFrame); 439 mDayLabels = new QFrame (mDayLabelsFrame);
440 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 440 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
441 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 441 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
442 agendaLayout->addWidget(mEventIndicatorTop,1,1); 442 agendaLayout->addWidget(mEventIndicatorTop,1,1);
443 443
444 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 444 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
445 agendaFrame); 445 agendaFrame);
446 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 446 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
447 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 447 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
448 agendaLayout->addWidget(dummyAgendaRight,1,2); 448 agendaLayout->addWidget(dummyAgendaRight,1,2);
449 449
450 // Create time labels 450 // Create time labels
451 mTimeLabels = new TimeLabels(24,agendaFrame); 451 mTimeLabels = new TimeLabels(24,agendaFrame);
452 agendaLayout->addWidget(mTimeLabels,2,0); 452 agendaLayout->addWidget(mTimeLabels,2,0);
453 connect(mTimeLabels,SIGNAL( scaleChanged()), 453 connect(mTimeLabels,SIGNAL( scaleChanged()),
454 this,SLOT(updateConfig())); 454 this,SLOT(updateConfig()));
455 455
456 // Create agenda 456 // Create agenda
457 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 457 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
458 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 458 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
459 agendaLayout->setColStretch(1,1); 459 agendaLayout->setColStretch(1,1);
460 mAgenda->setFocusPolicy(NoFocus); 460 mAgenda->setFocusPolicy(NoFocus);
461 // Create event context menu for agenda 461 // Create event context menu for agenda
462 mAgendaPopup = eventPopup(); 462 mAgendaPopup = eventPopup();
463 463
464 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 464 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
465 i18n("Toggle Alarm"),mAgenda, 465 i18n("Toggle Alarm"),mAgenda,
466 SLOT(popupAlarm()),true); 466 SLOT(popupAlarm()),true);
467 467
468 468
469 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 469 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
470 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 470 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
471 471
472 // make connections between dependent widgets 472 // make connections between dependent widgets
473 mTimeLabels->setAgenda(mAgenda); 473 mTimeLabels->setAgenda(mAgenda);
474 474
475 // Update widgets to reflect user preferences 475 // Update widgets to reflect user preferences
476 // updateConfig(); 476 // updateConfig();
477 477
478 // createDayLabels(); 478 // createDayLabels();
479 479
480 // these blank widgets make the All Day Event box line up with the agenda 480 // these blank widgets make the All Day Event box line up with the agenda
481 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 481 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
482 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 482 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
483 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 483 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
484 484
485 // Scrolling 485 // Scrolling
486 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 486 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
487 mTimeLabels, SLOT(positionChanged())); 487 mTimeLabels, SLOT(positionChanged()));
488 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 488 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
489 SLOT(setContentsPos(int))); 489 SLOT(setContentsPos(int)));
490 490
491 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 491 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
492 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 492 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
493 493
494 // Create/Show/Edit/Delete Event 494 // Create/Show/Edit/Delete Event
495 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 495 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
496 SLOT(newEvent(int,int))); 496 SLOT(newEvent(int,int)));
497 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 497 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
498 SLOT(newTodo(int,int))); 498 SLOT(newTodo(int,int)));
499 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 499 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
500 SLOT(newEvent(int,int,int,int))); 500 SLOT(newEvent(int,int,int,int)));
501 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 501 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
502 SLOT(newEventAllDay(int,int))); 502 SLOT(newEventAllDay(int,int)));
503 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 503 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
504 SLOT(newTodoAllDay(int,int))); 504 SLOT(newTodoAllDay(int,int)));
505 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 505 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
506 SLOT(newEventAllDay(int,int))); 506 SLOT(newEventAllDay(int,int)));
507 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 507 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
508 SLOT(newTimeSpanSelected(int,int,int,int))); 508 SLOT(newTimeSpanSelected(int,int,int,int)));
509 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 509 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
510 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 510 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
511 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 511 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
512 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 512 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
513 513
514 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 514 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
515 SIGNAL(editIncidenceSignal(Incidence *))); 515 SIGNAL(editIncidenceSignal(Incidence *)));
516 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 516 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
517 SIGNAL(editIncidenceSignal(Incidence *))); 517 SIGNAL(editIncidenceSignal(Incidence *)));
518 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 518 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
519 SIGNAL(showIncidenceSignal(Incidence *))); 519 SIGNAL(showIncidenceSignal(Incidence *)));
520 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 520 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
521 SIGNAL(showIncidenceSignal(Incidence *))); 521 SIGNAL(showIncidenceSignal(Incidence *)));
522 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 522 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
523 SIGNAL(deleteIncidenceSignal(Incidence *))); 523 SIGNAL(deleteIncidenceSignal(Incidence *)));
524 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 524 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
525 SIGNAL(deleteIncidenceSignal(Incidence *))); 525 SIGNAL(deleteIncidenceSignal(Incidence *)));
526 526
527 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 527 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
528 SLOT(updateEventDates(KOAgendaItem *, int ))); 528 SLOT(updateEventDates(KOAgendaItem *, int )));
529 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 529 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
530 SLOT(updateEventDates(KOAgendaItem *, int))); 530 SLOT(updateEventDates(KOAgendaItem *, int)));
531 531
532 // event indicator update 532 // event indicator update
533 connect(mAgenda,SIGNAL(lowerYChanged(int)), 533 connect(mAgenda,SIGNAL(lowerYChanged(int)),
534 SLOT(updateEventIndicatorTop(int))); 534 SLOT(updateEventIndicatorTop(int)));
535 connect(mAgenda,SIGNAL(upperYChanged(int)), 535 connect(mAgenda,SIGNAL(upperYChanged(int)),
536 SLOT(updateEventIndicatorBottom(int))); 536 SLOT(updateEventIndicatorBottom(int)));
537 // drag signals 537 // drag signals
538 /* 538 /*
539 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 539 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
540 SLOT(startDrag(Event *))); 540 SLOT(startDrag(Event *)));
541 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 541 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
542 SLOT(startDrag(Event *))); 542 SLOT(startDrag(Event *)));
543 */ 543 */
544 // synchronize selections 544 // synchronize selections
545 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 545 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
546 mAllDayAgenda, SLOT( deselectItem() ) ); 546 mAllDayAgenda, SLOT( deselectItem() ) );
547 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 547 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
548 mAgenda, SLOT( deselectItem() ) ); 548 mAgenda, SLOT( deselectItem() ) );
549 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 549 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
550 SIGNAL( incidenceSelected( Incidence * ) ) ); 550 SIGNAL( incidenceSelected( Incidence * ) ) );
551 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 551 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
552 SIGNAL( incidenceSelected( Incidence * ) ) ); 552 SIGNAL( incidenceSelected( Incidence * ) ) );
553 connect( mAgenda, SIGNAL( resizedSignal() ), 553 connect( mAgenda, SIGNAL( resizedSignal() ),
554 SLOT( updateConfig( ) ) ); 554 SLOT( updateConfig( ) ) );
555 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 555 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
556 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 556 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
557 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 557 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
558 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 558 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
559 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 559 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
560 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 560 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
561 561
562 562
563} 563}
564 564
565void KOAgendaView::toggleAllDay() 565void KOAgendaView::toggleAllDay()
566{ 566{
567 if ( mSplitterAgenda->firstHandle() ) 567 if ( mSplitterAgenda->firstHandle() )
568 mSplitterAgenda->firstHandle()->toggle(); 568 mSplitterAgenda->firstHandle()->toggle();
569} 569}
570void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 570void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
571{ 571{
572 calendar()->addIncidence( inc ); 572 calendar()->addIncidence( inc );
573 573
574 if ( incOld ) { 574 if ( incOld ) {
575 if ( incOld->type() == "Todo" ) 575 if ( incOld->type() == "Todo" )
576 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 576 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
577 else 577 else
578 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 578 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
579 } 579 }
580 580
581} 581}
582 582
583KOAgendaView::~KOAgendaView() 583KOAgendaView::~KOAgendaView()
584{ 584{
585 delete mAgendaPopup; 585 delete mAgendaPopup;
586 delete mAllDayAgendaPopup; 586 delete mAllDayAgendaPopup;
587 delete KOAgendaItem::paintPix(); 587 delete KOAgendaItem::paintPix();
588 delete KOAgendaItem::paintPixSel(); 588 delete KOAgendaItem::paintPixSel();
589} 589}
590void KOAgendaView::resizeEvent( QResizeEvent* e ) 590void KOAgendaView::resizeEvent( QResizeEvent* e )
591{ 591{
592 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 592 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
593 bool uc = false; 593 bool uc = false;
594 int ow = e->oldSize().width(); 594 int ow = e->oldSize().width();
595 int oh = e->oldSize().height(); 595 int oh = e->oldSize().height();
596 int w = e->size().width(); 596 int w = e->size().width();
597 int h = e->size().height(); 597 int h = e->size().height();
598 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 598 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
599 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 599 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
600 uc = true; 600 uc = true;
601 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 601 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
602 } 602 }
603 mUpcomingWidth = e->size().width() ; 603 mUpcomingWidth = e->size().width() ;
604 if ( mBlockUpdating || uc ) { 604 if ( mBlockUpdating || uc ) {
605 mBlockUpdating = false; 605 mBlockUpdating = false;
606 //mAgenda->setMinimumSize(800 , 600 ); 606 //mAgenda->setMinimumSize(800 , 600 );
607 //qDebug("mAgenda->resize+++++++++++++++ "); 607 //qDebug("mAgenda->resize+++++++++++++++ ");
608 updateConfig(); 608 updateConfig();
609 //qDebug("KOAgendaView::Updating now possible "); 609 //qDebug("KOAgendaView::Updating now possible ");
610 } else 610 } else
611 createDayLabels(); 611 createDayLabels();
612 //qDebug("resizeEvent end "); 612 //qDebug("resizeEvent end ");
613 613
614} 614}
615void KOAgendaView::slotDaylabelClicked( int num ) 615void KOAgendaView::slotDaylabelClicked( int num )
616{ 616{
617 617
618 QDate firstDate = mSelectedDates.first(); 618 QDate firstDate = mSelectedDates.first();
619 if ( num == -1 ) 619 if ( num == -1 )
620 emit showDateView( 6, firstDate ); 620 emit showDateView( 6, firstDate );
621 else if (num >= 0 ) { 621 else if (num >= 0 ) {
622 if ( mSelectedDates.count() == 1) 622 if ( mSelectedDates.count() == 1)
623 emit showDateView( 9, firstDate.addDays( num ) ); 623 emit showDateView( 9, firstDate.addDays( num ) );
624 else 624 else
625 emit showDateView( 3, firstDate.addDays( num ) ); 625 emit showDateView( 3, firstDate.addDays( num ) );
626 } 626 }
627 else 627 else
628 showDateView( 10, firstDate.addDays(1) ); 628 showDateView( 10, firstDate.addDays(1) );
629} 629}
630 630
631KOAgendaButton* KOAgendaView::getNewDaylabel() 631KOAgendaButton* KOAgendaView::getNewDaylabel()
632{ 632{
633 633
634 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 634 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
635 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 635 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
636 mDayLabelsList.append( dayLabel ); 636 mDayLabelsList.append( dayLabel );
637 mLayoutDayLabels->addWidget(dayLabel); 637 mLayoutDayLabels->addWidget(dayLabel);
638 return dayLabel ; 638 return dayLabel ;
639} 639}
640 640
641void KOAgendaView::createDayLabels() 641void KOAgendaView::createDayLabels()
642{ 642{
643 643
644 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 644 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
645 // qDebug(" KOAgendaView::createDayLabels() blocked "); 645 // qDebug(" KOAgendaView::createDayLabels() blocked ");
646 return; 646 return;
647 647
648 } 648 }
649 int newHight; 649 int newHight;
650 650
651 // ### Before deleting and recreating we could check if mSelectedDates changed... 651 // ### Before deleting and recreating we could check if mSelectedDates changed...
652 // It would remove some flickering and gain speed (since this is called by 652 // It would remove some flickering and gain speed (since this is called by
653 // each updateView() call) 653 // each updateView() call)
654 654
655 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 655 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
656 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 656 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
657 if ( maxWid < 0 ) 657 if ( maxWid < 0 )
658 maxWid = 20; 658 maxWid = 20;
659 659
660 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 660 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
661 QFontMetrics fm ( dlf ); 661 QFontMetrics fm ( dlf );
662 int selCount = mSelectedDates.count(); 662 int selCount = mSelectedDates.count();
663 QString dayTest = "Mon 20"; 663 QString dayTest = "Mon 20";
664 //QString dayTest = "Mon 20"; 664 //QString dayTest = "Mon 20";
665 int wid = fm.width( dayTest ); 665 int wid = fm.width( dayTest );
666 //maxWid -= ( selCount * 3 ); //working for QLabels 666 //maxWid -= ( selCount * 3 ); //working for QLabels
667 maxWid -= ( selCount * 3 ); //working for QPushButton 667 maxWid -= ( selCount * 3 ); //working for QPushButton
668 if ( maxWid < 0 ) 668 if ( maxWid < 0 )
669 maxWid = 20; 669 maxWid = 20;
670 int needWid = wid * selCount; 670 int needWid = wid * selCount;
671 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 671 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
672 //if ( needWid > maxWid ) 672 //if ( needWid > maxWid )
673 // qDebug("DAYLABELS TOOOOOOO BIG "); 673 // qDebug("DAYLABELS TOOOOOOO BIG ");
674 while ( needWid > maxWid ) { 674 while ( needWid > maxWid ) {
675 dayTest = dayTest.left( dayTest.length() - 1 ); 675 dayTest = dayTest.left( dayTest.length() - 1 );
676 wid = fm.width( dayTest ); 676 wid = fm.width( dayTest );
677 needWid = wid * selCount; 677 needWid = wid * selCount;
678 } 678 }
679 int maxLen = dayTest.length(); 679 int maxLen = dayTest.length();
680 int fontPoint = dlf.pointSize(); 680 int fontPoint = dlf.pointSize();
681 if ( maxLen < 2 ) { 681 if ( maxLen < 2 ) {
682 int fontPoint = dlf.pointSize(); 682 int fontPoint = dlf.pointSize();
683 while ( fontPoint > 4 ) { 683 while ( fontPoint > 4 ) {
684 --fontPoint; 684 --fontPoint;
685 dlf.setPointSize( fontPoint ); 685 dlf.setPointSize( fontPoint );
686 QFontMetrics f( dlf ); 686 QFontMetrics f( dlf );
687 wid = f.width( "30" ); 687 wid = f.width( "30" );
688 needWid = wid * selCount; 688 needWid = wid * selCount;
689 if ( needWid < maxWid ) 689 if ( needWid < maxWid )
690 break; 690 break;
691 } 691 }
692 maxLen = 2; 692 maxLen = 2;
693 } 693 }
694 //qDebug("Max len %d ", dayTest.length() ); 694 //qDebug("Max len %d ", dayTest.length() );
695 695
696 QFontMetrics tempF( dlf ); 696 QFontMetrics tempF( dlf );
697 newHight = tempF.height(); 697 newHight = tempF.height();
698 mDayLabels->setFont( dlf ); 698 mDayLabels->setFont( dlf );
699 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 699 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
700 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 700 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
701 //mLayoutDayLabels->addSpacing( 2 ); 701 //mLayoutDayLabels->addSpacing( 2 );
702 // QFont lFont = dlf; 702 // QFont lFont = dlf;
703 bool appendLabels = false; 703 bool appendLabels = false;
704 KOAgendaButton *dayLabel; 704 KOAgendaButton *dayLabel;
705 dayLabel = mDayLabelsList.first(); 705 dayLabel = mDayLabelsList.first();
706 if ( !dayLabel ) { 706 if ( !dayLabel ) {
707 appendLabels = true; 707 appendLabels = true;
708 dayLabel = getNewDaylabel(); 708 dayLabel = getNewDaylabel();
709 } 709 }
710 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 710 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
711 dayLabel->setFont( dlf ); 711 dayLabel->setFont( dlf );
712 dayLabel->setNum( -1 ); 712 dayLabel->setNum( -1 );
713 //dayLabel->setAlignment(QLabel::AlignHCenter); 713 //dayLabel->setAlignment(QLabel::AlignHCenter);
714 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 714 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
715 dayLabel->show(); 715 dayLabel->show();
716 DateList::ConstIterator dit; 716 DateList::ConstIterator dit;
717 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 717 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
718 int counter = -1; 718 int counter = -1;
719 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 719 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
720 ++counter; 720 ++counter;
721 QDate date = *dit; 721 QDate date = *dit;
722 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 722 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
723 if ( ! appendLabels ) { 723 if ( ! appendLabels ) {
724 dayLabel = mDayLabelsList.next(); 724 dayLabel = mDayLabelsList.next();
725 if ( !dayLabel ) 725 if ( !dayLabel )
726 appendLabels = true; 726 appendLabels = true;
727 } 727 }
728 if ( appendLabels ) { 728 if ( appendLabels ) {
729 dayLabel = getNewDaylabel(); 729 dayLabel = getNewDaylabel();
730 } 730 }
731 dayLabel->setMinimumWidth( 1 ); 731 dayLabel->setMinimumWidth( 1 );
732 dayLabel->setMaximumWidth( 10240 ); 732 dayLabel->setMaximumWidth( 10240 );
733 dayLabel->setFont( dlf ); 733 dayLabel->setFont( dlf );
734 dayLabel->show(); 734 dayLabel->show();
735 dayLabel->setNum( counter ); 735 dayLabel->setNum( counter );
736 QString str; 736 QString str;
737 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 737 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
738 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 738 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
739 switch ( maxLen ) { 739 switch ( maxLen ) {
740 case 2: 740 case 2:
741 str = QString::number( date.day() ); 741 str = QString::number( date.day() );
742 break; 742 break;
743 743
744 case 3: 744 case 3:
745 str = dayName.left( 1 ) +QString::number( date.day()); 745 str = dayName.left( 1 ) +QString::number( date.day());
746 746
747 break; 747 break;
748 case 4: 748 case 4:
749 str = dayName.left( 1 ) + " " +QString::number( date.day()); 749 str = dayName.left( 1 ) + " " +QString::number( date.day());
750 750
751 break; 751 break;
752 case 5: 752 case 5:
753 str = dayName.left( 2 ) + " " +QString::number( date.day()); 753 str = dayName.left( 2 ) + " " +QString::number( date.day());
754 754
755 break; 755 break;
756 case 6: 756 case 6:
757 str = dayName.left( 3 ) + " " +QString::number( date.day()); 757 str = dayName.left( 3 ) + " " +QString::number( date.day());
758 break; 758 break;
759 759
760 default: 760 default:
761 break; 761 break;
762 } 762 }
763 if ( oneday ) { 763 if ( oneday ) {
764 QString addString; 764 QString addString;
765 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 765 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
766 addString = i18n("Today"); 766 addString = i18n("Today");
767 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 767 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
768 addString = i18n("Tomorrow"); 768 addString = i18n("Tomorrow");
769 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 769 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
770 addString = i18n("Yesterday"); 770 addString = i18n("Yesterday");
771 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 771 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
772 addString = i18n("Day before yesterday"); 772 addString = i18n("Day before yesterday");
773 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 773 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
774 addString = i18n("Day after tomorrow"); 774 addString = i18n("Day after tomorrow");
775 if ( !addString.isEmpty() ) { 775 if ( !addString.isEmpty() ) {
776 str = addString+", " + str; 776 str = addString+", " + str;
777 } else { 777 } else {
778 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 778 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
779 } 779 }
780 } 780 }
781 dayLabel->setText(str); 781 dayLabel->setText(str);
782 //dayLabel->setAlignment(QLabel::AlignHCenter); 782 //dayLabel->setAlignment(QLabel::AlignHCenter);
783 if (date == QDate::currentDate()) { 783 if (date == QDate::currentDate()) {
784 QFont bFont = dlf; 784 QFont bFont = dlf;
785 bFont.setBold( true ); 785 bFont.setBold( true );
786 dayLabel->setFont(bFont); 786 dayLabel->setFont(bFont);
787 } 787 }
788 //dayLayout->addWidget(dayLabel); 788 //dayLayout->addWidget(dayLabel);
789 789
790#ifndef KORG_NOPLUGINS 790#ifndef KORG_NOPLUGINS
791 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 791 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
792 CalendarDecoration *it; 792 CalendarDecoration *it;
793 for(it = cds.first(); it; it = cds.next()) { 793 for(it = cds.first(); it; it = cds.next()) {
794 QString text = it->shortText( date ); 794 QString text = it->shortText( date );
795 if ( !text.isEmpty() ) { 795 if ( !text.isEmpty() ) {
796 QLabel *label = new QLabel(text,mDayLabels); 796 QLabel *label = new QLabel(text,mDayLabels);
797 label->setAlignment(AlignCenter); 797 label->setAlignment(AlignCenter);
798 dayLayout->addWidget(label); 798 dayLayout->addWidget(label);
799 } 799 }
800 } 800 }
801 801
802 for(it = cds.first(); it; it = cds.next()) { 802 for(it = cds.first(); it; it = cds.next()) {
803 QWidget *wid = it->smallWidget(mDayLabels,date); 803 QWidget *wid = it->smallWidget(mDayLabels,date);
804 if ( wid ) { 804 if ( wid ) {
805 // wid->setHeight(20); 805 // wid->setHeight(20);
806 dayLayout->addWidget(wid); 806 dayLayout->addWidget(wid);
807 } 807 }
808 } 808 }
809#endif 809#endif
810 } 810 }
811 if ( ! appendLabels ) { 811 if ( ! appendLabels ) {
812 dayLabel = mDayLabelsList.next(); 812 dayLabel = mDayLabelsList.next();
813 if ( !dayLabel ) 813 if ( !dayLabel )
814 appendLabels = true; 814 appendLabels = true;
815 } 815 }
816 if ( appendLabels ) { 816 if ( appendLabels ) {
817 dayLabel = getNewDaylabel(); 817 dayLabel = getNewDaylabel();
818 } 818 }
819 //dayLabel->hide();//test only 819 //dayLabel->hide();//test only
820 820
821 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 821 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
822 if ( offset < 0 ) offset = 0; 822 if ( offset < 0 ) offset = 0;
823 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 823 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
824 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 824 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
825 dayLabel->setFont( dlf ); 825 dayLabel->setFont( dlf );
826 dayLabel->show(); 826 dayLabel->show();
827 dayLabel->setNum( -2 ); 827 dayLabel->setNum( -2 );
828 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 828 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
829 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 829 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
830 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 830 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
831 if ( !appendLabels ) { 831 if ( !appendLabels ) {
832 dayLabel = mDayLabelsList.next(); 832 dayLabel = mDayLabelsList.next();
833 while ( dayLabel ) { 833 while ( dayLabel ) {
834 //qDebug("!dayLabel %d",dayLabel ); 834 //qDebug("!dayLabel %d",dayLabel );
835 dayLabel->hide(); 835 dayLabel->hide();
836 dayLabel = mDayLabelsList.next(); 836 dayLabel = mDayLabelsList.next();
837 } 837 }
838 } 838 }
839 //mDayLabelsFrame->show(); 839
840 //mDayLabels->show(); 840 mDayLabelsFrame->setFixedHeight( newHight + 4 );
841 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
842 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
843 mDayLabelsFrame->setFixedHeight( newHight );
844} 841}
845 842
846int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
847{ 844{
848 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
849 return 0; 846 return 0;
850} 847}
851 848
852int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
853{ 850{
854 return mSelectedDates.count(); 851 return mSelectedDates.count();
855} 852}
856 853
857QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
858{ 855{
859 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
860 Incidence *incidence; 857 Incidence *incidence;
861 858
862 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
864 861
865 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
866 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
867 864
868 return selected; 865 return selected;
869} 866}
870 867
871DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
872{ 869{
873 DateList selected; 870 DateList selected;
874 QDate qd; 871 QDate qd;
875 872
876 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
877 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
878 875
879 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
880 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
881 878
882 return selected; 879 return selected;
883} 880}
884 881
885 882
886void KOAgendaView::updateView() 883void KOAgendaView::updateView()
887{ 884{
888 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
889 return; 886 return;
890 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
891 fillAgenda(); 888 fillAgenda();
892 889
893} 890}
894 891
895 892
896/* 893/*
897 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
898 complete. 895 complete.
899*/ 896*/
900void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
901{ 898{
902 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
903 return; 900 return;
904 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 901 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
905 int old = KOPrefs::instance()->mHourSize; 902 int old = KOPrefs::instance()->mHourSize;
906 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 903 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
907 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 904 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
908 } 905 }
909 906
910 907
911 // update config for children 908 // update config for children
912 mTimeLabels->updateConfig(); 909 mTimeLabels->updateConfig();
913 mAgenda->storePosition(); 910 mAgenda->storePosition();
914 mAgenda->updateConfig(); 911 mAgenda->updateConfig();
915 mAllDayAgenda->updateConfig(); 912 mAllDayAgenda->updateConfig();
916 // widget synchronization 913 // widget synchronization
917 //TODO: find a better way, maybe signal/slot 914 //TODO: find a better way, maybe signal/slot
918 mTimeLabels->positionChanged(); 915 mTimeLabels->positionChanged();
919 916
920 // for some reason, this needs to be called explicitly 917 // for some reason, this needs to be called explicitly
921 mTimeLabels->repaint(); 918 mTimeLabels->repaint();
922 919
923 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 920 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
924 921
925 // ToolTips displaying summary of events 922 // ToolTips displaying summary of events
926 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 923 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
927 ->mEnableToolTips); 924 ->mEnableToolTips);
928 925
929 //setHolidayMasks(); 926 //setHolidayMasks();
930 927
931 //createDayLabels(); called by via updateView(); 928 //createDayLabels(); called by via updateView();
932 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 929 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
933 updateView(); 930 updateView();
934 mAgenda->restorePosition(); 931 mAgenda->restorePosition();
935} 932}
936 933
937 934
938void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 935void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
939{ 936{
940 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 937 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
941 //qDebug("KOAgendaView::updateEventDates "); 938 //qDebug("KOAgendaView::updateEventDates ");
942 QDateTime startDt,endDt; 939 QDateTime startDt,endDt;
943 QDate startDate; 940 QDate startDate;
944 int lenInSecs; 941 int lenInSecs;
945 // if ( type == KOAgenda::RESIZETOP ) 942 // if ( type == KOAgenda::RESIZETOP )
946 // qDebug("RESIZETOP "); 943 // qDebug("RESIZETOP ");
947 // if ( type == KOAgenda::RESIZEBOTTOM ) 944 // if ( type == KOAgenda::RESIZEBOTTOM )
948 // qDebug("RESIZEBOTTOM "); 945 // qDebug("RESIZEBOTTOM ");
949 // if ( type == KOAgenda::MOVE ) 946 // if ( type == KOAgenda::MOVE )
950 // qDebug("MOVE "); 947 // qDebug("MOVE ");
951 if ( item->incidence()->type() == "Event" ) { 948 if ( item->incidence()->type() == "Event" ) {
952 startDt =item->incidence()->dtStart(); 949 startDt =item->incidence()->dtStart();
953 endDt = item->incidence()->dtEnd(); 950 endDt = item->incidence()->dtEnd();
954 lenInSecs = startDt.secsTo( endDt ); 951 lenInSecs = startDt.secsTo( endDt );
955 } 952 }
956 953
957 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 954 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
958 955
959 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 956 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
960 startDate = mSelectedDates[item->mLastMoveXPos]; 957 startDate = mSelectedDates[item->mLastMoveXPos];
961 } else { 958 } else {
962 if (item->cellX() < 0) { 959 if (item->cellX() < 0) {
963 startDate = (mSelectedDates.first()).addDays(item->cellX()); 960 startDate = (mSelectedDates.first()).addDays(item->cellX());
964 } else { 961 } else {
965 startDate = mSelectedDates[item->cellX()]; 962 startDate = mSelectedDates[item->cellX()];
966 } 963 }
967 } 964 }
968 startDt.setDate(startDate); 965 startDt.setDate(startDate);
969 966
970 if (item->incidence()->doesFloat()) { 967 if (item->incidence()->doesFloat()) {
971 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 968 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
972 } else { 969 } else {
973 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 970 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
974 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 971 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
975 if ( item->incidence()->type() == "Event" ) { 972 if ( item->incidence()->type() == "Event" ) {
976 if ( type == KOAgenda::MOVE ) { 973 if ( type == KOAgenda::MOVE ) {
977 endDt = startDt.addSecs(lenInSecs); 974 endDt = startDt.addSecs(lenInSecs);
978 975
979 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 976 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
980 if (item->lastMultiItem()) { 977 if (item->lastMultiItem()) {
981 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 978 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
982 endDt.setDate(startDate. 979 endDt.setDate(startDate.
983 addDays(item->lastMultiItem()->cellX() - item->cellX())); 980 addDays(item->lastMultiItem()->cellX() - item->cellX()));
984 } else { 981 } else {
985 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 982 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
986 endDt.setDate(startDate); 983 endDt.setDate(startDate);
987 } 984 }
988 } 985 }
989 } else { 986 } else {
990 // todo 987 // todo
991 if (item->lastMultiItem()) { 988 if (item->lastMultiItem()) {
992 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 989 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
993 endDt.setDate(startDate. 990 endDt.setDate(startDate.
994 addDays(item->lastMultiItem()->cellX() - item->cellX())); 991 addDays(item->lastMultiItem()->cellX() - item->cellX()));
995 } else { 992 } else {
996 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 993 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
997 if ( item->cellYBottom() > 0 ) 994 if ( item->cellYBottom() > 0 )
998 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 995 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
999 else 996 else
1000 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 997 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1001 endDt.setDate(startDate); 998 endDt.setDate(startDate);
1002 } 999 }
1003 } 1000 }
1004 } 1001 }
1005 if ( item->incidence()->type() == "Event" ) { 1002 if ( item->incidence()->type() == "Event" ) {
1006 item->incidence()->setDtStart(startDt); 1003 item->incidence()->setDtStart(startDt);
1007 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1004 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1008 } else if ( item->incidence()->type() == "Todo" ) { 1005 } else if ( item->incidence()->type() == "Todo" ) {
1009 Todo* to = static_cast<Todo*>(item->incidence()); 1006 Todo* to = static_cast<Todo*>(item->incidence());
1010 1007
1011 to->setDtDue(endDt); 1008 to->setDtDue(endDt);
1012 if ( to->hasStartDate() ) { 1009 if ( to->hasStartDate() ) {
1013 if (to->dtStart() >= to->dtDue() ) 1010 if (to->dtStart() >= to->dtDue() )
1014 to->setDtStart(to->dtDue().addDays( -2 )); 1011 to->setDtStart(to->dtDue().addDays( -2 ));
1015 } 1012 }
1016 1013
1017 } 1014 }
1018 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1015 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1019 item->incidence()->setRevision(item->incidence()->revision()+1); 1016 item->incidence()->setRevision(item->incidence()->revision()+1);
1020 item->setItemDate(startDt.date()); 1017 item->setItemDate(startDt.date());
1021 //item->updateItem(); 1018 //item->updateItem();
1022 if ( item->incidence()->type() == "Todo" ) { 1019 if ( item->incidence()->type() == "Todo" ) {
1023 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1020 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1024 1021
1025 } 1022 }
1026 else 1023 else
1027 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1024 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1028 item->updateItem(); 1025 item->updateItem();
1029} 1026}
1030 1027
1031void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1028void KOAgendaView::showDates( const QDate &start, const QDate &end )
1032{ 1029{
1033 // kdDebug() << "KOAgendaView::selectDates" << endl; 1030 // kdDebug() << "KOAgendaView::selectDates" << endl;
1034 1031
1035 mSelectedDates.clear(); 1032 mSelectedDates.clear();
1036 // qDebug("KOAgendaView::showDates "); 1033 // qDebug("KOAgendaView::showDates ");
1037 QDate d = start; 1034 QDate d = start;
1038 while (d <= end) { 1035 while (d <= end) {
1039 mSelectedDates.append(d); 1036 mSelectedDates.append(d);
1040 d = d.addDays( 1 ); 1037 d = d.addDays( 1 );
1041 } 1038 }
1042 1039
1043 // and update the view 1040 // and update the view
1044 fillAgenda(); 1041 fillAgenda();
1045} 1042}
1046 1043
1047 1044
1048void KOAgendaView::showEvents(QPtrList<Event>) 1045void KOAgendaView::showEvents(QPtrList<Event>)
1049{ 1046{
1050 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1047 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1051} 1048}
1052 1049
1053void KOAgendaView::changeEventDisplay(Event *, int) 1050void KOAgendaView::changeEventDisplay(Event *, int)
1054{ 1051{
1055 // qDebug("KOAgendaView::changeEventDisplay "); 1052 // qDebug("KOAgendaView::changeEventDisplay ");
1056 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1053 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1057 // this should be re-written to be MUCH smarter. Right now we 1054 // this should be re-written to be MUCH smarter. Right now we
1058 // are just playing dumb. 1055 // are just playing dumb.
1059 fillAgenda(); 1056 fillAgenda();
1060} 1057}
1061 1058
1062void KOAgendaView::fillAgenda(const QDate &) 1059void KOAgendaView::fillAgenda(const QDate &)
1063{ 1060{
1064 // qDebug("KOAgendaView::fillAgenda "); 1061 // qDebug("KOAgendaView::fillAgenda ");
1065 fillAgenda(); 1062 fillAgenda();
1066} 1063}
1067 1064
1068void KOAgendaView::fillAgenda() 1065void KOAgendaView::fillAgenda()
1069{ 1066{
1070 if ( globalFlagBlockStartup ) 1067 if ( globalFlagBlockStartup )
1071 return; 1068 return;
1072 if ( globalFlagBlockAgenda == 1 ) 1069 if ( globalFlagBlockAgenda == 1 )
1073 return; 1070 return;
1074 //if ( globalFlagBlockAgenda == 2 ) 1071 //if ( globalFlagBlockAgenda == 2 )
1075 //globalFlagBlockAgenda = 0; 1072 //globalFlagBlockAgenda = 0;
1076 // globalFlagBlockPainting = false; 1073 // globalFlagBlockPainting = false;
1077 if ( globalFlagBlockAgenda == 0 ) 1074 if ( globalFlagBlockAgenda == 0 )
1078 globalFlagBlockAgenda = 1; 1075 globalFlagBlockAgenda = 1;
1079 // clearView(); 1076 // clearView();
1080 //qDebug("fillAgenda()++++ "); 1077 //qDebug("fillAgenda()++++ ");
1081 globalFlagBlockAgendaItemPaint = 1; 1078 globalFlagBlockAgendaItemPaint = 1;
1082 1079
1083 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1080 mAllDayAgenda->changeColumns(mSelectedDates.count());
1084 mAgenda->changeColumns(mSelectedDates.count()); 1081 mAgenda->changeColumns(mSelectedDates.count());
1085 qApp->processEvents(); 1082 qApp->processEvents();
1086 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1083 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1087 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1084 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1088 setHolidayMasks(); 1085 setHolidayMasks();
1089 1086
1090 //mAgenda->hideUnused(); 1087 //mAgenda->hideUnused();
1091 //mAllDayAgenda->hideUnused(); 1088 //mAllDayAgenda->hideUnused();
1092 1089
1093 // mAgenda->blockNextRepaint( false ); 1090 // mAgenda->blockNextRepaint( false );
1094 // mAgenda->viewport()->repaint(); 1091 // mAgenda->viewport()->repaint();
1095 // mAgenda->blockNextRepaint( true ); 1092 // mAgenda->blockNextRepaint( true );
1096 mMinY.resize(mSelectedDates.count()); 1093 mMinY.resize(mSelectedDates.count());
1097 mMaxY.resize(mSelectedDates.count()); 1094 mMaxY.resize(mSelectedDates.count());
1098 1095
1099 QPtrList<Event> dayEvents; 1096 QPtrList<Event> dayEvents;
1100 1097
1101 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1098 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1102 // Therefore, gtodoset all of them. 1099 // Therefore, gtodoset all of them.
1103 QPtrList<Todo> todos = calendar()->todos(); 1100 QPtrList<Todo> todos = calendar()->todos();
1104 1101
1105 mAgenda->setDateList(mSelectedDates); 1102 mAgenda->setDateList(mSelectedDates);
1106 1103
1107 QDate today = QDate::currentDate(); 1104 QDate today = QDate::currentDate();
1108 1105
1109 DateList::ConstIterator dit; 1106 DateList::ConstIterator dit;
1110 int curCol = 0; 1107 int curCol = 0;
1111 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1108 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1112 QDate currentDate = *dit; 1109 QDate currentDate = *dit;
1113 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1110 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1114 // << endl; 1111 // << endl;
1115 1112
1116 dayEvents = calendar()->events(currentDate,true); 1113 dayEvents = calendar()->events(currentDate,true);
1117 1114
1118 // Default values, which can never be reached 1115 // Default values, which can never be reached
1119 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1116 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1120 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1117 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1121 1118
1122 unsigned int numEvent; 1119 unsigned int numEvent;
1123 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1120 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1124 Event *event = dayEvents.at(numEvent); 1121 Event *event = dayEvents.at(numEvent);
1125 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1122 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1126 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1123 if ( event->uid().left(15) == QString("last-syncEvent-") )
1127 continue; 1124 continue;
1128 // kdDebug() << " Event: " << event->summary() << endl; 1125 // kdDebug() << " Event: " << event->summary() << endl;
1129 1126
1130 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1127 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1131 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1128 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1132 1129
1133 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1130 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1134 1131
1135 if (event->doesFloat()) { 1132 if (event->doesFloat()) {
1136 if (event->recurrence()->doesRecur()) { 1133 if (event->recurrence()->doesRecur()) {
1137 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1134 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1138 } else { 1135 } else {
1139 if (beginX <= 0 && curCol == 0) { 1136 if (beginX <= 0 && curCol == 0) {
1140 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1137 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1141 } else if (beginX == curCol) { 1138 } else if (beginX == curCol) {
1142 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1139 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1143 } 1140 }
1144 } 1141 }
1145 } else if (event->isMultiDay()) { 1142 } else if (event->isMultiDay()) {
1146 if ( event->doesRecur () ) { 1143 if ( event->doesRecur () ) {
1147 QDate dateit = currentDate; 1144 QDate dateit = currentDate;
1148 int count = 0; 1145 int count = 0;
1149 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1146 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1150 while (! event->recursOn( dateit ) && count <= max ) { 1147 while (! event->recursOn( dateit ) && count <= max ) {
1151 ++count; 1148 ++count;
1152 dateit = dateit.addDays( -1 ); 1149 dateit = dateit.addDays( -1 );
1153 } 1150 }
1154 bool ok; 1151 bool ok;
1155 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1152 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1156 if ( ok ) 1153 if ( ok )
1157 { 1154 {
1158 int secs = event->dtStart().secsTo( event->dtEnd() ); 1155 int secs = event->dtStart().secsTo( event->dtEnd() );
1159 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1156 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1160 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1157 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1161 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1158 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1162 1159
1163 } 1160 }
1164 } 1161 }
1165 int startY = mAgenda->timeToY(event->dtStart().time()); 1162 int startY = mAgenda->timeToY(event->dtStart().time());
1166 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1163 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1167 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1164 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1168 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1165 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1169 //qDebug("insert!!! "); 1166 //qDebug("insert!!! ");
1170 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1167 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1171 } 1168 }
1172 if (beginX == curCol) { 1169 if (beginX == curCol) {
1173 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1170 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1174 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1171 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1175 } else if (endX == curCol) { 1172 } else if (endX == curCol) {
1176 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1173 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1177 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1174 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1178 } else { 1175 } else {
1179 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1176 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1180 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1177 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1181 } 1178 }
1182 } else { 1179 } else {
1183 int startY = mAgenda->timeToY(event->dtStart().time()); 1180 int startY = mAgenda->timeToY(event->dtStart().time());
1184 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1181 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1185 if (endY < startY) endY = startY; 1182 if (endY < startY) endY = startY;
1186 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1183 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1187 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1188 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1189 } 1186 }
1190 } 1187 }
1191 // ---------- [display Todos -------------- 1188 // ---------- [display Todos --------------
1192 unsigned int numTodo; 1189 unsigned int numTodo;
1193 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1190 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1194 Todo *todo = todos.at(numTodo); 1191 Todo *todo = todos.at(numTodo);
1195 1192
1196 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1193 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1197 1194
1198 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1195 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1199 // Already completed items can be displayed on their original due date 1196 // Already completed items can be displayed on their original due date
1200 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1197 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1201 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1198 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1202 bool fillIn = false; 1199 bool fillIn = false;
1203 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1200 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1204 fillIn = true; 1201 fillIn = true;
1205 if ( ! fillIn && !todo->hasCompletedDate() ) 1202 if ( ! fillIn && !todo->hasCompletedDate() )
1206 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1203 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1207 if ( fillIn ) { 1204 if ( fillIn ) {
1208 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1205 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1209 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1206 if ( KOPrefs::instance()->mShowTodoInAgenda )
1210 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1207 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1211 } 1208 }
1212 else { 1209 else {
1213 QDateTime dt; 1210 QDateTime dt;
1214 if ( todo->hasCompletedDate() ) 1211 if ( todo->hasCompletedDate() )
1215 dt = todo->completed(); 1212 dt = todo->completed();
1216 else 1213 else
1217 dt = todo->dtDue();; 1214 dt = todo->dtDue();;
1218 1215
1219 1216
1220 int endY = mAgenda->timeToY(dt.time()) - 1; 1217 int endY = mAgenda->timeToY(dt.time()) - 1;
1221 int hi = (18/KOPrefs::instance()->mHourSize); 1218 int hi = (18/KOPrefs::instance()->mHourSize);
1222 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1219 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1223 int startY = endY -hi; 1220 int startY = endY -hi;
1224 1221
1225 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1222 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1226 1223
1227 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1224 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1228 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1225 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1229 } 1226 }
1230 } 1227 }
1231 } 1228 }
1232 // ---------- display Todos] -------------- 1229 // ---------- display Todos] --------------
1233 1230
1234 ++curCol; 1231 ++curCol;
1235 } 1232 }
1236 mAgenda->hideUnused(); 1233 mAgenda->hideUnused();
1237 mAllDayAgenda->hideUnused(); 1234 mAllDayAgenda->hideUnused();
1238 mAgenda->checkScrollBoundaries(); 1235 mAgenda->checkScrollBoundaries();
1239 1236
1240 deleteSelectedDateTime(); 1237 deleteSelectedDateTime();
1241 1238
1242 createDayLabels(); 1239 createDayLabels();
1243 emit incidenceSelected( 0 ); 1240 emit incidenceSelected( 0 );
1244 1241
1245 if ( globalFlagBlockAgenda == 2 ) { 1242 if ( globalFlagBlockAgenda == 2 ) {
1246 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1243 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1247 setStartHour( KOPrefs::instance()->mDayBegins ); 1244 setStartHour( KOPrefs::instance()->mDayBegins );
1248 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1245 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1249 setStartHour( QTime::currentTime ().hour() ); 1246 setStartHour( QTime::currentTime ().hour() );
1250 // qApp->processEvents(); 1247 // qApp->processEvents();
1251 } 1248 }
1252 qApp->processEvents(); 1249 qApp->processEvents();
1253 //qDebug("qApp->processEvents(); END "); 1250 //qDebug("qApp->processEvents(); END ");
1254 globalFlagBlockAgenda = 0; 1251 globalFlagBlockAgenda = 0;
1255 1252
1256 // mAgenda->hideUnused(); 1253 // mAgenda->hideUnused();
1257 //mAllDayAgenda->hideUnused(); 1254 //mAllDayAgenda->hideUnused();
1258 mAllDayAgenda->drawContentsToPainter(); 1255 mAllDayAgenda->drawContentsToPainter();
1259 mAgenda->drawContentsToPainter(); 1256 mAgenda->drawContentsToPainter();
1260 repaintAgenda(); 1257 repaintAgenda();
1261 // mAgenda->finishUpdate(); 1258 // mAgenda->finishUpdate();
1262 //mAllDayAgenda->finishUpdate(); 1259 //mAllDayAgenda->finishUpdate();
1263 1260
1264 // repaintAgenda(); 1261 // repaintAgenda();
1265 //qApp->processEvents(); 1262 //qApp->processEvents();
1266 // globalFlagBlockAgenda = 0; 1263 // globalFlagBlockAgenda = 0;
1267} 1264}
1268void KOAgendaView::repaintAgenda() 1265void KOAgendaView::repaintAgenda()
1269{ 1266{
1270 // mAllDayAgenda->drawContentsToPainter(); 1267 // mAllDayAgenda->drawContentsToPainter();
1271// mAllDayAgenda->viewport()->repaint( false ); 1268// mAllDayAgenda->viewport()->repaint( false );
1272// mAgenda->drawContentsToPainter(); 1269// mAgenda->drawContentsToPainter();
1273// mAgenda->viewport()->repaint( false ); 1270// mAgenda->viewport()->repaint( false );
1274// qApp->processEvents(); 1271// qApp->processEvents();
1275 1272
1276 //qDebug("KOAgendaView::repaintAgenda() "); 1273 //qDebug("KOAgendaView::repaintAgenda() ");
1277 //qApp->processEvents(); 1274 //qApp->processEvents();
1278 mAgenda->viewport()->repaint( false ); 1275 mAgenda->viewport()->repaint( false );
1279 mAllDayAgenda->viewport()->repaint( false ); 1276 mAllDayAgenda->viewport()->repaint( false );
1280 mAgenda->finishUpdate(); 1277 mAgenda->finishUpdate();
1281 mAllDayAgenda->finishUpdate(); 1278 mAllDayAgenda->finishUpdate();
1282} 1279}
1283 1280
1284 1281
1285void KOAgendaView::clearView() 1282void KOAgendaView::clearView()
1286{ 1283{
1287 // kdDebug() << "ClearView" << endl; 1284 // kdDebug() << "ClearView" << endl;
1288 mAllDayAgenda->clear(); 1285 mAllDayAgenda->clear();
1289 mAgenda->clear(); 1286 mAgenda->clear();
1290} 1287}
1291 1288
1292void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1289void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1293 const QDate &td) 1290 const QDate &td)
1294{ 1291{
1295#ifndef KORG_NOPRINTER 1292#ifndef KORG_NOPRINTER
1296 if (fd == td) 1293 if (fd == td)
1297 calPrinter->preview(CalPrinter::Day, fd, td); 1294 calPrinter->preview(CalPrinter::Day, fd, td);
1298 else 1295 else
1299 calPrinter->preview(CalPrinter::Week, fd, td); 1296 calPrinter->preview(CalPrinter::Week, fd, td);
1300#endif 1297#endif
1301} 1298}
1302 1299
1303// void KOAgendaView::updateMovedTodo() 1300// void KOAgendaView::updateMovedTodo()
1304// { 1301// {
1305// // updateConfig(); 1302// // updateConfig();
1306// // emit updateTodoViews(); 1303// // emit updateTodoViews();
1307// } 1304// }
1308 1305
1309void KOAgendaView::newEvent(int gx, int gy) 1306void KOAgendaView::newEvent(int gx, int gy)
1310{ 1307{
1311 if (!mSelectedDates.count()) return; 1308 if (!mSelectedDates.count()) return;
1312 1309
1313 QDate day = mSelectedDates[gx]; 1310 QDate day = mSelectedDates[gx];
1314 1311
1315 QTime time = mAgenda->gyToTime(gy); 1312 QTime time = mAgenda->gyToTime(gy);
1316 QDateTime dt(day,time); 1313 QDateTime dt(day,time);
1317 // if ( dt < QDateTime::currentDateTime () ) 1314 // if ( dt < QDateTime::currentDateTime () )
1318 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1315 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1319 emit newEventSignal(dt); 1316 emit newEventSignal(dt);
1320} 1317}
1321 1318
1322void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1319void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1323{ 1320{
1324 if (!mSelectedDates.count()) return; 1321 if (!mSelectedDates.count()) return;
1325 1322
1326 QDate dayStart = mSelectedDates[gxStart]; 1323 QDate dayStart = mSelectedDates[gxStart];
1327 QDate dayEnd = mSelectedDates[gxEnd]; 1324 QDate dayEnd = mSelectedDates[gxEnd];
1328 1325
1329 QTime timeStart = mAgenda->gyToTime(gyStart); 1326 QTime timeStart = mAgenda->gyToTime(gyStart);
1330 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1327 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1331 1328
1332 QDateTime dtStart(dayStart,timeStart); 1329 QDateTime dtStart(dayStart,timeStart);
1333 QDateTime dtEnd(dayEnd,timeEnd); 1330 QDateTime dtEnd(dayEnd,timeEnd);
1334 1331
1335 emit newEventSignal(dtStart,dtEnd); 1332 emit newEventSignal(dtStart,dtEnd);
1336} 1333}
1337 1334
1338void KOAgendaView::newEventAllDay(int gx, int ) 1335void KOAgendaView::newEventAllDay(int gx, int )
1339{ 1336{
1340 if (!mSelectedDates.count()) return; 1337 if (!mSelectedDates.count()) return;
1341 1338
1342 QDate day = mSelectedDates[gx]; 1339 QDate day = mSelectedDates[gx];
1343 1340
1344 emit newEventSignal(day); 1341 emit newEventSignal(day);
1345} 1342}
1346void KOAgendaView::newTodoAllDay(int gx, int ) 1343void KOAgendaView::newTodoAllDay(int gx, int )
1347{ 1344{
1348 if (!mSelectedDates.count()) return; 1345 if (!mSelectedDates.count()) return;
1349 1346
1350 QDateTime day (mSelectedDates[gx] ); 1347 QDateTime day (mSelectedDates[gx] );
1351 emit newTodoSignal(day, true); 1348 emit newTodoSignal(day, true);
1352} 1349}
1353void KOAgendaView::newTodo(int gx, int gy ) 1350void KOAgendaView::newTodo(int gx, int gy )
1354{ 1351{
1355 if (!mSelectedDates.count()) return; 1352 if (!mSelectedDates.count()) return;
1356 QDate dayStart = mSelectedDates[gx]; 1353 QDate dayStart = mSelectedDates[gx];
1357 QTime timeStart = mAgenda->gyToTime(gy); 1354 QTime timeStart = mAgenda->gyToTime(gy);
1358 QDateTime dt (dayStart,timeStart); 1355 QDateTime dt (dayStart,timeStart);
1359 emit newTodoSignal( dt, false ); 1356 emit newTodoSignal( dt, false );
1360} 1357}
1361 1358
1362void KOAgendaView::updateEventIndicatorTop(int newY) 1359void KOAgendaView::updateEventIndicatorTop(int newY)
1363{ 1360{
1364 uint i; 1361 uint i;
1365 for(i=0;i<mMinY.size();++i) { 1362 for(i=0;i<mMinY.size();++i) {
1366 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1363 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1367 else mEventIndicatorTop->enableColumn(i,false); 1364 else mEventIndicatorTop->enableColumn(i,false);
1368 } 1365 }
1369 1366
1370 mEventIndicatorTop->update(); 1367 mEventIndicatorTop->update();
1371} 1368}
1372 1369
1373void KOAgendaView::updateEventIndicatorBottom(int newY) 1370void KOAgendaView::updateEventIndicatorBottom(int newY)
1374{ 1371{
1375 uint i; 1372 uint i;
1376 for(i=0;i<mMaxY.size();++i) { 1373 for(i=0;i<mMaxY.size();++i) {
1377 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1374 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1378 else mEventIndicatorBottom->enableColumn(i,false); 1375 else mEventIndicatorBottom->enableColumn(i,false);
1379 } 1376 }
1380 1377
1381 mEventIndicatorBottom->update(); 1378 mEventIndicatorBottom->update();
1382} 1379}
1383 1380
1384void KOAgendaView::startDrag(Event *event) 1381void KOAgendaView::startDrag(Event *event)
1385{ 1382{
1386#ifndef KORG_NODND 1383#ifndef KORG_NODND
1387 DndFactory factory( calendar() ); 1384 DndFactory factory( calendar() );
1388 ICalDrag *vd = factory.createDrag(event,this); 1385 ICalDrag *vd = factory.createDrag(event,this);
1389 if (vd->drag()) { 1386 if (vd->drag()) {
1390 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1387 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1391 } 1388 }
1392#endif 1389#endif
1393} 1390}
1394 1391
1395void KOAgendaView::readSettings() 1392void KOAgendaView::readSettings()
1396{ 1393{
1397 readSettings(KOGlobals::config()); 1394 readSettings(KOGlobals::config());
1398} 1395}
1399 1396
1400void KOAgendaView::readSettings(KConfig *config) 1397void KOAgendaView::readSettings(KConfig *config)
1401{ 1398{
1402 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1399 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1403 1400
1404 config->setGroup("Views"); 1401 config->setGroup("Views");
1405 1402
1406 //#ifndef KORG_NOSPLITTER 1403 //#ifndef KORG_NOSPLITTER
1407 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1404 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1408 if (sizes.count() == 2) { 1405 if (sizes.count() == 2) {
1409 if ( sizes[0] < 20 ) { 1406 if ( sizes[0] < 20 ) {
1410 sizes[1] = sizes[1] +20 - sizes[0]; 1407 sizes[1] = sizes[1] +20 - sizes[0];
1411 sizes[0] = 20; 1408 sizes[0] = 20;
1412 } 1409 }
1413 mSplitterAgenda->setSizes(sizes); 1410 mSplitterAgenda->setSizes(sizes);
1414 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1411 // qDebug("read %d %d ",sizes[0],sizes[1] );
1415 } 1412 }
1416 //#endif 1413 //#endif
1417 1414
1418 // updateConfig(); 1415 // updateConfig();
1419} 1416}
1420 1417
1421void KOAgendaView::writeSettings(KConfig *config) 1418void KOAgendaView::writeSettings(KConfig *config)
1422{ 1419{
1423 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1420 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1424 1421
1425 config->setGroup("Views"); 1422 config->setGroup("Views");
1426 1423
1427 //#ifndef KORG_NOSPLITTER 1424 //#ifndef KORG_NOSPLITTER
1428 QValueList<int> list = mSplitterAgenda->sizes(); 1425 QValueList<int> list = mSplitterAgenda->sizes();
1429 config->writeEntry("Separator AgendaView",list); 1426 config->writeEntry("Separator AgendaView",list);
1430 //qDebug("write %d %d ", list[0],list[1] ); 1427 //qDebug("write %d %d ", list[0],list[1] );
1431 //#endif 1428 //#endif
1432} 1429}
1433 1430
1434void KOAgendaView::setHolidayMasks() 1431void KOAgendaView::setHolidayMasks()
1435{ 1432{
1436 mHolidayMask.resize(mSelectedDates.count()); 1433 mHolidayMask.resize(mSelectedDates.count());
1437 1434
1438 uint i; 1435 uint i;
1439 for(i=0;i<mSelectedDates.count();++i) { 1436 for(i=0;i<mSelectedDates.count();++i) {
1440 QDate date = mSelectedDates[i]; 1437 QDate date = mSelectedDates[i];
1441 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1438 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1442 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1439 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1443 bool showHoliday = false; 1440 bool showHoliday = false;
1444 if ( KOPrefs::instance()->mExcludeHolidays ) { 1441 if ( KOPrefs::instance()->mExcludeHolidays ) {
1445 QPtrList<Event> events = calendar()->events( date, true ); 1442 QPtrList<Event> events = calendar()->events( date, true );
1446 Event *event; 1443 Event *event;
1447 for( event = events.first(); event; event = events.next() ) { 1444 for( event = events.first(); event; event = events.next() ) {
1448 if ( event->isHoliday()) { 1445 if ( event->isHoliday()) {
1449 showHoliday = true; 1446 showHoliday = true;
1450 break; 1447 break;
1451 } 1448 }
1452 } 1449 }
1453 1450
1454 } 1451 }
1455 1452
1456#ifndef KORG_NOPLUGINS 1453#ifndef KORG_NOPLUGINS
1457 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1454 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1458 !KOCore::self()->holiday(date).isEmpty(); 1455 !KOCore::self()->holiday(date).isEmpty();
1459#endif 1456#endif
1460 bool showDay = showSaturday || showSunday || showHoliday; 1457 bool showDay = showSaturday || showSunday || showHoliday;
1461 1458
1462 if (showDay) { 1459 if (showDay) {
1463 mHolidayMask.at(i) = true; 1460 mHolidayMask.at(i) = true;
1464 } else { 1461 } else {
1465 mHolidayMask.at(i) = false; 1462 mHolidayMask.at(i) = false;
1466 } 1463 }
1467 } 1464 }
1468 1465
1469 mAgenda->setHolidayMask(&mHolidayMask); 1466 mAgenda->setHolidayMask(&mHolidayMask);
1470 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1467 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1471} 1468}
1472 1469
1473void KOAgendaView::setContentsPos(int y) 1470void KOAgendaView::setContentsPos(int y)
1474{ 1471{
1475 mAgenda->setContentsPos(0,y); 1472 mAgenda->setContentsPos(0,y);
1476} 1473}
1477 1474
1478void KOAgendaView::clearSelection() 1475void KOAgendaView::clearSelection()
1479{ 1476{
1480 mAgenda->deselectItem(); 1477 mAgenda->deselectItem();
1481 mAllDayAgenda->deselectItem(); 1478 mAllDayAgenda->deselectItem();
1482} 1479}
1483 1480
1484void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1481void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1485 int gxEnd, int gyEnd) 1482 int gxEnd, int gyEnd)
1486{ 1483{
1487 mTimeSpanInAllDay = true; 1484 mTimeSpanInAllDay = true;
1488 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1485 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1489} 1486}
1490 1487
1491 1488
1492 1489
1493 1490
1494void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1491void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1495 int gxEnd, int gyEnd) 1492 int gxEnd, int gyEnd)
1496{ 1493{
1497 if (!mSelectedDates.count()) return; 1494 if (!mSelectedDates.count()) return;
1498 1495
1499 QDate dayStart = mSelectedDates[gxStart]; 1496 QDate dayStart = mSelectedDates[gxStart];
1500 QDate dayEnd = mSelectedDates[gxEnd]; 1497 QDate dayEnd = mSelectedDates[gxEnd];
1501 1498
1502 QTime timeStart = mAgenda->gyToTime(gyStart); 1499 QTime timeStart = mAgenda->gyToTime(gyStart);
1503 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1500 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1504 1501
1505 QDateTime dtStart(dayStart,timeStart); 1502 QDateTime dtStart(dayStart,timeStart);
1506 QDateTime dtEnd(dayEnd,timeEnd); 1503 QDateTime dtEnd(dayEnd,timeEnd);
1507 1504
1508 mTimeSpanBegin = dtStart; 1505 mTimeSpanBegin = dtStart;
1509 mTimeSpanEnd = dtEnd; 1506 mTimeSpanEnd = dtEnd;
1510 1507
1511} 1508}
1512 1509
1513void KOAgendaView::deleteSelectedDateTime() 1510void KOAgendaView::deleteSelectedDateTime()
1514{ 1511{
1515 mTimeSpanBegin.setDate(QDate()); 1512 mTimeSpanBegin.setDate(QDate());
1516 mTimeSpanEnd.setDate(QDate()); 1513 mTimeSpanEnd.setDate(QDate());
1517 mTimeSpanInAllDay = false; 1514 mTimeSpanInAllDay = false;
1518} 1515}
1519 1516
1520void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1517void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1521{ 1518{
1522 e->ignore(); 1519 e->ignore();
1523} 1520}
1524 1521
1525void KOAgendaView::scrollOneHourUp() 1522void KOAgendaView::scrollOneHourUp()
1526{ 1523{
1527 1524
1528 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1525 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1529} 1526}
1530void KOAgendaView::scrollOneHourDown() 1527void KOAgendaView::scrollOneHourDown()
1531{ 1528{
1532 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1529 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1533} 1530}
1534 1531
1535void KOAgendaView::setStartHour( int h ) 1532void KOAgendaView::setStartHour( int h )
1536{ 1533{
1537 mAgenda->setStartHour( h ); 1534 mAgenda->setStartHour( h );
1538 1535
1539} 1536}
1540void KOAgendaView::setInitStartHour() 1537void KOAgendaView::setInitStartHour()
1541{ 1538{
1542 1539
1543 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1540 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1544 setStartHour( QTime::currentTime ().hour() ); 1541 setStartHour( QTime::currentTime ().hour() );
1545 else 1542 else
1546 setStartHour( KOPrefs::instance()->mDayBegins ); 1543 setStartHour( KOPrefs::instance()->mDayBegins );
1547 1544
1548} 1545}
1549 1546
1550 1547
1551void KOAgendaView::updateTodo( Todo * t, int ) 1548void KOAgendaView::updateTodo( Todo * t, int )
1552{ 1549{
1553 if ( !isVisible() ) 1550 if ( !isVisible() )
1554 return; 1551 return;
1555 bool remove = false; 1552 bool remove = false;
1556 bool removeAD = false; 1553 bool removeAD = false;
1557 QDate da; 1554 QDate da;
1558 if ( t->hasCompletedDate() ) 1555 if ( t->hasCompletedDate() )
1559 da = t->completed().date(); 1556 da = t->completed().date();
1560 else 1557 else
1561 da = t->dtDue().date(); 1558 da = t->dtDue().date();
1562 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1559 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1563 remove = true; 1560 remove = true;
1564 removeAD = true; 1561 removeAD = true;
1565 } 1562 }
1566 else { 1563 else {
1567 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1564 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1568 if ( overdue && 1565 if ( overdue &&
1569 QDate::currentDate() >= mSelectedDates.first() && 1566 QDate::currentDate() >= mSelectedDates.first() &&
1570 QDate::currentDate() <= mSelectedDates.last()) { 1567 QDate::currentDate() <= mSelectedDates.last()) {
1571 removeAD = false; 1568 removeAD = false;
1572 remove = true; 1569 remove = true;
1573 } 1570 }
1574 else { 1571 else {
1575 1572
1576 if ( da < mSelectedDates.first() || 1573 if ( da < mSelectedDates.first() ||
1577 da > mSelectedDates.last() ) { 1574 da > mSelectedDates.last() ) {
1578 remove = true; 1575 remove = true;
1579 removeAD = true; 1576 removeAD = true;
1580 } else { 1577 } else {
1581 remove = t->doesFloat() && !t->hasCompletedDate(); 1578 remove = t->doesFloat() && !t->hasCompletedDate();
1582 removeAD = !remove; 1579 removeAD = !remove;
1583 } 1580 }
1584 } 1581 }
1585 } 1582 }
1586 int days = mSelectedDates.first().daysTo( da ); 1583 int days = mSelectedDates.first().daysTo( da );
1587 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1584 //qDebug("daysto %d %d %d", days, remove,removeAD );
1588 mAgenda->updateTodo( t , days, remove); 1585 mAgenda->updateTodo( t , days, remove);
1589 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1586 if ( KOPrefs::instance()->mShowTodoInAgenda )
1590 mAllDayAgenda->updateTodo( t , days, removeAD); 1587 mAllDayAgenda->updateTodo( t , days, removeAD);
1591 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1588 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1592 1589
1593} 1590}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7a4275b..ca0d542 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -958,1193 +958,1197 @@ void MainWindow::initActions()
958 connect( action, SIGNAL( activated() ), 958 connect( action, SIGNAL( activated() ),
959 SLOT( keyBindings() ) ); 959 SLOT( keyBindings() ) );
960 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 960 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
961 action->addTo( helpMenu ); 961 action->addTo( helpMenu );
962 connect( action, SIGNAL( activated() ), 962 connect( action, SIGNAL( activated() ),
963 SLOT( synchowto() ) ); 963 SLOT( synchowto() ) );
964 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 964 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
965 action->addTo( helpMenu ); 965 action->addTo( helpMenu );
966 connect( action, SIGNAL( activated() ), 966 connect( action, SIGNAL( activated() ),
967 SLOT( kdesynchowto() ) ); 967 SLOT( kdesynchowto() ) );
968 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 968 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
969 action->addTo( helpMenu ); 969 action->addTo( helpMenu );
970 connect( action, SIGNAL( activated() ), 970 connect( action, SIGNAL( activated() ),
971 SLOT( multisynchowto() ) ); 971 SLOT( multisynchowto() ) );
972 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 972 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
973 action->addTo( helpMenu ); 973 action->addTo( helpMenu );
974 connect( action, SIGNAL( activated() ), 974 connect( action, SIGNAL( activated() ),
975 SLOT( aboutAutoSaving() ) ); 975 SLOT( aboutAutoSaving() ) );
976 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 976 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
977 action->addTo( helpMenu ); 977 action->addTo( helpMenu );
978 connect( action, SIGNAL( activated() ), 978 connect( action, SIGNAL( activated() ),
979 SLOT( aboutKnownBugs() ) ); 979 SLOT( aboutKnownBugs() ) );
980 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 980 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
981 action->addTo( helpMenu ); 981 action->addTo( helpMenu );
982 connect( action, SIGNAL( activated() ), 982 connect( action, SIGNAL( activated() ),
983 SLOT( usertrans() ) ); 983 SLOT( usertrans() ) );
984 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 984 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
985 action->addTo( helpMenu ); 985 action->addTo( helpMenu );
986 connect( action, SIGNAL( activated() ), 986 connect( action, SIGNAL( activated() ),
987 SLOT( faq() ) ); 987 SLOT( faq() ) );
988 action = new QAction( "licence", i18n("Licence..."), 0, this ); 988 action = new QAction( "licence", i18n("Licence..."), 0, this );
989 action->addTo( helpMenu ); 989 action->addTo( helpMenu );
990 connect( action, SIGNAL( activated() ), 990 connect( action, SIGNAL( activated() ),
991 SLOT( licence() ) ); 991 SLOT( licence() ) );
992 action = new QAction( "about", i18n("About..."), 0, this ); 992 action = new QAction( "about", i18n("About..."), 0, this );
993 action->addTo( helpMenu ); 993 action->addTo( helpMenu );
994 connect( action, SIGNAL( activated() ), 994 connect( action, SIGNAL( activated() ),
995 SLOT( about() ) ); 995 SLOT( about() ) );
996 //menuBar->insertSeparator(); 996 //menuBar->insertSeparator();
997 997
998 // ****************************************************** 998 // ******************************************************
999 // menubar icons 999 // menubar icons
1000 1000
1001 1001
1002 iconToolBar->setHorizontalStretchable (true ); 1002 iconToolBar->setHorizontalStretchable (true );
1003 //menuBar->insertItem( iconToolBar ); 1003 //menuBar->insertItem( iconToolBar );
1004 //xdays_action 1004 //xdays_action
1005 if (p-> mShowIconNewEvent) 1005 if (p-> mShowIconNewEvent)
1006 ne_action->addTo( iconToolBar ); 1006 ne_action->addTo( iconToolBar );
1007 if (p->mShowIconNewTodo ) 1007 if (p->mShowIconNewTodo )
1008 nt_action->addTo( iconToolBar ); 1008 nt_action->addTo( iconToolBar );
1009 if (p-> mShowIconSearch) 1009 if (p-> mShowIconSearch)
1010 search_action->addTo( iconToolBar ); 1010 search_action->addTo( iconToolBar );
1011 if (p-> mShowIconWhatsThis) 1011 if (p-> mShowIconWhatsThis)
1012 QWhatsThis::whatsThisButton ( iconToolBar ); 1012 QWhatsThis::whatsThisButton ( iconToolBar );
1013 if (p-> mShowIconNext) 1013 if (p-> mShowIconNext)
1014 whatsnext_action->addTo( iconToolBar ); 1014 whatsnext_action->addTo( iconToolBar );
1015 if (p-> mShowIconNextDays) 1015 if (p-> mShowIconNextDays)
1016 xdays_action->addTo( iconToolBar ); 1016 xdays_action->addTo( iconToolBar );
1017 if (p-> mShowIconJournal) 1017 if (p-> mShowIconJournal)
1018 viewjournal_action->addTo( iconToolBar ); 1018 viewjournal_action->addTo( iconToolBar );
1019 if (p-> mShowIconDay1) 1019 if (p-> mShowIconDay1)
1020 day1_action->addTo( iconToolBar ); 1020 day1_action->addTo( iconToolBar );
1021 if (p-> mShowIconDay5) 1021 if (p-> mShowIconDay5)
1022 day5_action->addTo( iconToolBar ); 1022 day5_action->addTo( iconToolBar );
1023 if (p-> mShowIconDay7) 1023 if (p-> mShowIconDay7)
1024 day7_action->addTo( iconToolBar ); 1024 day7_action->addTo( iconToolBar );
1025 if (p-> mShowIconDay6) 1025 if (p-> mShowIconDay6)
1026 day6_action->addTo( iconToolBar ); 1026 day6_action->addTo( iconToolBar );
1027 if (p-> mShowIconMonth) 1027 if (p-> mShowIconMonth)
1028 month_action->addTo( iconToolBar ); 1028 month_action->addTo( iconToolBar );
1029 if (p-> mShowIconList) 1029 if (p-> mShowIconList)
1030 showlist_action->addTo( iconToolBar ); 1030 showlist_action->addTo( iconToolBar );
1031 if (p-> mShowIconTodoview) 1031 if (p-> mShowIconTodoview)
1032 todoview_action->addTo( iconToolBar ); 1032 todoview_action->addTo( iconToolBar );
1033 1033
1034 icon = loadPixmap( pathString + "2leftarrowB" ); 1034 icon = loadPixmap( pathString + "2leftarrowB" );
1035 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1035 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1036 if (p-> mShowIconBackFast) { 1036 if (p-> mShowIconBackFast) {
1037 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1037 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1038 connect( action, SIGNAL( activated() ), 1038 connect( action, SIGNAL( activated() ),
1039 mView, SLOT( goPreviousMonth() ) ); 1039 mView, SLOT( goPreviousMonth() ) );
1040 action->addTo( iconToolBar ); 1040 action->addTo( iconToolBar );
1041 } 1041 }
1042 icon = loadPixmap( pathString + "1leftarrowB" ); 1042 icon = loadPixmap( pathString + "1leftarrowB" );
1043 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1043 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1044 if (p-> mShowIconBack) { 1044 if (p-> mShowIconBack) {
1045 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1045 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1046 connect( action, SIGNAL( activated() ), 1046 connect( action, SIGNAL( activated() ),
1047 mView, SLOT( goPrevious() ) ); 1047 mView, SLOT( goPrevious() ) );
1048 action->addTo( iconToolBar ); 1048 action->addTo( iconToolBar );
1049 } 1049 }
1050 icon = loadPixmap( pathString + "today" ); 1050 icon = loadPixmap( pathString + "today" );
1051 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1051 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1052 if (p-> mShowIconToday) 1052 if (p-> mShowIconToday)
1053 today_action->addTo( iconToolBar ); 1053 today_action->addTo( iconToolBar );
1054 icon = loadPixmap( pathString + "1rightarrowB" ); 1054 icon = loadPixmap( pathString + "1rightarrowB" );
1055 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1055 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1056 if (p-> mShowIconForward) { 1056 if (p-> mShowIconForward) {
1057 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1057 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1058 connect( action, SIGNAL( activated() ), 1058 connect( action, SIGNAL( activated() ),
1059 mView, SLOT( goNext() ) ); 1059 mView, SLOT( goNext() ) );
1060 action->addTo( iconToolBar ); 1060 action->addTo( iconToolBar );
1061 } 1061 }
1062 icon = loadPixmap( pathString + "2rightarrowB" ); 1062 icon = loadPixmap( pathString + "2rightarrowB" );
1063 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1063 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1064 if (p-> mShowIconForwardFast) { 1064 if (p-> mShowIconForwardFast) {
1065 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1065 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1066 connect( action, SIGNAL( activated() ), 1066 connect( action, SIGNAL( activated() ),
1067 mView, SLOT( goNextMonth() ) ); 1067 mView, SLOT( goNextMonth() ) );
1068 action->addTo( iconToolBar ); 1068 action->addTo( iconToolBar );
1069 } 1069 }
1070 1070
1071 1071
1072 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1072 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1073 1073
1074 if (p-> mShowIconNewEvent) 1074 if (p-> mShowIconNewEvent)
1075 configureToolBarMenu->setItemChecked( 10, true ); 1075 configureToolBarMenu->setItemChecked( 10, true );
1076 if (p->mShowIconNewTodo ) 1076 if (p->mShowIconNewTodo )
1077 configureToolBarMenu->setItemChecked( 20, true ); 1077 configureToolBarMenu->setItemChecked( 20, true );
1078 if (p-> mShowIconSearch) 1078 if (p-> mShowIconSearch)
1079 configureToolBarMenu->setItemChecked( 120, true ); 1079 configureToolBarMenu->setItemChecked( 120, true );
1080 if (p-> mShowIconList) 1080 if (p-> mShowIconList)
1081 configureToolBarMenu->setItemChecked( 30, true ); 1081 configureToolBarMenu->setItemChecked( 30, true );
1082 if (p-> mShowIconDay1) 1082 if (p-> mShowIconDay1)
1083 configureToolBarMenu->setItemChecked( 40, true ); 1083 configureToolBarMenu->setItemChecked( 40, true );
1084 if (p-> mShowIconDay5) 1084 if (p-> mShowIconDay5)
1085 configureToolBarMenu->setItemChecked( 50, true ); 1085 configureToolBarMenu->setItemChecked( 50, true );
1086 if (p-> mShowIconDay6) 1086 if (p-> mShowIconDay6)
1087 configureToolBarMenu->setItemChecked( 75, true ); 1087 configureToolBarMenu->setItemChecked( 75, true );
1088 if (p-> mShowIconDay7) 1088 if (p-> mShowIconDay7)
1089 configureToolBarMenu->setItemChecked( 60, true ); 1089 configureToolBarMenu->setItemChecked( 60, true );
1090 if (p-> mShowIconMonth) 1090 if (p-> mShowIconMonth)
1091 configureToolBarMenu->setItemChecked( 70, true ); 1091 configureToolBarMenu->setItemChecked( 70, true );
1092 if (p-> mShowIconTodoview) 1092 if (p-> mShowIconTodoview)
1093 configureToolBarMenu->setItemChecked( 80, true ); 1093 configureToolBarMenu->setItemChecked( 80, true );
1094 if (p-> mShowIconBackFast) 1094 if (p-> mShowIconBackFast)
1095 configureToolBarMenu->setItemChecked( 200, true ); 1095 configureToolBarMenu->setItemChecked( 200, true );
1096 if (p-> mShowIconBack) 1096 if (p-> mShowIconBack)
1097 configureToolBarMenu->setItemChecked( 210, true ); 1097 configureToolBarMenu->setItemChecked( 210, true );
1098 if (p-> mShowIconToday) 1098 if (p-> mShowIconToday)
1099 configureToolBarMenu->setItemChecked( 130, true ); 1099 configureToolBarMenu->setItemChecked( 130, true );
1100 if (p-> mShowIconForward) 1100 if (p-> mShowIconForward)
1101 configureToolBarMenu->setItemChecked( 220, true ); 1101 configureToolBarMenu->setItemChecked( 220, true );
1102 if (p-> mShowIconForwardFast) 1102 if (p-> mShowIconForwardFast)
1103 configureToolBarMenu->setItemChecked( 230, true ); 1103 configureToolBarMenu->setItemChecked( 230, true );
1104 if (p-> mShowIconNextDays) 1104 if (p-> mShowIconNextDays)
1105 configureToolBarMenu->setItemChecked( 100, true ); 1105 configureToolBarMenu->setItemChecked( 100, true );
1106 if (p-> mShowIconNext) 1106 if (p-> mShowIconNext)
1107 configureToolBarMenu->setItemChecked( 110, true ); 1107 configureToolBarMenu->setItemChecked( 110, true );
1108 if (p-> mShowIconJournal) 1108 if (p-> mShowIconJournal)
1109 configureToolBarMenu->setItemChecked( 90, true ); 1109 configureToolBarMenu->setItemChecked( 90, true );
1110 if (p-> mShowIconWhatsThis) 1110 if (p-> mShowIconWhatsThis)
1111 configureToolBarMenu->setItemChecked( 300, true ); 1111 configureToolBarMenu->setItemChecked( 300, true );
1112 if (p-> mShowIconWeekNum) 1112 if (p-> mShowIconWeekNum)
1113 configureToolBarMenu->setItemChecked( 400, true ); 1113 configureToolBarMenu->setItemChecked( 400, true );
1114 QLabel* dummy = new QLabel( iconToolBar ); 1114 QLabel* dummy = new QLabel( iconToolBar );
1115 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1115 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1116 if (!p-> mShowIconStretch) 1116 if (!p-> mShowIconStretch)
1117 iconToolBar->setStretchableWidget ( dummy ) ; 1117 iconToolBar->setStretchableWidget ( dummy ) ;
1118 else 1118 else
1119 configureToolBarMenu->setItemChecked( 5, true ); 1119 configureToolBarMenu->setItemChecked( 5, true );
1120 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1120 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1121 configureAgenda( p->mHourSize ); 1121 configureAgenda( p->mHourSize );
1122 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1122 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1123} 1123}
1124 1124
1125void MainWindow::exportToPhone( int mode ) 1125void MainWindow::exportToPhone( int mode )
1126{ 1126{
1127 1127
1128 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1128 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1129 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1129 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1130 KOex2phonePrefs ex2phone; 1130 KOex2phonePrefs ex2phone;
1131 1131
1132 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1132 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1133 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1133 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1134 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1134 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1135 if ( mode == 1 ) 1135 if ( mode == 1 )
1136 ex2phone.setCaption(i18n("Export complete calendar")); 1136 ex2phone.setCaption(i18n("Export complete calendar"));
1137 if ( mode == 2 ) 1137 if ( mode == 2 )
1138 ex2phone.setCaption(i18n("Export filtered calendar")); 1138 ex2phone.setCaption(i18n("Export filtered calendar"));
1139 1139
1140 if ( !ex2phone.exec() ) { 1140 if ( !ex2phone.exec() ) {
1141 return; 1141 return;
1142 } 1142 }
1143 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1143 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1144 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1144 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1145 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1145 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1146 1146
1147 int inFuture = 0; 1147 int inFuture = 0;
1148 if ( ex2phone.mWriteBackFuture->isChecked() ) 1148 if ( ex2phone.mWriteBackFuture->isChecked() )
1149 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1149 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1150 QPtrList<Incidence> delSel; 1150 QPtrList<Incidence> delSel;
1151 if ( mode == 1 ) 1151 if ( mode == 1 )
1152 delSel = mCalendar->rawIncidences(); 1152 delSel = mCalendar->rawIncidences();
1153 if ( mode == 2 ) 1153 if ( mode == 2 )
1154 delSel = mCalendar->incidences(); 1154 delSel = mCalendar->incidences();
1155 CalendarLocal* cal = new CalendarLocal(); 1155 CalendarLocal* cal = new CalendarLocal();
1156 cal->setLocalTime(); 1156 cal->setLocalTime();
1157 Incidence *incidence = delSel.first(); 1157 Incidence *incidence = delSel.first();
1158 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1158 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1159 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1159 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1160 while ( incidence ) { 1160 while ( incidence ) {
1161 if ( incidence->type() != "Journal" ) { 1161 if ( incidence->type() != "Journal" ) {
1162 bool add = true; 1162 bool add = true;
1163 if ( inFuture ) { 1163 if ( inFuture ) {
1164 QDateTime dt; 1164 QDateTime dt;
1165 if ( incidence->type() == "Todo" ) { 1165 if ( incidence->type() == "Todo" ) {
1166 Todo * t = (Todo*)incidence; 1166 Todo * t = (Todo*)incidence;
1167 if ( t->hasDueDate() ) 1167 if ( t->hasDueDate() )
1168 dt = t->dtDue(); 1168 dt = t->dtDue();
1169 else 1169 else
1170 dt = cur.addSecs( 62 ); 1170 dt = cur.addSecs( 62 );
1171 } 1171 }
1172 else { 1172 else {
1173 bool ok; 1173 bool ok;
1174 dt = incidence->getNextOccurence( cur, &ok ); 1174 dt = incidence->getNextOccurence( cur, &ok );
1175 if ( !ok ) 1175 if ( !ok )
1176 dt = cur.addSecs( -62 ); 1176 dt = cur.addSecs( -62 );
1177 } 1177 }
1178 if ( dt < cur || dt > end ) { 1178 if ( dt < cur || dt > end ) {
1179 add = false; 1179 add = false;
1180 } 1180 }
1181 } 1181 }
1182 if ( add ) { 1182 if ( add ) {
1183 Incidence *in = incidence->clone(); 1183 Incidence *in = incidence->clone();
1184 cal->addIncidence( in ); 1184 cal->addIncidence( in );
1185 } 1185 }
1186 } 1186 }
1187 incidence = delSel.next(); 1187 incidence = delSel.next();
1188 } 1188 }
1189 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1189 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1190 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1190 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1191 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1191 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1192 1192
1193 setCaption( i18n("Writing to phone...")); 1193 setCaption( i18n("Writing to phone..."));
1194 if ( PhoneFormat::writeToPhone( cal ) ) 1194 if ( PhoneFormat::writeToPhone( cal ) )
1195 setCaption( i18n("Export to phone successful!")); 1195 setCaption( i18n("Export to phone successful!"));
1196 else 1196 else
1197 setCaption( i18n("Error exporting to phone!")); 1197 setCaption( i18n("Error exporting to phone!"));
1198 delete cal; 1198 delete cal;
1199} 1199}
1200 1200
1201 1201
1202void MainWindow::setDefaultPreferences() 1202void MainWindow::setDefaultPreferences()
1203{ 1203{
1204 KOPrefs *p = KOPrefs::instance(); 1204 KOPrefs *p = KOPrefs::instance();
1205 1205
1206 p->mCompactDialogs = true; 1206 p->mCompactDialogs = true;
1207 p->mConfirm = true; 1207 p->mConfirm = true;
1208 // p->mEnableQuickTodo = false; 1208 // p->mEnableQuickTodo = false;
1209 1209
1210} 1210}
1211 1211
1212QString MainWindow::resourcePath() 1212QString MainWindow::resourcePath()
1213{ 1213{
1214 return KGlobal::iconLoader()->iconPath(); 1214 return KGlobal::iconLoader()->iconPath();
1215} 1215}
1216 1216
1217void MainWindow::displayText( QString text ,QString cap ) 1217void MainWindow::displayText( QString text ,QString cap )
1218{ 1218{
1219 QDialog dia( this, "name", true ); ; 1219 QDialog dia( this, "name", true ); ;
1220 dia.setCaption( cap ); 1220 dia.setCaption( cap );
1221 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1221 QVBoxLayout* lay = new QVBoxLayout( &dia );
1222 lay->setSpacing( 3 ); 1222 lay->setSpacing( 3 );
1223 lay->setMargin( 3 ); 1223 lay->setMargin( 3 );
1224 QTextBrowser tb ( &dia ); 1224 QTextBrowser tb ( &dia );
1225 lay->addWidget( &tb ); 1225 lay->addWidget( &tb );
1226 tb.setText( text ); 1226 tb.setText( text );
1227#ifdef DESKTOP_VERSION 1227#ifdef DESKTOP_VERSION
1228 dia.resize( 640, 480); 1228 dia.resize( 640, 480);
1229#else 1229#else
1230 dia.showMaximized(); 1230 dia.showMaximized();
1231#endif 1231#endif
1232 dia.exec(); 1232 dia.exec();
1233} 1233}
1234 1234
1235void MainWindow::features() 1235void MainWindow::features()
1236{ 1236{
1237 1237
1238 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1238 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1239} 1239}
1240 1240
1241void MainWindow::usertrans() 1241void MainWindow::usertrans()
1242{ 1242{
1243 1243
1244 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1244 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1245} 1245}
1246 1246
1247void MainWindow::kdesynchowto() 1247void MainWindow::kdesynchowto()
1248{ 1248{
1249 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1249 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1250} 1250}
1251void MainWindow::multisynchowto() 1251void MainWindow::multisynchowto()
1252{ 1252{
1253 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1253 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1254} 1254}
1255void MainWindow::synchowto() 1255void MainWindow::synchowto()
1256{ 1256{
1257 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1257 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1258} 1258}
1259void MainWindow::faq() 1259void MainWindow::faq()
1260{ 1260{
1261 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1261 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1262 1262
1263} 1263}
1264void MainWindow::whatsNew() 1264void MainWindow::whatsNew()
1265{ 1265{
1266 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1266 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1267 1267
1268} 1268}
1269void MainWindow::licence() 1269void MainWindow::licence()
1270{ 1270{
1271 KApplication::showLicence(); 1271 KApplication::showLicence();
1272 1272
1273} 1273}
1274void MainWindow::about() 1274void MainWindow::about()
1275{ 1275{
1276 QString version; 1276 QString version;
1277#include <../version> 1277#include <../version>
1278 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1278 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1279 i18n("KOrganizer/Platform-independent\n") + 1279 i18n("KOrganizer/Platform-independent\n") +
1280 "(KO/Pi) " + version + " - " + 1280 "(KO/Pi) " + version + " - " +
1281 1281
1282#ifdef DESKTOP_VERSION 1282#ifdef DESKTOP_VERSION
1283 i18n("Desktop Edition\n") + 1283 i18n("Desktop Edition\n") +
1284#else 1284#else
1285 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1285 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1286#endif 1286#endif
1287 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1287 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1288} 1288}
1289void MainWindow::keyBindings() 1289void MainWindow::keyBindings()
1290{ 1290{
1291 QString cap = i18n("KO/Pi Keys + Colors"); 1291 QString cap = i18n("KO/Pi Keys + Colors");
1292 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1292 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1293 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1293 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1294 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1294 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1295 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1295 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1296 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1296 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1297 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1297 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1298 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1298 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1299 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1299 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1300 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1300 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1301 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1301 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1302 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1302 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1303 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1303 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1304 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1304 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1305 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1305 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1306 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1306 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1307 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1307 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1308 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1308 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1309 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1309 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1310 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1310 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1311 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1311 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1312 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1312 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1313 i18n("<p><h3>In agenda view:</h3></p>\n") + 1313 i18n("<p><h3>In agenda view:</h3></p>\n") +
1314 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1314 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1315 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1315 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1316 i18n("<p><h3>In todo view:</h3></p>\n") + 1316 i18n("<p><h3>In todo view:</h3></p>\n") +
1317 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1317 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1318 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1318 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1319 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1319 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1320 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1320 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1321 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1321 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1322 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1322 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1323 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1323 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1324 i18n("<p><h3>In list view:</h3></p>\n") + 1324 i18n("<p><h3>In list view:</h3></p>\n") +
1325 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1325 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1326 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1326 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1327 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1327 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1328 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1328 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1329 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1329 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1330 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1330 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1331 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1331 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1332 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1332 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1333 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1333 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1334 i18n("<p><b>E</b>: Edit item</p>\n") + 1334 i18n("<p><b>E</b>: Edit item</p>\n") +
1335 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1335 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1336 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1336 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1337 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1337 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1338 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1338 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1339 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1339 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1340 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1340 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1341 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1341 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1342 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1342 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1343 i18n("<p><b>White</b>: Item readonly</p>\n"); 1343 i18n("<p><b>White</b>: Item readonly</p>\n");
1344 displayText( text, cap); 1344 displayText( text, cap);
1345} 1345}
1346void MainWindow::aboutAutoSaving() 1346void MainWindow::aboutAutoSaving()
1347{ 1347{
1348 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1348 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1349 1349
1350 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1350 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1351 1351
1352} 1352}
1353void MainWindow::aboutKnownBugs() 1353void MainWindow::aboutKnownBugs()
1354{ 1354{
1355 QMessageBox* msg; 1355 QMessageBox* msg;
1356 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1356 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1357 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1357 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1358 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1358 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1359 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1359 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1360 i18n("\nor report them in the bugtracker on\n") + 1360 i18n("\nor report them in the bugtracker on\n") +
1361 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1361 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1362 QMessageBox::NoIcon, 1362 QMessageBox::NoIcon,
1363 QMessageBox::Ok, 1363 QMessageBox::Ok,
1364 QMessageBox::NoButton, 1364 QMessageBox::NoButton,
1365 QMessageBox::NoButton); 1365 QMessageBox::NoButton);
1366 msg->exec(); 1366 msg->exec();
1367 delete msg; 1367 delete msg;
1368 1368
1369} 1369}
1370 1370
1371QString MainWindow::defaultFileName() 1371QString MainWindow::defaultFileName()
1372{ 1372{
1373 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1373 return locateLocal( "data", "korganizer/mycalendar.ics" );
1374} 1374}
1375QString MainWindow::syncFileName() 1375QString MainWindow::syncFileName()
1376{ 1376{
1377#ifdef DESKTOP_VERSION 1377#ifdef DESKTOP_VERSION
1378 return locateLocal( "tmp", "synccalendar.ics" ); 1378 return locateLocal( "tmp", "synccalendar.ics" );
1379#else 1379#else
1380 return QString( "/tmp/synccalendar.ics" ); 1380 return QString( "/tmp/synccalendar.ics" );
1381#endif 1381#endif
1382} 1382}
1383void MainWindow::updateWeek(QDate seda) 1383void MainWindow::updateWeek(QDate seda)
1384{ 1384{
1385 int weekNum = 0; 1385 int weekNum = 0;
1386 QDate d = QDate ( seda.year(), 1,1); 1386 QDate d = QDate ( seda.year(), 1,1);
1387 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1387 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1388 if ( seda.addDays(6).year() != seda.year() ) { 1388 if ( seda.addDays(6).year() != seda.year() ) {
1389 if ( seda.year() != d.year() ) { 1389 if ( seda.year() != d.year() ) {
1390 if ( d.dayOfWeek() > 4 ) 1390 if ( d.dayOfWeek() > 4 )
1391 d = QDate ( seda.year(), 1,1); 1391 d = QDate ( seda.year(), 1,1);
1392 else 1392 else
1393 weekNum = 1; 1393 weekNum = 1;
1394 } else { 1394 } else {
1395 QDate dd( seda.year()+1, 1,1); 1395 QDate dd( seda.year()+1, 1,1);
1396 if ( dd.dayOfWeek() <= 4 ) 1396 if ( dd.dayOfWeek() <= 4 )
1397 weekNum = 1; 1397 weekNum = 1;
1398 } 1398 }
1399 } 1399 }
1400 if ( weekNum == 0 ){ 1400 if ( weekNum == 0 ){
1401 int dow = d.dayOfWeek(); 1401 int dow = d.dayOfWeek();
1402 if ( dow <= 4 ) 1402 if ( dow <= 4 )
1403 d = d.addDays( 1-dow ); 1403 d = d.addDays( 1-dow );
1404 else // 5,6,7 1404 else // 5,6,7
1405 d = d.addDays( 8-dow ); 1405 d = d.addDays( 8-dow );
1406 // we have the first week of the year.we are on monday 1406 // we have the first week of the year.we are on monday
1407 weekNum = d.daysTo( seda ) / 7 +1; 1407 weekNum = d.daysTo( seda ) / 7 +1;
1408 } 1408 }
1409 1409
1410 mWeekPixmap.fill( mWeekBgColor ); 1410 mWeekPixmap.fill( mWeekBgColor );
1411 QPainter p ( &mWeekPixmap ); 1411 QPainter p ( &mWeekPixmap );
1412 p.setFont( mWeekFont ); 1412 p.setFont( mWeekFont );
1413 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1413 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1414 p.end(); 1414 p.end();
1415 QIconSet icon3 ( mWeekPixmap ); 1415 QIconSet icon3 ( mWeekPixmap );
1416 mWeekAction->setIconSet ( icon3 ); 1416 mWeekAction->setIconSet ( icon3 );
1417 1417
1418} 1418}
1419void MainWindow::updateWeekNum(const DateList &selectedDates) 1419void MainWindow::updateWeekNum(const DateList &selectedDates)
1420{ 1420{
1421 updateWeek( selectedDates.first() ); 1421 updateWeek( selectedDates.first() );
1422} 1422}
1423void MainWindow::processIncidenceSelection( Incidence *incidence ) 1423void MainWindow::processIncidenceSelection( Incidence *incidence )
1424{ 1424{
1425 1425
1426 if ( !incidence ) { 1426 if ( !incidence ) {
1427 enableIncidenceActions( false ); 1427 enableIncidenceActions( false );
1428 1428
1429 mNewSubTodoAction->setEnabled( false ); 1429 mNewSubTodoAction->setEnabled( false );
1430 setCaptionToDates(); 1430 setCaptionToDates();
1431 return; 1431 return;
1432 1432
1433 } 1433 }
1434 1434
1435 //KGlobal::locale()->formatDateTime(nextA, true); 1435 //KGlobal::locale()->formatDateTime(nextA, true);
1436 QString startString = ""; 1436 QString startString = "";
1437 if ( incidence->type() != "Todo" ) { 1437 if ( incidence->type() != "Todo" ) {
1438 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1438 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1439 if ( incidence->doesFloat() ) { 1439 if ( incidence->doesFloat() ) {
1440 startString += ": "+incidence->dtStartDateStr( true ); 1440 startString += ": "+incidence->dtStartDateStr( true );
1441 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1441 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1442 1442
1443 } else { 1443 } else {
1444 startString = ": "+incidence->dtStartStr(true); 1444 startString = ": "+incidence->dtStartStr(true);
1445 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1445 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1446 1446
1447 } 1447 }
1448 1448
1449 } else { 1449 } else {
1450 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1450 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1451 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1451 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1452 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1452 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1453 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1453 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1454 bool ok; 1454 bool ok;
1455 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1455 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1456 if ( ok ) { 1456 if ( ok ) {
1457 int years = noc.date().year() - incidence->dtStart().date().year(); 1457 int years = noc.date().year() - incidence->dtStart().date().year();
1458 startString += i18n(" (%1 y.)"). arg( years ); 1458 startString += i18n(" (%1 y.)"). arg( years );
1459 } 1459 }
1460 } 1460 }
1461 else 1461 else
1462 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1462 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1463 } 1463 }
1464 1464
1465 } 1465 }
1466 else 1466 else
1467 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1467 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1468 if ( !incidence->location().isEmpty() ) 1468 if ( !incidence->location().isEmpty() )
1469 startString += " (" +incidence->location()+")"; 1469 startString += " (" +incidence->location()+")";
1470 setCaption( incidence->summary()+startString); 1470 setCaption( incidence->summary()+startString);
1471 1471
1472 enableIncidenceActions( true ); 1472 enableIncidenceActions( true );
1473 1473
1474 if ( incidence->type() == "Event" ) { 1474 if ( incidence->type() == "Event" ) {
1475 mShowAction->setText( i18n("Show Event...") ); 1475 mShowAction->setText( i18n("Show Event...") );
1476 mEditAction->setText( i18n("Edit Event...") ); 1476 mEditAction->setText( i18n("Edit Event...") );
1477 mDeleteAction->setText( i18n("Delete Event...") ); 1477 mDeleteAction->setText( i18n("Delete Event...") );
1478 1478
1479 mNewSubTodoAction->setEnabled( false ); 1479 mNewSubTodoAction->setEnabled( false );
1480 } else if ( incidence->type() == "Todo" ) { 1480 } else if ( incidence->type() == "Todo" ) {
1481 mShowAction->setText( i18n("Show Todo...") ); 1481 mShowAction->setText( i18n("Show Todo...") );
1482 mEditAction->setText( i18n("Edit Todo...") ); 1482 mEditAction->setText( i18n("Edit Todo...") );
1483 mDeleteAction->setText( i18n("Delete Todo...") ); 1483 mDeleteAction->setText( i18n("Delete Todo...") );
1484 1484
1485 mNewSubTodoAction->setEnabled( true ); 1485 mNewSubTodoAction->setEnabled( true );
1486 } else { 1486 } else {
1487 mShowAction->setText( i18n("Show...") ); 1487 mShowAction->setText( i18n("Show...") );
1488 mShowAction->setText( i18n("Edit...") ); 1488 mShowAction->setText( i18n("Edit...") );
1489 mShowAction->setText( i18n("Delete...") ); 1489 mShowAction->setText( i18n("Delete...") );
1490 1490
1491 mNewSubTodoAction->setEnabled( false ); 1491 mNewSubTodoAction->setEnabled( false );
1492 } 1492 }
1493} 1493}
1494 1494
1495void MainWindow::enableIncidenceActions( bool enabled ) 1495void MainWindow::enableIncidenceActions( bool enabled )
1496{ 1496{
1497 mShowAction->setEnabled( enabled ); 1497 mShowAction->setEnabled( enabled );
1498 mEditAction->setEnabled( enabled ); 1498 mEditAction->setEnabled( enabled );
1499 mDeleteAction->setEnabled( enabled ); 1499 mDeleteAction->setEnabled( enabled );
1500 1500
1501 mCloneAction->setEnabled( enabled ); 1501 mCloneAction->setEnabled( enabled );
1502 mMoveAction->setEnabled( enabled ); 1502 mMoveAction->setEnabled( enabled );
1503 mBeamAction->setEnabled( enabled ); 1503 mBeamAction->setEnabled( enabled );
1504 mCancelAction->setEnabled( enabled ); 1504 mCancelAction->setEnabled( enabled );
1505} 1505}
1506 1506
1507void MainWindow::importOL() 1507void MainWindow::importOL()
1508{ 1508{
1509#ifdef _OL_IMPORT_ 1509#ifdef _OL_IMPORT_
1510 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1510 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1511 id->exec(); 1511 id->exec();
1512 delete id; 1512 delete id;
1513 mView->updateView(); 1513 mView->updateView();
1514#endif 1514#endif
1515} 1515}
1516void MainWindow::importBday() 1516void MainWindow::importBday()
1517{ 1517{
1518 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1518 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1519 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1519 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1520 i18n("Import!"), i18n("Cancel"), 0, 1520 i18n("Import!"), i18n("Cancel"), 0,
1521 0, 1 ); 1521 0, 1 );
1522 if ( result == 0 ) { 1522 if ( result == 0 ) {
1523 mView->importBday(); 1523 mView->importBday();
1524 1524
1525 } 1525 }
1526 1526
1527 1527
1528} 1528}
1529void MainWindow::importQtopia() 1529void MainWindow::importQtopia()
1530{ 1530{
1531 //#ifndef DESKTOP_VERSION 1531 //#ifndef DESKTOP_VERSION
1532 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1532 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1533#ifdef DESKTOP_VERSION 1533#ifdef DESKTOP_VERSION
1534 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1534 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1535#endif 1535#endif
1536 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1536 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1537 i18n("Import!"), i18n("Cancel"), 0, 1537 i18n("Import!"), i18n("Cancel"), 0,
1538 0, 1 ); 1538 0, 1 );
1539 if ( result == 0 ) { 1539 if ( result == 0 ) {
1540#ifndef DESKTOP_VERSION 1540#ifndef DESKTOP_VERSION
1541 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1541 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1542 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1542 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1543 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1543 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1544#else 1544#else
1545 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1545 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1546 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1546 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1547 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1547 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1548#endif 1548#endif
1549 mView->importQtopia( categories, datebook, todolist ); 1549 mView->importQtopia( categories, datebook, todolist );
1550 } 1550 }
1551#if 0 1551#if 0
1552 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1552 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1553 i18n("Not supported \non desktop!\n"), 1553 i18n("Not supported \non desktop!\n"),
1554 i18n("Ok"), i18n("Cancel"), 0, 1554 i18n("Ok"), i18n("Cancel"), 0,
1555 0, 1 ); 1555 0, 1 );
1556 1556
1557#endif 1557#endif
1558} 1558}
1559 1559
1560void MainWindow::saveOnClose() 1560void MainWindow::saveOnClose()
1561{ 1561{
1562 KOPrefs *p = KOPrefs::instance(); 1562 KOPrefs *p = KOPrefs::instance();
1563 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1563 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1564 p->mToolBarUp = iconToolBar->x() > width()/2 || 1564 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1565 iconToolBar->y() > height()/2; 1565 iconToolBar->y() > height()/2;
1566 mView->writeSettings(); 1566 mView->writeSettings();
1567 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1567 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1568 save(); 1568 save();
1569} 1569}
1570void MainWindow::slotModifiedChanged( bool changed ) 1570void MainWindow::slotModifiedChanged( bool changed )
1571{ 1571{
1572 if ( mBlockAtStartup ) 1572 if ( mBlockAtStartup )
1573 return; 1573 return;
1574 1574
1575 int msec; 1575 int msec;
1576 // we store the changes after 1 minute, 1576 // we store the changes after 1 minute,
1577 // and for safety reasons after 10 minutes again 1577 // and for safety reasons after 10 minutes again
1578 if ( !mSyncManager->blockSave() ) 1578 if ( !mSyncManager->blockSave() )
1579 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1579 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1580 else 1580 else
1581 msec = 1000 * 600; 1581 msec = 1000 * 600;
1582 mSaveTimer.start( msec, true ); // 1 minute 1582 mSaveTimer.start( msec, true ); // 1 minute
1583 qDebug("KO: Saving File in %d secs!", msec/1000); 1583 qDebug("KO: Saving File in %d secs!", msec/1000);
1584 mCalendarModifiedFlag = true; 1584 mCalendarModifiedFlag = true;
1585} 1585}
1586void MainWindow::saveStopTimer() 1586void MainWindow::saveStopTimer()
1587{ 1587{
1588 mSaveTimer.stop(); 1588 mSaveTimer.stop();
1589 if (mSaveTimer.isActive() ) 1589 if (mSaveTimer.isActive() )
1590 qDebug("ti active "); 1590 qDebug("ti active ");
1591 else 1591 else
1592 qDebug("KO: Save timer stopped"); 1592 qDebug("KO: Save timer stopped");
1593} 1593}
1594void MainWindow::save() 1594void MainWindow::save()
1595{ 1595{
1596 if ( !mCalendarModifiedFlag ) { 1596 if ( !mCalendarModifiedFlag ) {
1597 qDebug("KO: Calendar not modified. Nothing saved."); 1597 qDebug("KO: Calendar not modified. Nothing saved.");
1598 return; 1598 return;
1599 } 1599 }
1600 if ( mSyncManager->blockSave() ) 1600 if ( mSyncManager->blockSave() )
1601 return; 1601 return;
1602 mSyncManager->setBlockSave(true); 1602 mSyncManager->setBlockSave(true);
1603 if ( mView->checkFileVersion( defaultFileName()) ) { 1603 if ( mView->checkFileVersion( defaultFileName()) ) {
1604 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1604 QTime neededSaveTime = QDateTime::currentDateTime().time();
1605 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1605 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1606 qDebug("KO: Start saving data to file!"); 1606 qDebug("KO: Start saving data to file!");
1607 mView->saveCalendar( defaultFileName() ); 1607 mView->saveCalendar( defaultFileName() );
1608 mCalendarModifiedFlag = false; 1608 mCalendarModifiedFlag = false;
1609 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1609 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1610 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1610 qDebug("KO: Needed %d ms for saving.",msNeeded );
1611 QString savemes; 1611 QString savemes;
1612 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1612 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1613 setCaption(savemes); 1613 setCaption(savemes);
1614 } else 1614 } else
1615 setCaption(i18n("Saving cancelled!")); 1615 setCaption(i18n("Saving cancelled!"));
1616 mSyncManager->setBlockSave( false ); 1616 mSyncManager->setBlockSave( false );
1617} 1617}
1618 1618
1619void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1619void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1620{ 1620{
1621 if ( !e->isAutoRepeat() ) { 1621 if ( !e->isAutoRepeat() ) {
1622 mFlagKeyPressed = false; 1622 mFlagKeyPressed = false;
1623 } 1623 }
1624} 1624}
1625void MainWindow::keyPressEvent ( QKeyEvent * e ) 1625void MainWindow::keyPressEvent ( QKeyEvent * e )
1626{ 1626{
1627 qApp->processEvents(); 1627 qApp->processEvents();
1628 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1628 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1629 e->ignore(); 1629 e->ignore();
1630 // qDebug(" ignore %d",e->isAutoRepeat() ); 1630 // qDebug(" ignore %d",e->isAutoRepeat() );
1631 return; 1631 return;
1632 } 1632 }
1633 if (! e->isAutoRepeat() ) 1633 if (! e->isAutoRepeat() )
1634 mFlagKeyPressed = true; 1634 mFlagKeyPressed = true;
1635 KOPrefs *p = KOPrefs::instance(); 1635 KOPrefs *p = KOPrefs::instance();
1636 bool showSelectedDates = false; 1636 bool showSelectedDates = false;
1637 int size; 1637 int size;
1638 int pro = 0; 1638 int pro = 0;
1639 //qDebug("MainWindow::keyPressEvent "); 1639 //qDebug("MainWindow::keyPressEvent ");
1640 switch ( e->key() ) { 1640 switch ( e->key() ) {
1641 case Qt::Key_Right: 1641 case Qt::Key_Right:
1642 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1642 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1643 mView->goNextMonth(); 1643 mView->goNextMonth();
1644 else 1644 else
1645 mView->goNext(); 1645 mView->goNext();
1646 showSelectedDates = true; 1646 showSelectedDates = true;
1647 break; 1647 break;
1648 case Qt::Key_Left: 1648 case Qt::Key_Left:
1649 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1649 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1650 mView->goPreviousMonth(); 1650 mView->goPreviousMonth();
1651 else 1651 else
1652 mView->goPrevious(); 1652 mView->goPrevious();
1653 showSelectedDates = true; 1653 showSelectedDates = true;
1654 break; 1654 break;
1655 case Qt::Key_Down: 1655 case Qt::Key_Down:
1656 mView->viewManager()->agendaView()->scrollOneHourDown(); 1656 mView->viewManager()->agendaView()->scrollOneHourDown();
1657 break; 1657 break;
1658 case Qt::Key_Up: 1658 case Qt::Key_Up:
1659 mView->viewManager()->agendaView()->scrollOneHourUp(); 1659 mView->viewManager()->agendaView()->scrollOneHourUp();
1660 break; 1660 break;
1661 case Qt::Key_K: 1661 case Qt::Key_K:
1662 mView->viewManager()->showMonthViewWeek(); 1662 mView->viewManager()->showMonthViewWeek();
1663 break; 1663 break;
1664 case Qt::Key_I: 1664 case Qt::Key_I:
1665 mView->showIncidence(); 1665 mView->showIncidence();
1666 break; 1666 break;
1667 case Qt::Key_Delete: 1667 case Qt::Key_Delete:
1668 case Qt::Key_Backspace: 1668 case Qt::Key_Backspace:
1669 mView->deleteIncidence(); 1669 mView->deleteIncidence();
1670 break; 1670 break;
1671 case Qt::Key_D: 1671 case Qt::Key_D:
1672 mView->viewManager()->showDayView(); 1672 mView->viewManager()->showDayView();
1673 showSelectedDates = true; 1673 showSelectedDates = true;
1674 break; 1674 break;
1675 case Qt::Key_O: 1675 case Qt::Key_O:
1676 mView->toggleFilerEnabled( ); 1676 mView->toggleFilerEnabled( );
1677 break; 1677 break;
1678 case Qt::Key_0: 1678 case Qt::Key_0:
1679 case Qt::Key_1: 1679 case Qt::Key_1:
1680 case Qt::Key_2: 1680 case Qt::Key_2:
1681 case Qt::Key_3: 1681 case Qt::Key_3:
1682 case Qt::Key_4: 1682 case Qt::Key_4:
1683 case Qt::Key_5: 1683 case Qt::Key_5:
1684 case Qt::Key_6: 1684 case Qt::Key_6:
1685 case Qt::Key_7: 1685 case Qt::Key_7:
1686 case Qt::Key_8: 1686 case Qt::Key_8:
1687 case Qt::Key_9: 1687 case Qt::Key_9:
1688 pro = e->key()-48; 1688 pro = e->key()-48;
1689 if ( pro == 0 ) 1689 if ( pro == 0 )
1690 pro = 10; 1690 pro = 10;
1691 if ( e->state() == Qt::ControlButton) 1691 if ( e->state() == Qt::ControlButton)
1692 pro += 10; 1692 pro += 10;
1693 break; 1693 break;
1694 case Qt::Key_M: 1694 case Qt::Key_M:
1695 mView->viewManager()->showMonthView(); 1695 mView->viewManager()->showMonthView();
1696 showSelectedDates = true; 1696 showSelectedDates = true;
1697 break; 1697 break;
1698 case Qt::Key_Insert: 1698 case Qt::Key_Insert:
1699 mView->newEvent(); 1699 mView->newEvent();
1700 break; 1700 break;
1701 case Qt::Key_S : 1701 case Qt::Key_S :
1702 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1702 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1703 mView->newSubTodo(); 1703 mView->newSubTodo();
1704 else 1704 else
1705 mView->dialogManager()->showSearchDialog(); 1705 mView->dialogManager()->showSearchDialog();
1706 break; 1706 break;
1707 case Qt::Key_Y : 1707 case Qt::Key_Y :
1708 case Qt::Key_Z : 1708 case Qt::Key_Z :
1709 mView->viewManager()->showWorkWeekView(); 1709 mView->viewManager()->showWorkWeekView();
1710 showSelectedDates = true; 1710 showSelectedDates = true;
1711 break; 1711 break;
1712 case Qt::Key_U : 1712 case Qt::Key_U :
1713 mView->viewManager()->showWeekView(); 1713 mView->viewManager()->showWeekView();
1714 showSelectedDates = true; 1714 showSelectedDates = true;
1715 break; 1715 break;
1716 case Qt::Key_H : 1716 case Qt::Key_H :
1717 keyBindings(); 1717 keyBindings();
1718 break; 1718 break;
1719 case Qt::Key_W: 1719 case Qt::Key_W:
1720 mView->viewManager()->showWhatsNextView(); 1720 mView->viewManager()->showWhatsNextView();
1721 break; 1721 break;
1722 case Qt::Key_L: 1722 case Qt::Key_L:
1723 mView->viewManager()->showListView(); 1723 mView->viewManager()->showListView();
1724 break; 1724 break;
1725 case Qt::Key_N: 1725 case Qt::Key_N:
1726 mView->viewManager()->showNextXView(); 1726 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1727 showSelectedDates = true; 1727 mView->viewManager()->showNextView();
1728 else {
1729 mView->viewManager()->showNextXView();
1730 showSelectedDates = true;
1731 }
1728 break; 1732 break;
1729 case Qt::Key_V: 1733 case Qt::Key_V:
1730 mView->viewManager()->showTodoView(); 1734 mView->viewManager()->showTodoView();
1731 break; 1735 break;
1732 case Qt::Key_C: 1736 case Qt::Key_C:
1733 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1737 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1734 break; 1738 break;
1735 case Qt::Key_P: 1739 case Qt::Key_P:
1736 mView->showDatePicker( ); 1740 mView->showDatePicker( );
1737 break; 1741 break;
1738 case Qt::Key_F: 1742 case Qt::Key_F:
1739 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1743 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1740 mView->editFilters(); 1744 mView->editFilters();
1741 else 1745 else
1742 mView->toggleFilter(); 1746 mView->toggleFilter();
1743 break; 1747 break;
1744 case Qt::Key_X: 1748 case Qt::Key_X:
1745 mView->toggleDateNavigatorWidget(); 1749 mView->toggleDateNavigatorWidget();
1746 break; 1750 break;
1747 case Qt::Key_Space: 1751 case Qt::Key_Space:
1748 mView->toggleExpand(); 1752 mView->toggleExpand();
1749 break; 1753 break;
1750 case Qt::Key_A: 1754 case Qt::Key_A:
1751 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1755 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1752 mView->showNextAlarms(); 1756 mView->showNextAlarms();
1753 else 1757 else
1754 mView->toggleAllDaySize(); 1758 mView->toggleAllDaySize();
1755 break; 1759 break;
1756 case Qt::Key_T: 1760 case Qt::Key_T:
1757 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1761 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1758 mView->newTodo(); 1762 mView->newTodo();
1759 else { 1763 else {
1760 mView->goToday(); 1764 mView->goToday();
1761 showSelectedDates = true; 1765 showSelectedDates = true;
1762 } 1766 }
1763 break; 1767 break;
1764 case Qt::Key_J: 1768 case Qt::Key_J:
1765 mView->viewManager()->showJournalView(); 1769 mView->viewManager()->showJournalView();
1766 break; 1770 break;
1767 case Qt::Key_B: 1771 case Qt::Key_B:
1768 mView->editIncidenceDescription();; 1772 mView->editIncidenceDescription();;
1769 break; 1773 break;
1770 // case Qt::Key_Return: 1774 // case Qt::Key_Return:
1771 case Qt::Key_E: 1775 case Qt::Key_E:
1772 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1776 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1773 mView->newEvent(); 1777 mView->newEvent();
1774 else 1778 else
1775 mView->editIncidence(); 1779 mView->editIncidence();
1776 break; 1780 break;
1777 case Qt::Key_Plus: 1781 case Qt::Key_Plus:
1778 size = p->mHourSize +2; 1782 size = p->mHourSize +2;
1779 if ( size <= 22 ) 1783 if ( size <= 22 )
1780 configureAgenda( size ); 1784 configureAgenda( size );
1781 break; 1785 break;
1782 case Qt::Key_Minus: 1786 case Qt::Key_Minus:
1783 size = p->mHourSize - 2; 1787 size = p->mHourSize - 2;
1784 if ( size >= 4 ) 1788 if ( size >= 4 )
1785 configureAgenda( size ); 1789 configureAgenda( size );
1786 break; 1790 break;
1787 1791
1788 1792
1789 default: 1793 default:
1790 e->ignore(); 1794 e->ignore();
1791 } 1795 }
1792 if ( pro > 0 ) { 1796 if ( pro > 0 ) {
1793 mView->selectFilter( pro-1 ); 1797 mView->selectFilter( pro-1 );
1794 } 1798 }
1795 if ( showSelectedDates ) { 1799 if ( showSelectedDates ) {
1796 ;// setCaptionToDates(); 1800 ;// setCaptionToDates();
1797 } 1801 }
1798 1802
1799} 1803}
1800 1804
1801void MainWindow::fillFilterMenu() 1805void MainWindow::fillFilterMenu()
1802{ 1806{
1803 selectFilterMenu->clear(); 1807 selectFilterMenu->clear();
1804 bool disable = false; 1808 bool disable = false;
1805 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1809 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1806 selectFilterMenu->insertSeparator(); 1810 selectFilterMenu->insertSeparator();
1807 if ( mView->filterView()->filtersEnabled() ) { 1811 if ( mView->filterView()->filtersEnabled() ) {
1808 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1812 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1809 } 1813 }
1810 else { 1814 else {
1811 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1815 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1812 disable = true; 1816 disable = true;
1813 } 1817 }
1814 selectFilterMenu->insertSeparator(); 1818 selectFilterMenu->insertSeparator();
1815 QPtrList<CalFilter> fili = mView->filters(); 1819 QPtrList<CalFilter> fili = mView->filters();
1816 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1820 CalFilter *curfilter = mView->filterView()->selectedFilter();
1817 CalFilter *filter = fili.first(); 1821 CalFilter *filter = fili.first();
1818 int iii = 2; 1822 int iii = 2;
1819 while(filter) { 1823 while(filter) {
1820 selectFilterMenu->insertItem( filter->name(), iii ); 1824 selectFilterMenu->insertItem( filter->name(), iii );
1821 if ( filter == curfilter) 1825 if ( filter == curfilter)
1822 selectFilterMenu->setItemChecked( iii, true ); 1826 selectFilterMenu->setItemChecked( iii, true );
1823 if ( disable ) 1827 if ( disable )
1824 selectFilterMenu->setItemEnabled( iii, false ); 1828 selectFilterMenu->setItemEnabled( iii, false );
1825 filter = fili.next(); 1829 filter = fili.next();
1826 ++iii; 1830 ++iii;
1827 } 1831 }
1828} 1832}
1829void MainWindow::selectFilter( int fil ) 1833void MainWindow::selectFilter( int fil )
1830{ 1834{
1831 if ( fil == 0 ) { 1835 if ( fil == 0 ) {
1832 mView->editFilters( ); 1836 mView->editFilters( );
1833 } else if ( fil == 1 ){ 1837 } else if ( fil == 1 ){
1834 mView->toggleFilerEnabled( ); 1838 mView->toggleFilerEnabled( );
1835 } else { 1839 } else {
1836 mView->selectFilter( fil-2 ); 1840 mView->selectFilter( fil-2 );
1837 } 1841 }
1838} 1842}
1839void MainWindow::configureToolBar( int item ) 1843void MainWindow::configureToolBar( int item )
1840{ 1844{
1841 1845
1842 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1846 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1843 KOPrefs *p = KOPrefs::instance(); 1847 KOPrefs *p = KOPrefs::instance();
1844 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1848 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1845 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1849 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1846 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1850 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1847 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1851 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1848 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1852 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1849 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1853 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1850 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1854 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1851 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 1855 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
1852 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1856 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1853 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1857 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1854 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1858 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1855 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1859 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1856 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1860 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1857 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1861 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1858 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1862 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1859 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1863 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1860 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1864 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1861 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1865 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1862 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1866 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1863 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1867 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1864 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 1868 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
1865 // initActions(); 1869 // initActions();
1866} 1870}
1867void MainWindow::setCaption ( const QString & c ) 1871void MainWindow::setCaption ( const QString & c )
1868{ 1872{
1869 QString cap = c; 1873 QString cap = c;
1870 cap.replace( QRegExp("\n"), " " ); 1874 cap.replace( QRegExp("\n"), " " );
1871 cap = cap.stripWhiteSpace(); 1875 cap = cap.stripWhiteSpace();
1872 if ( cap.isEmpty() ) 1876 if ( cap.isEmpty() )
1873 cap = "KO/Pi"; 1877 cap = "KO/Pi";
1874 QWidget::setCaption( cap ); 1878 QWidget::setCaption( cap );
1875} 1879}
1876void MainWindow::setCaptionToDates() 1880void MainWindow::setCaptionToDates()
1877{ 1881{
1878 QString selDates; 1882 QString selDates;
1879 QDate date = mView->startDate(); 1883 QDate date = mView->startDate();
1880 if ( ! date.isValid() ) { 1884 if ( ! date.isValid() ) {
1881 setCaption(""); 1885 setCaption("");
1882 return; 1886 return;
1883 } 1887 }
1884 selDates = KGlobal::locale()->formatDate( date, true); 1888 selDates = KGlobal::locale()->formatDate( date, true);
1885 if (mView->startDate() < mView->endDate() ) 1889 if (mView->startDate() < mView->endDate() )
1886 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1890 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1887 else { 1891 else {
1888 QString addString; 1892 QString addString;
1889 if ( date == QDateTime::currentDateTime().date() ) 1893 if ( date == QDateTime::currentDateTime().date() )
1890 addString = i18n("Today"); 1894 addString = i18n("Today");
1891 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 1895 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
1892 addString = i18n("Tomorrow"); 1896 addString = i18n("Tomorrow");
1893 if ( !addString.isEmpty() ) 1897 if ( !addString.isEmpty() )
1894 selDates = addString+", "+selDates ; 1898 selDates = addString+", "+selDates ;
1895 } 1899 }
1896 setCaption( i18n("Dates: ") + selDates ); 1900 setCaption( i18n("Dates: ") + selDates );
1897 1901
1898} 1902}
1899void MainWindow::showConfigureAgenda( ) 1903void MainWindow::showConfigureAgenda( )
1900{ 1904{
1901 int iii; 1905 int iii;
1902 for ( iii = 1;iii<= 10 ;++iii ){ 1906 for ( iii = 1;iii<= 10 ;++iii ){
1903 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1907 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1904 } 1908 }
1905 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1909 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1906} 1910}
1907void MainWindow::configureAgenda( int item ) 1911void MainWindow::configureAgenda( int item )
1908{ 1912{
1909 if ( KOPrefs::instance()->mHourSize == item ) 1913 if ( KOPrefs::instance()->mHourSize == item )
1910 return; 1914 return;
1911 KOPrefs::instance()->mHourSize=item; 1915 KOPrefs::instance()->mHourSize=item;
1912 mView->viewManager()->agendaView()->updateConfig(); 1916 mView->viewManager()->agendaView()->updateConfig();
1913} 1917}
1914 1918
1915void MainWindow::saveCalendar() 1919void MainWindow::saveCalendar()
1916{ 1920{
1917 QString fn = KOPrefs::instance()->mLastSaveFile; 1921 QString fn = KOPrefs::instance()->mLastSaveFile;
1918 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1922 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1919 1923
1920 if ( fn == "" ) 1924 if ( fn == "" )
1921 return; 1925 return;
1922 QFileInfo info; 1926 QFileInfo info;
1923 info.setFile( fn ); 1927 info.setFile( fn );
1924 QString mes; 1928 QString mes;
1925 bool createbup = true; 1929 bool createbup = true;
1926 if ( info. exists() ) { 1930 if ( info. exists() ) {
1927 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1931 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1928 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1932 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1929 i18n("Overwrite!"), i18n("Cancel"), 0, 1933 i18n("Overwrite!"), i18n("Cancel"), 0,
1930 0, 1 ); 1934 0, 1 );
1931 if ( result != 0 ) { 1935 if ( result != 0 ) {
1932 createbup = false; 1936 createbup = false;
1933 } 1937 }
1934 } 1938 }
1935 if ( createbup ) { 1939 if ( createbup ) {
1936 mView->saveCalendar( fn ); 1940 mView->saveCalendar( fn );
1937 mes = i18n("KO/Pi:Saved %1").arg(fn); 1941 mes = i18n("KO/Pi:Saved %1").arg(fn);
1938 KOPrefs::instance()->mLastSaveFile = fn; 1942 KOPrefs::instance()->mLastSaveFile = fn;
1939 setCaption(mes); 1943 setCaption(mes);
1940 } 1944 }
1941} 1945}
1942void MainWindow::loadCalendar() 1946void MainWindow::loadCalendar()
1943{ 1947{
1944 1948
1945 QString fn = KOPrefs::instance()->mLastLoadFile; 1949 QString fn = KOPrefs::instance()->mLastLoadFile;
1946 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1950 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1947 1951
1948 if ( fn == "" ) 1952 if ( fn == "" )
1949 return; 1953 return;
1950 QFileInfo info; 1954 QFileInfo info;
1951 info.setFile( fn ); 1955 info.setFile( fn );
1952 QString mess; 1956 QString mess;
1953 bool loadbup = true; 1957 bool loadbup = true;
1954 if ( info. exists() ) { 1958 if ( info. exists() ) {
1955 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1959 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1956 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1960 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1957 mess, 1961 mess,
1958 i18n("Load!"), i18n("Cancel"), 0, 1962 i18n("Load!"), i18n("Cancel"), 0,
1959 0, 1 ); 1963 0, 1 );
1960 if ( result != 0 ) { 1964 if ( result != 0 ) {
1961 loadbup = false; 1965 loadbup = false;
1962 } 1966 }
1963 } else { 1967 } else {
1964 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1968 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1965 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1969 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1966 0, 1 ); 1970 0, 1 );
1967 1971
1968 return; 1972 return;
1969 } 1973 }
1970 if ( loadbup ) { 1974 if ( loadbup ) {
1971 mView->openCalendar( fn ); 1975 mView->openCalendar( fn );
1972 KOPrefs::instance()->mLastLoadFile = fn; 1976 KOPrefs::instance()->mLastLoadFile = fn;
1973 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1977 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1974 setCaption(mess); 1978 setCaption(mess);
1975 } 1979 }
1976 1980
1977} 1981}
1978void MainWindow::quickImportIcal() 1982void MainWindow::quickImportIcal()
1979{ 1983{
1980 importFile( KOPrefs::instance()->mLastImportFile, false ); 1984 importFile( KOPrefs::instance()->mLastImportFile, false );
1981} 1985}
1982void MainWindow::importFile( QString fn, bool quick ) 1986void MainWindow::importFile( QString fn, bool quick )
1983{ 1987{
1984 QFileInfo info; 1988 QFileInfo info;
1985 info.setFile( fn ); 1989 info.setFile( fn );
1986 QString mess; 1990 QString mess;
1987 bool loadbup = true; 1991 bool loadbup = true;
1988 if ( !info. exists() ) { 1992 if ( !info. exists() ) {
1989 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1993 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1990 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1994 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1991 mess ); 1995 mess );
1992 return; 1996 return;
1993 } 1997 }
1994 int result = 0; 1998 int result = 0;
1995 if ( !quick ) { 1999 if ( !quick ) {
1996 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2000 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1997 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2001 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1998 mess, 2002 mess,
1999 "Import", "Cancel", 0, 2003 "Import", "Cancel", 0,
2000 0, 1 ); 2004 0, 1 );
2001 } 2005 }
2002 if ( result == 0 ) { 2006 if ( result == 0 ) {
2003 if ( mView->openCalendar( fn, true )) { 2007 if ( mView->openCalendar( fn, true )) {
2004 KOPrefs::instance()->mLastImportFile = fn; 2008 KOPrefs::instance()->mLastImportFile = fn;
2005 setCaption(i18n("Imported file successfully")); 2009 setCaption(i18n("Imported file successfully"));
2006 } else { 2010 } else {
2007 setCaption(i18n("Error importing file")); 2011 setCaption(i18n("Error importing file"));
2008 } 2012 }
2009 } 2013 }
2010} 2014}
2011 2015
2012void MainWindow::importIcal() 2016void MainWindow::importIcal()
2013{ 2017{
2014 2018
2015 QString fn =KOPrefs::instance()->mLastImportFile; 2019 QString fn =KOPrefs::instance()->mLastImportFile;
2016 2020
2017 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2021 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2018 if ( fn == "" ) 2022 if ( fn == "" )
2019 return; 2023 return;
2020 importFile( fn, true ); 2024 importFile( fn, true );
2021 2025
2022} 2026}
2023 2027
2024void MainWindow::exportVCalendar() 2028void MainWindow::exportVCalendar()
2025{ 2029{
2026 QString fn = KOPrefs::instance()->mLastVcalFile; 2030 QString fn = KOPrefs::instance()->mLastVcalFile;
2027 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2031 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2028 if ( fn == "" ) 2032 if ( fn == "" )
2029 return; 2033 return;
2030 QFileInfo info; 2034 QFileInfo info;
2031 info.setFile( fn ); 2035 info.setFile( fn );
2032 QString mes; 2036 QString mes;
2033 bool createbup = true; 2037 bool createbup = true;
2034 if ( info. exists() ) { 2038 if ( info. exists() ) {
2035 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2039 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2036 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2040 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2037 i18n("Overwrite!"), i18n("Cancel"), 0, 2041 i18n("Overwrite!"), i18n("Cancel"), 0,
2038 0, 1 ); 2042 0, 1 );
2039 if ( result != 0 ) { 2043 if ( result != 0 ) {
2040 createbup = false; 2044 createbup = false;
2041 } 2045 }
2042 } 2046 }
2043 if ( createbup ) { 2047 if ( createbup ) {
2044 if ( mView->exportVCalendar( fn ) ) { 2048 if ( mView->exportVCalendar( fn ) ) {
2045 KOPrefs::instance()->mLastVcalFile = fn; 2049 KOPrefs::instance()->mLastVcalFile = fn;
2046 if ( fn.length() > 20 ) 2050 if ( fn.length() > 20 )
2047 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2051 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2048 else 2052 else
2049 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2053 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2050 setCaption(mes); 2054 setCaption(mes);
2051 } 2055 }
2052 } 2056 }
2053 2057
2054} 2058}
2055QString MainWindow::sentSyncFile() 2059QString MainWindow::sentSyncFile()
2056{ 2060{
2057#ifdef DESKTOP_VERSION 2061#ifdef DESKTOP_VERSION
2058 return locateLocal( "tmp", "copysynccal.ics" ); 2062 return locateLocal( "tmp", "copysynccal.ics" );
2059#else 2063#else
2060 return QString( "/tmp/copysynccal.ics" ); 2064 return QString( "/tmp/copysynccal.ics" );
2061#endif 2065#endif
2062} 2066}
2063 2067
2064void MainWindow::syncFileRequest() 2068void MainWindow::syncFileRequest()
2065{ 2069{
2066 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2070 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2067 mSyncManager->slotSyncMenu( 999 ); 2071 mSyncManager->slotSyncMenu( 999 );
2068 } 2072 }
2069 2073
2070 setCaption(i18n("Saving Data to temp file ..." )); 2074 setCaption(i18n("Saving Data to temp file ..." ));
2071 mView->saveCalendar( sentSyncFile() ); 2075 mView->saveCalendar( sentSyncFile() );
2072 setCaption(i18n("Data saved to temp file!" )); 2076 setCaption(i18n("Data saved to temp file!" ));
2073 2077
2074} 2078}
2075void MainWindow::getFile( bool success ) 2079void MainWindow::getFile( bool success )
2076{ 2080{
2077 if ( ! success ) { 2081 if ( ! success ) {
2078 setCaption( i18n("Error receiving file. Nothing changed!") ); 2082 setCaption( i18n("Error receiving file. Nothing changed!") );
2079 return; 2083 return;
2080 } 2084 }
2081 mView->openCalendar( sentSyncFile() ); 2085 mView->openCalendar( sentSyncFile() );
2082 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2086 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2083 mSyncManager->slotSyncMenu( 999 ); 2087 mSyncManager->slotSyncMenu( 999 );
2084 } 2088 }
2085 setCaption( i18n("Pi-Sync successful!") ); 2089 setCaption( i18n("Pi-Sync successful!") );
2086} 2090}
2087 2091
2088void MainWindow::printSel( ) 2092void MainWindow::printSel( )
2089{ 2093{
2090 mView->viewManager()->agendaView()->agenda()->printSelection(); 2094 mView->viewManager()->agendaView()->agenda()->printSelection();
2091} 2095}
2092 2096
2093void MainWindow::printCal() 2097void MainWindow::printCal()
2094{ 2098{
2095 mView->print();//mCp->showDialog(); 2099 mView->print();//mCp->showDialog();
2096} 2100}
2097 2101
2098 2102
2099#include "libkdepim/kdatepicker.h" 2103#include "libkdepim/kdatepicker.h"
2100#include <kdatetbl.h> 2104#include <kdatetbl.h>
2101void MainWindow::weekAction() 2105void MainWindow::weekAction()
2102{ 2106{
2103 int month; 2107 int month;
2104 KPopupFrame* popup = new KPopupFrame(this); 2108 KPopupFrame* popup = new KPopupFrame(this);
2105 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2109 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2106 // ----- 2110 // -----
2107 picker->resize(picker->sizeHint()); 2111 picker->resize(picker->sizeHint());
2108 popup->setMainWidget(picker); 2112 popup->setMainWidget(picker);
2109 picker->setFocus(); 2113 picker->setFocus();
2110 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2114 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2111 int x = 0; 2115 int x = 0;
2112 int y = iconToolBar->height(); 2116 int y = iconToolBar->height();
2113 int dX = 0; 2117 int dX = 0;
2114 int dY = 0; 2118 int dY = 0;
2115 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2119 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2116 if ( iconToolBar->y() > height()/2 ) { 2120 if ( iconToolBar->y() > height()/2 ) {
2117 dY = picker->sizeHint().height()+8; 2121 dY = picker->sizeHint().height()+8;
2118 y = 0; 2122 y = 0;
2119 } 2123 }
2120 } else { 2124 } else {
2121 if ( iconToolBar->x() > width()/2 ) { // right side 2125 if ( iconToolBar->x() > width()/2 ) { // right side
2122 x=0; 2126 x=0;
2123 dX= picker->sizeHint().width()+8; 2127 dX= picker->sizeHint().width()+8;
2124 y = 0; 2128 y = 0;
2125 } else { 2129 } else {
2126 x= iconToolBar->width(); 2130 x= iconToolBar->width();
2127 y = 0; 2131 y = 0;
2128 } 2132 }
2129 } 2133 }
2130 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2134 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2131 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2135 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2132 { 2136 {
2133 month = picker->getResult(); 2137 month = picker->getResult();
2134 emit selectWeek ( month ); 2138 emit selectWeek ( month );
2135 //qDebug("weekSelected %d ", month); 2139 //qDebug("weekSelected %d ", month);
2136 } 2140 }
2137 delete popup; 2141 delete popup;
2138} 2142}
2139 2143
2140void MainWindow::hideEvent ( QHideEvent * ) 2144void MainWindow::hideEvent ( QHideEvent * )
2141{ 2145{
2142 QString message; 2146 QString message;
2143 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2147 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2144 if ( nextA.isValid() ) { 2148 if ( nextA.isValid() ) {
2145 QString sum = mCalendar->nextSummary(); 2149 QString sum = mCalendar->nextSummary();
2146 2150
2147 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2151 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2148 setCaption( message ); 2152 setCaption( message );
2149 } 2153 }
2150} 2154}