author | zautrix <zautrix> | 2005-03-20 10:57:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-20 10:57:02 (UTC) |
commit | 289dd44f4f23d92c45d8f28c867a14a980fd5dde (patch) (unidiff) | |
tree | 0c27baeb80e563e191da2a75ce3b79bfeaeec051 /korganizer | |
parent | 1ebfa83d28d9eb3f48d8240e65212bbe22defb3c (diff) | |
download | kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.zip kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.tar.gz kdepimpi-289dd44f4f23d92c45d8f28c867a14a980fd5dde.tar.bz2 |
compile fix
-rw-r--r-- | korganizer/calendarview.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9acbbb1..3ce123c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -382,3095 +382,3085 @@ void CalendarView::init() | |||
382 | connect( mDateNavigator, SIGNAL( goNext() ), | 382 | connect( mDateNavigator, SIGNAL( goNext() ), |
383 | mNavigator, SLOT( selectNext() ) ); | 383 | mNavigator, SLOT( selectNext() ) ); |
384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
386 | 386 | ||
387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
389 | #if 0 | 389 | #if 0 |
390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
391 | SLOT( incidenceAdded( Incidence *) ) ); | 391 | SLOT( incidenceAdded( Incidence *) ) ); |
392 | #endif | 392 | #endif |
393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
394 | 394 | ||
395 | connect( this, SIGNAL( configChanged() ), | 395 | connect( this, SIGNAL( configChanged() ), |
396 | mDateNavigator, SLOT( updateConfig() ) ); | 396 | mDateNavigator, SLOT( updateConfig() ) ); |
397 | 397 | ||
398 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 398 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
399 | SLOT( newTodo() ) ); | 399 | SLOT( newTodo() ) ); |
400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
401 | SLOT( newSubTodo( Todo * ) ) ); | 401 | SLOT( newSubTodo( Todo * ) ) ); |
402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
403 | SLOT( editTodo( Todo * ) ) ); | 403 | SLOT( editTodo( Todo * ) ) ); |
404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
405 | SLOT( showTodo( Todo *) ) ); | 405 | SLOT( showTodo( Todo *) ) ); |
406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
407 | SLOT( deleteTodo( Todo *) ) ); | 407 | SLOT( deleteTodo( Todo *) ) ); |
408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
410 | SLOT( purgeCompleted() ) ); | 410 | SLOT( purgeCompleted() ) ); |
411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
412 | SIGNAL( todoModified( Todo *, int ) ) ); | 412 | SIGNAL( todoModified( Todo *, int ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
417 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 417 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
420 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 420 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
422 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 422 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
423 | 423 | ||
424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
425 | this, SLOT ( todo_unsub( Todo * ) ) ); | 425 | this, SLOT ( todo_unsub( Todo * ) ) ); |
426 | 426 | ||
427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
430 | SLOT( updateTodo( Todo *, int ) ) ); | 430 | SLOT( updateTodo( Todo *, int ) ) ); |
431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
433 | 433 | ||
434 | 434 | ||
435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
443 | 443 | ||
444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
445 | SLOT(checkClipboard())); | 445 | SLOT(checkClipboard())); |
446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
447 | SLOT( processTodoListSelection( Incidence * ) ) ); | 447 | SLOT( processTodoListSelection( Incidence * ) ) ); |
448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
449 | 449 | ||
450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
451 | 451 | ||
452 | mDateFrame = new QVBox(0,0,WType_Popup); | 452 | mDateFrame = new QVBox(0,0,WType_Popup); |
453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
455 | mDateFrame->setLineWidth(3); | 455 | mDateFrame->setLineWidth(3); |
456 | mDateFrame->hide(); | 456 | mDateFrame->hide(); |
457 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 457 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
459 | 459 | ||
460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
461 | 461 | ||
462 | mEventEditor = mDialogManager->getEventEditor(); | 462 | mEventEditor = mDialogManager->getEventEditor(); |
463 | mTodoEditor = mDialogManager->getTodoEditor(); | 463 | mTodoEditor = mDialogManager->getTodoEditor(); |
464 | 464 | ||
465 | mFlagEditDescription = false; | 465 | mFlagEditDescription = false; |
466 | 466 | ||
467 | mSuspendTimer = new QTimer( this ); | 467 | mSuspendTimer = new QTimer( this ); |
468 | mAlarmTimer = new QTimer( this ); | 468 | mAlarmTimer = new QTimer( this ); |
469 | mRecheckAlarmTimer = new QTimer( this ); | 469 | mRecheckAlarmTimer = new QTimer( this ); |
470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
473 | mAlarmDialog = new AlarmDialog( this ); | 473 | mAlarmDialog = new AlarmDialog( this ); |
474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
475 | mAlarmDialog->setServerNotification( false ); | 475 | mAlarmDialog->setServerNotification( false ); |
476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
477 | 477 | ||
478 | 478 | ||
479 | #ifndef DESKTOP_VERSION | 479 | #ifndef DESKTOP_VERSION |
480 | //US listen for arriving address resultsets | 480 | //US listen for arriving address resultsets |
481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
483 | #endif | 483 | #endif |
484 | mDateNavigator->setCalendar( mCalendar ); | 484 | mDateNavigator->setCalendar( mCalendar ); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | CalendarView::~CalendarView() | 488 | CalendarView::~CalendarView() |
489 | { | 489 | { |
490 | // kdDebug() << "~CalendarView()" << endl; | 490 | // kdDebug() << "~CalendarView()" << endl; |
491 | //qDebug("CalendarView::~CalendarView() "); | 491 | //qDebug("CalendarView::~CalendarView() "); |
492 | delete mDialogManager; | 492 | delete mDialogManager; |
493 | delete mViewManager; | 493 | delete mViewManager; |
494 | delete mStorage; | 494 | delete mStorage; |
495 | delete mDateFrame ; | 495 | delete mDateFrame ; |
496 | delete beamDialog; | 496 | delete beamDialog; |
497 | delete mEventViewerDialog; | 497 | delete mEventViewerDialog; |
498 | //kdDebug() << "~CalendarView() done" << endl; | 498 | //kdDebug() << "~CalendarView() done" << endl; |
499 | } | 499 | } |
500 | 500 | ||
501 | void CalendarView::showDay( QDate d ) | 501 | void CalendarView::showDay( QDate d ) |
502 | { | 502 | { |
503 | dateNavigator()->blockSignals( true ); | 503 | dateNavigator()->blockSignals( true ); |
504 | dateNavigator()->selectDate( d ); | 504 | dateNavigator()->selectDate( d ); |
505 | dateNavigator()->blockSignals( false ); | 505 | dateNavigator()->blockSignals( false ); |
506 | mViewManager->showDayView(); | 506 | mViewManager->showDayView(); |
507 | //dateNavigator()->selectDate( d ); | 507 | //dateNavigator()->selectDate( d ); |
508 | } | 508 | } |
509 | void CalendarView::timerAlarm() | 509 | void CalendarView::timerAlarm() |
510 | { | 510 | { |
511 | //qDebug("CalendarView::timerAlarm() "); | 511 | //qDebug("CalendarView::timerAlarm() "); |
512 | computeAlarm(mAlarmNotification ); | 512 | computeAlarm(mAlarmNotification ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void CalendarView::suspendAlarm() | 515 | void CalendarView::suspendAlarm() |
516 | { | 516 | { |
517 | //qDebug(" CalendarView::suspendAlarm() "); | 517 | //qDebug(" CalendarView::suspendAlarm() "); |
518 | computeAlarm(mSuspendAlarmNotification ); | 518 | computeAlarm(mSuspendAlarmNotification ); |
519 | 519 | ||
520 | } | 520 | } |
521 | 521 | ||
522 | void CalendarView::startAlarm( QString mess , QString filename) | 522 | void CalendarView::startAlarm( QString mess , QString filename) |
523 | { | 523 | { |
524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | void CalendarView::checkNextTimerAlarm() | 529 | void CalendarView::checkNextTimerAlarm() |
530 | { | 530 | { |
531 | mCalendar->checkAlarmForIncidence( 0, true ); | 531 | mCalendar->checkAlarmForIncidence( 0, true ); |
532 | } | 532 | } |
533 | 533 | ||
534 | void CalendarView::computeAlarm( QString msg ) | 534 | void CalendarView::computeAlarm( QString msg ) |
535 | { | 535 | { |
536 | 536 | ||
537 | QString mess = msg; | 537 | QString mess = msg; |
538 | QString mAlarmMessage = mess.mid( 9 ); | 538 | QString mAlarmMessage = mess.mid( 9 ); |
539 | QString filename = MainWindow::resourcePath(); | 539 | QString filename = MainWindow::resourcePath(); |
540 | filename += "koalarm.wav"; | 540 | filename += "koalarm.wav"; |
541 | QString tempfilename; | 541 | QString tempfilename; |
542 | if ( mess.left( 13 ) == "suspend_alarm") { | 542 | if ( mess.left( 13 ) == "suspend_alarm") { |
543 | bool error = false; | 543 | bool error = false; |
544 | int len = mess.mid( 13 ).find("+++"); | 544 | int len = mess.mid( 13 ).find("+++"); |
545 | if ( len < 2 ) | 545 | if ( len < 2 ) |
546 | error = true; | 546 | error = true; |
547 | else { | 547 | else { |
548 | tempfilename = mess.mid( 13, len ); | 548 | tempfilename = mess.mid( 13, len ); |
549 | if ( !QFile::exists( tempfilename ) ) | 549 | if ( !QFile::exists( tempfilename ) ) |
550 | error = true; | 550 | error = true; |
551 | } | 551 | } |
552 | if ( ! error ) { | 552 | if ( ! error ) { |
553 | filename = tempfilename; | 553 | filename = tempfilename; |
554 | } | 554 | } |
555 | mAlarmMessage = mess.mid( 13+len+3 ); | 555 | mAlarmMessage = mess.mid( 13+len+3 ); |
556 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 556 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
557 | startAlarm( mAlarmMessage, filename); | 557 | startAlarm( mAlarmMessage, filename); |
558 | return; | 558 | return; |
559 | } | 559 | } |
560 | if ( mess.left( 11 ) == "timer_alarm") { | 560 | if ( mess.left( 11 ) == "timer_alarm") { |
561 | //mTimerTime = 0; | 561 | //mTimerTime = 0; |
562 | startAlarm( mess.mid( 11 ), filename ); | 562 | startAlarm( mess.mid( 11 ), filename ); |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | if ( mess.left( 10 ) == "proc_alarm") { | 565 | if ( mess.left( 10 ) == "proc_alarm") { |
566 | bool error = false; | 566 | bool error = false; |
567 | int len = mess.mid( 10 ).find("+++"); | 567 | int len = mess.mid( 10 ).find("+++"); |
568 | if ( len < 2 ) | 568 | if ( len < 2 ) |
569 | error = true; | 569 | error = true; |
570 | else { | 570 | else { |
571 | tempfilename = mess.mid( 10, len ); | 571 | tempfilename = mess.mid( 10, len ); |
572 | if ( !QFile::exists( tempfilename ) ) | 572 | if ( !QFile::exists( tempfilename ) ) |
573 | error = true; | 573 | error = true; |
574 | } | 574 | } |
575 | if ( error ) { | 575 | if ( error ) { |
576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
577 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 577 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
578 | } else { | 578 | } else { |
579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
580 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 580 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
581 | #ifndef _WIN32_ | 581 | #ifndef _WIN32_ |
582 | if ( vfork () == 0 ) { | 582 | if ( vfork () == 0 ) { |
583 | execl ( tempfilename.latin1(), 0 ); | 583 | execl ( tempfilename.latin1(), 0 ); |
584 | return; | 584 | return; |
585 | } | 585 | } |
586 | #else | 586 | #else |
587 | QProcess* p = new QProcess(); | 587 | QProcess* p = new QProcess(); |
588 | p->addArgument( tempfilename.latin1() ); | 588 | p->addArgument( tempfilename.latin1() ); |
589 | p->start(); | 589 | p->start(); |
590 | return; | 590 | return; |
591 | #endif | 591 | #endif |
592 | 592 | ||
593 | return; | 593 | return; |
594 | } | 594 | } |
595 | 595 | ||
596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
597 | } | 597 | } |
598 | if ( mess.left( 11 ) == "audio_alarm") { | 598 | if ( mess.left( 11 ) == "audio_alarm") { |
599 | bool error = false; | 599 | bool error = false; |
600 | int len = mess.mid( 11 ).find("+++"); | 600 | int len = mess.mid( 11 ).find("+++"); |
601 | if ( len < 2 ) | 601 | if ( len < 2 ) |
602 | error = true; | 602 | error = true; |
603 | else { | 603 | else { |
604 | tempfilename = mess.mid( 11, len ); | 604 | tempfilename = mess.mid( 11, len ); |
605 | if ( !QFile::exists( tempfilename ) ) | 605 | if ( !QFile::exists( tempfilename ) ) |
606 | error = true; | 606 | error = true; |
607 | } | 607 | } |
608 | if ( ! error ) { | 608 | if ( ! error ) { |
609 | filename = tempfilename; | 609 | filename = tempfilename; |
610 | } | 610 | } |
611 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 611 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
612 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 612 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
613 | } | 613 | } |
614 | if ( mess.left( 9 ) == "cal_alarm") { | 614 | if ( mess.left( 9 ) == "cal_alarm") { |
615 | mAlarmMessage = mess.mid( 9 ) ; | 615 | mAlarmMessage = mess.mid( 9 ) ; |
616 | } | 616 | } |
617 | 617 | ||
618 | startAlarm( mAlarmMessage, filename ); | 618 | startAlarm( mAlarmMessage, filename ); |
619 | 619 | ||
620 | 620 | ||
621 | } | 621 | } |
622 | 622 | ||
623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
624 | { | 624 | { |
625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
626 | 626 | ||
627 | mSuspendAlarmNotification = noti; | 627 | mSuspendAlarmNotification = noti; |
628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
630 | mSuspendTimer->start( ms , true ); | 630 | mSuspendTimer->start( ms , true ); |
631 | 631 | ||
632 | } | 632 | } |
633 | 633 | ||
634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
635 | { | 635 | { |
636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
640 | #endif | 640 | #endif |
641 | return; | 641 | return; |
642 | } | 642 | } |
643 | int maxSec; | 643 | int maxSec; |
644 | //maxSec = 5; //testing only | 644 | //maxSec = 5; //testing only |
645 | maxSec = 86400+3600; // one day+1hour | 645 | maxSec = 86400+3600; // one day+1hour |
646 | mAlarmNotification = noti; | 646 | mAlarmNotification = noti; |
647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
648 | if ( sec > maxSec ) { | 648 | if ( sec > maxSec ) { |
649 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 649 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
651 | return; | 651 | return; |
652 | } else { | 652 | } else { |
653 | mRecheckAlarmTimer->stop(); | 653 | mRecheckAlarmTimer->stop(); |
654 | } | 654 | } |
655 | //qDebug("Alarm timer started with secs: %d ", sec); | 655 | //qDebug("Alarm timer started with secs: %d ", sec); |
656 | mAlarmTimer->start( sec *1000 , true ); | 656 | mAlarmTimer->start( sec *1000 , true ); |
657 | 657 | ||
658 | } | 658 | } |
659 | // called by mRecheckAlarmTimer to get next alarm | 659 | // called by mRecheckAlarmTimer to get next alarm |
660 | // we need this, because a QTimer has only a max range of 25 days | 660 | // we need this, because a QTimer has only a max range of 25 days |
661 | void CalendarView::recheckTimerAlarm() | 661 | void CalendarView::recheckTimerAlarm() |
662 | { | 662 | { |
663 | mAlarmTimer->stop(); | 663 | mAlarmTimer->stop(); |
664 | mRecheckAlarmTimer->stop(); | 664 | mRecheckAlarmTimer->stop(); |
665 | mCalendar->checkAlarmForIncidence( 0, true ); | 665 | mCalendar->checkAlarmForIncidence( 0, true ); |
666 | } | 666 | } |
667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
668 | { | 668 | { |
669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
671 | #ifndef DESKTOP_VERSION | 671 | #ifndef DESKTOP_VERSION |
672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
673 | #endif | 673 | #endif |
674 | return; | 674 | return; |
675 | } | 675 | } |
676 | mAlarmTimer->stop(); | 676 | mAlarmTimer->stop(); |
677 | } | 677 | } |
678 | void CalendarView::selectWeekNum ( int num ) | 678 | void CalendarView::selectWeekNum ( int num ) |
679 | { | 679 | { |
680 | dateNavigator()->blockSignals( true ); | 680 | dateNavigator()->blockSignals( true ); |
681 | dateNavigator()->selectWeek( num ); | 681 | dateNavigator()->selectWeek( num ); |
682 | dateNavigator()->blockSignals( false ); | 682 | dateNavigator()->blockSignals( false ); |
683 | mViewManager->showWeekView(); | 683 | mViewManager->showWeekView(); |
684 | } | 684 | } |
685 | KOViewManager *CalendarView::viewManager() | 685 | KOViewManager *CalendarView::viewManager() |
686 | { | 686 | { |
687 | return mViewManager; | 687 | return mViewManager; |
688 | } | 688 | } |
689 | 689 | ||
690 | KODialogManager *CalendarView::dialogManager() | 690 | KODialogManager *CalendarView::dialogManager() |
691 | { | 691 | { |
692 | return mDialogManager; | 692 | return mDialogManager; |
693 | } | 693 | } |
694 | 694 | ||
695 | QDate CalendarView::startDate() | 695 | QDate CalendarView::startDate() |
696 | { | 696 | { |
697 | DateList dates = mNavigator->selectedDates(); | 697 | DateList dates = mNavigator->selectedDates(); |
698 | 698 | ||
699 | return dates.first(); | 699 | return dates.first(); |
700 | } | 700 | } |
701 | 701 | ||
702 | QDate CalendarView::endDate() | 702 | QDate CalendarView::endDate() |
703 | { | 703 | { |
704 | DateList dates = mNavigator->selectedDates(); | 704 | DateList dates = mNavigator->selectedDates(); |
705 | 705 | ||
706 | return dates.last(); | 706 | return dates.last(); |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | void CalendarView::createPrinter() | 710 | void CalendarView::createPrinter() |
711 | { | 711 | { |
712 | #ifndef KORG_NOPRINTER | 712 | #ifndef KORG_NOPRINTER |
713 | if (!mCalPrinter) { | 713 | if (!mCalPrinter) { |
714 | mCalPrinter = new CalPrinter(this, mCalendar); | 714 | mCalPrinter = new CalPrinter(this, mCalendar); |
715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
716 | } | 716 | } |
717 | #endif | 717 | #endif |
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | //KOPrefs::instance()->mWriteBackFile | 721 | //KOPrefs::instance()->mWriteBackFile |
722 | //KOPrefs::instance()->mWriteBackExistingOnly | 722 | //KOPrefs::instance()->mWriteBackExistingOnly |
723 | 723 | ||
724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
730 | 730 | ||
731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
732 | { | 732 | { |
733 | 733 | ||
734 | // 0 equal | 734 | // 0 equal |
735 | // 1 take local | 735 | // 1 take local |
736 | // 2 take remote | 736 | // 2 take remote |
737 | // 3 cancel | 737 | // 3 cancel |
738 | QDateTime lastSync = mLastCalendarSync; | 738 | QDateTime lastSync = mLastCalendarSync; |
739 | QDateTime localMod = local->lastModified(); | 739 | QDateTime localMod = local->lastModified(); |
740 | QDateTime remoteMod = remote->lastModified(); | 740 | QDateTime remoteMod = remote->lastModified(); |
741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
742 | bool remCh, locCh; | 742 | bool remCh, locCh; |
743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
744 | //if ( remCh ) | 744 | //if ( remCh ) |
745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
746 | locCh = ( localMod > mLastCalendarSync ); | 746 | locCh = ( localMod > mLastCalendarSync ); |
747 | if ( !remCh && ! locCh ) { | 747 | if ( !remCh && ! locCh ) { |
748 | //qDebug("both not changed "); | 748 | //qDebug("both not changed "); |
749 | lastSync = localMod.addDays(1); | 749 | lastSync = localMod.addDays(1); |
750 | if ( mode <= SYNC_PREF_ASK ) | 750 | if ( mode <= SYNC_PREF_ASK ) |
751 | return 0; | 751 | return 0; |
752 | } else { | 752 | } else { |
753 | if ( locCh ) { | 753 | if ( locCh ) { |
754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
755 | lastSync = localMod.addDays( -1 ); | 755 | lastSync = localMod.addDays( -1 ); |
756 | if ( !remCh ) | 756 | if ( !remCh ) |
757 | remoteMod = ( lastSync.addDays( -1 ) ); | 757 | remoteMod = ( lastSync.addDays( -1 ) ); |
758 | } else { | 758 | } else { |
759 | //qDebug(" not loc changed "); | 759 | //qDebug(" not loc changed "); |
760 | lastSync = localMod.addDays( 1 ); | 760 | lastSync = localMod.addDays( 1 ); |
761 | if ( remCh ) | 761 | if ( remCh ) |
762 | remoteMod =( lastSync.addDays( 1 ) ); | 762 | remoteMod =( lastSync.addDays( 1 ) ); |
763 | 763 | ||
764 | } | 764 | } |
765 | } | 765 | } |
766 | full = true; | 766 | full = true; |
767 | if ( mode < SYNC_PREF_ASK ) | 767 | if ( mode < SYNC_PREF_ASK ) |
768 | mode = SYNC_PREF_ASK; | 768 | mode = SYNC_PREF_ASK; |
769 | } else { | 769 | } else { |
770 | if ( localMod == remoteMod ) | 770 | if ( localMod == remoteMod ) |
771 | // if ( local->revision() == remote->revision() ) | 771 | // if ( local->revision() == remote->revision() ) |
772 | return 0; | 772 | return 0; |
773 | 773 | ||
774 | } | 774 | } |
775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
776 | 776 | ||
777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
779 | //full = true; //debug only | 779 | //full = true; //debug only |
780 | if ( full ) { | 780 | if ( full ) { |
781 | bool equ = false; | 781 | bool equ = false; |
782 | if ( local->type() == "Event" ) { | 782 | if ( local->type() == "Event" ) { |
783 | equ = (*((Event*) local) == *((Event*) remote)); | 783 | equ = (*((Event*) local) == *((Event*) remote)); |
784 | } | 784 | } |
785 | else if ( local->type() =="Todo" ) | 785 | else if ( local->type() =="Todo" ) |
786 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 786 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
787 | else if ( local->type() =="Journal" ) | 787 | else if ( local->type() =="Journal" ) |
788 | equ = (*((Journal*) local) == *((Journal*) remote)); | 788 | equ = (*((Journal*) local) == *((Journal*) remote)); |
789 | if ( equ ) { | 789 | if ( equ ) { |
790 | //qDebug("equal "); | 790 | //qDebug("equal "); |
791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
793 | } | 793 | } |
794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
795 | return 0; | 795 | return 0; |
796 | 796 | ||
797 | }//else //debug only | 797 | }//else //debug only |
798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
799 | } | 799 | } |
800 | int result; | 800 | int result; |
801 | bool localIsNew; | 801 | bool localIsNew; |
802 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 802 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
803 | 803 | ||
804 | if ( full && mode < SYNC_PREF_NEWEST ) | 804 | if ( full && mode < SYNC_PREF_NEWEST ) |
805 | mode = SYNC_PREF_ASK; | 805 | mode = SYNC_PREF_ASK; |
806 | 806 | ||
807 | switch( mode ) { | 807 | switch( mode ) { |
808 | case SYNC_PREF_LOCAL: | 808 | case SYNC_PREF_LOCAL: |
809 | if ( lastSync > remoteMod ) | 809 | if ( lastSync > remoteMod ) |
810 | return 1; | 810 | return 1; |
811 | if ( lastSync > localMod ) | 811 | if ( lastSync > localMod ) |
812 | return 2; | 812 | return 2; |
813 | return 1; | 813 | return 1; |
814 | break; | 814 | break; |
815 | case SYNC_PREF_REMOTE: | 815 | case SYNC_PREF_REMOTE: |
816 | if ( lastSync > remoteMod ) | 816 | if ( lastSync > remoteMod ) |
817 | return 1; | 817 | return 1; |
818 | if ( lastSync > localMod ) | 818 | if ( lastSync > localMod ) |
819 | return 2; | 819 | return 2; |
820 | return 2; | 820 | return 2; |
821 | break; | 821 | break; |
822 | case SYNC_PREF_NEWEST: | 822 | case SYNC_PREF_NEWEST: |
823 | if ( localMod > remoteMod ) | 823 | if ( localMod > remoteMod ) |
824 | return 1; | 824 | return 1; |
825 | else | 825 | else |
826 | return 2; | 826 | return 2; |
827 | break; | 827 | break; |
828 | case SYNC_PREF_ASK: | 828 | case SYNC_PREF_ASK: |
829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
830 | if ( lastSync > remoteMod ) | 830 | if ( lastSync > remoteMod ) |
831 | return 1; | 831 | return 1; |
832 | if ( lastSync > localMod ) | 832 | if ( lastSync > localMod ) |
833 | return 2; | 833 | return 2; |
834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
835 | localIsNew = localMod >= remoteMod; | 835 | localIsNew = localMod >= remoteMod; |
836 | if ( localIsNew ) | 836 | if ( localIsNew ) |
837 | getEventViewerDialog()->setColorMode( 1 ); | 837 | getEventViewerDialog()->setColorMode( 1 ); |
838 | else | 838 | else |
839 | getEventViewerDialog()->setColorMode( 2 ); | 839 | getEventViewerDialog()->setColorMode( 2 ); |
840 | getEventViewerDialog()->setIncidence(local); | 840 | getEventViewerDialog()->setIncidence(local); |
841 | if ( localIsNew ) | 841 | if ( localIsNew ) |
842 | getEventViewerDialog()->setColorMode( 2 ); | 842 | getEventViewerDialog()->setColorMode( 2 ); |
843 | else | 843 | else |
844 | getEventViewerDialog()->setColorMode( 1 ); | 844 | getEventViewerDialog()->setColorMode( 1 ); |
845 | getEventViewerDialog()->addIncidence(remote); | 845 | getEventViewerDialog()->addIncidence(remote); |
846 | getEventViewerDialog()->setColorMode( 0 ); | 846 | getEventViewerDialog()->setColorMode( 0 ); |
847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
849 | getEventViewerDialog()->showMe(); | 849 | getEventViewerDialog()->showMe(); |
850 | result = getEventViewerDialog()->executeS( localIsNew ); | 850 | result = getEventViewerDialog()->executeS( localIsNew ); |
851 | return result; | 851 | return result; |
852 | 852 | ||
853 | break; | 853 | break; |
854 | case SYNC_PREF_FORCE_LOCAL: | 854 | case SYNC_PREF_FORCE_LOCAL: |
855 | return 1; | 855 | return 1; |
856 | break; | 856 | break; |
857 | case SYNC_PREF_FORCE_REMOTE: | 857 | case SYNC_PREF_FORCE_REMOTE: |
858 | return 2; | 858 | return 2; |
859 | break; | 859 | break; |
860 | 860 | ||
861 | default: | 861 | default: |
862 | // SYNC_PREF_TAKE_BOTH not implemented | 862 | // SYNC_PREF_TAKE_BOTH not implemented |
863 | break; | 863 | break; |
864 | } | 864 | } |
865 | return 0; | 865 | return 0; |
866 | } | 866 | } |
867 | Event* CalendarView::getLastSyncEvent() | 867 | Event* CalendarView::getLastSyncEvent() |
868 | { | 868 | { |
869 | Event* lse; | 869 | Event* lse; |
870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
872 | if (!lse) { | 872 | if (!lse) { |
873 | lse = new Event(); | 873 | lse = new Event(); |
874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
875 | QString sum = ""; | 875 | QString sum = ""; |
876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
877 | sum = "E: "; | 877 | sum = "E: "; |
878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
879 | lse->setDtStart( mLastCalendarSync ); | 879 | lse->setDtStart( mLastCalendarSync ); |
880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
881 | lse->setCategories( i18n("SyncEvent") ); | 881 | lse->setCategories( i18n("SyncEvent") ); |
882 | lse->setReadOnly( true ); | 882 | lse->setReadOnly( true ); |
883 | mCalendar->addEvent( lse ); | 883 | mCalendar->addEvent( lse ); |
884 | } | 884 | } |
885 | 885 | ||
886 | return lse; | 886 | return lse; |
887 | 887 | ||
888 | } | 888 | } |
889 | 889 | ||
890 | // we check, if the to delete event has a id for a profile | 890 | // we check, if the to delete event has a id for a profile |
891 | // if yes, we set this id in the profile to delete | 891 | // if yes, we set this id in the profile to delete |
892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
893 | { | 893 | { |
894 | if ( lastSync.count() == 0 ) { | 894 | if ( lastSync.count() == 0 ) { |
895 | //qDebug(" lastSync.count() == 0"); | 895 | //qDebug(" lastSync.count() == 0"); |
896 | return; | 896 | return; |
897 | } | 897 | } |
898 | if ( toDelete->type() == "Journal" ) | 898 | if ( toDelete->type() == "Journal" ) |
899 | return; | 899 | return; |
900 | 900 | ||
901 | Event* eve = lastSync.first(); | 901 | Event* eve = lastSync.first(); |
902 | 902 | ||
903 | while ( eve ) { | 903 | while ( eve ) { |
904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
905 | if ( !id.isEmpty() ) { | 905 | if ( !id.isEmpty() ) { |
906 | QString des = eve->description(); | 906 | QString des = eve->description(); |
907 | QString pref = "e"; | 907 | QString pref = "e"; |
908 | if ( toDelete->type() == "Todo" ) | 908 | if ( toDelete->type() == "Todo" ) |
909 | pref = "t"; | 909 | pref = "t"; |
910 | des += pref+ id + ","; | 910 | des += pref+ id + ","; |
911 | eve->setReadOnly( false ); | 911 | eve->setReadOnly( false ); |
912 | eve->setDescription( des ); | 912 | eve->setDescription( des ); |
913 | //qDebug("setdes %s ", des.latin1()); | 913 | //qDebug("setdes %s ", des.latin1()); |
914 | eve->setReadOnly( true ); | 914 | eve->setReadOnly( true ); |
915 | } | 915 | } |
916 | eve = lastSync.next(); | 916 | eve = lastSync.next(); |
917 | } | 917 | } |
918 | 918 | ||
919 | } | 919 | } |
920 | void CalendarView::checkExternalId( Incidence * inc ) | 920 | void CalendarView::checkExternalId( Incidence * inc ) |
921 | { | 921 | { |
922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
923 | checkExternSyncEvent( lastSync, inc ); | 923 | checkExternSyncEvent( lastSync, inc ); |
924 | 924 | ||
925 | } | 925 | } |
926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
927 | { | 927 | { |
928 | bool syncOK = true; | 928 | bool syncOK = true; |
929 | int addedEvent = 0; | 929 | int addedEvent = 0; |
930 | int addedEventR = 0; | 930 | int addedEventR = 0; |
931 | int deletedEventR = 0; | 931 | int deletedEventR = 0; |
932 | int deletedEventL = 0; | 932 | int deletedEventL = 0; |
933 | int changedLocal = 0; | 933 | int changedLocal = 0; |
934 | int changedRemote = 0; | 934 | int changedRemote = 0; |
935 | int filteredIN = 0; | 935 | int filteredIN = 0; |
936 | int filteredOUT = 0; | 936 | int filteredOUT = 0; |
937 | //QPtrList<Event> el = local->rawEvents(); | 937 | //QPtrList<Event> el = local->rawEvents(); |
938 | Event* eventR; | 938 | Event* eventR; |
939 | QString uid; | 939 | QString uid; |
940 | int take; | 940 | int take; |
941 | Event* eventL; | 941 | Event* eventL; |
942 | Event* eventRSync; | 942 | Event* eventRSync; |
943 | Event* eventLSync; | 943 | Event* eventLSync; |
944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
946 | bool fullDateRange = false; | 946 | bool fullDateRange = false; |
947 | local->resetTempSyncStat(); | 947 | local->resetTempSyncStat(); |
948 | mLastCalendarSync = QDateTime::currentDateTime(); | 948 | mLastCalendarSync = QDateTime::currentDateTime(); |
949 | if ( mSyncManager->syncWithDesktop() ) { | 949 | if ( mSyncManager->syncWithDesktop() ) { |
950 | remote->resetPilotStat(1); | 950 | remote->resetPilotStat(1); |
951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
954 | } else { | 954 | } else { |
955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
956 | } | 956 | } |
957 | } | 957 | } |
958 | QDateTime modifiedCalendar = mLastCalendarSync; | 958 | QDateTime modifiedCalendar = mLastCalendarSync; |
959 | eventLSync = getLastSyncEvent(); | 959 | eventLSync = getLastSyncEvent(); |
960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
961 | if ( eventR ) { | 961 | if ( eventR ) { |
962 | eventRSync = (Event*) eventR->clone(); | 962 | eventRSync = (Event*) eventR->clone(); |
963 | remote->deleteEvent(eventR ); | 963 | remote->deleteEvent(eventR ); |
964 | 964 | ||
965 | } else { | 965 | } else { |
966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
967 | eventRSync = (Event*)eventLSync->clone(); | 967 | eventRSync = (Event*)eventLSync->clone(); |
968 | } else { | 968 | } else { |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | eventRSync = new Event(); | 970 | eventRSync = new Event(); |
971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
973 | eventRSync->setDtStart( mLastCalendarSync ); | 973 | eventRSync->setDtStart( mLastCalendarSync ); |
974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
975 | eventRSync->setCategories( i18n("SyncEvent") ); | 975 | eventRSync->setCategories( i18n("SyncEvent") ); |
976 | } | 976 | } |
977 | } | 977 | } |
978 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 978 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
979 | fullDateRange = true; | 979 | fullDateRange = true; |
980 | 980 | ||
981 | if ( ! fullDateRange ) { | 981 | if ( ! fullDateRange ) { |
982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
983 | 983 | ||
984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
986 | fullDateRange = true; | 986 | fullDateRange = true; |
987 | } | 987 | } |
988 | } | 988 | } |
989 | if ( mSyncManager->syncWithDesktop() ) { | 989 | if ( mSyncManager->syncWithDesktop() ) { |
990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
991 | } | 991 | } |
992 | if ( fullDateRange ) | 992 | if ( fullDateRange ) |
993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
994 | else | 994 | else |
995 | mLastCalendarSync = eventLSync->dtStart(); | 995 | mLastCalendarSync = eventLSync->dtStart(); |
996 | // for resyncing if own file has changed | 996 | // for resyncing if own file has changed |
997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
998 | mLastCalendarSync = loadedFileVersion; | 998 | mLastCalendarSync = loadedFileVersion; |
999 | //qDebug("setting mLastCalendarSync "); | 999 | //qDebug("setting mLastCalendarSync "); |
1000 | } | 1000 | } |
1001 | //qDebug("*************************** "); | 1001 | //qDebug("*************************** "); |
1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1003 | QPtrList<Incidence> er = remote->rawIncidences(); | 1003 | QPtrList<Incidence> er = remote->rawIncidences(); |
1004 | Incidence* inR = er.first(); | 1004 | Incidence* inR = er.first(); |
1005 | Incidence* inL; | 1005 | Incidence* inL; |
1006 | QProgressBar bar( er.count(),0 ); | 1006 | QProgressBar bar( er.count(),0 ); |
1007 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1007 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1008 | 1008 | ||
1009 | // ************** setting up filter ************* | 1009 | // ************** setting up filter ************* |
1010 | CalFilter *filterIN = 0; | 1010 | CalFilter *filterIN = 0; |
1011 | CalFilter *filterOUT = 0; | 1011 | CalFilter *filterOUT = 0; |
1012 | CalFilter *filter = mFilters.first(); | 1012 | CalFilter *filter = mFilters.first(); |
1013 | while(filter) { | 1013 | while(filter) { |
1014 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1015 | filterIN = filter; | 1015 | filterIN = filter; |
1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1017 | filterOUT = filter; | 1017 | filterOUT = filter; |
1018 | filter = mFilters.next(); | 1018 | filter = mFilters.next(); |
1019 | } | 1019 | } |
1020 | int w = 300; | 1020 | int w = 300; |
1021 | if ( QApplication::desktop()->width() < 320 ) | 1021 | if ( QApplication::desktop()->width() < 320 ) |
1022 | w = 220; | 1022 | w = 220; |
1023 | int h = bar.sizeHint().height() ; | 1023 | int h = bar.sizeHint().height() ; |
1024 | int dw = QApplication::desktop()->width(); | 1024 | int dw = QApplication::desktop()->width(); |
1025 | int dh = QApplication::desktop()->height(); | 1025 | int dh = QApplication::desktop()->height(); |
1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1027 | bar.show(); | 1027 | bar.show(); |
1028 | int modulo = (er.count()/10)+1; | 1028 | int modulo = (er.count()/10)+1; |
1029 | int incCounter = 0; | 1029 | int incCounter = 0; |
1030 | while ( inR ) { | 1030 | while ( inR ) { |
1031 | if ( ! bar.isVisible() ) | 1031 | if ( ! bar.isVisible() ) |
1032 | return false; | 1032 | return false; |
1033 | if ( incCounter % modulo == 0 ) | 1033 | if ( incCounter % modulo == 0 ) |
1034 | bar.setProgress( incCounter ); | 1034 | bar.setProgress( incCounter ); |
1035 | ++incCounter; | 1035 | ++incCounter; |
1036 | uid = inR->uid(); | 1036 | uid = inR->uid(); |
1037 | bool skipIncidence = false; | 1037 | bool skipIncidence = false; |
1038 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1038 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1039 | skipIncidence = true; | 1039 | skipIncidence = true; |
1040 | QString idS; | 1040 | QString idS; |
1041 | qApp->processEvents(); | 1041 | qApp->processEvents(); |
1042 | if ( !skipIncidence ) { | 1042 | if ( !skipIncidence ) { |
1043 | inL = local->incidence( uid ); | 1043 | inL = local->incidence( uid ); |
1044 | if ( inL ) { // maybe conflict - same uid in both calendars | 1044 | if ( inL ) { // maybe conflict - same uid in both calendars |
1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1047 | if ( take == 3 ) | 1047 | if ( take == 3 ) |
1048 | return false; | 1048 | return false; |
1049 | if ( take == 1 ) {// take local ********************** | 1049 | if ( take == 1 ) {// take local ********************** |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1052 | else | 1052 | else |
1053 | idS = inR->IDStr(); | 1053 | idS = inR->IDStr(); |
1054 | remote->deleteIncidence( inR ); | 1054 | remote->deleteIncidence( inR ); |
1055 | inR = inL->clone(); | 1055 | inR = inL->clone(); |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1058 | inR->setIDStr( idS ); | 1058 | inR->setIDStr( idS ); |
1059 | remote->addIncidence( inR ); | 1059 | remote->addIncidence( inR ); |
1060 | if ( mSyncManager->syncWithDesktop() ) | 1060 | if ( mSyncManager->syncWithDesktop() ) |
1061 | inR->setPilotId( 2 ); | 1061 | inR->setPilotId( 2 ); |
1062 | ++changedRemote; | 1062 | ++changedRemote; |
1063 | } else {// take remote ********************** | 1063 | } else {// take remote ********************** |
1064 | idS = inL->IDStr(); | 1064 | idS = inL->IDStr(); |
1065 | int pid = inL->pilotId(); | 1065 | int pid = inL->pilotId(); |
1066 | local->deleteIncidence( inL ); | 1066 | local->deleteIncidence( inL ); |
1067 | inL = inR->clone(); | 1067 | inL = inR->clone(); |
1068 | if ( mSyncManager->syncWithDesktop() ) | 1068 | if ( mSyncManager->syncWithDesktop() ) |
1069 | inL->setPilotId( pid ); | 1069 | inL->setPilotId( pid ); |
1070 | inL->setIDStr( idS ); | 1070 | inL->setIDStr( idS ); |
1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1074 | } | 1074 | } |
1075 | local->addIncidence( inL ); | 1075 | local->addIncidence( inL ); |
1076 | ++changedLocal; | 1076 | ++changedLocal; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } else { // no conflict ********** add or delete remote | 1079 | } else { // no conflict ********** add or delete remote |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1082 | QString des = eventLSync->description(); | 1082 | QString des = eventLSync->description(); |
1083 | QString pref = "e"; | 1083 | QString pref = "e"; |
1084 | if ( inR->type() == "Todo" ) | 1084 | if ( inR->type() == "Todo" ) |
1085 | pref = "t"; | 1085 | pref = "t"; |
1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1088 | //remote->deleteIncidence( inR ); | 1088 | //remote->deleteIncidence( inR ); |
1089 | ++deletedEventR; | 1089 | ++deletedEventR; |
1090 | } else { | 1090 | } else { |
1091 | inR->setLastModified( modifiedCalendar ); | 1091 | inR->setLastModified( modifiedCalendar ); |
1092 | inL = inR->clone(); | 1092 | inL = inR->clone(); |
1093 | inL->setIDStr( ":" ); | 1093 | inL->setIDStr( ":" ); |
1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1096 | local->addIncidence( inL ); | 1096 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1097 | ++addedEvent; |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | } else { | 1100 | } else { |
1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1102 | inR->setLastModified( modifiedCalendar ); | 1102 | inR->setLastModified( modifiedCalendar ); |
1103 | inL = inR->clone(); | 1103 | inL = inR->clone(); |
1104 | inL->setIDStr( ":" ); | 1104 | inL->setIDStr( ":" ); |
1105 | local->addIncidence( inL ); | 1105 | local->addIncidence( inL ); |
1106 | ++addedEvent; | 1106 | ++addedEvent; |
1107 | 1107 | ||
1108 | } else { | 1108 | } else { |
1109 | checkExternSyncEvent(eventRSyncSharp, inR); | 1109 | checkExternSyncEvent(eventRSyncSharp, inR); |
1110 | remote->deleteIncidence( inR ); | 1110 | remote->deleteIncidence( inR ); |
1111 | ++deletedEventR; | 1111 | ++deletedEventR; |
1112 | } | 1112 | } |
1113 | } | 1113 | } |
1114 | } else { | 1114 | } else { |
1115 | ++filteredIN; | 1115 | ++filteredIN; |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | inR = er.next(); | 1119 | inR = er.next(); |
1120 | } | 1120 | } |
1121 | QPtrList<Incidence> el = local->rawIncidences(); | 1121 | QPtrList<Incidence> el = local->rawIncidences(); |
1122 | inL = el.first(); | 1122 | inL = el.first(); |
1123 | modulo = (el.count()/10)+1; | 1123 | modulo = (el.count()/10)+1; |
1124 | bar.setCaption (i18n("Add / remove events") ); | 1124 | bar.setCaption (i18n("Add / remove events") ); |
1125 | bar.setTotalSteps ( el.count() ) ; | 1125 | bar.setTotalSteps ( el.count() ) ; |
1126 | bar.show(); | 1126 | bar.show(); |
1127 | incCounter = 0; | 1127 | incCounter = 0; |
1128 | 1128 | ||
1129 | while ( inL ) { | 1129 | while ( inL ) { |
1130 | 1130 | ||
1131 | qApp->processEvents(); | 1131 | qApp->processEvents(); |
1132 | if ( ! bar.isVisible() ) | 1132 | if ( ! bar.isVisible() ) |
1133 | return false; | 1133 | return false; |
1134 | if ( incCounter % modulo == 0 ) | 1134 | if ( incCounter % modulo == 0 ) |
1135 | bar.setProgress( incCounter ); | 1135 | bar.setProgress( incCounter ); |
1136 | ++incCounter; | 1136 | ++incCounter; |
1137 | uid = inL->uid(); | 1137 | uid = inL->uid(); |
1138 | bool skipIncidence = false; | 1138 | bool skipIncidence = false; |
1139 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1139 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1140 | skipIncidence = true; | 1140 | skipIncidence = true; |
1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1142 | skipIncidence = true; | 1142 | skipIncidence = true; |
1143 | if ( !skipIncidence ) { | 1143 | if ( !skipIncidence ) { |
1144 | inR = remote->incidence( uid ); | 1144 | inR = remote->incidence( uid ); |
1145 | if ( ! inR ) { | 1145 | if ( ! inR ) { |
1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1147 | // no conflict ********** add or delete local | 1147 | // no conflict ********** add or delete local |
1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1150 | checkExternSyncEvent(eventLSyncSharp, inL); | 1150 | checkExternSyncEvent(eventLSyncSharp, inL); |
1151 | local->deleteIncidence( inL ); | 1151 | local->deleteIncidence( inL ); |
1152 | ++deletedEventL; | 1152 | ++deletedEventL; |
1153 | } else { | 1153 | } else { |
1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1155 | inL->removeID(mCurrentSyncDevice ); | 1155 | inL->removeID(mCurrentSyncDevice ); |
1156 | ++addedEventR; | 1156 | ++addedEventR; |
1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1158 | inL->setLastModified( modifiedCalendar ); | 1158 | inL->setLastModified( modifiedCalendar ); |
1159 | inR = inL->clone(); | 1159 | inR = inL->clone(); |
1160 | inR->setIDStr( ":" ); | 1160 | inR->setIDStr( ":" ); |
1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1162 | remote->addIncidence( inR ); | 1162 | remote->addIncidence( inR ); |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } else { | 1165 | } else { |
1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1167 | checkExternSyncEvent(eventLSyncSharp, inL); | 1167 | checkExternSyncEvent(eventLSyncSharp, inL); |
1168 | local->deleteIncidence( inL ); | 1168 | local->deleteIncidence( inL ); |
1169 | ++deletedEventL; | 1169 | ++deletedEventL; |
1170 | } else { | 1170 | } else { |
1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1172 | ++addedEventR; | 1172 | ++addedEventR; |
1173 | inL->setLastModified( modifiedCalendar ); | 1173 | inL->setLastModified( modifiedCalendar ); |
1174 | inR = inL->clone(); | 1174 | inR = inL->clone(); |
1175 | inR->setIDStr( ":" ); | 1175 | inR->setIDStr( ":" ); |
1176 | remote->addIncidence( inR ); | 1176 | remote->addIncidence( inR ); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | } else { | 1180 | } else { |
1181 | ++filteredOUT; | 1181 | ++filteredOUT; |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | inL = el.next(); | 1185 | inL = el.next(); |
1186 | } | 1186 | } |
1187 | int delFut = 0; | 1187 | int delFut = 0; |
1188 | int remRem = 0; | 1188 | int remRem = 0; |
1189 | if ( mSyncManager->mWriteBackInFuture ) { | 1189 | if ( mSyncManager->mWriteBackInFuture ) { |
1190 | er = remote->rawIncidences(); | 1190 | er = remote->rawIncidences(); |
1191 | remRem = er.count(); | 1191 | remRem = er.count(); |
1192 | inR = er.first(); | 1192 | inR = er.first(); |
1193 | QDateTime dt; | 1193 | QDateTime dt; |
1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1196 | while ( inR ) { | 1196 | while ( inR ) { |
1197 | if ( inR->type() == "Todo" ) { | 1197 | if ( inR->type() == "Todo" ) { |
1198 | Todo * t = (Todo*)inR; | 1198 | Todo * t = (Todo*)inR; |
1199 | if ( t->hasDueDate() ) | 1199 | if ( t->hasDueDate() ) |
1200 | dt = t->dtDue(); | 1200 | dt = t->dtDue(); |
1201 | else | 1201 | else |
1202 | dt = cur.addSecs( 62 ); | 1202 | dt = cur.addSecs( 62 ); |
1203 | } | 1203 | } |
1204 | else if (inR->type() == "Event" ) { | 1204 | else if (inR->type() == "Event" ) { |
1205 | bool ok; | 1205 | bool ok; |
1206 | dt = inR->getNextOccurence( cur, &ok ); | 1206 | dt = inR->getNextOccurence( cur, &ok ); |
1207 | if ( !ok ) | 1207 | if ( !ok ) |
1208 | dt = cur.addSecs( -62 ); | 1208 | dt = cur.addSecs( -62 ); |
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | dt = inR->dtStart(); | 1211 | dt = inR->dtStart(); |
1212 | if ( dt < cur || dt > end ) { | 1212 | if ( dt < cur || dt > end ) { |
1213 | remote->deleteIncidence( inR ); | 1213 | remote->deleteIncidence( inR ); |
1214 | ++delFut; | 1214 | ++delFut; |
1215 | } | 1215 | } |
1216 | inR = er.next(); | 1216 | inR = er.next(); |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | bar.hide(); | 1219 | bar.hide(); |
1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1221 | eventLSync->setReadOnly( false ); | 1221 | eventLSync->setReadOnly( false ); |
1222 | eventLSync->setDtStart( mLastCalendarSync ); | 1222 | eventLSync->setDtStart( mLastCalendarSync ); |
1223 | eventRSync->setDtStart( mLastCalendarSync ); | 1223 | eventRSync->setDtStart( mLastCalendarSync ); |
1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1228 | eventLSync->setReadOnly( true ); | 1228 | eventLSync->setReadOnly( true ); |
1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1231 | remote->addEvent( eventRSync ); | 1231 | remote->addEvent( eventRSync ); |
1232 | else | 1232 | else |
1233 | delete eventRSync; | 1233 | delete eventRSync; |
1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1235 | QString mes; | 1235 | QString mes; |
1236 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1236 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1237 | QString delmess; | 1237 | QString delmess; |
1238 | if ( delFut ) { | 1238 | if ( delFut ) { |
1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1240 | mes += delmess; | 1240 | mes += delmess; |
1241 | } | 1241 | } |
1242 | mes = i18n("Local calendar changed!\n") +mes; | 1242 | mes = i18n("Local calendar changed!\n") +mes; |
1243 | mCalendar->checkAlarmForIncidence( 0, true ); | 1243 | mCalendar->checkAlarmForIncidence( 0, true ); |
1244 | qDebug( mes ); | 1244 | qDebug( mes ); |
1245 | if ( mSyncManager->mShowSyncSummary ) { | 1245 | if ( mSyncManager->mShowSyncSummary ) { |
1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1248 | qDebug("KO: WB cancelled "); | 1248 | qDebug("KO: WB cancelled "); |
1249 | mSyncManager->mWriteBackFile = false; | 1249 | mSyncManager->mWriteBackFile = false; |
1250 | return syncOK; | 1250 | return syncOK; |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | return syncOK; | 1253 | return syncOK; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void CalendarView::setSyncDevice( QString s ) | 1256 | void CalendarView::setSyncDevice( QString s ) |
1257 | { | 1257 | { |
1258 | mCurrentSyncDevice= s; | 1258 | mCurrentSyncDevice= s; |
1259 | } | 1259 | } |
1260 | void CalendarView::setSyncName( QString s ) | 1260 | void CalendarView::setSyncName( QString s ) |
1261 | { | 1261 | { |
1262 | mCurrentSyncName= s; | 1262 | mCurrentSyncName= s; |
1263 | } | 1263 | } |
1264 | bool CalendarView::syncCalendar(QString filename, int mode) | 1264 | bool CalendarView::syncCalendar(QString filename, int mode) |
1265 | { | 1265 | { |
1266 | //qDebug("syncCalendar %s ", filename.latin1()); | 1266 | //qDebug("syncCalendar %s ", filename.latin1()); |
1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1268 | CalendarLocal* calendar = new CalendarLocal(); | 1268 | CalendarLocal* calendar = new CalendarLocal(); |
1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1270 | FileStorage* storage = new FileStorage( calendar ); | 1270 | FileStorage* storage = new FileStorage( calendar ); |
1271 | bool syncOK = false; | 1271 | bool syncOK = false; |
1272 | storage->setFileName( filename ); | 1272 | storage->setFileName( filename ); |
1273 | // qDebug("loading ... "); | 1273 | // qDebug("loading ... "); |
1274 | if ( storage->load() ) { | 1274 | if ( storage->load() ) { |
1275 | getEventViewerDialog()->setSyncMode( true ); | 1275 | getEventViewerDialog()->setSyncMode( true ); |
1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1277 | getEventViewerDialog()->setSyncMode( false ); | 1277 | getEventViewerDialog()->setSyncMode( false ); |
1278 | if ( syncOK ) { | 1278 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1279 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1280 | { |
1281 | storage->setSaveFormat( new ICalFormat() ); | 1281 | storage->setSaveFormat( new ICalFormat() ); |
1282 | storage->save(); | 1282 | storage->save(); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | setModified( true ); | 1285 | setModified( true ); |
1286 | } | 1286 | } |
1287 | delete storage; | 1287 | delete storage; |
1288 | delete calendar; | 1288 | delete calendar; |
1289 | if ( syncOK ) | 1289 | if ( syncOK ) |
1290 | updateView(); | 1290 | updateView(); |
1291 | return syncOK; | 1291 | return syncOK; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void CalendarView::syncExternal( int mode ) | 1294 | void CalendarView::syncExternal( int mode ) |
1295 | { | 1295 | { |
1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1297 | 1297 | ||
1298 | qApp->processEvents(); | 1298 | qApp->processEvents(); |
1299 | CalendarLocal* calendar = new CalendarLocal(); | 1299 | CalendarLocal* calendar = new CalendarLocal(); |
1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1301 | bool syncOK = false; | 1301 | bool syncOK = false; |
1302 | bool loadSuccess = false; | 1302 | bool loadSuccess = false; |
1303 | PhoneFormat* phoneFormat = 0; | 1303 | PhoneFormat* phoneFormat = 0; |
1304 | emit tempDisableBR(true); | 1304 | emit tempDisableBR(true); |
1305 | #ifndef DESKTOP_VERSION | 1305 | #ifndef DESKTOP_VERSION |
1306 | SharpFormat* sharpFormat = 0; | 1306 | SharpFormat* sharpFormat = 0; |
1307 | if ( mode == 0 ) { // sharp | 1307 | if ( mode == 0 ) { // sharp |
1308 | sharpFormat = new SharpFormat () ; | 1308 | sharpFormat = new SharpFormat () ; |
1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1310 | 1310 | ||
1311 | } else | 1311 | } else |
1312 | #endif | 1312 | #endif |
1313 | if ( mode == 1 ) { // phone | 1313 | if ( mode == 1 ) { // phone |
1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1315 | mSyncManager->mPhoneDevice, | 1315 | mSyncManager->mPhoneDevice, |
1316 | mSyncManager->mPhoneConnection, | 1316 | mSyncManager->mPhoneConnection, |
1317 | mSyncManager->mPhoneModel); | 1317 | mSyncManager->mPhoneModel); |
1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1319 | 1319 | ||
1320 | } else { | 1320 | } else { |
1321 | emit tempDisableBR(false); | 1321 | emit tempDisableBR(false); |
1322 | return; | 1322 | return; |
1323 | } | 1323 | } |
1324 | if ( loadSuccess ) { | 1324 | if ( loadSuccess ) { |
1325 | getEventViewerDialog()->setSyncMode( true ); | 1325 | getEventViewerDialog()->setSyncMode( true ); |
1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1327 | getEventViewerDialog()->setSyncMode( false ); | 1327 | getEventViewerDialog()->setSyncMode( false ); |
1328 | qApp->processEvents(); | 1328 | qApp->processEvents(); |
1329 | if ( syncOK ) { | 1329 | if ( syncOK ) { |
1330 | if ( mSyncManager->mWriteBackFile ) | 1330 | if ( mSyncManager->mWriteBackFile ) |
1331 | { | 1331 | { |
1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1333 | Incidence* inc = iL.first(); | 1333 | Incidence* inc = iL.first(); |
1334 | if ( phoneFormat ) { | 1334 | if ( phoneFormat ) { |
1335 | while ( inc ) { | 1335 | while ( inc ) { |
1336 | inc->removeID(mCurrentSyncDevice); | 1336 | inc->removeID(mCurrentSyncDevice); |
1337 | inc = iL.next(); | 1337 | inc = iL.next(); |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1341 | if ( sharpFormat ) | 1341 | if ( sharpFormat ) |
1342 | sharpFormat->save(calendar); | 1342 | sharpFormat->save(calendar); |
1343 | #endif | 1343 | #endif |
1344 | if ( phoneFormat ) | 1344 | if ( phoneFormat ) |
1345 | phoneFormat->save(calendar); | 1345 | phoneFormat->save(calendar); |
1346 | iL = calendar->rawIncidences(); | 1346 | iL = calendar->rawIncidences(); |
1347 | inc = iL.first(); | 1347 | inc = iL.first(); |
1348 | Incidence* loc; | 1348 | Incidence* loc; |
1349 | while ( inc ) { | 1349 | while ( inc ) { |
1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1351 | loc = mCalendar->incidence(inc->uid() ); | 1351 | loc = mCalendar->incidence(inc->uid() ); |
1352 | if ( loc ) { | 1352 | if ( loc ) { |
1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1355 | } | 1355 | } |
1356 | } | 1356 | } |
1357 | inc = iL.next(); | 1357 | inc = iL.next(); |
1358 | } | 1358 | } |
1359 | Incidence* lse = getLastSyncEvent(); | 1359 | Incidence* lse = getLastSyncEvent(); |
1360 | if ( lse ) { | 1360 | if ( lse ) { |
1361 | lse->setReadOnly( false ); | 1361 | lse->setReadOnly( false ); |
1362 | lse->setDescription( "" ); | 1362 | lse->setDescription( "" ); |
1363 | lse->setReadOnly( true ); | 1363 | lse->setReadOnly( true ); |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | } else { | 1366 | } else { |
1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1368 | } | 1368 | } |
1369 | setModified( true ); | 1369 | setModified( true ); |
1370 | } else { | 1370 | } else { |
1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1373 | question, i18n("Ok")) ; | 1373 | question, i18n("Ok")) ; |
1374 | 1374 | ||
1375 | } | 1375 | } |
1376 | delete calendar; | 1376 | delete calendar; |
1377 | updateView(); | 1377 | updateView(); |
1378 | emit tempDisableBR(false); | 1378 | emit tempDisableBR(false); |
1379 | return ;//syncOK; | 1379 | return ;//syncOK; |
1380 | 1380 | ||
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool CalendarView::importBday() | 1383 | bool CalendarView::importBday() |
1384 | { | 1384 | { |
1385 | #ifndef KORG_NOKABC | 1385 | #ifndef KORG_NOKABC |
1386 | 1386 | ||
1387 | #ifdef DESKTOP_VERSION | 1387 | #ifdef DESKTOP_VERSION |
1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1389 | KABC::AddressBook::Iterator it; | 1389 | KABC::AddressBook::Iterator it; |
1390 | int count = 0; | 1390 | int count = 0; |
1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1392 | ++count; | 1392 | ++count; |
1393 | } | 1393 | } |
1394 | QProgressBar bar(count,0 ); | 1394 | QProgressBar bar(count,0 ); |
1395 | int w = 300; | 1395 | int w = 300; |
1396 | if ( QApplication::desktop()->width() < 320 ) | 1396 | if ( QApplication::desktop()->width() < 320 ) |
1397 | w = 220; | 1397 | w = 220; |
1398 | int h = bar.sizeHint().height() ; | 1398 | int h = bar.sizeHint().height() ; |
1399 | int dw = QApplication::desktop()->width(); | 1399 | int dw = QApplication::desktop()->width(); |
1400 | int dh = QApplication::desktop()->height(); | 1400 | int dh = QApplication::desktop()->height(); |
1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1402 | bar.show(); | 1402 | bar.show(); |
1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1404 | qApp->processEvents(); | 1404 | qApp->processEvents(); |
1405 | count = 0; | 1405 | count = 0; |
1406 | int addCount = 0; | 1406 | int addCount = 0; |
1407 | KCal::Attendee* a = 0; | 1407 | KCal::Attendee* a = 0; |
1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1409 | if ( ! bar.isVisible() ) | 1409 | if ( ! bar.isVisible() ) |
1410 | return false; | 1410 | return false; |
1411 | bar.setProgress( count++ ); | 1411 | bar.setProgress( count++ ); |
1412 | qApp->processEvents(); | 1412 | qApp->processEvents(); |
1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1414 | if ( (*it).birthday().date().isValid() ){ | 1414 | if ( (*it).birthday().date().isValid() ){ |
1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1417 | ++addCount; | 1417 | ++addCount; |
1418 | } | 1418 | } |
1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1420 | if ( anni.isValid() ){ | 1420 | if ( anni.isValid() ){ |
1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1423 | ++addCount; | 1423 | ++addCount; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | updateView(); | 1426 | updateView(); |
1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1428 | #else //DESKTOP_VERSION | 1428 | #else //DESKTOP_VERSION |
1429 | 1429 | ||
1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1431 | // the result should now arrive through method insertBirthdays | 1431 | // the result should now arrive through method insertBirthdays |
1432 | 1432 | ||
1433 | #endif //DESKTOP_VERSION | 1433 | #endif //DESKTOP_VERSION |
1434 | 1434 | ||
1435 | #endif //KORG_NOKABC | 1435 | #endif //KORG_NOKABC |
1436 | 1436 | ||
1437 | 1437 | ||
1438 | return true; | 1438 | return true; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1443 | const QStringList& anniversaryList, const QStringList& realNameList, | 1443 | const QStringList& anniversaryList, const QStringList& realNameList, |
1444 | const QStringList& emailList, const QStringList& assembledNameList, | 1444 | const QStringList& emailList, const QStringList& assembledNameList, |
1445 | const QStringList& uidList) | 1445 | const QStringList& uidList) |
1446 | { | 1446 | { |
1447 | //qDebug("KO::CalendarView::insertBirthdays"); | 1447 | //qDebug("KO::CalendarView::insertBirthdays"); |
1448 | if (uid == this->name()) | 1448 | if (uid == this->name()) |
1449 | { | 1449 | { |
1450 | int count = birthdayList.count(); | 1450 | int count = birthdayList.count(); |
1451 | int addCount = 0; | 1451 | int addCount = 0; |
1452 | KCal::Attendee* a = 0; | 1452 | KCal::Attendee* a = 0; |
1453 | 1453 | ||
1454 | //qDebug("CalView 1 %i", count); | 1454 | //qDebug("CalView 1 %i", count); |
1455 | 1455 | ||
1456 | QProgressBar bar(count,0 ); | 1456 | QProgressBar bar(count,0 ); |
1457 | int w = 300; | 1457 | int w = 300; |
1458 | if ( QApplication::desktop()->width() < 320 ) | 1458 | if ( QApplication::desktop()->width() < 320 ) |
1459 | w = 220; | 1459 | w = 220; |
1460 | int h = bar.sizeHint().height() ; | 1460 | int h = bar.sizeHint().height() ; |
1461 | int dw = QApplication::desktop()->width(); | 1461 | int dw = QApplication::desktop()->width(); |
1462 | int dh = QApplication::desktop()->height(); | 1462 | int dh = QApplication::desktop()->height(); |
1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1464 | bar.show(); | 1464 | bar.show(); |
1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1466 | qApp->processEvents(); | 1466 | qApp->processEvents(); |
1467 | 1467 | ||
1468 | QDate birthday; | 1468 | QDate birthday; |
1469 | QDate anniversary; | 1469 | QDate anniversary; |
1470 | QString realName; | 1470 | QString realName; |
1471 | QString email; | 1471 | QString email; |
1472 | QString assembledName; | 1472 | QString assembledName; |
1473 | QString uid; | 1473 | QString uid; |
1474 | bool ok = true; | 1474 | bool ok = true; |
1475 | for ( int i = 0; i < count; i++) | 1475 | for ( int i = 0; i < count; i++) |
1476 | { | 1476 | { |
1477 | if ( ! bar.isVisible() ) | 1477 | if ( ! bar.isVisible() ) |
1478 | return; | 1478 | return; |
1479 | bar.setProgress( i ); | 1479 | bar.setProgress( i ); |
1480 | qApp->processEvents(); | 1480 | qApp->processEvents(); |
1481 | 1481 | ||
1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1483 | if (!ok) { | 1483 | if (!ok) { |
1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1488 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1490 | } | 1490 | } |
1491 | realName = realNameList[i]; | 1491 | realName = realNameList[i]; |
1492 | email = emailList[i]; | 1492 | email = emailList[i]; |
1493 | assembledName = assembledNameList[i]; | 1493 | assembledName = assembledNameList[i]; |
1494 | uid = uidList[i]; | 1494 | uid = uidList[i]; |
1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1496 | 1496 | ||
1497 | if ( birthday.isValid() ){ | 1497 | if ( birthday.isValid() ){ |
1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1499 | KCal::Attendee::ReqParticipant,uid) ; | 1499 | KCal::Attendee::ReqParticipant,uid) ; |
1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1501 | ++addCount; | 1501 | ++addCount; |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | if ( anniversary.isValid() ){ | 1504 | if ( anniversary.isValid() ){ |
1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1506 | KCal::Attendee::ReqParticipant,uid) ; | 1506 | KCal::Attendee::ReqParticipant,uid) ; |
1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1508 | ++addCount; | 1508 | ++addCount; |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | updateView(); | 1512 | updateView(); |
1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | 1520 | ||
1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1522 | { | 1522 | { |
1523 | //qDebug("addAnni "); | 1523 | //qDebug("addAnni "); |
1524 | Event * ev = new Event(); | 1524 | Event * ev = new Event(); |
1525 | ev->setOrganizer(KOPrefs::instance()->email()); | 1525 | ev->setOrganizer(KOPrefs::instance()->email()); |
1526 | if ( a ) { | 1526 | if ( a ) { |
1527 | ev->addAttendee( a ); | 1527 | ev->addAttendee( a ); |
1528 | } | 1528 | } |
1529 | QString kind; | 1529 | QString kind; |
1530 | if ( birthday ) { | 1530 | if ( birthday ) { |
1531 | kind = i18n( "Birthday" ); | 1531 | kind = i18n( "Birthday" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1533 | } | 1533 | } |
1534 | else { | 1534 | else { |
1535 | kind = i18n( "Anniversary" ); | 1535 | kind = i18n( "Anniversary" ); |
1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1537 | } | 1537 | } |
1538 | ev->setCategories( kind ); | 1538 | ev->setCategories( kind ); |
1539 | ev->setDtStart( QDateTime(date) ); | 1539 | ev->setDtStart( QDateTime(date) ); |
1540 | ev->setDtEnd( QDateTime(date) ); | 1540 | ev->setDtEnd( QDateTime(date) ); |
1541 | ev->setFloats( true ); | 1541 | ev->setFloats( true ); |
1542 | Recurrence * rec = ev->recurrence(); | 1542 | Recurrence * rec = ev->recurrence(); |
1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1544 | rec->addYearlyNum( date.month() ); | 1544 | rec->addYearlyNum( date.month() ); |
1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1546 | delete ev; | 1546 | delete ev; |
1547 | return false; | 1547 | return false; |
1548 | } | 1548 | } |
1549 | return true; | 1549 | return true; |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | bool CalendarView::importQtopia( const QString &categories, | 1552 | bool CalendarView::importQtopia( const QString &categories, |
1553 | const QString &datebook, | 1553 | const QString &datebook, |
1554 | const QString &todolist ) | 1554 | const QString &todolist ) |
1555 | { | 1555 | { |
1556 | 1556 | ||
1557 | QtopiaFormat qtopiaFormat; | 1557 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1562 | 1562 | ||
1563 | updateView(); | 1563 | updateView(); |
1564 | return true; | 1564 | return true; |
1565 | 1565 | ||
1566 | #if 0 | 1566 | #if 0 |
1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1568 | mCurrentSyncDevice = "qtopia-XML"; | 1568 | mCurrentSyncDevice = "qtopia-XML"; |
1569 | if ( mSyncManager->mAskForPreferences ) | 1569 | if ( mSyncManager->mAskForPreferences ) |
1570 | edit_sync_options(); | 1570 | edit_sync_options(); |
1571 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1572 | CalendarLocal* calendar = new CalendarLocal(); | 1572 | CalendarLocal* calendar = new CalendarLocal(); |
1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1574 | bool syncOK = false; | 1574 | bool syncOK = false; |
1575 | QtopiaFormat qtopiaFormat; | 1575 | QtopiaFormat qtopiaFormat; |
1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1577 | bool loadOk = true; | 1577 | bool loadOk = true; |
1578 | if ( !categories.isEmpty() ) | 1578 | if ( !categories.isEmpty() ) |
1579 | loadOk = qtopiaFormat.load( calendar, categories ); | 1579 | loadOk = qtopiaFormat.load( calendar, categories ); |
1580 | if ( loadOk && !datebook.isEmpty() ) | 1580 | if ( loadOk && !datebook.isEmpty() ) |
1581 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1581 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1582 | if ( loadOk && !todolist.isEmpty() ) | 1582 | if ( loadOk && !todolist.isEmpty() ) |
1583 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1583 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1584 | 1584 | ||
1585 | if ( loadOk ) { | 1585 | if ( loadOk ) { |
1586 | getEventViewerDialog()->setSyncMode( true ); | 1586 | getEventViewerDialog()->setSyncMode( true ); |
1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1588 | getEventViewerDialog()->setSyncMode( false ); | 1588 | getEventViewerDialog()->setSyncMode( false ); |
1589 | qApp->processEvents(); | 1589 | qApp->processEvents(); |
1590 | if ( syncOK ) { | 1590 | if ( syncOK ) { |
1591 | if ( mSyncManager->mWriteBackFile ) | 1591 | if ( mSyncManager->mWriteBackFile ) |
1592 | { | 1592 | { |
1593 | // write back XML file | 1593 | // write back XML file |
1594 | 1594 | ||
1595 | } | 1595 | } |
1596 | setModified( true ); | 1596 | setModified( true ); |
1597 | } | 1597 | } |
1598 | } else { | 1598 | } else { |
1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1601 | question, i18n("Ok")) ; | 1601 | question, i18n("Ok")) ; |
1602 | } | 1602 | } |
1603 | delete calendar; | 1603 | delete calendar; |
1604 | updateView(); | 1604 | updateView(); |
1605 | return syncOK; | 1605 | return syncOK; |
1606 | 1606 | ||
1607 | 1607 | ||
1608 | #endif | 1608 | #endif |
1609 | 1609 | ||
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | void CalendarView::setSyncEventsReadOnly() | 1612 | void CalendarView::setSyncEventsReadOnly() |
1613 | { | 1613 | { |
1614 | Event * ev; | 1614 | Event * ev; |
1615 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1615 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1616 | ev = eL.first(); | 1616 | ev = eL.first(); |
1617 | while ( ev ) { | 1617 | while ( ev ) { |
1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1619 | ev->setReadOnly( true ); | 1619 | ev->setReadOnly( true ); |
1620 | ev = eL.next(); | 1620 | ev = eL.next(); |
1621 | } | 1621 | } |
1622 | } | 1622 | } |
1623 | bool CalendarView::openCalendar(QString filename, bool merge) | 1623 | bool CalendarView::openCalendar(QString filename, bool merge) |
1624 | { | 1624 | { |
1625 | 1625 | ||
1626 | if (filename.isEmpty()) { | 1626 | if (filename.isEmpty()) { |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | if (!QFile::exists(filename)) { | 1630 | if (!QFile::exists(filename)) { |
1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | globalFlagBlockAgenda = 1; | 1635 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1636 | if (!merge) mCalendar->close(); |
1637 | 1637 | ||
1638 | mStorage->setFileName( filename ); | 1638 | mStorage->setFileName( filename ); |
1639 | 1639 | ||
1640 | if ( mStorage->load() ) { | 1640 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1641 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1642 | else { |
1643 | //setModified( true ); | 1643 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1644 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1645 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1646 | mTodoList->setDocumentId( filename ); |
1647 | } | 1647 | } |
1648 | globalFlagBlockAgenda = 2; | 1648 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1649 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1650 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1651 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1652 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1653 | updateUnmanagedViews(); |
1654 | updateView(); | 1654 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1655 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1656 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1657 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1658 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1659 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1660 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | return true; | 1663 | return true; |
1664 | } else { | 1664 | } else { |
1665 | // while failing to load, the calendar object could | 1665 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1666 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1667 | if ( !merge ) { |
1668 | mCalendar->close(); | 1668 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1675 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1677 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1678 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1679 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1680 | updateUnmanagedViews(); |
1681 | updateView(); | 1681 | updateView(); |
1682 | } | 1682 | } |
1683 | return false; | 1683 | return false; |
1684 | } | 1684 | } |
1685 | void CalendarView::showOpenError() | 1685 | void CalendarView::showOpenError() |
1686 | { | 1686 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1688 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1690 | { |
1691 | loadedFileVersion = dt; | 1691 | loadedFileVersion = dt; |
1692 | } | 1692 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1693 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1694 | { |
1695 | QFileInfo finf ( fn ); | 1695 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1696 | if ( !finf.exists() ) |
1697 | return true; | 1697 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1698 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1699 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1700 | return false; |
1701 | return true; | 1701 | return true; |
1702 | 1702 | ||
1703 | } | 1703 | } |
1704 | void CalendarView::watchSavedFile() | 1704 | void CalendarView::watchSavedFile() |
1705 | { | 1705 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1706 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1708 | return; | 1708 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1710 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1713 | return; |
1714 | } | 1714 | } |
1715 | loadedFileVersion = dt; | 1715 | loadedFileVersion = dt; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1718 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1719 | { |
1720 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1722 | return true; | 1722 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1725 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1726 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1727 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1730 | i18n("Sync+save")); |
1731 | 1731 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1732 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1733 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1734 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1735 | return true; |
1736 | 1736 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1737 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1738 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1739 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1740 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1741 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1742 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1743 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1744 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1745 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1746 | updateView(); |
1747 | return true; | 1747 | return true; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1750 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1751 | { |
1752 | 1752 | ||
1753 | // Store back all unsaved data into calendar object | 1753 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1755 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1756 | mViewManager->currentView()->flushView(); |
1757 | 1757 | ||
1758 | 1758 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1760 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1761 | mStorage->setFileName( filename ); |
1762 | bool success; | 1762 | bool success; |
1763 | success = mStorage->save(); | 1763 | success = mStorage->save(); |
1764 | if ( !success ) { | 1764 | if ( !success ) { |
1765 | return false; | 1765 | return false; |
1766 | } | 1766 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1767 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1768 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1769 | watchSavedFile(); |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::closeCalendar() | 1774 | void CalendarView::closeCalendar() |
1775 | { | 1775 | { |
1776 | 1776 | ||
1777 | // child windows no longer valid | 1777 | // child windows no longer valid |
1778 | emit closingDown(); | 1778 | emit closingDown(); |
1779 | 1779 | ||
1780 | mCalendar->close(); | 1780 | mCalendar->close(); |
1781 | setModified(false); | 1781 | setModified(false); |
1782 | updateView(); | 1782 | updateView(); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void CalendarView::archiveCalendar() | 1785 | void CalendarView::archiveCalendar() |
1786 | { | 1786 | { |
1787 | mDialogManager->showArchiveDialog(); | 1787 | mDialogManager->showArchiveDialog(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | 1790 | ||
1791 | void CalendarView::readSettings() | 1791 | void CalendarView::readSettings() |
1792 | { | 1792 | { |
1793 | 1793 | ||
1794 | 1794 | ||
1795 | // mViewManager->showAgendaView(); | 1795 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1796 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1797 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1798 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1799 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1800 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1801 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1802 | config->setGroup("KOrganizer Geometry"); |
1803 | 1803 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1805 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1806 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1807 | sizes << 300; |
1808 | } | 1808 | } |
1809 | mPanner->setSizes(sizes); | 1809 | mPanner->setSizes(sizes); |
1810 | 1810 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1811 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1812 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1813 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1814 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1817 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1818 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1819 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1821 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1822 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1824 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1826 | ||
1827 | int resetval = 0; | 1827 | int resetval = 0; |
1828 | int maxVal = 0; | 1828 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1829 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1830 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1831 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1832 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1833 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1834 | } |
1835 | } | 1835 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1836 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1837 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1839 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1840 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1842 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | if ( resetval ) { | 1845 | if ( resetval ) { |
1846 | sizes.clear(); | 1846 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1847 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1848 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1849 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1850 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1851 | } |
1852 | sizes << resetval; | 1852 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1853 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1854 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1855 | sizes << resetval; |
1856 | sizes << 100; | 1856 | sizes << 100; |
1857 | } | 1857 | } |
1858 | mLeftFrame->setSizes(sizes); | 1858 | mLeftFrame->setSizes(sizes); |
1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1861 | else mNavigator->selectDates( dateCount ); | 1861 | else mNavigator->selectDates( dateCount ); |
1862 | // mViewManager->readSettings( config ); | 1862 | // mViewManager->readSettings( config ); |
1863 | updateConfig(); | 1863 | updateConfig(); |
1864 | globalFlagBlockAgenda = 2; | 1864 | globalFlagBlockAgenda = 2; |
1865 | mViewManager->readSettings( config ); | 1865 | mViewManager->readSettings( config ); |
1866 | #ifdef DESKTOP_VERSION | 1866 | #ifdef DESKTOP_VERSION |
1867 | config->setGroup("WidgetLayout"); | 1867 | config->setGroup("WidgetLayout"); |
1868 | QStringList list; | 1868 | QStringList list; |
1869 | list = config->readListEntry("MainLayout"); | 1869 | list = config->readListEntry("MainLayout"); |
1870 | int x,y,w,h; | 1870 | int x,y,w,h; |
1871 | if ( ! list.isEmpty() ) { | 1871 | if ( ! list.isEmpty() ) { |
1872 | x = list[0].toInt(); | 1872 | x = list[0].toInt(); |
1873 | y = list[1].toInt(); | 1873 | y = list[1].toInt(); |
1874 | w = list[2].toInt(); | 1874 | w = list[2].toInt(); |
1875 | h = list[3].toInt(); | 1875 | h = list[3].toInt(); |
1876 | topLevelWidget()->setGeometry(x,y,w,h); | 1876 | topLevelWidget()->setGeometry(x,y,w,h); |
1877 | 1877 | ||
1878 | } else { | 1878 | } else { |
1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1880 | } | 1880 | } |
1881 | list = config->readListEntry("EditEventLayout"); | 1881 | list = config->readListEntry("EditEventLayout"); |
1882 | if ( ! list.isEmpty() ) { | 1882 | if ( ! list.isEmpty() ) { |
1883 | x = list[0].toInt(); | 1883 | x = list[0].toInt(); |
1884 | y = list[1].toInt(); | 1884 | y = list[1].toInt(); |
1885 | w = list[2].toInt(); | 1885 | w = list[2].toInt(); |
1886 | h = list[3].toInt(); | 1886 | h = list[3].toInt(); |
1887 | mEventEditor->setGeometry(x,y,w,h); | 1887 | mEventEditor->setGeometry(x,y,w,h); |
1888 | 1888 | ||
1889 | } | 1889 | } |
1890 | list = config->readListEntry("EditTodoLayout"); | 1890 | list = config->readListEntry("EditTodoLayout"); |
1891 | if ( ! list.isEmpty() ) { | 1891 | if ( ! list.isEmpty() ) { |
1892 | x = list[0].toInt(); | 1892 | x = list[0].toInt(); |
1893 | y = list[1].toInt(); | 1893 | y = list[1].toInt(); |
1894 | w = list[2].toInt(); | 1894 | w = list[2].toInt(); |
1895 | h = list[3].toInt(); | 1895 | h = list[3].toInt(); |
1896 | mTodoEditor->setGeometry(x,y,w,h); | 1896 | mTodoEditor->setGeometry(x,y,w,h); |
1897 | 1897 | ||
1898 | } | 1898 | } |
1899 | list = config->readListEntry("ViewerLayout"); | 1899 | list = config->readListEntry("ViewerLayout"); |
1900 | if ( ! list.isEmpty() ) { | 1900 | if ( ! list.isEmpty() ) { |
1901 | x = list[0].toInt(); | 1901 | x = list[0].toInt(); |
1902 | y = list[1].toInt(); | 1902 | y = list[1].toInt(); |
1903 | w = list[2].toInt(); | 1903 | w = list[2].toInt(); |
1904 | h = list[3].toInt(); | 1904 | h = list[3].toInt(); |
1905 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1905 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1906 | } | 1906 | } |
1907 | #endif | 1907 | #endif |
1908 | 1908 | ||
1909 | } | 1909 | } |
1910 | 1910 | ||
1911 | 1911 | ||
1912 | void CalendarView::writeSettings() | 1912 | void CalendarView::writeSettings() |
1913 | { | 1913 | { |
1914 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1914 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1915 | 1915 | ||
1916 | KConfig *config = KOGlobals::config(); | 1916 | KConfig *config = KOGlobals::config(); |
1917 | 1917 | ||
1918 | #ifndef KORG_NOSPLITTER | ||
1919 | config->setGroup("KOrganizer Geometry"); | ||
1920 | |||
1921 | QValueList<int> list = mPanner->sizes(); | ||
1922 | config->writeEntry("Separator1",list); | ||
1923 | |||
1924 | list = mLeftSplitter->sizes(); | ||
1925 | config->writeEntry("Separator2",list); | ||
1926 | #endif | ||
1927 | |||
1928 | mViewManager->writeSettings( config ); | 1918 | mViewManager->writeSettings( config ); |
1929 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1919 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1930 | mDialogManager->writeSettings( config ); | 1920 | mDialogManager->writeSettings( config ); |
1931 | //KOPrefs::instance()->usrWriteConfig(); | 1921 | //KOPrefs::instance()->usrWriteConfig(); |
1932 | KOPrefs::instance()->writeConfig(); | 1922 | KOPrefs::instance()->writeConfig(); |
1933 | 1923 | ||
1934 | writeFilterSettings(config); | 1924 | writeFilterSettings(config); |
1935 | 1925 | ||
1936 | config->setGroup( "Views" ); | 1926 | config->setGroup( "Views" ); |
1937 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1927 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1938 | 1928 | ||
1939 | QValueList<int> list = mLeftFrame->sizes(); | 1929 | QValueList<int> listINT = mLeftFrame->sizes(); |
1940 | config->writeEntry("Left Splitter Frame",list); | 1930 | config->writeEntry("Left Splitter Frame",listINT); |
1941 | 1931 | ||
1942 | #ifdef DESKTOP_VERSION | 1932 | #ifdef DESKTOP_VERSION |
1943 | config->setGroup("WidgetLayout"); | 1933 | config->setGroup("WidgetLayout"); |
1944 | QStringList list ;//= config->readListEntry("MainLayout"); | 1934 | QStringList list ;//= config->readListEntry("MainLayout"); |
1945 | int x,y,w,h; | 1935 | int x,y,w,h; |
1946 | QWidget* wid; | 1936 | QWidget* wid; |
1947 | wid = topLevelWidget(); | 1937 | wid = topLevelWidget(); |
1948 | x = wid->geometry().x(); | 1938 | x = wid->geometry().x(); |
1949 | y = wid->geometry().y(); | 1939 | y = wid->geometry().y(); |
1950 | w = wid->width(); | 1940 | w = wid->width(); |
1951 | h = wid->height(); | 1941 | h = wid->height(); |
1952 | list.clear(); | 1942 | list.clear(); |
1953 | list << QString::number( x ); | 1943 | list << QString::number( x ); |
1954 | list << QString::number( y ); | 1944 | list << QString::number( y ); |
1955 | list << QString::number( w ); | 1945 | list << QString::number( w ); |
1956 | list << QString::number( h ); | 1946 | list << QString::number( h ); |
1957 | config->writeEntry("MainLayout",list ); | 1947 | config->writeEntry("MainLayout",list ); |
1958 | 1948 | ||
1959 | wid = mEventEditor; | 1949 | wid = mEventEditor; |
1960 | x = wid->geometry().x(); | 1950 | x = wid->geometry().x(); |
1961 | y = wid->geometry().y(); | 1951 | y = wid->geometry().y(); |
1962 | w = wid->width(); | 1952 | w = wid->width(); |
1963 | h = wid->height(); | 1953 | h = wid->height(); |
1964 | list.clear(); | 1954 | list.clear(); |
1965 | list << QString::number( x ); | 1955 | list << QString::number( x ); |
1966 | list << QString::number( y ); | 1956 | list << QString::number( y ); |
1967 | list << QString::number( w ); | 1957 | list << QString::number( w ); |
1968 | list << QString::number( h ); | 1958 | list << QString::number( h ); |
1969 | config->writeEntry("EditEventLayout",list ); | 1959 | config->writeEntry("EditEventLayout",list ); |
1970 | 1960 | ||
1971 | wid = mTodoEditor; | 1961 | wid = mTodoEditor; |
1972 | x = wid->geometry().x(); | 1962 | x = wid->geometry().x(); |
1973 | y = wid->geometry().y(); | 1963 | y = wid->geometry().y(); |
1974 | w = wid->width(); | 1964 | w = wid->width(); |
1975 | h = wid->height(); | 1965 | h = wid->height(); |
1976 | list.clear(); | 1966 | list.clear(); |
1977 | list << QString::number( x ); | 1967 | list << QString::number( x ); |
1978 | list << QString::number( y ); | 1968 | list << QString::number( y ); |
1979 | list << QString::number( w ); | 1969 | list << QString::number( w ); |
1980 | list << QString::number( h ); | 1970 | list << QString::number( h ); |
1981 | config->writeEntry("EditTodoLayout",list ); | 1971 | config->writeEntry("EditTodoLayout",list ); |
1982 | wid = getEventViewerDialog(); | 1972 | wid = getEventViewerDialog(); |
1983 | x = wid->geometry().x(); | 1973 | x = wid->geometry().x(); |
1984 | y = wid->geometry().y(); | 1974 | y = wid->geometry().y(); |
1985 | w = wid->width(); | 1975 | w = wid->width(); |
1986 | h = wid->height(); | 1976 | h = wid->height(); |
1987 | list.clear(); | 1977 | list.clear(); |
1988 | list << QString::number( x ); | 1978 | list << QString::number( x ); |
1989 | list << QString::number( y ); | 1979 | list << QString::number( y ); |
1990 | list << QString::number( w ); | 1980 | list << QString::number( w ); |
1991 | list << QString::number( h ); | 1981 | list << QString::number( h ); |
1992 | config->writeEntry("ViewerLayout",list ); | 1982 | config->writeEntry("ViewerLayout",list ); |
1993 | wid = mDialogManager->getSearchDialog(); | 1983 | wid = mDialogManager->getSearchDialog(); |
1994 | if ( wid ) { | 1984 | if ( wid ) { |
1995 | x = wid->geometry().x(); | 1985 | x = wid->geometry().x(); |
1996 | y = wid->geometry().y(); | 1986 | y = wid->geometry().y(); |
1997 | w = wid->width(); | 1987 | w = wid->width(); |
1998 | h = wid->height(); | 1988 | h = wid->height(); |
1999 | list.clear(); | 1989 | list.clear(); |
2000 | list << QString::number( x ); | 1990 | list << QString::number( x ); |
2001 | list << QString::number( y ); | 1991 | list << QString::number( y ); |
2002 | list << QString::number( w ); | 1992 | list << QString::number( w ); |
2003 | list << QString::number( h ); | 1993 | list << QString::number( h ); |
2004 | config->writeEntry("SearchLayout",list ); | 1994 | config->writeEntry("SearchLayout",list ); |
2005 | } | 1995 | } |
2006 | #endif | 1996 | #endif |
2007 | 1997 | ||
2008 | 1998 | ||
2009 | config->sync(); | 1999 | config->sync(); |
2010 | } | 2000 | } |
2011 | 2001 | ||
2012 | void CalendarView::readFilterSettings(KConfig *config) | 2002 | void CalendarView::readFilterSettings(KConfig *config) |
2013 | { | 2003 | { |
2014 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2004 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2015 | 2005 | ||
2016 | mFilters.clear(); | 2006 | mFilters.clear(); |
2017 | 2007 | ||
2018 | config->setGroup("General"); | 2008 | config->setGroup("General"); |
2019 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2009 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2020 | 2010 | ||
2021 | QStringList::ConstIterator it = filterList.begin(); | 2011 | QStringList::ConstIterator it = filterList.begin(); |
2022 | QStringList::ConstIterator end = filterList.end(); | 2012 | QStringList::ConstIterator end = filterList.end(); |
2023 | while(it != end) { | 2013 | while(it != end) { |
2024 | // kdDebug() << " filter: " << (*it) << endl; | 2014 | // kdDebug() << " filter: " << (*it) << endl; |
2025 | 2015 | ||
2026 | CalFilter *filter; | 2016 | CalFilter *filter; |
2027 | filter = new CalFilter(*it); | 2017 | filter = new CalFilter(*it); |
2028 | config->setGroup("Filter_" + (*it)); | 2018 | config->setGroup("Filter_" + (*it)); |
2029 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2019 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2030 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2020 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2031 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2021 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2032 | mFilters.append(filter); | 2022 | mFilters.append(filter); |
2033 | 2023 | ||
2034 | ++it; | 2024 | ++it; |
2035 | } | 2025 | } |
2036 | 2026 | ||
2037 | if (mFilters.count() == 0) { | 2027 | if (mFilters.count() == 0) { |
2038 | CalFilter *filter = new CalFilter(i18n("Default")); | 2028 | CalFilter *filter = new CalFilter(i18n("Default")); |
2039 | mFilters.append(filter); | 2029 | mFilters.append(filter); |
2040 | } | 2030 | } |
2041 | mFilterView->updateFilters(); | 2031 | mFilterView->updateFilters(); |
2042 | config->setGroup("FilterView"); | 2032 | config->setGroup("FilterView"); |
2043 | 2033 | ||
2044 | mFilterView->blockSignals(true); | 2034 | mFilterView->blockSignals(true); |
2045 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2035 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2046 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2036 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2047 | mFilterView->blockSignals(false); | 2037 | mFilterView->blockSignals(false); |
2048 | // We do it manually to avoid it being done twice by the above calls | 2038 | // We do it manually to avoid it being done twice by the above calls |
2049 | updateFilter(); | 2039 | updateFilter(); |
2050 | } | 2040 | } |
2051 | 2041 | ||
2052 | void CalendarView::writeFilterSettings(KConfig *config) | 2042 | void CalendarView::writeFilterSettings(KConfig *config) |
2053 | { | 2043 | { |
2054 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2044 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2055 | 2045 | ||
2056 | QStringList filterList; | 2046 | QStringList filterList; |
2057 | 2047 | ||
2058 | CalFilter *filter = mFilters.first(); | 2048 | CalFilter *filter = mFilters.first(); |
2059 | while(filter) { | 2049 | while(filter) { |
2060 | // kdDebug() << " fn: " << filter->name() << endl; | 2050 | // kdDebug() << " fn: " << filter->name() << endl; |
2061 | filterList << filter->name(); | 2051 | filterList << filter->name(); |
2062 | config->setGroup("Filter_" + filter->name()); | 2052 | config->setGroup("Filter_" + filter->name()); |
2063 | config->writeEntry("Criteria",filter->criteria()); | 2053 | config->writeEntry("Criteria",filter->criteria()); |
2064 | config->writeEntry("CategoryList",filter->categoryList()); | 2054 | config->writeEntry("CategoryList",filter->categoryList()); |
2065 | filter = mFilters.next(); | 2055 | filter = mFilters.next(); |
2066 | } | 2056 | } |
2067 | config->setGroup("General"); | 2057 | config->setGroup("General"); |
2068 | config->writeEntry("CalendarFilters",filterList); | 2058 | config->writeEntry("CalendarFilters",filterList); |
2069 | 2059 | ||
2070 | config->setGroup("FilterView"); | 2060 | config->setGroup("FilterView"); |
2071 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2061 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2072 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2062 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2073 | } | 2063 | } |
2074 | 2064 | ||
2075 | 2065 | ||
2076 | void CalendarView::goToday() | 2066 | void CalendarView::goToday() |
2077 | { | 2067 | { |
2078 | if ( mViewManager->currentView()->isMonthView() ) | 2068 | if ( mViewManager->currentView()->isMonthView() ) |
2079 | mNavigator->selectTodayMonth(); | 2069 | mNavigator->selectTodayMonth(); |
2080 | else | 2070 | else |
2081 | mNavigator->selectToday(); | 2071 | mNavigator->selectToday(); |
2082 | } | 2072 | } |
2083 | 2073 | ||
2084 | void CalendarView::goNext() | 2074 | void CalendarView::goNext() |
2085 | { | 2075 | { |
2086 | mNavigator->selectNext(); | 2076 | mNavigator->selectNext(); |
2087 | } | 2077 | } |
2088 | 2078 | ||
2089 | void CalendarView::goPrevious() | 2079 | void CalendarView::goPrevious() |
2090 | { | 2080 | { |
2091 | mNavigator->selectPrevious(); | 2081 | mNavigator->selectPrevious(); |
2092 | } | 2082 | } |
2093 | void CalendarView::goNextMonth() | 2083 | void CalendarView::goNextMonth() |
2094 | { | 2084 | { |
2095 | mNavigator->selectNextMonth(); | 2085 | mNavigator->selectNextMonth(); |
2096 | } | 2086 | } |
2097 | 2087 | ||
2098 | void CalendarView::goPreviousMonth() | 2088 | void CalendarView::goPreviousMonth() |
2099 | { | 2089 | { |
2100 | mNavigator->selectPreviousMonth(); | 2090 | mNavigator->selectPreviousMonth(); |
2101 | } | 2091 | } |
2102 | void CalendarView::writeLocale() | 2092 | void CalendarView::writeLocale() |
2103 | { | 2093 | { |
2104 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2094 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2105 | #if 0 | 2095 | #if 0 |
2106 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2096 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2107 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2097 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2108 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2098 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2109 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2099 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2110 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2100 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2111 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2101 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2112 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2102 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2113 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2103 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2114 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2104 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2115 | KOPrefs::instance()->mDaylightsavingStart, | 2105 | KOPrefs::instance()->mDaylightsavingStart, |
2116 | KOPrefs::instance()->mDaylightsavingEnd ); | 2106 | KOPrefs::instance()->mDaylightsavingEnd ); |
2117 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2107 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2118 | #endif | 2108 | #endif |
2119 | } | 2109 | } |
2120 | void CalendarView::updateConfig() | 2110 | void CalendarView::updateConfig() |
2121 | { | 2111 | { |
2122 | writeLocale(); | 2112 | writeLocale(); |
2123 | if ( KOPrefs::instance()->mUseAppColors ) | 2113 | if ( KOPrefs::instance()->mUseAppColors ) |
2124 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2125 | emit configChanged(); | 2115 | emit configChanged(); |
2126 | mTodoList->updateConfig(); | 2116 | mTodoList->updateConfig(); |
2127 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2117 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2128 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2118 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2129 | // To make the "fill window" configurations work | 2119 | // To make the "fill window" configurations work |
2130 | //mViewManager->raiseCurrentView(); | 2120 | //mViewManager->raiseCurrentView(); |
2131 | } | 2121 | } |
2132 | 2122 | ||
2133 | 2123 | ||
2134 | void CalendarView::eventChanged(Event *event) | 2124 | void CalendarView::eventChanged(Event *event) |
2135 | { | 2125 | { |
2136 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2126 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2137 | //updateUnmanagedViews(); | 2127 | //updateUnmanagedViews(); |
2138 | } | 2128 | } |
2139 | 2129 | ||
2140 | void CalendarView::eventAdded(Event *event) | 2130 | void CalendarView::eventAdded(Event *event) |
2141 | { | 2131 | { |
2142 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2132 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2143 | } | 2133 | } |
2144 | 2134 | ||
2145 | void CalendarView::eventToBeDeleted(Event *) | 2135 | void CalendarView::eventToBeDeleted(Event *) |
2146 | { | 2136 | { |
2147 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2137 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2148 | } | 2138 | } |
2149 | 2139 | ||
2150 | void CalendarView::eventDeleted() | 2140 | void CalendarView::eventDeleted() |
2151 | { | 2141 | { |
2152 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2142 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2153 | } | 2143 | } |
2154 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2144 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2155 | { | 2145 | { |
2156 | changeIncidenceDisplay((Incidence *)which, action); | 2146 | changeIncidenceDisplay((Incidence *)which, action); |
2157 | mDateNavigator->updateView(); //LR | 2147 | mDateNavigator->updateView(); //LR |
2158 | //mDialogManager->updateSearchDialog(); | 2148 | //mDialogManager->updateSearchDialog(); |
2159 | 2149 | ||
2160 | if (which) { | 2150 | if (which) { |
2161 | mViewManager->updateWNview(); | 2151 | mViewManager->updateWNview(); |
2162 | //mTodoList->updateView(); | 2152 | //mTodoList->updateView(); |
2163 | } | 2153 | } |
2164 | 2154 | ||
2165 | } | 2155 | } |
2166 | 2156 | ||
2167 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2157 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2168 | { | 2158 | { |
2169 | updateUnmanagedViews(); | 2159 | updateUnmanagedViews(); |
2170 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2160 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2171 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2161 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2172 | mCalendar->checkAlarmForIncidence( 0, true ); | 2162 | mCalendar->checkAlarmForIncidence( 0, true ); |
2173 | if ( mEventViewerDialog ) | 2163 | if ( mEventViewerDialog ) |
2174 | mEventViewerDialog->hide(); | 2164 | mEventViewerDialog->hide(); |
2175 | } | 2165 | } |
2176 | else | 2166 | else |
2177 | mCalendar->checkAlarmForIncidence( which , false ); | 2167 | mCalendar->checkAlarmForIncidence( which , false ); |
2178 | } | 2168 | } |
2179 | 2169 | ||
2180 | // most of the changeEventDisplays() right now just call the view's | 2170 | // most of the changeEventDisplays() right now just call the view's |
2181 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2171 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2182 | void CalendarView::changeEventDisplay(Event *which, int action) | 2172 | void CalendarView::changeEventDisplay(Event *which, int action) |
2183 | { | 2173 | { |
2184 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2174 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2185 | changeIncidenceDisplay((Incidence *)which, action); | 2175 | changeIncidenceDisplay((Incidence *)which, action); |
2186 | mDateNavigator->updateView(); | 2176 | mDateNavigator->updateView(); |
2187 | //mDialogManager->updateSearchDialog(); | 2177 | //mDialogManager->updateSearchDialog(); |
2188 | 2178 | ||
2189 | if (which) { | 2179 | if (which) { |
2190 | // If there is an event view visible update the display | 2180 | // If there is an event view visible update the display |
2191 | mViewManager->currentView()->changeEventDisplay(which,action); | 2181 | mViewManager->currentView()->changeEventDisplay(which,action); |
2192 | // TODO: check, if update needed | 2182 | // TODO: check, if update needed |
2193 | // if (which->getTodoStatus()) { | 2183 | // if (which->getTodoStatus()) { |
2194 | mTodoList->updateView(); | 2184 | mTodoList->updateView(); |
2195 | // } | 2185 | // } |
2196 | } else { | 2186 | } else { |
2197 | mViewManager->currentView()->updateView(); | 2187 | mViewManager->currentView()->updateView(); |
2198 | } | 2188 | } |
2199 | } | 2189 | } |
2200 | 2190 | ||
2201 | 2191 | ||
2202 | void CalendarView::updateTodoViews() | 2192 | void CalendarView::updateTodoViews() |
2203 | { | 2193 | { |
2204 | mTodoList->updateView(); | 2194 | mTodoList->updateView(); |
2205 | mViewManager->currentView()->updateView(); | 2195 | mViewManager->currentView()->updateView(); |
2206 | 2196 | ||
2207 | } | 2197 | } |
2208 | 2198 | ||
2209 | 2199 | ||
2210 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2200 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2211 | { | 2201 | { |
2212 | mTodoList->updateView(); | 2202 | mTodoList->updateView(); |
2213 | mViewManager->updateView(start, end); | 2203 | mViewManager->updateView(start, end); |
2214 | //mDateNavigator->updateView(); | 2204 | //mDateNavigator->updateView(); |
2215 | } | 2205 | } |
2216 | 2206 | ||
2217 | void CalendarView::updateView() | 2207 | void CalendarView::updateView() |
2218 | { | 2208 | { |
2219 | DateList tmpList = mNavigator->selectedDates(); | 2209 | DateList tmpList = mNavigator->selectedDates(); |
2220 | 2210 | ||
2221 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2211 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2222 | mTodoList->updateView(); | 2212 | mTodoList->updateView(); |
2223 | // We assume that the navigator only selects consecutive days. | 2213 | // We assume that the navigator only selects consecutive days. |
2224 | updateView( tmpList.first(), tmpList.last() ); | 2214 | updateView( tmpList.first(), tmpList.last() ); |
2225 | } | 2215 | } |
2226 | 2216 | ||
2227 | void CalendarView::updateUnmanagedViews() | 2217 | void CalendarView::updateUnmanagedViews() |
2228 | { | 2218 | { |
2229 | mDateNavigator->updateDayMatrix(); | 2219 | mDateNavigator->updateDayMatrix(); |
2230 | } | 2220 | } |
2231 | 2221 | ||
2232 | int CalendarView::msgItemDelete(const QString name) | 2222 | int CalendarView::msgItemDelete(const QString name) |
2233 | { | 2223 | { |
2234 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2224 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2235 | i18n("This item will be\npermanently deleted."), | 2225 | i18n("This item will be\npermanently deleted."), |
2236 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2226 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2237 | } | 2227 | } |
2238 | 2228 | ||
2239 | 2229 | ||
2240 | void CalendarView::edit_cut() | 2230 | void CalendarView::edit_cut() |
2241 | { | 2231 | { |
2242 | Event *anEvent=0; | 2232 | Event *anEvent=0; |
2243 | 2233 | ||
2244 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2234 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2245 | 2235 | ||
2246 | if (mViewManager->currentView()->isEventView()) { | 2236 | if (mViewManager->currentView()->isEventView()) { |
2247 | if ( incidence && incidence->type() == "Event" ) { | 2237 | if ( incidence && incidence->type() == "Event" ) { |
2248 | anEvent = static_cast<Event *>(incidence); | 2238 | anEvent = static_cast<Event *>(incidence); |
2249 | } | 2239 | } |
2250 | } | 2240 | } |
2251 | 2241 | ||
2252 | if (!anEvent) { | 2242 | if (!anEvent) { |
2253 | KNotifyClient::beep(); | 2243 | KNotifyClient::beep(); |
2254 | return; | 2244 | return; |
2255 | } | 2245 | } |
2256 | DndFactory factory( mCalendar ); | 2246 | DndFactory factory( mCalendar ); |
2257 | factory.cutIncidence(anEvent); | 2247 | factory.cutIncidence(anEvent); |
2258 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2248 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2259 | } | 2249 | } |
2260 | 2250 | ||
2261 | void CalendarView::edit_copy() | 2251 | void CalendarView::edit_copy() |
2262 | { | 2252 | { |
2263 | Event *anEvent=0; | 2253 | Event *anEvent=0; |
2264 | 2254 | ||
2265 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2255 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2266 | 2256 | ||
2267 | if (mViewManager->currentView()->isEventView()) { | 2257 | if (mViewManager->currentView()->isEventView()) { |
2268 | if ( incidence && incidence->type() == "Event" ) { | 2258 | if ( incidence && incidence->type() == "Event" ) { |
2269 | anEvent = static_cast<Event *>(incidence); | 2259 | anEvent = static_cast<Event *>(incidence); |
2270 | } | 2260 | } |
2271 | } | 2261 | } |
2272 | 2262 | ||
2273 | if (!anEvent) { | 2263 | if (!anEvent) { |
2274 | KNotifyClient::beep(); | 2264 | KNotifyClient::beep(); |
2275 | return; | 2265 | return; |
2276 | } | 2266 | } |
2277 | DndFactory factory( mCalendar ); | 2267 | DndFactory factory( mCalendar ); |
2278 | factory.copyIncidence(anEvent); | 2268 | factory.copyIncidence(anEvent); |
2279 | } | 2269 | } |
2280 | 2270 | ||
2281 | void CalendarView::edit_paste() | 2271 | void CalendarView::edit_paste() |
2282 | { | 2272 | { |
2283 | QDate date = mNavigator->selectedDates().first(); | 2273 | QDate date = mNavigator->selectedDates().first(); |
2284 | 2274 | ||
2285 | DndFactory factory( mCalendar ); | 2275 | DndFactory factory( mCalendar ); |
2286 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2276 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2287 | 2277 | ||
2288 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2278 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2289 | } | 2279 | } |
2290 | 2280 | ||
2291 | void CalendarView::edit_options() | 2281 | void CalendarView::edit_options() |
2292 | { | 2282 | { |
2293 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2283 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2294 | emit save(); | 2284 | emit save(); |
2295 | emit saveStopTimer(); | 2285 | emit saveStopTimer(); |
2296 | mDialogManager->showOptionsDialog(); | 2286 | mDialogManager->showOptionsDialog(); |
2297 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2287 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2298 | emit saveStopTimer(); | 2288 | emit saveStopTimer(); |
2299 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2289 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2300 | i18n("Timezone settings"),i18n("Reload"))) { | 2290 | i18n("Timezone settings"),i18n("Reload"))) { |
2301 | qDebug("KO: TZ reload cancelled "); | 2291 | qDebug("KO: TZ reload cancelled "); |
2302 | return; | 2292 | return; |
2303 | } | 2293 | } |
2304 | qDebug("KO: Timezone change "); | 2294 | qDebug("KO: Timezone change "); |
2305 | openCalendar( MainWindow::defaultFileName() ); | 2295 | openCalendar( MainWindow::defaultFileName() ); |
2306 | setModified(true); | 2296 | setModified(true); |
2307 | } | 2297 | } |
2308 | else | 2298 | else |
2309 | qDebug("KO: No tz change "); | 2299 | qDebug("KO: No tz change "); |
2310 | 2300 | ||
2311 | } | 2301 | } |
2312 | 2302 | ||
2313 | 2303 | ||
2314 | void CalendarView::slotSelectPickerDate( QDate d) | 2304 | void CalendarView::slotSelectPickerDate( QDate d) |
2315 | { | 2305 | { |
2316 | mDateFrame->hide(); | 2306 | mDateFrame->hide(); |
2317 | if ( mDatePickerMode == 1 ) { | 2307 | if ( mDatePickerMode == 1 ) { |
2318 | mNavigator->slotDaySelect( d ); | 2308 | mNavigator->slotDaySelect( d ); |
2319 | } else if ( mDatePickerMode == 2 ) { | 2309 | } else if ( mDatePickerMode == 2 ) { |
2320 | if ( mMoveIncidence->type() == "Todo" ) { | 2310 | if ( mMoveIncidence->type() == "Todo" ) { |
2321 | Todo * to = (Todo *) mMoveIncidence; | 2311 | Todo * to = (Todo *) mMoveIncidence; |
2322 | QTime tim; | 2312 | QTime tim; |
2323 | int len = 0; | 2313 | int len = 0; |
2324 | if ( to->hasStartDate() && to->hasDueDate() ) | 2314 | if ( to->hasStartDate() && to->hasDueDate() ) |
2325 | len = to->dtStart().secsTo( to->dtDue()); | 2315 | len = to->dtStart().secsTo( to->dtDue()); |
2326 | if ( to->hasDueDate() ) | 2316 | if ( to->hasDueDate() ) |
2327 | tim = to->dtDue().time(); | 2317 | tim = to->dtDue().time(); |
2328 | else { | 2318 | else { |
2329 | tim = QTime ( 0,0,0 ); | 2319 | tim = QTime ( 0,0,0 ); |
2330 | to->setFloats( true ); | 2320 | to->setFloats( true ); |
2331 | to->setHasDueDate( true ); | 2321 | to->setHasDueDate( true ); |
2332 | } | 2322 | } |
2333 | QDateTime dt ( d,tim ); | 2323 | QDateTime dt ( d,tim ); |
2334 | to->setDtDue( dt ); | 2324 | to->setDtDue( dt ); |
2335 | 2325 | ||
2336 | if ( to->hasStartDate() ) { | 2326 | if ( to->hasStartDate() ) { |
2337 | if ( len>0 ) | 2327 | if ( len>0 ) |
2338 | to->setDtStart(to->dtDue().addSecs( -len )); | 2328 | to->setDtStart(to->dtDue().addSecs( -len )); |
2339 | else | 2329 | else |
2340 | if (to->dtStart() > to->dtDue() ) | 2330 | if (to->dtStart() > to->dtDue() ) |
2341 | to->setDtStart(to->dtDue().addDays( -3 )); | 2331 | to->setDtStart(to->dtDue().addDays( -3 )); |
2342 | } | 2332 | } |
2343 | 2333 | ||
2344 | todoChanged( to ); | 2334 | todoChanged( to ); |
2345 | } else { | 2335 | } else { |
2346 | if ( mMoveIncidence->doesRecur() ) { | 2336 | if ( mMoveIncidence->doesRecur() ) { |
2347 | #if 0 | 2337 | #if 0 |
2348 | // PENDING implement this | 2338 | // PENDING implement this |
2349 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2339 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2350 | mCalendar()->addIncidence( newInc ); | 2340 | mCalendar()->addIncidence( newInc ); |
2351 | if ( mMoveIncidence->type() == "Todo" ) | 2341 | if ( mMoveIncidence->type() == "Todo" ) |
2352 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2342 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2353 | else | 2343 | else |
2354 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2344 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2355 | mMoveIncidence = newInc; | 2345 | mMoveIncidence = newInc; |
2356 | 2346 | ||
2357 | #endif | 2347 | #endif |
2358 | } | 2348 | } |
2359 | QTime tim = mMoveIncidence->dtStart().time(); | 2349 | QTime tim = mMoveIncidence->dtStart().time(); |
2360 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2350 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2361 | QDateTime dt ( d,tim ); | 2351 | QDateTime dt ( d,tim ); |
2362 | mMoveIncidence->setDtStart( dt ); | 2352 | mMoveIncidence->setDtStart( dt ); |
2363 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2353 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2364 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2354 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2365 | } | 2355 | } |
2366 | 2356 | ||
2367 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2357 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2368 | } | 2358 | } |
2369 | } | 2359 | } |
2370 | 2360 | ||
2371 | void CalendarView::removeCategories() | 2361 | void CalendarView::removeCategories() |
2372 | { | 2362 | { |
2373 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2363 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2374 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2364 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2375 | QStringList catIncList; | 2365 | QStringList catIncList; |
2376 | QStringList newCatList; | 2366 | QStringList newCatList; |
2377 | Incidence* inc = incList.first(); | 2367 | Incidence* inc = incList.first(); |
2378 | int i; | 2368 | int i; |
2379 | int count = 0; | 2369 | int count = 0; |
2380 | while ( inc ) { | 2370 | while ( inc ) { |
2381 | newCatList.clear(); | 2371 | newCatList.clear(); |
2382 | catIncList = inc->categories() ; | 2372 | catIncList = inc->categories() ; |
2383 | for( i = 0; i< catIncList.count(); ++i ) { | 2373 | for( i = 0; i< catIncList.count(); ++i ) { |
2384 | if ( catList.contains (catIncList[i])) | 2374 | if ( catList.contains (catIncList[i])) |
2385 | newCatList.append( catIncList[i] ); | 2375 | newCatList.append( catIncList[i] ); |
2386 | } | 2376 | } |
2387 | newCatList.sort(); | 2377 | newCatList.sort(); |
2388 | inc->setCategories( newCatList.join(",") ); | 2378 | inc->setCategories( newCatList.join(",") ); |
2389 | inc = incList.next(); | 2379 | inc = incList.next(); |
2390 | } | 2380 | } |
2391 | } | 2381 | } |
2392 | 2382 | ||
2393 | int CalendarView::addCategories() | 2383 | int CalendarView::addCategories() |
2394 | { | 2384 | { |
2395 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2385 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2396 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2386 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2397 | QStringList catIncList; | 2387 | QStringList catIncList; |
2398 | Incidence* inc = incList.first(); | 2388 | Incidence* inc = incList.first(); |
2399 | int i; | 2389 | int i; |
2400 | int count = 0; | 2390 | int count = 0; |
2401 | while ( inc ) { | 2391 | while ( inc ) { |
2402 | catIncList = inc->categories() ; | 2392 | catIncList = inc->categories() ; |
2403 | for( i = 0; i< catIncList.count(); ++i ) { | 2393 | for( i = 0; i< catIncList.count(); ++i ) { |
2404 | if ( !catList.contains (catIncList[i])) { | 2394 | if ( !catList.contains (catIncList[i])) { |
2405 | catList.append( catIncList[i] ); | 2395 | catList.append( catIncList[i] ); |
2406 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2396 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2407 | ++count; | 2397 | ++count; |
2408 | } | 2398 | } |
2409 | } | 2399 | } |
2410 | inc = incList.next(); | 2400 | inc = incList.next(); |
2411 | } | 2401 | } |
2412 | catList.sort(); | 2402 | catList.sort(); |
2413 | KOPrefs::instance()->mCustomCategories = catList; | 2403 | KOPrefs::instance()->mCustomCategories = catList; |
2414 | return count; | 2404 | return count; |
2415 | } | 2405 | } |
2416 | 2406 | ||
2417 | void CalendarView::manageCategories() | 2407 | void CalendarView::manageCategories() |
2418 | { | 2408 | { |
2419 | KOCatPrefs* cp = new KOCatPrefs(); | 2409 | KOCatPrefs* cp = new KOCatPrefs(); |
2420 | cp->show(); | 2410 | cp->show(); |
2421 | int w =cp->sizeHint().width() ; | 2411 | int w =cp->sizeHint().width() ; |
2422 | int h = cp->sizeHint().height() ; | 2412 | int h = cp->sizeHint().height() ; |
2423 | int dw = QApplication::desktop()->width(); | 2413 | int dw = QApplication::desktop()->width(); |
2424 | int dh = QApplication::desktop()->height(); | 2414 | int dh = QApplication::desktop()->height(); |
2425 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2415 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2426 | if ( !cp->exec() ) { | 2416 | if ( !cp->exec() ) { |
2427 | delete cp; | 2417 | delete cp; |
2428 | return; | 2418 | return; |
2429 | } | 2419 | } |
2430 | int count = 0; | 2420 | int count = 0; |
2431 | if ( cp->addCat() ) { | 2421 | if ( cp->addCat() ) { |
2432 | count = addCategories(); | 2422 | count = addCategories(); |
2433 | if ( count ) { | 2423 | if ( count ) { |
2434 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2424 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2435 | writeSettings(); | 2425 | writeSettings(); |
2436 | } else | 2426 | } else |
2437 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2427 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2438 | } else { | 2428 | } else { |
2439 | removeCategories(); | 2429 | removeCategories(); |
2440 | updateView(); | 2430 | updateView(); |
2441 | } | 2431 | } |
2442 | delete cp; | 2432 | delete cp; |
2443 | } | 2433 | } |
2444 | 2434 | ||
2445 | void CalendarView::beamIncidence(Incidence * Inc) | 2435 | void CalendarView::beamIncidence(Incidence * Inc) |
2446 | { | 2436 | { |
2447 | QPtrList<Incidence> delSel ; | 2437 | QPtrList<Incidence> delSel ; |
2448 | delSel.append(Inc); | 2438 | delSel.append(Inc); |
2449 | beamIncidenceList( delSel ); | 2439 | beamIncidenceList( delSel ); |
2450 | } | 2440 | } |
2451 | void CalendarView::beamCalendar() | 2441 | void CalendarView::beamCalendar() |
2452 | { | 2442 | { |
2453 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2443 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2454 | //qDebug("beamCalendar() "); | 2444 | //qDebug("beamCalendar() "); |
2455 | beamIncidenceList( delSel ); | 2445 | beamIncidenceList( delSel ); |
2456 | } | 2446 | } |
2457 | void CalendarView::beamFilteredCalendar() | 2447 | void CalendarView::beamFilteredCalendar() |
2458 | { | 2448 | { |
2459 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2449 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2460 | //qDebug("beamFilteredCalendar() "); | 2450 | //qDebug("beamFilteredCalendar() "); |
2461 | beamIncidenceList( delSel ); | 2451 | beamIncidenceList( delSel ); |
2462 | } | 2452 | } |
2463 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2453 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2464 | { | 2454 | { |
2465 | if ( beamDialog->exec () == QDialog::Rejected ) | 2455 | if ( beamDialog->exec () == QDialog::Rejected ) |
2466 | return; | 2456 | return; |
2467 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2468 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2458 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2469 | #else | 2459 | #else |
2470 | QString fn = "/tmp/kopibeamfile"; | 2460 | QString fn = "/tmp/kopibeamfile"; |
2471 | #endif | 2461 | #endif |
2472 | QString mes; | 2462 | QString mes; |
2473 | bool createbup = true; | 2463 | bool createbup = true; |
2474 | if ( createbup ) { | 2464 | if ( createbup ) { |
2475 | QString description = "\n"; | 2465 | QString description = "\n"; |
2476 | CalendarLocal* cal = new CalendarLocal(); | 2466 | CalendarLocal* cal = new CalendarLocal(); |
2477 | if ( beamDialog->beamLocal() ) | 2467 | if ( beamDialog->beamLocal() ) |
2478 | cal->setLocalTime(); | 2468 | cal->setLocalTime(); |
2479 | else | 2469 | else |
2480 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2470 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2481 | Incidence *incidence = delSel.first(); | 2471 | Incidence *incidence = delSel.first(); |
2482 | bool addText = false; | 2472 | bool addText = false; |
2483 | if ( delSel.count() < 10 ) | 2473 | if ( delSel.count() < 10 ) |
2484 | addText = true; | 2474 | addText = true; |
2485 | else { | 2475 | else { |
2486 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2476 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2487 | } | 2477 | } |
2488 | while ( incidence ) { | 2478 | while ( incidence ) { |
2489 | Incidence *in = incidence->clone(); | 2479 | Incidence *in = incidence->clone(); |
2490 | if ( ! in->summary().isEmpty() ) { | 2480 | if ( ! in->summary().isEmpty() ) { |
2491 | in->setDescription(""); | 2481 | in->setDescription(""); |
2492 | } else { | 2482 | } else { |
2493 | in->setSummary( in->description().left(20)); | 2483 | in->setSummary( in->description().left(20)); |
2494 | in->setDescription(""); | 2484 | in->setDescription(""); |
2495 | } | 2485 | } |
2496 | if ( addText ) | 2486 | if ( addText ) |
2497 | description += in->summary() + "\n"; | 2487 | description += in->summary() + "\n"; |
2498 | cal->addIncidence( in ); | 2488 | cal->addIncidence( in ); |
2499 | incidence = delSel.next(); | 2489 | incidence = delSel.next(); |
2500 | } | 2490 | } |
2501 | if ( beamDialog->beamVcal() ) { | 2491 | if ( beamDialog->beamVcal() ) { |
2502 | fn += ".vcs"; | 2492 | fn += ".vcs"; |
2503 | FileStorage storage( cal, fn, new VCalFormat ); | 2493 | FileStorage storage( cal, fn, new VCalFormat ); |
2504 | storage.save(); | 2494 | storage.save(); |
2505 | } else { | 2495 | } else { |
2506 | fn += ".ics"; | 2496 | fn += ".ics"; |
2507 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2497 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2508 | storage.save(); | 2498 | storage.save(); |
2509 | } | 2499 | } |
2510 | delete cal; | 2500 | delete cal; |
2511 | mes = i18n("KO/Pi: Ready for beaming"); | 2501 | mes = i18n("KO/Pi: Ready for beaming"); |
2512 | topLevelWidget()->setCaption(mes); | 2502 | topLevelWidget()->setCaption(mes); |
2513 | KApplication::convert2latin1( fn ); | 2503 | KApplication::convert2latin1( fn ); |
2514 | #ifndef DESKTOP_VERSION | 2504 | #ifndef DESKTOP_VERSION |
2515 | Ir *ir = new Ir( this ); | 2505 | Ir *ir = new Ir( this ); |
2516 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2506 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2517 | ir->send( fn, description, "text/x-vCalendar" ); | 2507 | ir->send( fn, description, "text/x-vCalendar" ); |
2518 | #endif | 2508 | #endif |
2519 | } | 2509 | } |
2520 | } | 2510 | } |
2521 | void CalendarView::beamDone( Ir *ir ) | 2511 | void CalendarView::beamDone( Ir *ir ) |
2522 | { | 2512 | { |
2523 | #ifndef DESKTOP_VERSION | 2513 | #ifndef DESKTOP_VERSION |
2524 | delete ir; | 2514 | delete ir; |
2525 | #endif | 2515 | #endif |
2526 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2516 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2527 | topLevelWidget()->raise(); | 2517 | topLevelWidget()->raise(); |
2528 | } | 2518 | } |
2529 | 2519 | ||
2530 | void CalendarView::moveIncidence(Incidence * inc ) | 2520 | void CalendarView::moveIncidence(Incidence * inc ) |
2531 | { | 2521 | { |
2532 | if ( !inc ) return; | 2522 | if ( !inc ) return; |
2533 | showDatePickerPopup(); | 2523 | showDatePickerPopup(); |
2534 | mDatePickerMode = 2; | 2524 | mDatePickerMode = 2; |
2535 | mMoveIncidence = inc ; | 2525 | mMoveIncidence = inc ; |
2536 | QDate da; | 2526 | QDate da; |
2537 | if ( mMoveIncidence->type() == "Todo" ) { | 2527 | if ( mMoveIncidence->type() == "Todo" ) { |
2538 | Todo * to = (Todo *) mMoveIncidence; | 2528 | Todo * to = (Todo *) mMoveIncidence; |
2539 | if ( to->hasDueDate() ) | 2529 | if ( to->hasDueDate() ) |
2540 | da = to->dtDue().date(); | 2530 | da = to->dtDue().date(); |
2541 | else | 2531 | else |
2542 | da = QDate::currentDate(); | 2532 | da = QDate::currentDate(); |
2543 | } else { | 2533 | } else { |
2544 | da = mMoveIncidence->dtStart().date(); | 2534 | da = mMoveIncidence->dtStart().date(); |
2545 | } | 2535 | } |
2546 | //PENDING set date for recurring incidence to date of recurrence | 2536 | //PENDING set date for recurring incidence to date of recurrence |
2547 | //mMoveIncidenceOldDate; | 2537 | //mMoveIncidenceOldDate; |
2548 | mDatePicker->setDate( da ); | 2538 | mDatePicker->setDate( da ); |
2549 | } | 2539 | } |
2550 | void CalendarView::showDatePickerPopup() | 2540 | void CalendarView::showDatePickerPopup() |
2551 | { | 2541 | { |
2552 | if ( mDateFrame->isVisible() ) | 2542 | if ( mDateFrame->isVisible() ) |
2553 | mDateFrame->hide(); | 2543 | mDateFrame->hide(); |
2554 | else { | 2544 | else { |
2555 | int offX = 0, offY = 0; | 2545 | int offX = 0, offY = 0; |
2556 | #ifdef DESKTOP_VERSION | 2546 | #ifdef DESKTOP_VERSION |
2557 | int w =mDatePicker->sizeHint().width() ; | 2547 | int w =mDatePicker->sizeHint().width() ; |
2558 | int h = mDatePicker->sizeHint().height() ; | 2548 | int h = mDatePicker->sizeHint().height() ; |
2559 | int dw = topLevelWidget()->width(); | 2549 | int dw = topLevelWidget()->width(); |
2560 | int dh = topLevelWidget()->height(); | 2550 | int dh = topLevelWidget()->height(); |
2561 | offX = topLevelWidget()->x(); | 2551 | offX = topLevelWidget()->x(); |
2562 | offY = topLevelWidget()->y(); | 2552 | offY = topLevelWidget()->y(); |
2563 | #else | 2553 | #else |
2564 | int w =mDatePicker->sizeHint().width() ; | 2554 | int w =mDatePicker->sizeHint().width() ; |
2565 | int h = mDatePicker->sizeHint().height() ; | 2555 | int h = mDatePicker->sizeHint().height() ; |
2566 | int dw = QApplication::desktop()->width(); | 2556 | int dw = QApplication::desktop()->width(); |
2567 | int dh = QApplication::desktop()->height(); | 2557 | int dh = QApplication::desktop()->height(); |
2568 | #endif | 2558 | #endif |
2569 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2559 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2570 | mDateFrame->show(); | 2560 | mDateFrame->show(); |
2571 | } | 2561 | } |
2572 | } | 2562 | } |
2573 | void CalendarView::showDatePicker( ) | 2563 | void CalendarView::showDatePicker( ) |
2574 | { | 2564 | { |
2575 | showDatePickerPopup(); | 2565 | showDatePickerPopup(); |
2576 | mDatePickerMode = 1; | 2566 | mDatePickerMode = 1; |
2577 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2567 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2578 | } | 2568 | } |
2579 | 2569 | ||
2580 | void CalendarView::showEventEditor() | 2570 | void CalendarView::showEventEditor() |
2581 | { | 2571 | { |
2582 | #ifdef DESKTOP_VERSION | 2572 | #ifdef DESKTOP_VERSION |
2583 | int x,y,w,h; | 2573 | int x,y,w,h; |
2584 | x = mEventEditor->geometry().x(); | 2574 | x = mEventEditor->geometry().x(); |
2585 | y = mEventEditor->geometry().y(); | 2575 | y = mEventEditor->geometry().y(); |
2586 | w = mEventEditor->width(); | 2576 | w = mEventEditor->width(); |
2587 | h = mEventEditor->height(); | 2577 | h = mEventEditor->height(); |
2588 | mEventEditor->show(); | 2578 | mEventEditor->show(); |
2589 | mEventEditor->setGeometry(x,y,w,h); | 2579 | mEventEditor->setGeometry(x,y,w,h); |
2590 | #else | 2580 | #else |
2591 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2581 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2592 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2582 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2593 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2583 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2594 | qApp->processEvents(); | 2584 | qApp->processEvents(); |
2595 | delete mEventEditor; | 2585 | delete mEventEditor; |
2596 | mEventEditor = mDialogManager->getEventEditor(); | 2586 | mEventEditor = mDialogManager->getEventEditor(); |
2597 | topLevelWidget()->setCaption( i18n("") ); | 2587 | topLevelWidget()->setCaption( i18n("") ); |
2598 | } | 2588 | } |
2599 | mEventEditor->showMaximized(); | 2589 | mEventEditor->showMaximized(); |
2600 | #endif | 2590 | #endif |
2601 | } | 2591 | } |
2602 | void CalendarView::showTodoEditor() | 2592 | void CalendarView::showTodoEditor() |
2603 | { | 2593 | { |
2604 | #ifdef DESKTOP_VERSION | 2594 | #ifdef DESKTOP_VERSION |
2605 | int x,y,w,h; | 2595 | int x,y,w,h; |
2606 | x = mTodoEditor->geometry().x(); | 2596 | x = mTodoEditor->geometry().x(); |
2607 | y = mTodoEditor->geometry().y(); | 2597 | y = mTodoEditor->geometry().y(); |
2608 | w = mTodoEditor->width(); | 2598 | w = mTodoEditor->width(); |
2609 | h = mTodoEditor->height(); | 2599 | h = mTodoEditor->height(); |
2610 | mTodoEditor->show(); | 2600 | mTodoEditor->show(); |
2611 | mTodoEditor->setGeometry(x,y,w,h); | 2601 | mTodoEditor->setGeometry(x,y,w,h); |
2612 | #else | 2602 | #else |
2613 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2603 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2614 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2604 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2615 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2605 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2616 | qApp->processEvents(); | 2606 | qApp->processEvents(); |
2617 | delete mTodoEditor; | 2607 | delete mTodoEditor; |
2618 | mTodoEditor = mDialogManager->getTodoEditor(); | 2608 | mTodoEditor = mDialogManager->getTodoEditor(); |
2619 | topLevelWidget()->setCaption( i18n("") ); | 2609 | topLevelWidget()->setCaption( i18n("") ); |
2620 | } | 2610 | } |
2621 | mTodoEditor->showMaximized(); | 2611 | mTodoEditor->showMaximized(); |
2622 | #endif | 2612 | #endif |
2623 | } | 2613 | } |
2624 | 2614 | ||
2625 | void CalendarView::cloneIncidence() | 2615 | void CalendarView::cloneIncidence() |
2626 | { | 2616 | { |
2627 | Incidence *incidence = currentSelection(); | 2617 | Incidence *incidence = currentSelection(); |
2628 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2618 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2629 | if ( incidence ) { | 2619 | if ( incidence ) { |
2630 | cloneIncidence(incidence); | 2620 | cloneIncidence(incidence); |
2631 | } | 2621 | } |
2632 | } | 2622 | } |
2633 | void CalendarView::moveIncidence() | 2623 | void CalendarView::moveIncidence() |
2634 | { | 2624 | { |
2635 | Incidence *incidence = currentSelection(); | 2625 | Incidence *incidence = currentSelection(); |
2636 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2626 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2637 | if ( incidence ) { | 2627 | if ( incidence ) { |
2638 | moveIncidence(incidence); | 2628 | moveIncidence(incidence); |
2639 | } | 2629 | } |
2640 | } | 2630 | } |
2641 | void CalendarView::beamIncidence() | 2631 | void CalendarView::beamIncidence() |
2642 | { | 2632 | { |
2643 | Incidence *incidence = currentSelection(); | 2633 | Incidence *incidence = currentSelection(); |
2644 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2634 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2645 | if ( incidence ) { | 2635 | if ( incidence ) { |
2646 | beamIncidence(incidence); | 2636 | beamIncidence(incidence); |
2647 | } | 2637 | } |
2648 | } | 2638 | } |
2649 | void CalendarView::toggleCancelIncidence() | 2639 | void CalendarView::toggleCancelIncidence() |
2650 | { | 2640 | { |
2651 | Incidence *incidence = currentSelection(); | 2641 | Incidence *incidence = currentSelection(); |
2652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2642 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2653 | if ( incidence ) { | 2643 | if ( incidence ) { |
2654 | cancelIncidence(incidence); | 2644 | cancelIncidence(incidence); |
2655 | } | 2645 | } |
2656 | } | 2646 | } |
2657 | 2647 | ||
2658 | 2648 | ||
2659 | void CalendarView::cancelIncidence(Incidence * inc ) | 2649 | void CalendarView::cancelIncidence(Incidence * inc ) |
2660 | { | 2650 | { |
2661 | inc->setCancelled( ! inc->cancelled() ); | 2651 | inc->setCancelled( ! inc->cancelled() ); |
2662 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2652 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2663 | updateView(); | 2653 | updateView(); |
2664 | } | 2654 | } |
2665 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2655 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2666 | { | 2656 | { |
2667 | Incidence * newInc = orgInc->clone(); | 2657 | Incidence * newInc = orgInc->clone(); |
2668 | newInc->recreate(); | 2658 | newInc->recreate(); |
2669 | 2659 | ||
2670 | if ( newInc->type() == "Todo" ) { | 2660 | if ( newInc->type() == "Todo" ) { |
2671 | Todo* t = (Todo*) newInc; | 2661 | Todo* t = (Todo*) newInc; |
2672 | showTodoEditor(); | 2662 | showTodoEditor(); |
2673 | mTodoEditor->editTodo( t ); | 2663 | mTodoEditor->editTodo( t ); |
2674 | if ( mTodoEditor->exec() ) { | 2664 | if ( mTodoEditor->exec() ) { |
2675 | mCalendar->addTodo( t ); | 2665 | mCalendar->addTodo( t ); |
2676 | updateView(); | 2666 | updateView(); |
2677 | } else { | 2667 | } else { |
2678 | delete t; | 2668 | delete t; |
2679 | } | 2669 | } |
2680 | } | 2670 | } |
2681 | else { | 2671 | else { |
2682 | Event* e = (Event*) newInc; | 2672 | Event* e = (Event*) newInc; |
2683 | showEventEditor(); | 2673 | showEventEditor(); |
2684 | mEventEditor->editEvent( e ); | 2674 | mEventEditor->editEvent( e ); |
2685 | if ( mEventEditor->exec() ) { | 2675 | if ( mEventEditor->exec() ) { |
2686 | mCalendar->addEvent( e ); | 2676 | mCalendar->addEvent( e ); |
2687 | updateView(); | 2677 | updateView(); |
2688 | } else { | 2678 | } else { |
2689 | delete e; | 2679 | delete e; |
2690 | } | 2680 | } |
2691 | } | 2681 | } |
2692 | setActiveWindow(); | 2682 | setActiveWindow(); |
2693 | } | 2683 | } |
2694 | 2684 | ||
2695 | void CalendarView::newEvent() | 2685 | void CalendarView::newEvent() |
2696 | { | 2686 | { |
2697 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2687 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2698 | KOAgendaView *aView = mViewManager->agendaView(); | 2688 | KOAgendaView *aView = mViewManager->agendaView(); |
2699 | if (aView) { | 2689 | if (aView) { |
2700 | if (aView->selectionStart().isValid()) { | 2690 | if (aView->selectionStart().isValid()) { |
2701 | if (aView->selectedIsAllDay()) { | 2691 | if (aView->selectedIsAllDay()) { |
2702 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2692 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2703 | } else { | 2693 | } else { |
2704 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2694 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2705 | } | 2695 | } |
2706 | return; | 2696 | return; |
2707 | } | 2697 | } |
2708 | } | 2698 | } |
2709 | 2699 | ||
2710 | QDate date = mNavigator->selectedDates().first(); | 2700 | QDate date = mNavigator->selectedDates().first(); |
2711 | QDateTime current = QDateTime::currentDateTime(); | 2701 | QDateTime current = QDateTime::currentDateTime(); |
2712 | if ( date <= current.date() ) { | 2702 | if ( date <= current.date() ) { |
2713 | int hour = current.time().hour() +1; | 2703 | int hour = current.time().hour() +1; |
2714 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2704 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2715 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2705 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2716 | } else | 2706 | } else |
2717 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2707 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2718 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2708 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2719 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2709 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2720 | } | 2710 | } |
2721 | 2711 | ||
2722 | void CalendarView::newEvent(QDateTime fh) | 2712 | void CalendarView::newEvent(QDateTime fh) |
2723 | { | 2713 | { |
2724 | newEvent(fh, | 2714 | newEvent(fh, |
2725 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2715 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2726 | } | 2716 | } |
2727 | 2717 | ||
2728 | void CalendarView::newEvent(QDate dt) | 2718 | void CalendarView::newEvent(QDate dt) |
2729 | { | 2719 | { |
2730 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2720 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2731 | QDateTime(dt, QTime(0,0,0)), true); | 2721 | QDateTime(dt, QTime(0,0,0)), true); |
2732 | } | 2722 | } |
2733 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2723 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2734 | { | 2724 | { |
2735 | newEvent(fromHint, toHint, false); | 2725 | newEvent(fromHint, toHint, false); |
2736 | } | 2726 | } |
2737 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2727 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2738 | { | 2728 | { |
2739 | 2729 | ||
2740 | showEventEditor(); | 2730 | showEventEditor(); |
2741 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2731 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2742 | if ( mFilterView->filtersEnabled() ) { | 2732 | if ( mFilterView->filtersEnabled() ) { |
2743 | CalFilter *filter = mFilterView->selectedFilter(); | 2733 | CalFilter *filter = mFilterView->selectedFilter(); |
2744 | if (filter && filter->showCategories()) { | 2734 | if (filter && filter->showCategories()) { |
2745 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2735 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2746 | } | 2736 | } |
2747 | if ( filter ) | 2737 | if ( filter ) |
2748 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2738 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2749 | } | 2739 | } |
2750 | mEventEditor->exec(); | 2740 | mEventEditor->exec(); |
2751 | setActiveWindow(); | 2741 | setActiveWindow(); |
2752 | } | 2742 | } |
2753 | void CalendarView::todoAdded(Todo * t) | 2743 | void CalendarView::todoAdded(Todo * t) |
2754 | { | 2744 | { |
2755 | 2745 | ||
2756 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2746 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2757 | updateTodoViews(); | 2747 | updateTodoViews(); |
2758 | } | 2748 | } |
2759 | void CalendarView::todoChanged(Todo * t) | 2749 | void CalendarView::todoChanged(Todo * t) |
2760 | { | 2750 | { |
2761 | emit todoModified( t, 4 ); | 2751 | emit todoModified( t, 4 ); |
2762 | // updateTodoViews(); | 2752 | // updateTodoViews(); |
2763 | } | 2753 | } |
2764 | void CalendarView::todoToBeDeleted(Todo *) | 2754 | void CalendarView::todoToBeDeleted(Todo *) |
2765 | { | 2755 | { |
2766 | //qDebug("todoToBeDeleted(Todo *) "); | 2756 | //qDebug("todoToBeDeleted(Todo *) "); |
2767 | updateTodoViews(); | 2757 | updateTodoViews(); |
2768 | } | 2758 | } |
2769 | void CalendarView::todoDeleted() | 2759 | void CalendarView::todoDeleted() |
2770 | { | 2760 | { |
2771 | //qDebug(" todoDeleted()"); | 2761 | //qDebug(" todoDeleted()"); |
2772 | updateTodoViews(); | 2762 | updateTodoViews(); |
2773 | } | 2763 | } |
2774 | 2764 | ||
2775 | 2765 | ||
2776 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2766 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2777 | { | 2767 | { |
2778 | showTodoEditor(); | 2768 | showTodoEditor(); |
2779 | mTodoEditor->newTodo(dt,0,allday); | 2769 | mTodoEditor->newTodo(dt,0,allday); |
2780 | if ( mFilterView->filtersEnabled() ) { | 2770 | if ( mFilterView->filtersEnabled() ) { |
2781 | CalFilter *filter = mFilterView->selectedFilter(); | 2771 | CalFilter *filter = mFilterView->selectedFilter(); |
2782 | if (filter && filter->showCategories()) { | 2772 | if (filter && filter->showCategories()) { |
2783 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2773 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2784 | } | 2774 | } |
2785 | if ( filter ) | 2775 | if ( filter ) |
2786 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2776 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2787 | } | 2777 | } |
2788 | mTodoEditor->exec(); | 2778 | mTodoEditor->exec(); |
2789 | setActiveWindow(); | 2779 | setActiveWindow(); |
2790 | } | 2780 | } |
2791 | 2781 | ||
2792 | void CalendarView::newTodo() | 2782 | void CalendarView::newTodo() |
2793 | { | 2783 | { |
2794 | newTodoDateTime( QDateTime(),true ); | 2784 | newTodoDateTime( QDateTime(),true ); |
2795 | } | 2785 | } |
2796 | 2786 | ||
2797 | void CalendarView::newSubTodo() | 2787 | void CalendarView::newSubTodo() |
2798 | { | 2788 | { |
2799 | Todo *todo = selectedTodo(); | 2789 | Todo *todo = selectedTodo(); |
2800 | if ( todo ) newSubTodo( todo ); | 2790 | if ( todo ) newSubTodo( todo ); |
2801 | } | 2791 | } |
2802 | 2792 | ||
2803 | void CalendarView::newSubTodo(Todo *parentEvent) | 2793 | void CalendarView::newSubTodo(Todo *parentEvent) |
2804 | { | 2794 | { |
2805 | 2795 | ||
2806 | showTodoEditor(); | 2796 | showTodoEditor(); |
2807 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2797 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2808 | mTodoEditor->exec(); | 2798 | mTodoEditor->exec(); |
2809 | setActiveWindow(); | 2799 | setActiveWindow(); |
2810 | } | 2800 | } |
2811 | 2801 | ||
2812 | void CalendarView::newFloatingEvent() | 2802 | void CalendarView::newFloatingEvent() |
2813 | { | 2803 | { |
2814 | DateList tmpList = mNavigator->selectedDates(); | 2804 | DateList tmpList = mNavigator->selectedDates(); |
2815 | QDate date = tmpList.first(); | 2805 | QDate date = tmpList.first(); |
2816 | 2806 | ||
2817 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2807 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2818 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2808 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2819 | } | 2809 | } |
2820 | 2810 | ||
2821 | 2811 | ||
2822 | void CalendarView::editEvent( Event *event ) | 2812 | void CalendarView::editEvent( Event *event ) |
2823 | { | 2813 | { |
2824 | 2814 | ||
2825 | if ( !event ) return; | 2815 | if ( !event ) return; |
2826 | if ( event->isReadOnly() ) { | 2816 | if ( event->isReadOnly() ) { |
2827 | showEvent( event ); | 2817 | showEvent( event ); |
2828 | return; | 2818 | return; |
2829 | } | 2819 | } |
2830 | showEventEditor(); | 2820 | showEventEditor(); |
2831 | mEventEditor->editEvent( event , mFlagEditDescription); | 2821 | mEventEditor->editEvent( event , mFlagEditDescription); |
2832 | mEventEditor->exec(); | 2822 | mEventEditor->exec(); |
2833 | setActiveWindow(); | 2823 | setActiveWindow(); |
2834 | 2824 | ||
2835 | } | 2825 | } |
2836 | void CalendarView::editJournal( Journal *jour ) | 2826 | void CalendarView::editJournal( Journal *jour ) |
2837 | { | 2827 | { |
2838 | if ( !jour ) return; | 2828 | if ( !jour ) return; |
2839 | mDialogManager->hideSearchDialog(); | 2829 | mDialogManager->hideSearchDialog(); |
2840 | mViewManager->showJournalView(); | 2830 | mViewManager->showJournalView(); |
2841 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2831 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2842 | } | 2832 | } |
2843 | void CalendarView::editTodo( Todo *todo ) | 2833 | void CalendarView::editTodo( Todo *todo ) |
2844 | { | 2834 | { |
2845 | if ( !todo ) return; | 2835 | if ( !todo ) return; |
2846 | 2836 | ||
2847 | if ( todo->isReadOnly() ) { | 2837 | if ( todo->isReadOnly() ) { |
2848 | showTodo( todo ); | 2838 | showTodo( todo ); |
2849 | return; | 2839 | return; |
2850 | } | 2840 | } |
2851 | showTodoEditor(); | 2841 | showTodoEditor(); |
2852 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2842 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2853 | mTodoEditor->exec(); | 2843 | mTodoEditor->exec(); |
2854 | setActiveWindow(); | 2844 | setActiveWindow(); |
2855 | 2845 | ||
2856 | } | 2846 | } |
2857 | 2847 | ||
2858 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2848 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2859 | { | 2849 | { |
2860 | if ( !mEventViewerDialog ) { | 2850 | if ( !mEventViewerDialog ) { |
2861 | mEventViewerDialog = new KOEventViewerDialog(0); | 2851 | mEventViewerDialog = new KOEventViewerDialog(0); |
2862 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2852 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2863 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2853 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2864 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2854 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2865 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2855 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2866 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2856 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2867 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2857 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2868 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2858 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2869 | this, SLOT( slotViewerClosed() ) ); | 2859 | this, SLOT( slotViewerClosed() ) ); |
2870 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2860 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2871 | this, SLOT( todoChanged(Todo *) ) ); | 2861 | this, SLOT( todoChanged(Todo *) ) ); |
2872 | mEventViewerDialog->resize( 640, 480 ); | 2862 | mEventViewerDialog->resize( 640, 480 ); |
2873 | 2863 | ||
2874 | } | 2864 | } |
2875 | return mEventViewerDialog; | 2865 | return mEventViewerDialog; |
2876 | } | 2866 | } |
2877 | void CalendarView::showEvent(Event *event) | 2867 | void CalendarView::showEvent(Event *event) |
2878 | { | 2868 | { |
2879 | getEventViewerDialog()->setEvent(event); | 2869 | getEventViewerDialog()->setEvent(event); |
2880 | getEventViewerDialog()->showMe(); | 2870 | getEventViewerDialog()->showMe(); |
2881 | } | 2871 | } |
2882 | 2872 | ||
2883 | void CalendarView::showTodo(Todo *event) | 2873 | void CalendarView::showTodo(Todo *event) |
2884 | { | 2874 | { |
2885 | getEventViewerDialog()->setTodo(event); | 2875 | getEventViewerDialog()->setTodo(event); |
2886 | getEventViewerDialog()->showMe(); | 2876 | getEventViewerDialog()->showMe(); |
2887 | } | 2877 | } |
2888 | void CalendarView::showJournal( Journal *jour ) | 2878 | void CalendarView::showJournal( Journal *jour ) |
2889 | { | 2879 | { |
2890 | getEventViewerDialog()->setJournal(jour); | 2880 | getEventViewerDialog()->setJournal(jour); |
2891 | getEventViewerDialog()->showMe(); | 2881 | getEventViewerDialog()->showMe(); |
2892 | 2882 | ||
2893 | } | 2883 | } |
2894 | // void CalendarView::todoModified (Todo *event, int changed) | 2884 | // void CalendarView::todoModified (Todo *event, int changed) |
2895 | // { | 2885 | // { |
2896 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2886 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2897 | // // kdDebug() << "Todo modified and open" << endl; | 2887 | // // kdDebug() << "Todo modified and open" << endl; |
2898 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2888 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2899 | // // temp->modified (changed); | 2889 | // // temp->modified (changed); |
2900 | 2890 | ||
2901 | // // } | 2891 | // // } |
2902 | 2892 | ||
2903 | // mViewManager->updateView(); | 2893 | // mViewManager->updateView(); |
2904 | // } | 2894 | // } |
2905 | 2895 | ||
2906 | void CalendarView::appointment_show() | 2896 | void CalendarView::appointment_show() |
2907 | { | 2897 | { |
2908 | Event *anEvent = 0; | 2898 | Event *anEvent = 0; |
2909 | 2899 | ||
2910 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2900 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2911 | 2901 | ||
2912 | if (mViewManager->currentView()->isEventView()) { | 2902 | if (mViewManager->currentView()->isEventView()) { |
2913 | if ( incidence && incidence->type() == "Event" ) { | 2903 | if ( incidence && incidence->type() == "Event" ) { |
2914 | anEvent = static_cast<Event *>(incidence); | 2904 | anEvent = static_cast<Event *>(incidence); |
2915 | } | 2905 | } |
2916 | } | 2906 | } |
2917 | 2907 | ||
2918 | if (!anEvent) { | 2908 | if (!anEvent) { |
2919 | KNotifyClient::beep(); | 2909 | KNotifyClient::beep(); |
2920 | return; | 2910 | return; |
2921 | } | 2911 | } |
2922 | 2912 | ||
2923 | showEvent(anEvent); | 2913 | showEvent(anEvent); |
2924 | } | 2914 | } |
2925 | 2915 | ||
2926 | void CalendarView::appointment_edit() | 2916 | void CalendarView::appointment_edit() |
2927 | { | 2917 | { |
2928 | Event *anEvent = 0; | 2918 | Event *anEvent = 0; |
2929 | 2919 | ||
2930 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2931 | 2921 | ||
2932 | if (mViewManager->currentView()->isEventView()) { | 2922 | if (mViewManager->currentView()->isEventView()) { |
2933 | if ( incidence && incidence->type() == "Event" ) { | 2923 | if ( incidence && incidence->type() == "Event" ) { |
2934 | anEvent = static_cast<Event *>(incidence); | 2924 | anEvent = static_cast<Event *>(incidence); |
2935 | } | 2925 | } |
2936 | } | 2926 | } |
2937 | 2927 | ||
2938 | if (!anEvent) { | 2928 | if (!anEvent) { |
2939 | KNotifyClient::beep(); | 2929 | KNotifyClient::beep(); |
2940 | return; | 2930 | return; |
2941 | } | 2931 | } |
2942 | 2932 | ||
2943 | editEvent(anEvent); | 2933 | editEvent(anEvent); |
2944 | } | 2934 | } |
2945 | 2935 | ||
2946 | void CalendarView::appointment_delete() | 2936 | void CalendarView::appointment_delete() |
2947 | { | 2937 | { |
2948 | Event *anEvent = 0; | 2938 | Event *anEvent = 0; |
2949 | 2939 | ||
2950 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2940 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2951 | 2941 | ||
2952 | if (mViewManager->currentView()->isEventView()) { | 2942 | if (mViewManager->currentView()->isEventView()) { |
2953 | if ( incidence && incidence->type() == "Event" ) { | 2943 | if ( incidence && incidence->type() == "Event" ) { |
2954 | anEvent = static_cast<Event *>(incidence); | 2944 | anEvent = static_cast<Event *>(incidence); |
2955 | } | 2945 | } |
2956 | } | 2946 | } |
2957 | 2947 | ||
2958 | if (!anEvent) { | 2948 | if (!anEvent) { |
2959 | KNotifyClient::beep(); | 2949 | KNotifyClient::beep(); |
2960 | return; | 2950 | return; |
2961 | } | 2951 | } |
2962 | 2952 | ||
2963 | deleteEvent(anEvent); | 2953 | deleteEvent(anEvent); |
2964 | } | 2954 | } |
2965 | 2955 | ||
2966 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2956 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2967 | { | 2957 | { |
2968 | if (!sub) return; | 2958 | if (!sub) return; |
2969 | if (!parent) return; | 2959 | if (!parent) return; |
2970 | if ( sub->relatedTo() ) | 2960 | if ( sub->relatedTo() ) |
2971 | sub->relatedTo()->removeRelation(sub); | 2961 | sub->relatedTo()->removeRelation(sub); |
2972 | sub->setRelatedTo(parent); | 2962 | sub->setRelatedTo(parent); |
2973 | sub->setRelatedToUid(parent->uid()); | 2963 | sub->setRelatedToUid(parent->uid()); |
2974 | parent->addRelation(sub); | 2964 | parent->addRelation(sub); |
2975 | sub->updated(); | 2965 | sub->updated(); |
2976 | parent->updated(); | 2966 | parent->updated(); |
2977 | setModified(true); | 2967 | setModified(true); |
2978 | updateView(); | 2968 | updateView(); |
2979 | } | 2969 | } |
2980 | void CalendarView::todo_unsub(Todo *anTodo ) | 2970 | void CalendarView::todo_unsub(Todo *anTodo ) |
2981 | { | 2971 | { |
2982 | // Todo *anTodo = selectedTodo(); | 2972 | // Todo *anTodo = selectedTodo(); |
2983 | if (!anTodo) return; | 2973 | if (!anTodo) return; |
2984 | if (!anTodo->relatedTo()) return; | 2974 | if (!anTodo->relatedTo()) return; |
2985 | anTodo->relatedTo()->removeRelation(anTodo); | 2975 | anTodo->relatedTo()->removeRelation(anTodo); |
2986 | anTodo->setRelatedTo(0); | 2976 | anTodo->setRelatedTo(0); |
2987 | anTodo->updated(); | 2977 | anTodo->updated(); |
2988 | anTodo->setRelatedToUid(""); | 2978 | anTodo->setRelatedToUid(""); |
2989 | setModified(true); | 2979 | setModified(true); |
2990 | updateView(); | 2980 | updateView(); |
2991 | } | 2981 | } |
2992 | 2982 | ||
2993 | void CalendarView::deleteTodo(Todo *todo) | 2983 | void CalendarView::deleteTodo(Todo *todo) |
2994 | { | 2984 | { |
2995 | if (!todo) { | 2985 | if (!todo) { |
2996 | KNotifyClient::beep(); | 2986 | KNotifyClient::beep(); |
2997 | return; | 2987 | return; |
2998 | } | 2988 | } |
2999 | if (KOPrefs::instance()->mConfirm) { | 2989 | if (KOPrefs::instance()->mConfirm) { |
3000 | QString text = todo->summary().left(20); | 2990 | QString text = todo->summary().left(20); |
3001 | if (!todo->relations().isEmpty()) { | 2991 | if (!todo->relations().isEmpty()) { |
3002 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2992 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3003 | 2993 | ||
3004 | } | 2994 | } |
3005 | switch (msgItemDelete(text)) { | 2995 | switch (msgItemDelete(text)) { |
3006 | case KMessageBox::Continue: // OK | 2996 | case KMessageBox::Continue: // OK |
3007 | bool deleteT = false; | 2997 | bool deleteT = false; |
3008 | if (!todo->relations().isEmpty()) { | 2998 | if (!todo->relations().isEmpty()) { |
3009 | deleteT = removeCompletedSubTodos( todo ); | 2999 | deleteT = removeCompletedSubTodos( todo ); |
3010 | } | 3000 | } |
3011 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3001 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3012 | if ( !deleteT ) { | 3002 | if ( !deleteT ) { |
3013 | checkExternalId( todo ); | 3003 | checkExternalId( todo ); |
3014 | calendar()->deleteTodo(todo); | 3004 | calendar()->deleteTodo(todo); |
3015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3005 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3016 | updateView(); | 3006 | updateView(); |
3017 | } | 3007 | } |
3018 | break; | 3008 | break; |
3019 | } // switch | 3009 | } // switch |
3020 | } else { | 3010 | } else { |
3021 | checkExternalId( todo ); | 3011 | checkExternalId( todo ); |
3022 | mCalendar->deleteTodo(todo); | 3012 | mCalendar->deleteTodo(todo); |
3023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3013 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3024 | updateView(); | 3014 | updateView(); |
3025 | } | 3015 | } |
3026 | 3016 | ||
3027 | emit updateSearchDialog(); | 3017 | emit updateSearchDialog(); |
3028 | } | 3018 | } |
3029 | void CalendarView::deleteJournal(Journal *jour) | 3019 | void CalendarView::deleteJournal(Journal *jour) |
3030 | { | 3020 | { |
3031 | if (!jour) { | 3021 | if (!jour) { |
3032 | KNotifyClient::beep(); | 3022 | KNotifyClient::beep(); |
3033 | return; | 3023 | return; |
3034 | } | 3024 | } |
3035 | if (KOPrefs::instance()->mConfirm) { | 3025 | if (KOPrefs::instance()->mConfirm) { |
3036 | switch (msgItemDelete( jour->description().left(20))) { | 3026 | switch (msgItemDelete( jour->description().left(20))) { |
3037 | case KMessageBox::Continue: // OK | 3027 | case KMessageBox::Continue: // OK |
3038 | calendar()->deleteJournal(jour); | 3028 | calendar()->deleteJournal(jour); |
3039 | updateView(); | 3029 | updateView(); |
3040 | break; | 3030 | break; |
3041 | } // switch | 3031 | } // switch |
3042 | } else { | 3032 | } else { |
3043 | calendar()->deleteJournal(jour);; | 3033 | calendar()->deleteJournal(jour);; |
3044 | updateView(); | 3034 | updateView(); |
3045 | } | 3035 | } |
3046 | emit updateSearchDialog(); | 3036 | emit updateSearchDialog(); |
3047 | } | 3037 | } |
3048 | 3038 | ||
3049 | void CalendarView::deleteEvent(Event *anEvent) | 3039 | void CalendarView::deleteEvent(Event *anEvent) |
3050 | { | 3040 | { |
3051 | if (!anEvent) { | 3041 | if (!anEvent) { |
3052 | KNotifyClient::beep(); | 3042 | KNotifyClient::beep(); |
3053 | return; | 3043 | return; |
3054 | } | 3044 | } |
3055 | 3045 | ||
3056 | if (anEvent->recurrence()->doesRecur()) { | 3046 | if (anEvent->recurrence()->doesRecur()) { |
3057 | QDate itemDate = mViewManager->currentSelectionDate(); | 3047 | QDate itemDate = mViewManager->currentSelectionDate(); |
3058 | int km; | 3048 | int km; |
3059 | if (!itemDate.isValid()) { | 3049 | if (!itemDate.isValid()) { |
3060 | //kdDebug() << "Date Not Valid" << endl; | 3050 | //kdDebug() << "Date Not Valid" << endl; |
3061 | if (KOPrefs::instance()->mConfirm) { | 3051 | if (KOPrefs::instance()->mConfirm) { |
3062 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3052 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3063 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3053 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3064 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3054 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3065 | if ( km == KMessageBox::Continue ) | 3055 | if ( km == KMessageBox::Continue ) |
3066 | km = KMessageBox::No; // No = all below | 3056 | km = KMessageBox::No; // No = all below |
3067 | } else | 3057 | } else |
3068 | km = KMessageBox::No; | 3058 | km = KMessageBox::No; |
3069 | } else { | 3059 | } else { |
3070 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3060 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3071 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3061 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3072 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3062 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3073 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3063 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3074 | i18n("All")); | 3064 | i18n("All")); |
3075 | } | 3065 | } |
3076 | switch(km) { | 3066 | switch(km) { |
3077 | 3067 | ||
3078 | case KMessageBox::No: // Continue // all | 3068 | case KMessageBox::No: // Continue // all |
3079 | //qDebug("KMessageBox::No "); | 3069 | //qDebug("KMessageBox::No "); |
3080 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3070 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3081 | schedule(Scheduler::Cancel,anEvent); | 3071 | schedule(Scheduler::Cancel,anEvent); |
3082 | 3072 | ||
3083 | checkExternalId( anEvent); | 3073 | checkExternalId( anEvent); |
3084 | mCalendar->deleteEvent(anEvent); | 3074 | mCalendar->deleteEvent(anEvent); |
3085 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3075 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3086 | break; | 3076 | break; |
3087 | 3077 | ||
3088 | // Disabled because it does not work | 3078 | // Disabled because it does not work |
3089 | //#if 0 | 3079 | //#if 0 |
3090 | case KMessageBox::Yes: // just this one | 3080 | case KMessageBox::Yes: // just this one |
3091 | //QDate qd = mNavigator->selectedDates().first(); | 3081 | //QDate qd = mNavigator->selectedDates().first(); |
3092 | //if (!qd.isValid()) { | 3082 | //if (!qd.isValid()) { |
3093 | // kdDebug() << "no date selected, or invalid date" << endl; | 3083 | // kdDebug() << "no date selected, or invalid date" << endl; |
3094 | // KNotifyClient::beep(); | 3084 | // KNotifyClient::beep(); |
3095 | // return; | 3085 | // return; |
3096 | //} | 3086 | //} |
3097 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3087 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3098 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3088 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3099 | anEvent->addExDate(itemDate); | 3089 | anEvent->addExDate(itemDate); |
3100 | int duration = anEvent->recurrence()->duration(); | 3090 | int duration = anEvent->recurrence()->duration(); |
3101 | if ( duration > 0 ) { | 3091 | if ( duration > 0 ) { |
3102 | anEvent->recurrence()->setDuration( duration - 1 ); | 3092 | anEvent->recurrence()->setDuration( duration - 1 ); |
3103 | } | 3093 | } |
3104 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3094 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3105 | } | 3095 | } |
3106 | break; | 3096 | break; |
3107 | //#endif | 3097 | //#endif |
3108 | } // switch | 3098 | } // switch |
3109 | } else { | 3099 | } else { |
3110 | if (KOPrefs::instance()->mConfirm) { | 3100 | if (KOPrefs::instance()->mConfirm) { |
3111 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3101 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3112 | i18n("\nAre you sure you want\nto delete this event?"), | 3102 | i18n("\nAre you sure you want\nto delete this event?"), |
3113 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3103 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3114 | case KMessageBox::Continue: // OK | 3104 | case KMessageBox::Continue: // OK |
3115 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3105 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3116 | schedule(Scheduler::Cancel,anEvent); | 3106 | schedule(Scheduler::Cancel,anEvent); |
3117 | checkExternalId( anEvent); | 3107 | checkExternalId( anEvent); |
3118 | mCalendar->deleteEvent(anEvent); | 3108 | mCalendar->deleteEvent(anEvent); |
3119 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3109 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3120 | break; | 3110 | break; |
3121 | } // switch | 3111 | } // switch |
3122 | } else { | 3112 | } else { |
3123 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3113 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3124 | schedule(Scheduler::Cancel,anEvent); | 3114 | schedule(Scheduler::Cancel,anEvent); |
3125 | checkExternalId( anEvent); | 3115 | checkExternalId( anEvent); |
3126 | mCalendar->deleteEvent(anEvent); | 3116 | mCalendar->deleteEvent(anEvent); |
3127 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3117 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3128 | } | 3118 | } |
3129 | } // if-else | 3119 | } // if-else |
3130 | emit updateSearchDialog(); | 3120 | emit updateSearchDialog(); |
3131 | } | 3121 | } |
3132 | 3122 | ||
3133 | bool CalendarView::deleteEvent(const QString &uid) | 3123 | bool CalendarView::deleteEvent(const QString &uid) |
3134 | { | 3124 | { |
3135 | Event *ev = mCalendar->event(uid); | 3125 | Event *ev = mCalendar->event(uid); |
3136 | if (ev) { | 3126 | if (ev) { |
3137 | deleteEvent(ev); | 3127 | deleteEvent(ev); |
3138 | return true; | 3128 | return true; |
3139 | } else { | 3129 | } else { |
3140 | return false; | 3130 | return false; |
3141 | } | 3131 | } |
3142 | } | 3132 | } |
3143 | 3133 | ||
3144 | /*****************************************************************************/ | 3134 | /*****************************************************************************/ |
3145 | 3135 | ||
3146 | void CalendarView::action_mail() | 3136 | void CalendarView::action_mail() |
3147 | { | 3137 | { |
3148 | #ifndef KORG_NOMAIL | 3138 | #ifndef KORG_NOMAIL |
3149 | KOMailClient mailClient; | 3139 | KOMailClient mailClient; |
3150 | 3140 | ||
3151 | Incidence *incidence = currentSelection(); | 3141 | Incidence *incidence = currentSelection(); |
3152 | 3142 | ||
3153 | if (!incidence) { | 3143 | if (!incidence) { |
3154 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3144 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3155 | return; | 3145 | return; |
3156 | } | 3146 | } |
3157 | if(incidence->attendeeCount() == 0 ) { | 3147 | if(incidence->attendeeCount() == 0 ) { |
3158 | KMessageBox::sorry(this, | 3148 | KMessageBox::sorry(this, |
3159 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3149 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3160 | return; | 3150 | return; |
3161 | } | 3151 | } |
3162 | 3152 | ||
3163 | CalendarLocal cal_tmp; | 3153 | CalendarLocal cal_tmp; |
3164 | Event *event = 0; | 3154 | Event *event = 0; |
3165 | Event *ev = 0; | 3155 | Event *ev = 0; |
3166 | if ( incidence && incidence->type() == "Event" ) { | 3156 | if ( incidence && incidence->type() == "Event" ) { |
3167 | event = static_cast<Event *>(incidence); | 3157 | event = static_cast<Event *>(incidence); |
3168 | ev = new Event(*event); | 3158 | ev = new Event(*event); |
3169 | cal_tmp.addEvent(ev); | 3159 | cal_tmp.addEvent(ev); |
3170 | } | 3160 | } |
3171 | ICalFormat mForm(); | 3161 | ICalFormat mForm(); |
3172 | QString attachment = mForm.toString( &cal_tmp ); | 3162 | QString attachment = mForm.toString( &cal_tmp ); |
3173 | if (ev) delete(ev); | 3163 | if (ev) delete(ev); |
3174 | 3164 | ||
3175 | mailClient.mailAttendees(currentSelection(), attachment); | 3165 | mailClient.mailAttendees(currentSelection(), attachment); |
3176 | 3166 | ||
3177 | #endif | 3167 | #endif |
3178 | 3168 | ||
3179 | #if 0 | 3169 | #if 0 |
3180 | Event *anEvent = 0; | 3170 | Event *anEvent = 0; |
3181 | if (mViewManager->currentView()->isEventView()) { | 3171 | if (mViewManager->currentView()->isEventView()) { |
3182 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3172 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3183 | } | 3173 | } |
3184 | 3174 | ||
3185 | if (!anEvent) { | 3175 | if (!anEvent) { |
3186 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3176 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3187 | return; | 3177 | return; |
3188 | } | 3178 | } |
3189 | if(anEvent->attendeeCount() == 0 ) { | 3179 | if(anEvent->attendeeCount() == 0 ) { |
3190 | KMessageBox::sorry(this, | 3180 | KMessageBox::sorry(this, |
3191 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3181 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3192 | return; | 3182 | return; |
3193 | } | 3183 | } |
3194 | 3184 | ||
3195 | mailobject.emailEvent(anEvent); | 3185 | mailobject.emailEvent(anEvent); |
3196 | #endif | 3186 | #endif |
3197 | } | 3187 | } |
3198 | 3188 | ||
3199 | 3189 | ||
3200 | void CalendarView::schedule_publish(Incidence *incidence) | 3190 | void CalendarView::schedule_publish(Incidence *incidence) |
3201 | { | 3191 | { |
3202 | Event *event = 0; | 3192 | Event *event = 0; |
3203 | Todo *todo = 0; | 3193 | Todo *todo = 0; |
3204 | 3194 | ||
3205 | if (incidence == 0) { | 3195 | if (incidence == 0) { |
3206 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3196 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3207 | if (incidence == 0) { | 3197 | if (incidence == 0) { |
3208 | incidence = mTodoList->selectedIncidences().first(); | 3198 | incidence = mTodoList->selectedIncidences().first(); |
3209 | } | 3199 | } |
3210 | } | 3200 | } |
3211 | if ( incidence && incidence->type() == "Event" ) { | 3201 | if ( incidence && incidence->type() == "Event" ) { |
3212 | event = static_cast<Event *>(incidence); | 3202 | event = static_cast<Event *>(incidence); |
3213 | } else { | 3203 | } else { |
3214 | if ( incidence && incidence->type() == "Todo" ) { | 3204 | if ( incidence && incidence->type() == "Todo" ) { |
3215 | todo = static_cast<Todo *>(incidence); | 3205 | todo = static_cast<Todo *>(incidence); |
3216 | } | 3206 | } |
3217 | } | 3207 | } |
3218 | 3208 | ||
3219 | if (!event && !todo) { | 3209 | if (!event && !todo) { |
3220 | KMessageBox::sorry(this,i18n("No event selected.")); | 3210 | KMessageBox::sorry(this,i18n("No event selected.")); |
3221 | return; | 3211 | return; |
3222 | } | 3212 | } |
3223 | 3213 | ||
3224 | PublishDialog *publishdlg = new PublishDialog(); | 3214 | PublishDialog *publishdlg = new PublishDialog(); |
3225 | if (incidence->attendeeCount()>0) { | 3215 | if (incidence->attendeeCount()>0) { |
3226 | QPtrList<Attendee> attendees = incidence->attendees(); | 3216 | QPtrList<Attendee> attendees = incidence->attendees(); |
3227 | attendees.first(); | 3217 | attendees.first(); |
3228 | while ( attendees.current()!=0 ) { | 3218 | while ( attendees.current()!=0 ) { |
3229 | publishdlg->addAttendee(attendees.current()); | 3219 | publishdlg->addAttendee(attendees.current()); |
3230 | attendees.next(); | 3220 | attendees.next(); |
3231 | } | 3221 | } |
3232 | } | 3222 | } |
3233 | bool send = true; | 3223 | bool send = true; |
3234 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3224 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3235 | if ( publishdlg->exec() != QDialog::Accepted ) | 3225 | if ( publishdlg->exec() != QDialog::Accepted ) |
3236 | send = false; | 3226 | send = false; |
3237 | } | 3227 | } |
3238 | if ( send ) { | 3228 | if ( send ) { |
3239 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3229 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3240 | if ( event ) { | 3230 | if ( event ) { |
3241 | Event *ev = new Event(*event); | 3231 | Event *ev = new Event(*event); |
3242 | ev->registerObserver(0); | 3232 | ev->registerObserver(0); |
3243 | ev->clearAttendees(); | 3233 | ev->clearAttendees(); |
3244 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3234 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3245 | delete(ev); | 3235 | delete(ev); |
3246 | } | 3236 | } |
3247 | } else { | 3237 | } else { |
3248 | if ( todo ) { | 3238 | if ( todo ) { |
3249 | Todo *ev = new Todo(*todo); | 3239 | Todo *ev = new Todo(*todo); |
3250 | ev->registerObserver(0); | 3240 | ev->registerObserver(0); |
3251 | ev->clearAttendees(); | 3241 | ev->clearAttendees(); |
3252 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3242 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3253 | delete(ev); | 3243 | delete(ev); |
3254 | } | 3244 | } |
3255 | } | 3245 | } |
3256 | } | 3246 | } |
3257 | } | 3247 | } |
3258 | delete publishdlg; | 3248 | delete publishdlg; |
3259 | } | 3249 | } |
3260 | 3250 | ||
3261 | void CalendarView::schedule_request(Incidence *incidence) | 3251 | void CalendarView::schedule_request(Incidence *incidence) |
3262 | { | 3252 | { |
3263 | schedule(Scheduler::Request,incidence); | 3253 | schedule(Scheduler::Request,incidence); |
3264 | } | 3254 | } |
3265 | 3255 | ||
3266 | void CalendarView::schedule_refresh(Incidence *incidence) | 3256 | void CalendarView::schedule_refresh(Incidence *incidence) |
3267 | { | 3257 | { |
3268 | schedule(Scheduler::Refresh,incidence); | 3258 | schedule(Scheduler::Refresh,incidence); |
3269 | } | 3259 | } |
3270 | 3260 | ||
3271 | void CalendarView::schedule_cancel(Incidence *incidence) | 3261 | void CalendarView::schedule_cancel(Incidence *incidence) |
3272 | { | 3262 | { |
3273 | schedule(Scheduler::Cancel,incidence); | 3263 | schedule(Scheduler::Cancel,incidence); |
3274 | } | 3264 | } |
3275 | 3265 | ||
3276 | void CalendarView::schedule_add(Incidence *incidence) | 3266 | void CalendarView::schedule_add(Incidence *incidence) |
3277 | { | 3267 | { |
3278 | schedule(Scheduler::Add,incidence); | 3268 | schedule(Scheduler::Add,incidence); |
3279 | } | 3269 | } |
3280 | 3270 | ||
3281 | void CalendarView::schedule_reply(Incidence *incidence) | 3271 | void CalendarView::schedule_reply(Incidence *incidence) |
3282 | { | 3272 | { |
3283 | schedule(Scheduler::Reply,incidence); | 3273 | schedule(Scheduler::Reply,incidence); |
3284 | } | 3274 | } |
3285 | 3275 | ||
3286 | void CalendarView::schedule_counter(Incidence *incidence) | 3276 | void CalendarView::schedule_counter(Incidence *incidence) |
3287 | { | 3277 | { |
3288 | schedule(Scheduler::Counter,incidence); | 3278 | schedule(Scheduler::Counter,incidence); |
3289 | } | 3279 | } |
3290 | 3280 | ||
3291 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3281 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3292 | { | 3282 | { |
3293 | schedule(Scheduler::Declinecounter,incidence); | 3283 | schedule(Scheduler::Declinecounter,incidence); |
3294 | } | 3284 | } |
3295 | 3285 | ||
3296 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3286 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3297 | { | 3287 | { |
3298 | QDateTime start = QDateTime::currentDateTime(); | 3288 | QDateTime start = QDateTime::currentDateTime(); |
3299 | QDateTime end = start.addDays(daysToPublish); | 3289 | QDateTime end = start.addDays(daysToPublish); |
3300 | 3290 | ||
3301 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3291 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3302 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3292 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3303 | 3293 | ||
3304 | 3294 | ||
3305 | PublishDialog *publishdlg = new PublishDialog(); | 3295 | PublishDialog *publishdlg = new PublishDialog(); |
3306 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3296 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3307 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3297 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3308 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3298 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3309 | delete(freebusy); | 3299 | delete(freebusy); |
3310 | } | 3300 | } |
3311 | } | 3301 | } |
3312 | delete publishdlg; | 3302 | delete publishdlg; |
3313 | } | 3303 | } |
3314 | 3304 | ||
3315 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3305 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3316 | { | 3306 | { |
3317 | Event *event = 0; | 3307 | Event *event = 0; |
3318 | Todo *todo = 0; | 3308 | Todo *todo = 0; |
3319 | 3309 | ||
3320 | if (incidence == 0) { | 3310 | if (incidence == 0) { |
3321 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3311 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3322 | if (incidence == 0) { | 3312 | if (incidence == 0) { |
3323 | incidence = mTodoList->selectedIncidences().first(); | 3313 | incidence = mTodoList->selectedIncidences().first(); |
3324 | } | 3314 | } |
3325 | } | 3315 | } |
3326 | if ( incidence && incidence->type() == "Event" ) { | 3316 | if ( incidence && incidence->type() == "Event" ) { |
3327 | event = static_cast<Event *>(incidence); | 3317 | event = static_cast<Event *>(incidence); |
3328 | } | 3318 | } |
3329 | if ( incidence && incidence->type() == "Todo" ) { | 3319 | if ( incidence && incidence->type() == "Todo" ) { |
3330 | todo = static_cast<Todo *>(incidence); | 3320 | todo = static_cast<Todo *>(incidence); |
3331 | } | 3321 | } |
3332 | 3322 | ||
3333 | if (!event && !todo) { | 3323 | if (!event && !todo) { |
3334 | KMessageBox::sorry(this,i18n("No event selected.")); | 3324 | KMessageBox::sorry(this,i18n("No event selected.")); |
3335 | return; | 3325 | return; |
3336 | } | 3326 | } |
3337 | 3327 | ||
3338 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3328 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3339 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3329 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3340 | return; | 3330 | return; |
3341 | } | 3331 | } |
3342 | 3332 | ||
3343 | Event *ev = 0; | 3333 | Event *ev = 0; |
3344 | if (event) ev = new Event(*event); | 3334 | if (event) ev = new Event(*event); |
3345 | Todo *to = 0; | 3335 | Todo *to = 0; |
3346 | if (todo) to = new Todo(*todo); | 3336 | if (todo) to = new Todo(*todo); |
3347 | 3337 | ||
3348 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3338 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3349 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3339 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3350 | if (!me) { | 3340 | if (!me) { |
3351 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3341 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3352 | return; | 3342 | return; |
3353 | } | 3343 | } |
3354 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3344 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3355 | StatusDialog *statdlg = new StatusDialog(this); | 3345 | StatusDialog *statdlg = new StatusDialog(this); |
3356 | if (!statdlg->exec()==QDialog::Accepted) return; | 3346 | if (!statdlg->exec()==QDialog::Accepted) return; |
3357 | me->setStatus( statdlg->status() ); | 3347 | me->setStatus( statdlg->status() ); |
3358 | delete(statdlg); | 3348 | delete(statdlg); |
3359 | } | 3349 | } |
3360 | Attendee *menew = new Attendee(*me); | 3350 | Attendee *menew = new Attendee(*me); |
3361 | if (ev) { | 3351 | if (ev) { |
3362 | ev->clearAttendees(); | 3352 | ev->clearAttendees(); |
3363 | ev->addAttendee(menew,false); | 3353 | ev->addAttendee(menew,false); |
3364 | } else { | 3354 | } else { |
3365 | if (to) { | 3355 | if (to) { |
3366 | todo->clearAttendees(); | 3356 | todo->clearAttendees(); |
3367 | todo->addAttendee(menew,false); | 3357 | todo->addAttendee(menew,false); |
3368 | } | 3358 | } |
3369 | } | 3359 | } |
3370 | } | 3360 | } |
3371 | 3361 | ||
3372 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3362 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3373 | if (ev) { | 3363 | if (ev) { |
3374 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3364 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3375 | } else { | 3365 | } else { |
3376 | if (to) { | 3366 | if (to) { |
3377 | if ( !dlg->addMessage(to,method) ) delete(to); | 3367 | if ( !dlg->addMessage(to,method) ) delete(to); |
3378 | } | 3368 | } |
3379 | } | 3369 | } |
3380 | } | 3370 | } |
3381 | 3371 | ||
3382 | void CalendarView::openAddressbook() | 3372 | void CalendarView::openAddressbook() |
3383 | { | 3373 | { |
3384 | KRun::runCommand("kaddressbook"); | 3374 | KRun::runCommand("kaddressbook"); |
3385 | } | 3375 | } |
3386 | 3376 | ||
3387 | void CalendarView::setModified(bool modified) | 3377 | void CalendarView::setModified(bool modified) |
3388 | { | 3378 | { |
3389 | if ( modified ) | 3379 | if ( modified ) |
3390 | emit signalmodified(); | 3380 | emit signalmodified(); |
3391 | if (mModified != modified) { | 3381 | if (mModified != modified) { |
3392 | mModified = modified; | 3382 | mModified = modified; |
3393 | emit modifiedChanged(mModified); | 3383 | emit modifiedChanged(mModified); |
3394 | } | 3384 | } |
3395 | } | 3385 | } |
3396 | 3386 | ||
3397 | bool CalendarView::isReadOnly() | 3387 | bool CalendarView::isReadOnly() |
3398 | { | 3388 | { |
3399 | return mReadOnly; | 3389 | return mReadOnly; |
3400 | } | 3390 | } |
3401 | 3391 | ||
3402 | void CalendarView::setReadOnly(bool readOnly) | 3392 | void CalendarView::setReadOnly(bool readOnly) |
3403 | { | 3393 | { |
3404 | if (mReadOnly != readOnly) { | 3394 | if (mReadOnly != readOnly) { |
3405 | mReadOnly = readOnly; | 3395 | mReadOnly = readOnly; |
3406 | emit readOnlyChanged(mReadOnly); | 3396 | emit readOnlyChanged(mReadOnly); |
3407 | } | 3397 | } |
3408 | } | 3398 | } |
3409 | 3399 | ||
3410 | bool CalendarView::isModified() | 3400 | bool CalendarView::isModified() |
3411 | { | 3401 | { |
3412 | return mModified; | 3402 | return mModified; |
3413 | } | 3403 | } |
3414 | 3404 | ||
3415 | void CalendarView::printSetup() | 3405 | void CalendarView::printSetup() |
3416 | { | 3406 | { |
3417 | #ifndef KORG_NOPRINTER | 3407 | #ifndef KORG_NOPRINTER |
3418 | createPrinter(); | 3408 | createPrinter(); |
3419 | 3409 | ||
3420 | mCalPrinter->setupPrinter(); | 3410 | mCalPrinter->setupPrinter(); |
3421 | #endif | 3411 | #endif |
3422 | } | 3412 | } |
3423 | 3413 | ||
3424 | void CalendarView::print() | 3414 | void CalendarView::print() |
3425 | { | 3415 | { |
3426 | #ifndef KORG_NOPRINTER | 3416 | #ifndef KORG_NOPRINTER |
3427 | createPrinter(); | 3417 | createPrinter(); |
3428 | 3418 | ||
3429 | DateList tmpDateList = mNavigator->selectedDates(); | 3419 | DateList tmpDateList = mNavigator->selectedDates(); |
3430 | mCalPrinter->print(CalPrinter::Month, | 3420 | mCalPrinter->print(CalPrinter::Month, |
3431 | tmpDateList.first(), tmpDateList.last()); | 3421 | tmpDateList.first(), tmpDateList.last()); |
3432 | #endif | 3422 | #endif |
3433 | } | 3423 | } |
3434 | 3424 | ||
3435 | void CalendarView::printPreview() | 3425 | void CalendarView::printPreview() |
3436 | { | 3426 | { |
3437 | #ifndef KORG_NOPRINTER | 3427 | #ifndef KORG_NOPRINTER |
3438 | kdDebug() << "CalendarView::printPreview()" << endl; | 3428 | kdDebug() << "CalendarView::printPreview()" << endl; |
3439 | 3429 | ||
3440 | createPrinter(); | 3430 | createPrinter(); |
3441 | 3431 | ||
3442 | DateList tmpDateList = mNavigator->selectedDates(); | 3432 | DateList tmpDateList = mNavigator->selectedDates(); |
3443 | 3433 | ||
3444 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3434 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3445 | tmpDateList.last()); | 3435 | tmpDateList.last()); |
3446 | #endif | 3436 | #endif |
3447 | } | 3437 | } |
3448 | 3438 | ||
3449 | void CalendarView::exportICalendar() | 3439 | void CalendarView::exportICalendar() |
3450 | { | 3440 | { |
3451 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3441 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3452 | 3442 | ||
3453 | // Force correct extension | 3443 | // Force correct extension |
3454 | if (filename.right(4) != ".ics") filename += ".ics"; | 3444 | if (filename.right(4) != ".ics") filename += ".ics"; |
3455 | 3445 | ||
3456 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3446 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3457 | storage.save(); | 3447 | storage.save(); |
3458 | } | 3448 | } |
3459 | 3449 | ||
3460 | bool CalendarView::exportVCalendar( QString filename ) | 3450 | bool CalendarView::exportVCalendar( QString filename ) |
3461 | { | 3451 | { |
3462 | if (mCalendar->journals().count() > 0) { | 3452 | if (mCalendar->journals().count() > 0) { |
3463 | int result = KMessageBox::warningContinueCancel(this, | 3453 | int result = KMessageBox::warningContinueCancel(this, |
3464 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3454 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3465 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3455 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3466 | true); | 3456 | true); |
3467 | if (result != KMessageBox::Continue) return false; | 3457 | if (result != KMessageBox::Continue) return false; |
3468 | } | 3458 | } |
3469 | 3459 | ||
3470 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3460 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3471 | 3461 | ||
3472 | // Force correct extension | 3462 | // Force correct extension |
3473 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3463 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3474 | 3464 | ||
3475 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3465 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3476 | return storage.save(); | 3466 | return storage.save(); |