-rw-r--r-- | korganizer/calendarview.cpp | 29 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 |
2 files changed, 19 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f727cd4..ff1db2c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -376,1194 +376,1195 @@ void CalendarView::init() | |||
376 | mNavigator, SLOT( selectNext() ) ); | 376 | mNavigator, SLOT( selectNext() ) ); |
377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 377 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 378 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 379 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 380 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
381 | 381 | ||
382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 382 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 383 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
384 | 384 | ||
385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 385 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
386 | SLOT( eventAdded( Event *) ) ); | 386 | SLOT( eventAdded( Event *) ) ); |
387 | 387 | ||
388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 388 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
389 | 389 | ||
390 | connect( this, SIGNAL( configChanged() ), | 390 | connect( this, SIGNAL( configChanged() ), |
391 | mDateNavigator, SLOT( updateConfig() ) ); | 391 | mDateNavigator, SLOT( updateConfig() ) ); |
392 | 392 | ||
393 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 393 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
394 | SLOT( newTodo() ) ); | 394 | SLOT( newTodo() ) ); |
395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
396 | SLOT( newSubTodo( Todo * ) ) ); | 396 | SLOT( newSubTodo( Todo * ) ) ); |
397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 397 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
398 | SLOT( editTodo( Todo * ) ) ); | 398 | SLOT( editTodo( Todo * ) ) ); |
399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 399 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
400 | SLOT( showTodo( Todo *) ) ); | 400 | SLOT( showTodo( Todo *) ) ); |
401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 401 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
402 | SLOT( deleteTodo( Todo *) ) ); | 402 | SLOT( deleteTodo( Todo *) ) ); |
403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 403 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 404 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
405 | SLOT( purgeCompleted() ) ); | 405 | SLOT( purgeCompleted() ) ); |
406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 406 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
407 | SIGNAL( todoModified( Todo *, int ) ) ); | 407 | SIGNAL( todoModified( Todo *, int ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 410 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
412 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 412 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
415 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 415 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
417 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 417 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 419 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
420 | this, SLOT ( todo_unsub( Todo * ) ) ); | 420 | this, SLOT ( todo_unsub( Todo * ) ) ); |
421 | 421 | ||
422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | //void setZaurusId(int id); | 717 | //void setZaurusId(int id); |
718 | // int zaurusId() const; | 718 | // int zaurusId() const; |
719 | // void setZaurusUid(int id); | 719 | // void setZaurusUid(int id); |
720 | // int zaurusUid() const; | 720 | // int zaurusUid() const; |
721 | // void setZaurusStat(int id); | 721 | // void setZaurusStat(int id); |
722 | // int zaurusStat() const; | 722 | // int zaurusStat() const; |
723 | // 0 equal | 723 | // 0 equal |
724 | // 1 take local | 724 | // 1 take local |
725 | // 2 take remote | 725 | // 2 take remote |
726 | // 3 cancel | 726 | // 3 cancel |
727 | QDateTime lastSync = mLastCalendarSync; | 727 | QDateTime lastSync = mLastCalendarSync; |
728 | QDateTime localMod = local->lastModified(); | 728 | QDateTime localMod = local->lastModified(); |
729 | QDateTime remoteMod = remote->lastModified(); | 729 | QDateTime remoteMod = remote->lastModified(); |
730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
731 | bool remCh, locCh; | 731 | bool remCh, locCh; |
732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
733 | //if ( remCh ) | 733 | //if ( remCh ) |
734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
735 | locCh = ( localMod > mLastCalendarSync ); | 735 | locCh = ( localMod > mLastCalendarSync ); |
736 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
737 | //qDebug("both not changed "); | 737 | //qDebug("both not changed "); |
738 | lastSync = localMod.addDays(1); | 738 | lastSync = localMod.addDays(1); |
739 | if ( mode <= SYNC_PREF_ASK ) | 739 | if ( mode <= SYNC_PREF_ASK ) |
740 | return 0; | 740 | return 0; |
741 | } else { | 741 | } else { |
742 | if ( locCh ) { | 742 | if ( locCh ) { |
743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
744 | lastSync = localMod.addDays( -1 ); | 744 | lastSync = localMod.addDays( -1 ); |
745 | if ( !remCh ) | 745 | if ( !remCh ) |
746 | remoteMod = ( lastSync.addDays( -1 ) ); | 746 | remoteMod = ( lastSync.addDays( -1 ) ); |
747 | } else { | 747 | } else { |
748 | //qDebug(" not loc changed "); | 748 | //qDebug(" not loc changed "); |
749 | lastSync = localMod.addDays( 1 ); | 749 | lastSync = localMod.addDays( 1 ); |
750 | if ( remCh ) | 750 | if ( remCh ) |
751 | remoteMod =( lastSync.addDays( 1 ) ); | 751 | remoteMod =( lastSync.addDays( 1 ) ); |
752 | 752 | ||
753 | } | 753 | } |
754 | } | 754 | } |
755 | full = true; | 755 | full = true; |
756 | if ( mode < SYNC_PREF_ASK ) | 756 | if ( mode < SYNC_PREF_ASK ) |
757 | mode = SYNC_PREF_ASK; | 757 | mode = SYNC_PREF_ASK; |
758 | } else { | 758 | } else { |
759 | if ( localMod == remoteMod ) | 759 | if ( localMod == remoteMod ) |
760 | if ( local->revision() == remote->revision() ) | 760 | // if ( local->revision() == remote->revision() ) |
761 | return 0; | 761 | return 0; |
762 | 762 | ||
763 | } | 763 | } |
764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
765 | 765 | ||
766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
768 | //full = true; //debug only | 768 | //full = true; //debug only |
769 | if ( full ) { | 769 | if ( full ) { |
770 | bool equ = false; | 770 | bool equ = false; |
771 | if ( local->type() == "Event" ) { | 771 | if ( local->type() == "Event" ) { |
772 | equ = (*((Event*) local) == *((Event*) remote)); | 772 | equ = (*((Event*) local) == *((Event*) remote)); |
773 | } | 773 | } |
774 | else if ( local->type() =="Todo" ) | 774 | else if ( local->type() =="Todo" ) |
775 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 775 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
776 | else if ( local->type() =="Journal" ) | 776 | else if ( local->type() =="Journal" ) |
777 | equ = (*((Journal*) local) == *((Journal*) remote)); | 777 | equ = (*((Journal*) local) == *((Journal*) remote)); |
778 | if ( equ ) { | 778 | if ( equ ) { |
779 | //qDebug("equal "); | 779 | //qDebug("equal "); |
780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
782 | } | 782 | } |
783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
784 | return 0; | 784 | return 0; |
785 | 785 | ||
786 | }//else //debug only | 786 | }//else //debug only |
787 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 787 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
788 | } | 788 | } |
789 | int result; | 789 | int result; |
790 | bool localIsNew; | 790 | bool localIsNew; |
791 | //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() ); | 791 | //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() ); |
792 | 792 | ||
793 | if ( full && mode < SYNC_PREF_NEWEST ) | 793 | if ( full && mode < SYNC_PREF_NEWEST ) |
794 | mode = SYNC_PREF_ASK; | 794 | mode = SYNC_PREF_ASK; |
795 | 795 | ||
796 | switch( mode ) { | 796 | switch( mode ) { |
797 | case SYNC_PREF_LOCAL: | 797 | case SYNC_PREF_LOCAL: |
798 | if ( lastSync > remoteMod ) | 798 | if ( lastSync > remoteMod ) |
799 | return 1; | 799 | return 1; |
800 | if ( lastSync > localMod ) | 800 | if ( lastSync > localMod ) |
801 | return 2; | 801 | return 2; |
802 | return 1; | 802 | return 1; |
803 | break; | 803 | break; |
804 | case SYNC_PREF_REMOTE: | 804 | case SYNC_PREF_REMOTE: |
805 | if ( lastSync > remoteMod ) | 805 | if ( lastSync > remoteMod ) |
806 | return 1; | 806 | return 1; |
807 | if ( lastSync > localMod ) | 807 | if ( lastSync > localMod ) |
808 | return 2; | 808 | return 2; |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_NEWEST: | 811 | case SYNC_PREF_NEWEST: |
812 | if ( localMod > remoteMod ) | 812 | if ( localMod > remoteMod ) |
813 | return 1; | 813 | return 1; |
814 | else | 814 | else |
815 | return 2; | 815 | return 2; |
816 | break; | 816 | break; |
817 | case SYNC_PREF_ASK: | 817 | case SYNC_PREF_ASK: |
818 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 818 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
819 | if ( lastSync > remoteMod ) | 819 | if ( lastSync > remoteMod ) |
820 | return 1; | 820 | return 1; |
821 | if ( lastSync > localMod ) | 821 | if ( lastSync > localMod ) |
822 | return 2; | 822 | return 2; |
823 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 823 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
824 | localIsNew = localMod >= remoteMod; | 824 | localIsNew = localMod >= remoteMod; |
825 | if ( localIsNew ) | 825 | if ( localIsNew ) |
826 | getEventViewerDialog()->setColorMode( 1 ); | 826 | getEventViewerDialog()->setColorMode( 1 ); |
827 | else | 827 | else |
828 | getEventViewerDialog()->setColorMode( 2 ); | 828 | getEventViewerDialog()->setColorMode( 2 ); |
829 | getEventViewerDialog()->setIncidence(local); | 829 | getEventViewerDialog()->setIncidence(local); |
830 | if ( localIsNew ) | 830 | if ( localIsNew ) |
831 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
832 | else | 832 | else |
833 | getEventViewerDialog()->setColorMode( 1 ); | 833 | getEventViewerDialog()->setColorMode( 1 ); |
834 | getEventViewerDialog()->addIncidence(remote); | 834 | getEventViewerDialog()->addIncidence(remote); |
835 | getEventViewerDialog()->setColorMode( 0 ); | 835 | getEventViewerDialog()->setColorMode( 0 ); |
836 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 836 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
837 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 837 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
838 | getEventViewerDialog()->showMe(); | 838 | getEventViewerDialog()->showMe(); |
839 | result = getEventViewerDialog()->executeS( localIsNew ); | 839 | result = getEventViewerDialog()->executeS( localIsNew ); |
840 | return result; | 840 | return result; |
841 | 841 | ||
842 | break; | 842 | break; |
843 | case SYNC_PREF_FORCE_LOCAL: | 843 | case SYNC_PREF_FORCE_LOCAL: |
844 | return 1; | 844 | return 1; |
845 | break; | 845 | break; |
846 | case SYNC_PREF_FORCE_REMOTE: | 846 | case SYNC_PREF_FORCE_REMOTE: |
847 | return 2; | 847 | return 2; |
848 | break; | 848 | break; |
849 | 849 | ||
850 | default: | 850 | default: |
851 | // SYNC_PREF_TAKE_BOTH not implemented | 851 | // SYNC_PREF_TAKE_BOTH not implemented |
852 | break; | 852 | break; |
853 | } | 853 | } |
854 | return 0; | 854 | return 0; |
855 | } | 855 | } |
856 | Event* CalendarView::getLastSyncEvent() | 856 | Event* CalendarView::getLastSyncEvent() |
857 | { | 857 | { |
858 | Event* lse; | 858 | Event* lse; |
859 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 859 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
860 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 860 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
861 | if (!lse) { | 861 | if (!lse) { |
862 | lse = new Event(); | 862 | lse = new Event(); |
863 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | QString sum = ""; | 864 | QString sum = ""; |
865 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 865 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
866 | sum = "E: "; | 866 | sum = "E: "; |
867 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 867 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
868 | lse->setDtStart( mLastCalendarSync ); | 868 | lse->setDtStart( mLastCalendarSync ); |
869 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 869 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
870 | lse->setCategories( i18n("SyncEvent") ); | 870 | lse->setCategories( i18n("SyncEvent") ); |
871 | lse->setReadOnly( true ); | 871 | lse->setReadOnly( true ); |
872 | mCalendar->addEvent( lse ); | 872 | mCalendar->addEvent( lse ); |
873 | } | 873 | } |
874 | 874 | ||
875 | return lse; | 875 | return lse; |
876 | 876 | ||
877 | } | 877 | } |
878 | 878 | ||
879 | // we check, if the to delete event has a id for a profile | 879 | // we check, if the to delete event has a id for a profile |
880 | // if yes, we set this id in the profile to delete | 880 | // if yes, we set this id in the profile to delete |
881 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 881 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
882 | { | 882 | { |
883 | if ( lastSync.count() == 0 ) { | 883 | if ( lastSync.count() == 0 ) { |
884 | //qDebug(" lastSync.count() == 0"); | 884 | //qDebug(" lastSync.count() == 0"); |
885 | return; | 885 | return; |
886 | } | 886 | } |
887 | if ( toDelete->type() == "Journal" ) | 887 | if ( toDelete->type() == "Journal" ) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | Event* eve = lastSync.first(); | 890 | Event* eve = lastSync.first(); |
891 | 891 | ||
892 | while ( eve ) { | 892 | while ( eve ) { |
893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
894 | if ( !id.isEmpty() ) { | 894 | if ( !id.isEmpty() ) { |
895 | QString des = eve->description(); | 895 | QString des = eve->description(); |
896 | QString pref = "e"; | 896 | QString pref = "e"; |
897 | if ( toDelete->type() == "Todo" ) | 897 | if ( toDelete->type() == "Todo" ) |
898 | pref = "t"; | 898 | pref = "t"; |
899 | des += pref+ id + ","; | 899 | des += pref+ id + ","; |
900 | eve->setReadOnly( false ); | 900 | eve->setReadOnly( false ); |
901 | eve->setDescription( des ); | 901 | eve->setDescription( des ); |
902 | //qDebug("setdes %s ", des.latin1()); | 902 | //qDebug("setdes %s ", des.latin1()); |
903 | eve->setReadOnly( true ); | 903 | eve->setReadOnly( true ); |
904 | } | 904 | } |
905 | eve = lastSync.next(); | 905 | eve = lastSync.next(); |
906 | } | 906 | } |
907 | 907 | ||
908 | } | 908 | } |
909 | void CalendarView::checkExternalId( Incidence * inc ) | 909 | void CalendarView::checkExternalId( Incidence * inc ) |
910 | { | 910 | { |
911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
912 | checkExternSyncEvent( lastSync, inc ); | 912 | checkExternSyncEvent( lastSync, inc ); |
913 | 913 | ||
914 | } | 914 | } |
915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
916 | { | 916 | { |
917 | bool syncOK = true; | 917 | bool syncOK = true; |
918 | int addedEvent = 0; | 918 | int addedEvent = 0; |
919 | int addedEventR = 0; | 919 | int addedEventR = 0; |
920 | int deletedEventR = 0; | 920 | int deletedEventR = 0; |
921 | int deletedEventL = 0; | 921 | int deletedEventL = 0; |
922 | int changedLocal = 0; | 922 | int changedLocal = 0; |
923 | int changedRemote = 0; | 923 | int changedRemote = 0; |
924 | //QPtrList<Event> el = local->rawEvents(); | 924 | //QPtrList<Event> el = local->rawEvents(); |
925 | Event* eventR; | 925 | Event* eventR; |
926 | QString uid; | 926 | QString uid; |
927 | int take; | 927 | int take; |
928 | Event* eventL; | 928 | Event* eventL; |
929 | Event* eventRSync; | 929 | Event* eventRSync; |
930 | Event* eventLSync; | 930 | Event* eventLSync; |
931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
933 | bool fullDateRange = false; | 933 | bool fullDateRange = false; |
934 | local->resetTempSyncStat(); | 934 | local->resetTempSyncStat(); |
935 | #ifdef DESKTOP_VERSION | 935 | if ( mSyncKDE ) |
936 | //Needed for KDE - OL sync | 936 | remote->resetPilotStat(1); |
937 | local->resetPilotStat(); | ||
938 | remote->resetPilotStat(); | ||
939 | #endif | ||
940 | mLastCalendarSync = QDateTime::currentDateTime(); | 937 | mLastCalendarSync = QDateTime::currentDateTime(); |
941 | QDateTime modifiedCalendar = mLastCalendarSync;; | 938 | QDateTime modifiedCalendar = mLastCalendarSync;; |
942 | eventLSync = getLastSyncEvent(); | 939 | eventLSync = getLastSyncEvent(); |
943 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
944 | if ( eventR ) { | 941 | if ( eventR ) { |
945 | eventRSync = (Event*) eventR->clone(); | 942 | eventRSync = (Event*) eventR->clone(); |
946 | remote->deleteEvent(eventR ); | 943 | remote->deleteEvent(eventR ); |
947 | 944 | ||
948 | } else { | 945 | } else { |
949 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
950 | eventRSync = (Event*)eventLSync->clone(); | 947 | eventRSync = (Event*)eventLSync->clone(); |
951 | } else { | 948 | } else { |
952 | fullDateRange = true; | 949 | fullDateRange = true; |
953 | eventRSync = new Event(); | 950 | eventRSync = new Event(); |
954 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
955 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
956 | eventRSync->setDtStart( mLastCalendarSync ); | 953 | eventRSync->setDtStart( mLastCalendarSync ); |
957 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
958 | eventRSync->setCategories( i18n("SyncEvent") ); | 955 | eventRSync->setCategories( i18n("SyncEvent") ); |
959 | } | 956 | } |
960 | } | 957 | } |
961 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 958 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
962 | fullDateRange = true; | 959 | fullDateRange = true; |
963 | 960 | ||
964 | if ( ! fullDateRange ) { | 961 | if ( ! fullDateRange ) { |
965 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
966 | 963 | ||
967 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
968 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
969 | fullDateRange = true; | 966 | fullDateRange = true; |
970 | } | 967 | } |
971 | } | 968 | } |
972 | if ( fullDateRange ) | 969 | if ( fullDateRange && !mSyncKDE ) |
973 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
974 | else | 971 | else |
975 | mLastCalendarSync = eventLSync->dtStart(); | 972 | mLastCalendarSync = eventLSync->dtStart(); |
976 | // for resyncing if own file has changed | 973 | // for resyncing if own file has changed |
977 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
978 | mLastCalendarSync = loadedFileVersion; | 975 | mLastCalendarSync = loadedFileVersion; |
979 | qDebug("setting mLastCalendarSync "); | 976 | qDebug("setting mLastCalendarSync "); |
980 | } | 977 | } |
981 | //qDebug("*************************** "); | 978 | //qDebug("*************************** "); |
982 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
983 | QPtrList<Incidence> er = remote->rawIncidences(); | 980 | QPtrList<Incidence> er = remote->rawIncidences(); |
984 | Incidence* inR = er.first(); | 981 | Incidence* inR = er.first(); |
985 | Incidence* inL; | 982 | Incidence* inL; |
986 | QProgressBar bar( er.count(),0 ); | 983 | QProgressBar bar( er.count(),0 ); |
987 | bar.setCaption (i18n("Syncing - close to abort!") ); | 984 | bar.setCaption (i18n("Syncing - close to abort!") ); |
988 | 985 | ||
989 | int w = 300; | 986 | int w = 300; |
990 | if ( QApplication::desktop()->width() < 320 ) | 987 | if ( QApplication::desktop()->width() < 320 ) |
991 | w = 220; | 988 | w = 220; |
992 | int h = bar.sizeHint().height() ; | 989 | int h = bar.sizeHint().height() ; |
993 | int dw = QApplication::desktop()->width(); | 990 | int dw = QApplication::desktop()->width(); |
994 | int dh = QApplication::desktop()->height(); | 991 | int dh = QApplication::desktop()->height(); |
995 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
996 | bar.show(); | 993 | bar.show(); |
997 | int modulo = (er.count()/10)+1; | 994 | int modulo = (er.count()/10)+1; |
998 | int incCounter = 0; | 995 | int incCounter = 0; |
999 | while ( inR ) { | 996 | while ( inR ) { |
1000 | if ( ! bar.isVisible() ) | 997 | if ( ! bar.isVisible() ) |
1001 | return false; | 998 | return false; |
1002 | if ( incCounter % modulo == 0 ) | 999 | if ( incCounter % modulo == 0 ) |
1003 | bar.setProgress( incCounter ); | 1000 | bar.setProgress( incCounter ); |
1004 | ++incCounter; | 1001 | ++incCounter; |
1005 | uid = inR->uid(); | 1002 | uid = inR->uid(); |
1006 | bool skipIncidence = false; | 1003 | bool skipIncidence = false; |
1007 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1004 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1008 | skipIncidence = true; | 1005 | skipIncidence = true; |
1009 | QString idS; | 1006 | QString idS; |
1010 | qApp->processEvents(); | 1007 | qApp->processEvents(); |
1011 | if ( !skipIncidence ) { | 1008 | if ( !skipIncidence ) { |
1012 | inL = local->incidence( uid ); | 1009 | inL = local->incidence( uid ); |
1013 | if ( inL ) { // maybe conflict - same uid in both calendars | 1010 | if ( inL ) { // maybe conflict - same uid in both calendars |
1014 | int maxrev = inL->revision(); | 1011 | int maxrev = inL->revision(); |
1015 | if ( maxrev < inR->revision() ) | 1012 | if ( maxrev < inR->revision() ) |
1016 | maxrev = inR->revision(); | 1013 | maxrev = inR->revision(); |
1017 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1018 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1019 | if ( take == 3 ) | 1016 | if ( take == 3 ) |
1020 | return false; | 1017 | return false; |
1021 | if ( take == 1 ) {// take local | 1018 | if ( take == 1 ) {// take local |
1022 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1019 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1023 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1024 | else | 1021 | else |
1025 | idS = inR->IDStr(); | 1022 | idS = inR->IDStr(); |
1026 | remote->deleteIncidence( inR ); | 1023 | remote->deleteIncidence( inR ); |
1027 | if ( inL->revision() < maxrev ) | 1024 | if ( inL->revision() < maxrev ) |
1028 | inL->setRevision( maxrev ); | 1025 | inL->setRevision( maxrev ); |
1029 | inR = inL->clone(); | 1026 | inR = inL->clone(); |
1030 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1027 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1031 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1028 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1032 | inR->setIDStr( idS ); | 1029 | inR->setIDStr( idS ); |
1033 | remote->addIncidence( inR ); | 1030 | remote->addIncidence( inR ); |
1034 | #ifdef DESKTOP_VERSION | 1031 | if ( mSyncKDE ) |
1035 | inR->setPilotId( 1 ); | 1032 | inR->setPilotId( 2 ); |
1036 | #endif | ||
1037 | ++changedRemote; | 1033 | ++changedRemote; |
1038 | } else { | 1034 | } else { |
1039 | if ( inR->revision() < maxrev ) | 1035 | if ( inR->revision() < maxrev ) |
1040 | inR->setRevision( maxrev ); | 1036 | inR->setRevision( maxrev ); |
1041 | idS = inL->IDStr(); | 1037 | idS = inL->IDStr(); |
1038 | int pid = inL->pilotId(); | ||
1042 | local->deleteIncidence( inL ); | 1039 | local->deleteIncidence( inL ); |
1043 | inL = inR->clone(); | 1040 | inL = inR->clone(); |
1041 | if ( mSyncKDE ) | ||
1042 | inL->setPilotId( pid ); | ||
1044 | inL->setIDStr( idS ); | 1043 | inL->setIDStr( idS ); |
1045 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1046 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1045 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1047 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1046 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1048 | } | 1047 | } |
1049 | local->addIncidence( inL ); | 1048 | local->addIncidence( inL ); |
1050 | ++changedLocal; | 1049 | ++changedLocal; |
1051 | } | 1050 | } |
1052 | } | 1051 | } |
1053 | } else { // no conflict | 1052 | } else { // no conflict |
1054 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1055 | QString des = eventLSync->description(); | 1054 | QString des = eventLSync->description(); |
1056 | QString pref = "e"; | 1055 | QString pref = "e"; |
1057 | if ( inR->type() == "Todo" ) | 1056 | if ( inR->type() == "Todo" ) |
1058 | pref = "t"; | 1057 | pref = "t"; |
1059 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1058 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1060 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1059 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1061 | //remote->deleteIncidence( inR ); | 1060 | //remote->deleteIncidence( inR ); |
1062 | ++deletedEventR; | 1061 | ++deletedEventR; |
1063 | } else { | 1062 | } else { |
1064 | inR->setLastModified( modifiedCalendar ); | 1063 | inR->setLastModified( modifiedCalendar ); |
1065 | inL = inR->clone(); | 1064 | inL = inR->clone(); |
1066 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1067 | ++addedEvent; | 1066 | ++addedEvent; |
1068 | } | 1067 | } |
1069 | } else { | 1068 | } else { |
1070 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1071 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1072 | local->addIncidence( inR->clone() ); | 1071 | local->addIncidence( inR->clone() ); |
1073 | ++addedEvent; | 1072 | ++addedEvent; |
1074 | } else { | 1073 | } else { |
1075 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1076 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1077 | ++deletedEventR; | 1076 | ++deletedEventR; |
1078 | } | 1077 | } |
1079 | } | 1078 | } |
1080 | } | 1079 | } |
1081 | } | 1080 | } |
1082 | inR = er.next(); | 1081 | inR = er.next(); |
1083 | } | 1082 | } |
1084 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1085 | inL = el.first(); | 1084 | inL = el.first(); |
1086 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1087 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
1088 | bar.setTotalSteps ( el.count() ) ; | 1087 | bar.setTotalSteps ( el.count() ) ; |
1089 | bar.show(); | 1088 | bar.show(); |
1090 | incCounter = 0; | 1089 | incCounter = 0; |
1091 | 1090 | ||
1092 | while ( inL ) { | 1091 | while ( inL ) { |
1093 | 1092 | ||
1094 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1095 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1096 | return false; | 1095 | return false; |
1097 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1098 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1099 | ++incCounter; | 1098 | ++incCounter; |
1100 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1101 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1102 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1103 | skipIncidence = true; | 1102 | skipIncidence = true; |
1104 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1105 | skipIncidence = true; | 1104 | skipIncidence = true; |
1106 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1107 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1108 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1109 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1110 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1111 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1112 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1113 | ++deletedEventL; | 1112 | ++deletedEventL; |
1114 | } else { | 1113 | } else { |
1115 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1116 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1117 | ++addedEventR; | 1116 | ++addedEventR; |
1118 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1119 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1120 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1120 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1121 | remote->addIncidence( inR ); |
1123 | } | 1122 | } |
1124 | } | 1123 | } |
1125 | } else { | 1124 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1125 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1126 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1127 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1128 | ++deletedEventL; |
1130 | } else { | 1129 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1130 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1131 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1132 | inL->setLastModified( modifiedCalendar ); |
1134 | remote->addIncidence( inL->clone() ); | 1133 | remote->addIncidence( inL->clone() ); |
1135 | } | 1134 | } |
1136 | } | 1135 | } |
1137 | } | 1136 | } |
1138 | } | 1137 | } |
1139 | } | 1138 | } |
1140 | inL = el.next(); | 1139 | inL = el.next(); |
1141 | } | 1140 | } |
1142 | int delFut = 0; | 1141 | int delFut = 0; |
1143 | int remRem = 0; | 1142 | int remRem = 0; |
1144 | if ( mSyncManager->mWriteBackInFuture ) { | 1143 | if ( mSyncManager->mWriteBackInFuture ) { |
1145 | er = remote->rawIncidences(); | 1144 | er = remote->rawIncidences(); |
1146 | remRem = er.count(); | 1145 | remRem = er.count(); |
1147 | inR = er.first(); | 1146 | inR = er.first(); |
1148 | QDateTime dt; | 1147 | QDateTime dt; |
1149 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1148 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1150 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1149 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1151 | while ( inR ) { | 1150 | while ( inR ) { |
1152 | if ( inR->type() == "Todo" ) { | 1151 | if ( inR->type() == "Todo" ) { |
1153 | Todo * t = (Todo*)inR; | 1152 | Todo * t = (Todo*)inR; |
1154 | if ( t->hasDueDate() ) | 1153 | if ( t->hasDueDate() ) |
1155 | dt = t->dtDue(); | 1154 | dt = t->dtDue(); |
1156 | else | 1155 | else |
1157 | dt = cur.addSecs( 62 ); | 1156 | dt = cur.addSecs( 62 ); |
1158 | } | 1157 | } |
1159 | else if (inR->type() == "Event" ) { | 1158 | else if (inR->type() == "Event" ) { |
1160 | bool ok; | 1159 | bool ok; |
1161 | dt = inR->getNextOccurence( cur, &ok ); | 1160 | dt = inR->getNextOccurence( cur, &ok ); |
1162 | if ( !ok ) | 1161 | if ( !ok ) |
1163 | dt = cur.addSecs( -62 ); | 1162 | dt = cur.addSecs( -62 ); |
1164 | } | 1163 | } |
1165 | else | 1164 | else |
1166 | dt = inR->dtStart(); | 1165 | dt = inR->dtStart(); |
1167 | if ( dt < cur || dt > end ) { | 1166 | if ( dt < cur || dt > end ) { |
1168 | remote->deleteIncidence( inR ); | 1167 | remote->deleteIncidence( inR ); |
1169 | ++delFut; | 1168 | ++delFut; |
1170 | } | 1169 | } |
1171 | inR = er.next(); | 1170 | inR = er.next(); |
1172 | } | 1171 | } |
1173 | } | 1172 | } |
1174 | bar.hide(); | 1173 | bar.hide(); |
1175 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1174 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1176 | eventLSync->setReadOnly( false ); | 1175 | eventLSync->setReadOnly( false ); |
1177 | eventLSync->setDtStart( mLastCalendarSync ); | 1176 | eventLSync->setDtStart( mLastCalendarSync ); |
1178 | eventRSync->setDtStart( mLastCalendarSync ); | 1177 | eventRSync->setDtStart( mLastCalendarSync ); |
1179 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1178 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1180 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1181 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1180 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1182 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1181 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1183 | eventLSync->setReadOnly( true ); | 1182 | eventLSync->setReadOnly( true ); |
1184 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1183 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1185 | remote->addEvent( eventRSync ); | 1184 | remote->addEvent( eventRSync ); |
1185 | else | ||
1186 | delete eventRSync; | ||
1186 | QString mes; | 1187 | QString mes; |
1187 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1188 | 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1188 | QString delmess; | 1189 | QString delmess; |
1189 | if ( delFut ) { | 1190 | if ( delFut ) { |
1190 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1191 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1191 | mes += delmess; | 1192 | mes += delmess; |
1192 | } | 1193 | } |
1193 | if ( mSyncManager->mShowSyncSummary ) { | 1194 | if ( mSyncManager->mShowSyncSummary ) { |
1194 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1195 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1195 | } | 1196 | } |
1196 | qDebug( mes ); | 1197 | qDebug( mes ); |
1197 | mCalendar->checkAlarmForIncidence( 0, true ); | 1198 | mCalendar->checkAlarmForIncidence( 0, true ); |
1198 | return syncOK; | 1199 | return syncOK; |
1199 | } | 1200 | } |
1200 | 1201 | ||
1201 | void CalendarView::setSyncDevice( QString s ) | 1202 | void CalendarView::setSyncDevice( QString s ) |
1202 | { | 1203 | { |
1203 | mCurrentSyncDevice= s; | 1204 | mCurrentSyncDevice= s; |
1204 | } | 1205 | } |
1205 | void CalendarView::setSyncName( QString s ) | 1206 | void CalendarView::setSyncName( QString s ) |
1206 | { | 1207 | { |
1207 | mCurrentSyncName= s; | 1208 | mCurrentSyncName= s; |
1208 | } | 1209 | } |
1209 | bool CalendarView::syncCalendar(QString filename, int mode) | 1210 | bool CalendarView::syncCalendar(QString filename, int mode) |
1210 | { | 1211 | { |
1211 | //qDebug("syncCalendar %s ", filename.latin1()); | 1212 | //qDebug("syncCalendar %s ", filename.latin1()); |
1212 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1213 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1213 | CalendarLocal* calendar = new CalendarLocal(); | 1214 | CalendarLocal* calendar = new CalendarLocal(); |
1214 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1215 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1215 | FileStorage* storage = new FileStorage( calendar ); | 1216 | FileStorage* storage = new FileStorage( calendar ); |
1216 | bool syncOK = false; | 1217 | bool syncOK = false; |
1217 | storage->setFileName( filename ); | 1218 | storage->setFileName( filename ); |
1218 | // qDebug("loading ... "); | 1219 | // qDebug("loading ... "); |
1219 | if ( storage->load() ) { | 1220 | if ( storage->load() ) { |
1220 | getEventViewerDialog()->setSyncMode( true ); | 1221 | getEventViewerDialog()->setSyncMode( true ); |
1221 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1222 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1222 | getEventViewerDialog()->setSyncMode( false ); | 1223 | getEventViewerDialog()->setSyncMode( false ); |
1223 | if ( syncOK ) { | 1224 | if ( syncOK ) { |
1224 | if ( mSyncManager->mWriteBackFile ) | 1225 | if ( mSyncManager->mWriteBackFile ) |
1225 | { | 1226 | { |
1226 | storage->setSaveFormat( new ICalFormat() ); | 1227 | storage->setSaveFormat( new ICalFormat() ); |
1227 | storage->save(); | 1228 | storage->save(); |
1228 | } | 1229 | } |
1229 | } | 1230 | } |
1230 | setModified( true ); | 1231 | setModified( true ); |
1231 | } | 1232 | } |
1232 | delete storage; | 1233 | delete storage; |
1233 | delete calendar; | 1234 | delete calendar; |
1234 | if ( syncOK ) | 1235 | if ( syncOK ) |
1235 | updateView(); | 1236 | updateView(); |
1236 | return syncOK; | 1237 | return syncOK; |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | void CalendarView::syncExternal( int mode ) | 1240 | void CalendarView::syncExternal( int mode ) |
1240 | { | 1241 | { |
1241 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1242 | 1243 | ||
1243 | qApp->processEvents(); | 1244 | qApp->processEvents(); |
1244 | CalendarLocal* calendar = new CalendarLocal(); | 1245 | CalendarLocal* calendar = new CalendarLocal(); |
1245 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1246 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1246 | bool syncOK = false; | 1247 | bool syncOK = false; |
1247 | bool loadSuccess = false; | 1248 | bool loadSuccess = false; |
1248 | PhoneFormat* phoneFormat = 0; | 1249 | PhoneFormat* phoneFormat = 0; |
1249 | #ifndef DESKTOP_VERSION | 1250 | #ifndef DESKTOP_VERSION |
1250 | SharpFormat* sharpFormat = 0; | 1251 | SharpFormat* sharpFormat = 0; |
1251 | if ( mode == 0 ) { // sharp | 1252 | if ( mode == 0 ) { // sharp |
1252 | sharpFormat = new SharpFormat () ; | 1253 | sharpFormat = new SharpFormat () ; |
1253 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1254 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1254 | 1255 | ||
1255 | } else | 1256 | } else |
1256 | #endif | 1257 | #endif |
1257 | if ( mode == 1 ) { // phone | 1258 | if ( mode == 1 ) { // phone |
1258 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1259 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1259 | mSyncManager->mPhoneDevice, | 1260 | mSyncManager->mPhoneDevice, |
1260 | mSyncManager->mPhoneConnection, | 1261 | mSyncManager->mPhoneConnection, |
1261 | mSyncManager->mPhoneModel); | 1262 | mSyncManager->mPhoneModel); |
1262 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1263 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1263 | 1264 | ||
1264 | } else | 1265 | } else |
1265 | return; | 1266 | return; |
1266 | if ( loadSuccess ) { | 1267 | if ( loadSuccess ) { |
1267 | getEventViewerDialog()->setSyncMode( true ); | 1268 | getEventViewerDialog()->setSyncMode( true ); |
1268 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1269 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1269 | getEventViewerDialog()->setSyncMode( false ); | 1270 | getEventViewerDialog()->setSyncMode( false ); |
1270 | qApp->processEvents(); | 1271 | qApp->processEvents(); |
1271 | if ( syncOK ) { | 1272 | if ( syncOK ) { |
1272 | if ( mSyncManager->mWriteBackFile ) | 1273 | if ( mSyncManager->mWriteBackFile ) |
1273 | { | 1274 | { |
1274 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1275 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1275 | Incidence* inc = iL.first(); | 1276 | Incidence* inc = iL.first(); |
1276 | if ( phoneFormat ) { | 1277 | if ( phoneFormat ) { |
1277 | while ( inc ) { | 1278 | while ( inc ) { |
1278 | inc->removeID(mCurrentSyncDevice); | 1279 | inc->removeID(mCurrentSyncDevice); |
1279 | inc = iL.next(); | 1280 | inc = iL.next(); |
1280 | } | 1281 | } |
1281 | } | 1282 | } |
1282 | #ifndef DESKTOP_VERSION | 1283 | #ifndef DESKTOP_VERSION |
1283 | if ( sharpFormat ) | 1284 | if ( sharpFormat ) |
1284 | sharpFormat->save(calendar); | 1285 | sharpFormat->save(calendar); |
1285 | #endif | 1286 | #endif |
1286 | if ( phoneFormat ) | 1287 | if ( phoneFormat ) |
1287 | phoneFormat->save(calendar); | 1288 | phoneFormat->save(calendar); |
1288 | iL = calendar->rawIncidences(); | 1289 | iL = calendar->rawIncidences(); |
1289 | inc = iL.first(); | 1290 | inc = iL.first(); |
1290 | Incidence* loc; | 1291 | Incidence* loc; |
1291 | while ( inc ) { | 1292 | while ( inc ) { |
1292 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1293 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1293 | loc = mCalendar->incidence(inc->uid() ); | 1294 | loc = mCalendar->incidence(inc->uid() ); |
1294 | if ( loc ) { | 1295 | if ( loc ) { |
1295 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1296 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1296 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1297 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1297 | } | 1298 | } |
1298 | } | 1299 | } |
1299 | inc = iL.next(); | 1300 | inc = iL.next(); |
1300 | } | 1301 | } |
1301 | Incidence* lse = getLastSyncEvent(); | 1302 | Incidence* lse = getLastSyncEvent(); |
1302 | if ( lse ) { | 1303 | if ( lse ) { |
1303 | lse->setReadOnly( false ); | 1304 | lse->setReadOnly( false ); |
1304 | lse->setDescription( "" ); | 1305 | lse->setDescription( "" ); |
1305 | lse->setReadOnly( true ); | 1306 | lse->setReadOnly( true ); |
1306 | } | 1307 | } |
1307 | } | 1308 | } |
1308 | } | 1309 | } |
1309 | setModified( true ); | 1310 | setModified( true ); |
1310 | } else { | 1311 | } else { |
1311 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1312 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1312 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1313 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1313 | question, i18n("Ok")) ; | 1314 | question, i18n("Ok")) ; |
1314 | 1315 | ||
1315 | } | 1316 | } |
1316 | delete calendar; | 1317 | delete calendar; |
1317 | updateView(); | 1318 | updateView(); |
1318 | return ;//syncOK; | 1319 | return ;//syncOK; |
1319 | 1320 | ||
1320 | } | 1321 | } |
1321 | 1322 | ||
1322 | bool CalendarView::importBday() | 1323 | bool CalendarView::importBday() |
1323 | { | 1324 | { |
1324 | #ifndef KORG_NOKABC | 1325 | #ifndef KORG_NOKABC |
1325 | 1326 | ||
1326 | #ifdef DESKTOP_VERSION | 1327 | #ifdef DESKTOP_VERSION |
1327 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1328 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1329 | int count = 0; | 1330 | int count = 0; |
1330 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1331 | ++count; | 1332 | ++count; |
1332 | } | 1333 | } |
1333 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1334 | int w = 300; | 1335 | int w = 300; |
1335 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1336 | w = 220; | 1337 | w = 220; |
1337 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1338 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1339 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1340 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1341 | bar.show(); | 1342 | bar.show(); |
1342 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1343 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1344 | count = 0; | 1345 | count = 0; |
1345 | int addCount = 0; | 1346 | int addCount = 0; |
1346 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1347 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1348 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1349 | return false; | 1350 | return false; |
1350 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1351 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1352 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1353 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1354 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1355 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1356 | ++addCount; | 1357 | ++addCount; |
1357 | } | 1358 | } |
1358 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1359 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1360 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1361 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1362 | ++addCount; | 1363 | ++addCount; |
1363 | } | 1364 | } |
1364 | } | 1365 | } |
1365 | updateView(); | 1366 | updateView(); |
1366 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1367 | #else //DESKTOP_VERSION | 1368 | #else //DESKTOP_VERSION |
1368 | 1369 | ||
1369 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1370 | // the result should now arrive through method insertBirthdays | 1371 | // the result should now arrive through method insertBirthdays |
1371 | 1372 | ||
1372 | #endif //DESKTOP_VERSION | 1373 | #endif //DESKTOP_VERSION |
1373 | 1374 | ||
1374 | #endif //KORG_NOKABC | 1375 | #endif //KORG_NOKABC |
1375 | 1376 | ||
1376 | 1377 | ||
1377 | return true; | 1378 | return true; |
1378 | } | 1379 | } |
1379 | 1380 | ||
1380 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1381 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1381 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1382 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1382 | const QStringList& anniversaryList, const QStringList& realNameList, | 1383 | const QStringList& anniversaryList, const QStringList& realNameList, |
1383 | const QStringList& emailList, const QStringList& assembledNameList, | 1384 | const QStringList& emailList, const QStringList& assembledNameList, |
1384 | const QStringList& uidList) | 1385 | const QStringList& uidList) |
1385 | { | 1386 | { |
1386 | qDebug("CalendarView::insertBirthdays"); | 1387 | qDebug("CalendarView::insertBirthdays"); |
1387 | if (uid == this->name()) | 1388 | if (uid == this->name()) |
1388 | { | 1389 | { |
1389 | int count = birthdayList.count(); | 1390 | int count = birthdayList.count(); |
1390 | int addCount = 0; | 1391 | int addCount = 0; |
1391 | KCal::Attendee* a = 0; | 1392 | KCal::Attendee* a = 0; |
1392 | 1393 | ||
1393 | qDebug("CalView 1 %i", count); | 1394 | qDebug("CalView 1 %i", count); |
1394 | 1395 | ||
1395 | QProgressBar bar(count,0 ); | 1396 | QProgressBar bar(count,0 ); |
1396 | int w = 300; | 1397 | int w = 300; |
1397 | if ( QApplication::desktop()->width() < 320 ) | 1398 | if ( QApplication::desktop()->width() < 320 ) |
1398 | w = 220; | 1399 | w = 220; |
1399 | int h = bar.sizeHint().height() ; | 1400 | int h = bar.sizeHint().height() ; |
1400 | int dw = QApplication::desktop()->width(); | 1401 | int dw = QApplication::desktop()->width(); |
1401 | int dh = QApplication::desktop()->height(); | 1402 | int dh = QApplication::desktop()->height(); |
1402 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1403 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1403 | bar.show(); | 1404 | bar.show(); |
1404 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1405 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1405 | qApp->processEvents(); | 1406 | qApp->processEvents(); |
1406 | 1407 | ||
1407 | QDate birthday; | 1408 | QDate birthday; |
1408 | QDate anniversary; | 1409 | QDate anniversary; |
1409 | QString realName; | 1410 | QString realName; |
1410 | QString email; | 1411 | QString email; |
1411 | QString assembledName; | 1412 | QString assembledName; |
1412 | QString uid; | 1413 | QString uid; |
1413 | bool ok = true; | 1414 | bool ok = true; |
1414 | for ( int i = 0; i < count; i++) | 1415 | for ( int i = 0; i < count; i++) |
1415 | { | 1416 | { |
1416 | if ( ! bar.isVisible() ) | 1417 | if ( ! bar.isVisible() ) |
1417 | return; | 1418 | return; |
1418 | bar.setProgress( i ); | 1419 | bar.setProgress( i ); |
1419 | qApp->processEvents(); | 1420 | qApp->processEvents(); |
1420 | 1421 | ||
1421 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1422 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1422 | if (!ok) { | 1423 | if (!ok) { |
1423 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1424 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1424 | } | 1425 | } |
1425 | 1426 | ||
1426 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1427 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1427 | if (!ok) { | 1428 | if (!ok) { |
1428 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1429 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1429 | } | 1430 | } |
1430 | realName = realNameList[i]; | 1431 | realName = realNameList[i]; |
1431 | email = emailList[i]; | 1432 | email = emailList[i]; |
1432 | assembledName = assembledNameList[i]; | 1433 | assembledName = assembledNameList[i]; |
1433 | uid = uidList[i]; | 1434 | uid = uidList[i]; |
1434 | //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() ); | 1435 | //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() ); |
1435 | 1436 | ||
1436 | if ( birthday.isValid() ){ | 1437 | if ( birthday.isValid() ){ |
1437 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1438 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1438 | KCal::Attendee::ReqParticipant,uid) ; | 1439 | KCal::Attendee::ReqParticipant,uid) ; |
1439 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1440 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1440 | ++addCount; | 1441 | ++addCount; |
1441 | } | 1442 | } |
1442 | 1443 | ||
1443 | if ( anniversary.isValid() ){ | 1444 | if ( anniversary.isValid() ){ |
1444 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1445 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1445 | KCal::Attendee::ReqParticipant,uid) ; | 1446 | KCal::Attendee::ReqParticipant,uid) ; |
1446 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1447 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1447 | ++addCount; | 1448 | ++addCount; |
1448 | } | 1449 | } |
1449 | } | 1450 | } |
1450 | 1451 | ||
1451 | updateView(); | 1452 | updateView(); |
1452 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1453 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1453 | 1454 | ||
1454 | } | 1455 | } |
1455 | 1456 | ||
1456 | } | 1457 | } |
1457 | 1458 | ||
1458 | 1459 | ||
1459 | 1460 | ||
1460 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1461 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1461 | { | 1462 | { |
1462 | //qDebug("addAnni "); | 1463 | //qDebug("addAnni "); |
1463 | Event * ev = new Event(); | 1464 | Event * ev = new Event(); |
1464 | if ( a ) { | 1465 | if ( a ) { |
1465 | ev->addAttendee( a ); | 1466 | ev->addAttendee( a ); |
1466 | } | 1467 | } |
1467 | QString kind; | 1468 | QString kind; |
1468 | if ( birthday ) | 1469 | if ( birthday ) |
1469 | kind = i18n( "Birthday" ); | 1470 | kind = i18n( "Birthday" ); |
1470 | else | 1471 | else |
1471 | kind = i18n( "Anniversary" ); | 1472 | kind = i18n( "Anniversary" ); |
1472 | ev->setSummary( name + " - " + kind ); | 1473 | ev->setSummary( name + " - " + kind ); |
1473 | ev->setOrganizer( "nobody@nowhere" ); | 1474 | ev->setOrganizer( "nobody@nowhere" ); |
1474 | ev->setCategories( kind ); | 1475 | ev->setCategories( kind ); |
1475 | ev->setDtStart( QDateTime(date) ); | 1476 | ev->setDtStart( QDateTime(date) ); |
1476 | ev->setDtEnd( QDateTime(date) ); | 1477 | ev->setDtEnd( QDateTime(date) ); |
1477 | ev->setFloats( true ); | 1478 | ev->setFloats( true ); |
1478 | Recurrence * rec = ev->recurrence(); | 1479 | Recurrence * rec = ev->recurrence(); |
1479 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1480 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1480 | rec->addYearlyNum( date.month() ); | 1481 | rec->addYearlyNum( date.month() ); |
1481 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1482 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1482 | delete ev; | 1483 | delete ev; |
1483 | return false; | 1484 | return false; |
1484 | } | 1485 | } |
1485 | return true; | 1486 | return true; |
1486 | 1487 | ||
1487 | } | 1488 | } |
1488 | bool CalendarView::importQtopia( const QString &categories, | 1489 | bool CalendarView::importQtopia( const QString &categories, |
1489 | const QString &datebook, | 1490 | const QString &datebook, |
1490 | const QString &todolist ) | 1491 | const QString &todolist ) |
1491 | { | 1492 | { |
1492 | 1493 | ||
1493 | QtopiaFormat qtopiaFormat; | 1494 | QtopiaFormat qtopiaFormat; |
1494 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1495 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1495 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1496 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1496 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1497 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1497 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1498 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1498 | 1499 | ||
1499 | updateView(); | 1500 | updateView(); |
1500 | return true; | 1501 | return true; |
1501 | 1502 | ||
1502 | #if 0 | 1503 | #if 0 |
1503 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1504 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1504 | mCurrentSyncDevice = "qtopia-XML"; | 1505 | mCurrentSyncDevice = "qtopia-XML"; |
1505 | if ( mSyncManager->mAskForPreferences ) | 1506 | if ( mSyncManager->mAskForPreferences ) |
1506 | edit_sync_options(); | 1507 | edit_sync_options(); |
1507 | qApp->processEvents(); | 1508 | qApp->processEvents(); |
1508 | CalendarLocal* calendar = new CalendarLocal(); | 1509 | CalendarLocal* calendar = new CalendarLocal(); |
1509 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1510 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1510 | bool syncOK = false; | 1511 | bool syncOK = false; |
1511 | QtopiaFormat qtopiaFormat; | 1512 | QtopiaFormat qtopiaFormat; |
1512 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1513 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1513 | bool loadOk = true; | 1514 | bool loadOk = true; |
1514 | if ( !categories.isEmpty() ) | 1515 | if ( !categories.isEmpty() ) |
1515 | loadOk = qtopiaFormat.load( calendar, categories ); | 1516 | loadOk = qtopiaFormat.load( calendar, categories ); |
1516 | if ( loadOk && !datebook.isEmpty() ) | 1517 | if ( loadOk && !datebook.isEmpty() ) |
1517 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1518 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1518 | if ( loadOk && !todolist.isEmpty() ) | 1519 | if ( loadOk && !todolist.isEmpty() ) |
1519 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1520 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1520 | 1521 | ||
1521 | if ( loadOk ) { | 1522 | if ( loadOk ) { |
1522 | getEventViewerDialog()->setSyncMode( true ); | 1523 | getEventViewerDialog()->setSyncMode( true ); |
1523 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1524 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1524 | getEventViewerDialog()->setSyncMode( false ); | 1525 | getEventViewerDialog()->setSyncMode( false ); |
1525 | qApp->processEvents(); | 1526 | qApp->processEvents(); |
1526 | if ( syncOK ) { | 1527 | if ( syncOK ) { |
1527 | if ( mSyncManager->mWriteBackFile ) | 1528 | if ( mSyncManager->mWriteBackFile ) |
1528 | { | 1529 | { |
1529 | // write back XML file | 1530 | // write back XML file |
1530 | 1531 | ||
1531 | } | 1532 | } |
1532 | setModified( true ); | 1533 | setModified( true ); |
1533 | } | 1534 | } |
1534 | } else { | 1535 | } else { |
1535 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1536 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1536 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1537 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1537 | question, i18n("Ok")) ; | 1538 | question, i18n("Ok")) ; |
1538 | } | 1539 | } |
1539 | delete calendar; | 1540 | delete calendar; |
1540 | updateView(); | 1541 | updateView(); |
1541 | return syncOK; | 1542 | return syncOK; |
1542 | 1543 | ||
1543 | 1544 | ||
1544 | #endif | 1545 | #endif |
1545 | 1546 | ||
1546 | } | 1547 | } |
1547 | 1548 | ||
1548 | void CalendarView::setSyncEventsReadOnly() | 1549 | void CalendarView::setSyncEventsReadOnly() |
1549 | { | 1550 | { |
1550 | Event * ev; | 1551 | Event * ev; |
1551 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1552 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1552 | ev = eL.first(); | 1553 | ev = eL.first(); |
1553 | while ( ev ) { | 1554 | while ( ev ) { |
1554 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1555 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1555 | ev->setReadOnly( true ); | 1556 | ev->setReadOnly( true ); |
1556 | ev = eL.next(); | 1557 | ev = eL.next(); |
1557 | } | 1558 | } |
1558 | } | 1559 | } |
1559 | bool CalendarView::openCalendar(QString filename, bool merge) | 1560 | bool CalendarView::openCalendar(QString filename, bool merge) |
1560 | { | 1561 | { |
1561 | 1562 | ||
1562 | if (filename.isEmpty()) { | 1563 | if (filename.isEmpty()) { |
1563 | return false; | 1564 | return false; |
1564 | } | 1565 | } |
1565 | 1566 | ||
1566 | if (!QFile::exists(filename)) { | 1567 | if (!QFile::exists(filename)) { |
1567 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1568 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1568 | return false; | 1569 | return false; |
1569 | } | 1570 | } |
@@ -3353,404 +3354,410 @@ void CalendarView::processIncidenceSelection( Incidence *incidence ) | |||
3353 | emit todoSelected( true ); | 3354 | emit todoSelected( true ); |
3354 | } else { | 3355 | } else { |
3355 | emit todoSelected( false ); | 3356 | emit todoSelected( false ); |
3356 | }*/ | 3357 | }*/ |
3357 | } | 3358 | } |
3358 | 3359 | ||
3359 | 3360 | ||
3360 | void CalendarView::checkClipboard() | 3361 | void CalendarView::checkClipboard() |
3361 | { | 3362 | { |
3362 | #ifndef KORG_NODND | 3363 | #ifndef KORG_NODND |
3363 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3364 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3364 | emit pasteEnabled(true); | 3365 | emit pasteEnabled(true); |
3365 | } else { | 3366 | } else { |
3366 | emit pasteEnabled(false); | 3367 | emit pasteEnabled(false); |
3367 | } | 3368 | } |
3368 | #endif | 3369 | #endif |
3369 | } | 3370 | } |
3370 | 3371 | ||
3371 | void CalendarView::showDates(const DateList &selectedDates) | 3372 | void CalendarView::showDates(const DateList &selectedDates) |
3372 | { | 3373 | { |
3373 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3374 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3374 | 3375 | ||
3375 | if ( mViewManager->currentView() ) { | 3376 | if ( mViewManager->currentView() ) { |
3376 | updateView( selectedDates.first(), selectedDates.last() ); | 3377 | updateView( selectedDates.first(), selectedDates.last() ); |
3377 | } else { | 3378 | } else { |
3378 | mViewManager->showAgendaView(); | 3379 | mViewManager->showAgendaView(); |
3379 | } | 3380 | } |
3380 | 3381 | ||
3381 | QString selDates; | 3382 | QString selDates; |
3382 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3383 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3383 | if (selectedDates.first() < selectedDates.last() ) | 3384 | if (selectedDates.first() < selectedDates.last() ) |
3384 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3385 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3385 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3386 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3386 | 3387 | ||
3387 | } | 3388 | } |
3388 | 3389 | ||
3389 | QPtrList<CalFilter> CalendarView::filters() | 3390 | QPtrList<CalFilter> CalendarView::filters() |
3390 | { | 3391 | { |
3391 | return mFilters; | 3392 | return mFilters; |
3392 | 3393 | ||
3393 | } | 3394 | } |
3394 | void CalendarView::editFilters() | 3395 | void CalendarView::editFilters() |
3395 | { | 3396 | { |
3396 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3397 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3397 | 3398 | ||
3398 | CalFilter *filter = mFilters.first(); | 3399 | CalFilter *filter = mFilters.first(); |
3399 | while(filter) { | 3400 | while(filter) { |
3400 | kdDebug() << " Filter: " << filter->name() << endl; | 3401 | kdDebug() << " Filter: " << filter->name() << endl; |
3401 | filter = mFilters.next(); | 3402 | filter = mFilters.next(); |
3402 | } | 3403 | } |
3403 | 3404 | ||
3404 | mDialogManager->showFilterEditDialog(&mFilters); | 3405 | mDialogManager->showFilterEditDialog(&mFilters); |
3405 | } | 3406 | } |
3406 | void CalendarView::toggleFilter() | 3407 | void CalendarView::toggleFilter() |
3407 | { | 3408 | { |
3408 | showFilter(! mFilterView->isVisible()); | 3409 | showFilter(! mFilterView->isVisible()); |
3409 | } | 3410 | } |
3410 | 3411 | ||
3411 | KOFilterView *CalendarView::filterView() | 3412 | KOFilterView *CalendarView::filterView() |
3412 | { | 3413 | { |
3413 | return mFilterView; | 3414 | return mFilterView; |
3414 | } | 3415 | } |
3415 | void CalendarView::selectFilter( int fil ) | 3416 | void CalendarView::selectFilter( int fil ) |
3416 | { | 3417 | { |
3417 | mFilterView->setSelectedFilter( fil ); | 3418 | mFilterView->setSelectedFilter( fil ); |
3418 | } | 3419 | } |
3419 | void CalendarView::showFilter(bool visible) | 3420 | void CalendarView::showFilter(bool visible) |
3420 | { | 3421 | { |
3421 | if (visible) mFilterView->show(); | 3422 | if (visible) mFilterView->show(); |
3422 | else mFilterView->hide(); | 3423 | else mFilterView->hide(); |
3423 | } | 3424 | } |
3424 | void CalendarView::toggleFilerEnabled( ) | 3425 | void CalendarView::toggleFilerEnabled( ) |
3425 | { | 3426 | { |
3426 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3427 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3427 | if ( !mFilterView->filtersEnabled() ) | 3428 | if ( !mFilterView->filtersEnabled() ) |
3428 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3429 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3429 | 3430 | ||
3430 | } | 3431 | } |
3431 | void CalendarView::updateFilter() | 3432 | void CalendarView::updateFilter() |
3432 | { | 3433 | { |
3433 | CalFilter *filter = mFilterView->selectedFilter(); | 3434 | CalFilter *filter = mFilterView->selectedFilter(); |
3434 | if (filter) { | 3435 | if (filter) { |
3435 | if (mFilterView->filtersEnabled()) { | 3436 | if (mFilterView->filtersEnabled()) { |
3436 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3437 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3437 | filter->setEnabled(true); | 3438 | filter->setEnabled(true); |
3438 | } | 3439 | } |
3439 | else filter->setEnabled(false); | 3440 | else filter->setEnabled(false); |
3440 | mCalendar->setFilter(filter); | 3441 | mCalendar->setFilter(filter); |
3441 | updateView(); | 3442 | updateView(); |
3442 | } | 3443 | } |
3443 | } | 3444 | } |
3444 | 3445 | ||
3445 | void CalendarView::filterEdited() | 3446 | void CalendarView::filterEdited() |
3446 | { | 3447 | { |
3447 | mFilterView->updateFilters(); | 3448 | mFilterView->updateFilters(); |
3448 | updateFilter(); | 3449 | updateFilter(); |
3449 | writeSettings(); | 3450 | writeSettings(); |
3450 | } | 3451 | } |
3451 | 3452 | ||
3452 | 3453 | ||
3453 | void CalendarView::takeOverEvent() | 3454 | void CalendarView::takeOverEvent() |
3454 | { | 3455 | { |
3455 | Incidence *incidence = currentSelection(); | 3456 | Incidence *incidence = currentSelection(); |
3456 | 3457 | ||
3457 | if (!incidence) return; | 3458 | if (!incidence) return; |
3458 | 3459 | ||
3459 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3460 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3460 | incidence->recreate(); | 3461 | incidence->recreate(); |
3461 | incidence->setReadOnly(false); | 3462 | incidence->setReadOnly(false); |
3462 | 3463 | ||
3463 | updateView(); | 3464 | updateView(); |
3464 | } | 3465 | } |
3465 | 3466 | ||
3466 | void CalendarView::takeOverCalendar() | 3467 | void CalendarView::takeOverCalendar() |
3467 | { | 3468 | { |
3468 | // TODO: Create Calendar::allIncidences() function and use it here | 3469 | // TODO: Create Calendar::allIncidences() function and use it here |
3469 | 3470 | ||
3470 | QPtrList<Event> events = mCalendar->events(); | 3471 | QPtrList<Event> events = mCalendar->events(); |
3471 | for(uint i=0; i<events.count(); ++i) { | 3472 | for(uint i=0; i<events.count(); ++i) { |
3472 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3473 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3473 | events.at(i)->recreate(); | 3474 | events.at(i)->recreate(); |
3474 | events.at(i)->setReadOnly(false); | 3475 | events.at(i)->setReadOnly(false); |
3475 | } | 3476 | } |
3476 | 3477 | ||
3477 | QPtrList<Todo> todos = mCalendar->todos(); | 3478 | QPtrList<Todo> todos = mCalendar->todos(); |
3478 | for(uint i=0; i<todos.count(); ++i) { | 3479 | for(uint i=0; i<todos.count(); ++i) { |
3479 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3480 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3480 | todos.at(i)->recreate(); | 3481 | todos.at(i)->recreate(); |
3481 | todos.at(i)->setReadOnly(false); | 3482 | todos.at(i)->setReadOnly(false); |
3482 | } | 3483 | } |
3483 | 3484 | ||
3484 | QPtrList<Journal> journals = mCalendar->journals(); | 3485 | QPtrList<Journal> journals = mCalendar->journals(); |
3485 | for(uint i=0; i<journals.count(); ++i) { | 3486 | for(uint i=0; i<journals.count(); ++i) { |
3486 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3487 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3487 | journals.at(i)->recreate(); | 3488 | journals.at(i)->recreate(); |
3488 | journals.at(i)->setReadOnly(false); | 3489 | journals.at(i)->setReadOnly(false); |
3489 | } | 3490 | } |
3490 | 3491 | ||
3491 | updateView(); | 3492 | updateView(); |
3492 | } | 3493 | } |
3493 | 3494 | ||
3494 | void CalendarView::showIntro() | 3495 | void CalendarView::showIntro() |
3495 | { | 3496 | { |
3496 | kdDebug() << "To be implemented." << endl; | 3497 | kdDebug() << "To be implemented." << endl; |
3497 | } | 3498 | } |
3498 | 3499 | ||
3499 | QWidgetStack *CalendarView::viewStack() | 3500 | QWidgetStack *CalendarView::viewStack() |
3500 | { | 3501 | { |
3501 | return mRightFrame; | 3502 | return mRightFrame; |
3502 | } | 3503 | } |
3503 | 3504 | ||
3504 | QWidget *CalendarView::leftFrame() | 3505 | QWidget *CalendarView::leftFrame() |
3505 | { | 3506 | { |
3506 | return mLeftFrame; | 3507 | return mLeftFrame; |
3507 | } | 3508 | } |
3508 | 3509 | ||
3509 | DateNavigator *CalendarView::dateNavigator() | 3510 | DateNavigator *CalendarView::dateNavigator() |
3510 | { | 3511 | { |
3511 | return mNavigator; | 3512 | return mNavigator; |
3512 | } | 3513 | } |
3513 | 3514 | ||
3514 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3515 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3515 | { | 3516 | { |
3516 | return mDateNavigator; | 3517 | return mDateNavigator; |
3517 | } | 3518 | } |
3518 | void CalendarView::toggleDateNavigatorWidget() | 3519 | void CalendarView::toggleDateNavigatorWidget() |
3519 | { | 3520 | { |
3520 | if (mDateNavigator->isVisible()) | 3521 | if (mDateNavigator->isVisible()) |
3521 | mDateNavigator->hide(); | 3522 | mDateNavigator->hide(); |
3522 | else | 3523 | else |
3523 | mDateNavigator->show(); | 3524 | mDateNavigator->show(); |
3524 | } | 3525 | } |
3525 | void CalendarView::addView(KOrg::BaseView *view) | 3526 | void CalendarView::addView(KOrg::BaseView *view) |
3526 | { | 3527 | { |
3527 | mViewManager->addView(view); | 3528 | mViewManager->addView(view); |
3528 | } | 3529 | } |
3529 | 3530 | ||
3530 | void CalendarView::showView(KOrg::BaseView *view) | 3531 | void CalendarView::showView(KOrg::BaseView *view) |
3531 | { | 3532 | { |
3532 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3533 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3533 | } | 3534 | } |
3534 | 3535 | ||
3535 | Incidence *CalendarView::currentSelection() | 3536 | Incidence *CalendarView::currentSelection() |
3536 | { | 3537 | { |
3537 | return mViewManager->currentSelection(); | 3538 | return mViewManager->currentSelection(); |
3538 | } | 3539 | } |
3539 | void CalendarView::toggleAllDaySize() | 3540 | void CalendarView::toggleAllDaySize() |
3540 | { | 3541 | { |
3541 | /* | 3542 | /* |
3542 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3543 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3543 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3544 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3544 | else | 3545 | else |
3545 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3546 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3546 | */ | 3547 | */ |
3547 | viewManager()->agendaView()->toggleAllDay(); | 3548 | viewManager()->agendaView()->toggleAllDay(); |
3548 | } | 3549 | } |
3549 | void CalendarView::toggleExpand() | 3550 | void CalendarView::toggleExpand() |
3550 | { | 3551 | { |
3551 | // if ( mLeftFrame->isHidden() ) { | 3552 | // if ( mLeftFrame->isHidden() ) { |
3552 | // mLeftFrame->show(); | 3553 | // mLeftFrame->show(); |
3553 | // emit calendarViewExpanded( false ); | 3554 | // emit calendarViewExpanded( false ); |
3554 | // } else { | 3555 | // } else { |
3555 | // mLeftFrame->hide(); | 3556 | // mLeftFrame->hide(); |
3556 | // emit calendarViewExpanded( true ); | 3557 | // emit calendarViewExpanded( true ); |
3557 | // } | 3558 | // } |
3558 | 3559 | ||
3559 | globalFlagBlockAgenda = 1; | 3560 | globalFlagBlockAgenda = 1; |
3560 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3561 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3561 | globalFlagBlockAgenda = 5; | 3562 | globalFlagBlockAgenda = 5; |
3562 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3563 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3563 | //mViewManager->showView( 0, true ); | 3564 | //mViewManager->showView( 0, true ); |
3564 | } | 3565 | } |
3565 | 3566 | ||
3566 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3567 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3567 | { | 3568 | { |
3568 | setModified( modified ); | 3569 | setModified( modified ); |
3569 | } | 3570 | } |
3570 | 3571 | ||
3571 | Todo *CalendarView::selectedTodo() | 3572 | Todo *CalendarView::selectedTodo() |
3572 | { | 3573 | { |
3573 | Incidence *incidence = currentSelection(); | 3574 | Incidence *incidence = currentSelection(); |
3574 | if ( incidence && incidence->type() == "Todo" ) { | 3575 | if ( incidence && incidence->type() == "Todo" ) { |
3575 | return static_cast<Todo *>( incidence ); | 3576 | return static_cast<Todo *>( incidence ); |
3576 | } | 3577 | } |
3577 | 3578 | ||
3578 | incidence = mTodoList->selectedIncidences().first(); | 3579 | incidence = mTodoList->selectedIncidences().first(); |
3579 | if ( incidence && incidence->type() == "Todo" ) { | 3580 | if ( incidence && incidence->type() == "Todo" ) { |
3580 | return static_cast<Todo *>( incidence ); | 3581 | return static_cast<Todo *>( incidence ); |
3581 | } | 3582 | } |
3582 | 3583 | ||
3583 | return 0; | 3584 | return 0; |
3584 | } | 3585 | } |
3585 | 3586 | ||
3586 | void CalendarView::dialogClosing(Incidence *in) | 3587 | void CalendarView::dialogClosing(Incidence *in) |
3587 | { | 3588 | { |
3588 | // mDialogList.remove(in); | 3589 | // mDialogList.remove(in); |
3589 | } | 3590 | } |
3590 | 3591 | ||
3591 | void CalendarView::showIncidence() | 3592 | void CalendarView::showIncidence() |
3592 | { | 3593 | { |
3593 | Incidence *incidence = currentSelection(); | 3594 | Incidence *incidence = currentSelection(); |
3594 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3595 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3595 | if ( incidence ) { | 3596 | if ( incidence ) { |
3596 | ShowIncidenceVisitor v; | 3597 | ShowIncidenceVisitor v; |
3597 | v.act( incidence, this ); | 3598 | v.act( incidence, this ); |
3598 | } | 3599 | } |
3599 | } | 3600 | } |
3600 | void CalendarView::editIncidenceDescription() | 3601 | void CalendarView::editIncidenceDescription() |
3601 | { | 3602 | { |
3602 | mFlagEditDescription = true; | 3603 | mFlagEditDescription = true; |
3603 | editIncidence(); | 3604 | editIncidence(); |
3604 | mFlagEditDescription = false; | 3605 | mFlagEditDescription = false; |
3605 | } | 3606 | } |
3606 | void CalendarView::editIncidence() | 3607 | void CalendarView::editIncidence() |
3607 | { | 3608 | { |
3608 | // qDebug("editIncidence() "); | 3609 | // qDebug("editIncidence() "); |
3609 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3610 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3611 | if ( incidence ) { | 3612 | if ( incidence ) { |
3612 | EditIncidenceVisitor v; | 3613 | EditIncidenceVisitor v; |
3613 | v.act( incidence, this ); | 3614 | v.act( incidence, this ); |
3614 | } | 3615 | } |
3615 | } | 3616 | } |
3616 | 3617 | ||
3617 | void CalendarView::deleteIncidence() | 3618 | void CalendarView::deleteIncidence() |
3618 | { | 3619 | { |
3619 | Incidence *incidence = currentSelection(); | 3620 | Incidence *incidence = currentSelection(); |
3620 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3621 | if ( incidence ) { | 3622 | if ( incidence ) { |
3622 | deleteIncidence(incidence); | 3623 | deleteIncidence(incidence); |
3623 | } | 3624 | } |
3624 | } | 3625 | } |
3625 | 3626 | ||
3626 | void CalendarView::showIncidence(Incidence *incidence) | 3627 | void CalendarView::showIncidence(Incidence *incidence) |
3627 | { | 3628 | { |
3628 | if ( incidence ) { | 3629 | if ( incidence ) { |
3629 | ShowIncidenceVisitor v; | 3630 | ShowIncidenceVisitor v; |
3630 | v.act( incidence, this ); | 3631 | v.act( incidence, this ); |
3631 | } | 3632 | } |
3632 | } | 3633 | } |
3633 | 3634 | ||
3634 | void CalendarView::editIncidence(Incidence *incidence) | 3635 | void CalendarView::editIncidence(Incidence *incidence) |
3635 | { | 3636 | { |
3636 | if ( incidence ) { | 3637 | if ( incidence ) { |
3637 | 3638 | ||
3638 | EditIncidenceVisitor v; | 3639 | EditIncidenceVisitor v; |
3639 | v.act( incidence, this ); | 3640 | v.act( incidence, this ); |
3640 | 3641 | ||
3641 | } | 3642 | } |
3642 | } | 3643 | } |
3643 | 3644 | ||
3644 | void CalendarView::deleteIncidence(Incidence *incidence) | 3645 | void CalendarView::deleteIncidence(Incidence *incidence) |
3645 | { | 3646 | { |
3646 | //qDebug(" CalendarView::deleteIncidence "); | 3647 | //qDebug(" CalendarView::deleteIncidence "); |
3647 | if ( incidence ) { | 3648 | if ( incidence ) { |
3648 | DeleteIncidenceVisitor v; | 3649 | DeleteIncidenceVisitor v; |
3649 | v.act( incidence, this ); | 3650 | v.act( incidence, this ); |
3650 | } | 3651 | } |
3651 | } | 3652 | } |
3652 | 3653 | ||
3653 | 3654 | ||
3654 | void CalendarView::lookForOutgoingMessages() | 3655 | void CalendarView::lookForOutgoingMessages() |
3655 | { | 3656 | { |
3656 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3657 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3657 | ogd->loadMessages(); | 3658 | ogd->loadMessages(); |
3658 | } | 3659 | } |
3659 | 3660 | ||
3660 | void CalendarView::lookForIncomingMessages() | 3661 | void CalendarView::lookForIncomingMessages() |
3661 | { | 3662 | { |
3662 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3663 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3663 | icd->retrieve(); | 3664 | icd->retrieve(); |
3664 | } | 3665 | } |
3665 | 3666 | ||
3666 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3667 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3667 | { | 3668 | { |
3668 | bool deleteTodo = true; | 3669 | bool deleteTodo = true; |
3669 | QPtrList<Incidence> subTodos; | 3670 | QPtrList<Incidence> subTodos; |
3670 | Incidence *aTodo; | 3671 | Incidence *aTodo; |
3671 | subTodos = t->relations(); | 3672 | subTodos = t->relations(); |
3672 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3673 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3673 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3674 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3674 | deleteTodo = false; | 3675 | deleteTodo = false; |
3675 | } | 3676 | } |
3676 | if ( deleteTodo ) { | 3677 | if ( deleteTodo ) { |
3677 | if ( t->isCompleted() ) { | 3678 | if ( t->isCompleted() ) { |
3678 | checkExternalId( t ); | 3679 | checkExternalId( t ); |
3679 | mCalendar->deleteTodo( t ); | 3680 | mCalendar->deleteTodo( t ); |
3680 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3681 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3681 | } | 3682 | } |
3682 | else | 3683 | else |
3683 | deleteTodo = false; | 3684 | deleteTodo = false; |
3684 | } | 3685 | } |
3685 | return deleteTodo; | 3686 | return deleteTodo; |
3686 | 3687 | ||
3687 | } | 3688 | } |
3688 | void CalendarView::purgeCompleted() | 3689 | void CalendarView::purgeCompleted() |
3689 | { | 3690 | { |
3690 | int result = KMessageBox::warningContinueCancel(this, | 3691 | int result = KMessageBox::warningContinueCancel(this, |
3691 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3692 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3692 | 3693 | ||
3693 | if (result == KMessageBox::Continue) { | 3694 | if (result == KMessageBox::Continue) { |
3694 | 3695 | ||
3695 | QPtrList<Todo> todoCal; | 3696 | QPtrList<Todo> todoCal; |
3696 | QPtrList<Todo> rootTodos; | 3697 | QPtrList<Todo> rootTodos; |
3697 | //QPtrList<Incidence> rel; | 3698 | //QPtrList<Incidence> rel; |
3698 | Todo *aTodo;//, *rTodo; | 3699 | Todo *aTodo;//, *rTodo; |
3699 | Incidence *rIncidence; | 3700 | Incidence *rIncidence; |
3700 | bool childDelete = false; | 3701 | bool childDelete = false; |
3701 | bool deletedOne = true; | 3702 | bool deletedOne = true; |
3702 | todoCal = calendar()->todos(); | 3703 | todoCal = calendar()->todos(); |
3703 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3704 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3704 | if ( !aTodo->relatedTo() ) | 3705 | if ( !aTodo->relatedTo() ) |
3705 | rootTodos.append( aTodo ); | 3706 | rootTodos.append( aTodo ); |
3706 | } | 3707 | } |
3707 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3708 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3708 | removeCompletedSubTodos( aTodo ); | 3709 | removeCompletedSubTodos( aTodo ); |
3709 | } | 3710 | } |
3710 | 3711 | ||
3711 | updateView(); | 3712 | updateView(); |
3712 | } | 3713 | } |
3713 | } | 3714 | } |
3714 | 3715 | ||
3715 | void CalendarView::slotCalendarChanged() | 3716 | void CalendarView::slotCalendarChanged() |
3716 | { | 3717 | { |
3717 | ; | 3718 | ; |
3718 | } | 3719 | } |
3719 | 3720 | ||
3720 | NavigatorBar *CalendarView::navigatorBar() | 3721 | NavigatorBar *CalendarView::navigatorBar() |
3721 | { | 3722 | { |
3722 | return mNavigatorBar; | 3723 | return mNavigatorBar; |
3723 | } | 3724 | } |
3724 | 3725 | ||
3725 | 3726 | ||
3726 | 3727 | ||
3727 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3728 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3728 | { | 3729 | { |
3729 | //qDebug(" alendarView::keyPressEvent "); | 3730 | //qDebug(" alendarView::keyPressEvent "); |
3730 | e->ignore(); | 3731 | e->ignore(); |
3731 | } | 3732 | } |
3732 | 3733 | ||
3733 | 3734 | ||
3734 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3735 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3735 | { | 3736 | { |
3736 | // mSyncManager = manager; | 3737 | // mSyncManager = manager; |
3738 | mSyncKDE = false; | ||
3739 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | ||
3740 | qDebug("SyncKDE request detected!"); | ||
3741 | mSyncKDE = true; | ||
3742 | } | ||
3737 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3743 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3738 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3744 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3739 | return syncCalendar( filename, mode ); | 3745 | return syncCalendar( filename, mode ); |
3740 | } | 3746 | } |
3741 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3747 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3742 | { | 3748 | { |
3749 | mSyncKDE = false; | ||
3743 | //mSyncManager = manager; | 3750 | //mSyncManager = manager; |
3744 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3745 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3746 | if ( resource == "sharp" ) | 3753 | if ( resource == "sharp" ) |
3747 | syncExternal( 0 ); | 3754 | syncExternal( 0 ); |
3748 | if ( resource == "phone" ) | 3755 | if ( resource == "phone" ) |
3749 | syncExternal( 1 ); | 3756 | syncExternal( 1 ); |
3750 | // pending setmodified | 3757 | // pending setmodified |
3751 | return true; | 3758 | return true; |
3752 | } | 3759 | } |
3753 | void CalendarView::setSyncManager(KSyncManager* manager) | 3760 | void CalendarView::setSyncManager(KSyncManager* manager) |
3754 | { | 3761 | { |
3755 | mSyncManager = manager; | 3762 | mSyncManager = manager; |
3756 | } | 3763 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 9f56cc8..1cd896d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -106,498 +106,499 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
106 | 106 | ||
107 | QWidgetStack *viewStack(); | 107 | QWidgetStack *viewStack(); |
108 | QWidget *leftFrame(); | 108 | QWidget *leftFrame(); |
109 | NavigatorBar *navigatorBar(); | 109 | NavigatorBar *navigatorBar(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | /** This todo has been modified */ | 120 | /** This todo has been modified */ |
121 | void todoModified(Todo *, int); | 121 | void todoModified(Todo *, int); |
122 | 122 | ||
123 | /** when change is made to options dialog, the topwidget will catch this | 123 | /** when change is made to options dialog, the topwidget will catch this |
124 | * and emit this signal which notifies all widgets which have registered | 124 | * and emit this signal which notifies all widgets which have registered |
125 | * for notification to update their settings. */ | 125 | * for notification to update their settings. */ |
126 | void configChanged(); | 126 | void configChanged(); |
127 | /** emitted when the topwidget is closing down, so that any attached | 127 | /** emitted when the topwidget is closing down, so that any attached |
128 | child windows can also close. */ | 128 | child windows can also close. */ |
129 | void closingDown(); | 129 | void closingDown(); |
130 | /** emitted right before we die */ | 130 | /** emitted right before we die */ |
131 | void closed(QWidget *); | 131 | void closed(QWidget *); |
132 | 132 | ||
133 | /** Emitted when state of modified flag changes */ | 133 | /** Emitted when state of modified flag changes */ |
134 | void modifiedChanged(bool); | 134 | void modifiedChanged(bool); |
135 | void signalmodified(); | 135 | void signalmodified(); |
136 | 136 | ||
137 | /** Emitted when state of read-only flag changes */ | 137 | /** Emitted when state of read-only flag changes */ |
138 | void readOnlyChanged(bool); | 138 | void readOnlyChanged(bool); |
139 | 139 | ||
140 | /** Emitted when the unit of navigation changes */ | 140 | /** Emitted when the unit of navigation changes */ |
141 | void changeNavStringPrev(const QString &); | 141 | void changeNavStringPrev(const QString &); |
142 | void changeNavStringNext(const QString &); | 142 | void changeNavStringNext(const QString &); |
143 | 143 | ||
144 | /** Emitted when state of events selection has changed and user is organizer*/ | 144 | /** Emitted when state of events selection has changed and user is organizer*/ |
145 | void organizerEventsSelected(bool); | 145 | void organizerEventsSelected(bool); |
146 | /** Emitted when state of events selection has changed and user is attendee*/ | 146 | /** Emitted when state of events selection has changed and user is attendee*/ |
147 | void groupEventsSelected(bool); | 147 | void groupEventsSelected(bool); |
148 | /** | 148 | /** |
149 | Emitted when an incidence gets selected. If the selection is cleared the | 149 | Emitted when an incidence gets selected. If the selection is cleared the |
150 | signal is emitted with 0 as argument. | 150 | signal is emitted with 0 as argument. |
151 | */ | 151 | */ |
152 | void incidenceSelected( Incidence * ); | 152 | void incidenceSelected( Incidence * ); |
153 | /** Emitted, when a todoitem is selected or deselected. */ | 153 | /** Emitted, when a todoitem is selected or deselected. */ |
154 | void todoSelected( bool ); | 154 | void todoSelected( bool ); |
155 | 155 | ||
156 | /** | 156 | /** |
157 | Emitted, when clipboard content changes. Parameter indicates if paste | 157 | Emitted, when clipboard content changes. Parameter indicates if paste |
158 | is possible or not. | 158 | is possible or not. |
159 | */ | 159 | */ |
160 | void pasteEnabled(bool); | 160 | void pasteEnabled(bool); |
161 | 161 | ||
162 | /** Emitted, when the number of incoming messages has changed. */ | 162 | /** Emitted, when the number of incoming messages has changed. */ |
163 | void numIncomingChanged(int); | 163 | void numIncomingChanged(int); |
164 | 164 | ||
165 | /** Emitted, when the number of outgoing messages has changed. */ | 165 | /** Emitted, when the number of outgoing messages has changed. */ |
166 | void numOutgoingChanged(int); | 166 | void numOutgoingChanged(int); |
167 | 167 | ||
168 | /** Send status message, which can e.g. be displayed in the status bar. */ | 168 | /** Send status message, which can e.g. be displayed in the status bar. */ |
169 | void statusMessage(const QString &); | 169 | void statusMessage(const QString &); |
170 | 170 | ||
171 | void calendarViewExpanded( bool ); | 171 | void calendarViewExpanded( bool ); |
172 | void updateSearchDialog(); | 172 | void updateSearchDialog(); |
173 | 173 | ||
174 | 174 | ||
175 | public slots: | 175 | public slots: |
176 | void showOpenError(); | 176 | void showOpenError(); |
177 | void watchSavedFile(); | 177 | void watchSavedFile(); |
178 | void recheckTimerAlarm(); | 178 | void recheckTimerAlarm(); |
179 | void checkNextTimerAlarm(); | 179 | void checkNextTimerAlarm(); |
180 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
181 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 182 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
183 | 183 | ||
184 | /** options dialog made a changed to the configuration. we catch this | 184 | /** options dialog made a changed to the configuration. we catch this |
185 | * and notify all widgets which need to update their configuration. */ | 185 | * and notify all widgets which need to update their configuration. */ |
186 | void updateConfig(); | 186 | void updateConfig(); |
187 | 187 | ||
188 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 188 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
189 | const QStringList& anniversaryList, const QStringList& realNameList, | 189 | const QStringList& anniversaryList, const QStringList& realNameList, |
190 | const QStringList& emailList, const QStringList& assembledNameList, | 190 | const QStringList& emailList, const QStringList& assembledNameList, |
191 | const QStringList& uidList); | 191 | const QStringList& uidList); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Load calendar from file \a filename. If \a merge is true, load | 194 | Load calendar from file \a filename. If \a merge is true, load |
195 | calendar into existing one, if it is false, clear calendar, before | 195 | calendar into existing one, if it is false, clear calendar, before |
196 | loading. Return true, if calendar could be successfully loaded. | 196 | loading. Return true, if calendar could be successfully loaded. |
197 | */ | 197 | */ |
198 | bool openCalendar(QString filename, bool merge=false); | 198 | bool openCalendar(QString filename, bool merge=false); |
199 | bool syncCalendar(QString filename,int mode = 0 ); | 199 | bool syncCalendar(QString filename,int mode = 0 ); |
200 | 200 | ||
201 | /** | 201 | /** |
202 | Save calendar data to file. Return true if calendar could be | 202 | Save calendar data to file. Return true if calendar could be |
203 | successfully saved. | 203 | successfully saved. |
204 | */ | 204 | */ |
205 | bool saveCalendar(QString filename); | 205 | bool saveCalendar(QString filename); |
206 | 206 | ||
207 | /** | 207 | /** |
208 | Close calendar. Clear calendar data and reset views to display an empty | 208 | Close calendar. Clear calendar data and reset views to display an empty |
209 | calendar. | 209 | calendar. |
210 | */ | 210 | */ |
211 | void closeCalendar(); | 211 | void closeCalendar(); |
212 | 212 | ||
213 | /** Archive old events of calendar */ | 213 | /** Archive old events of calendar */ |
214 | void archiveCalendar(); | 214 | void archiveCalendar(); |
215 | 215 | ||
216 | void showIncidence(); | 216 | void showIncidence(); |
217 | void editIncidence(); | 217 | void editIncidence(); |
218 | void editIncidenceDescription(); | 218 | void editIncidenceDescription(); |
219 | void deleteIncidence(); | 219 | void deleteIncidence(); |
220 | void cloneIncidence(); | 220 | void cloneIncidence(); |
221 | void moveIncidence(); | 221 | void moveIncidence(); |
222 | void beamIncidence(); | 222 | void beamIncidence(); |
223 | void toggleCancelIncidence(); | 223 | void toggleCancelIncidence(); |
224 | 224 | ||
225 | /** create an editeventwin with supplied date/time, and if bool is true, | 225 | /** create an editeventwin with supplied date/time, and if bool is true, |
226 | * make the event take all day. */ | 226 | * make the event take all day. */ |
227 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 227 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
228 | void newEvent(QDateTime fh); | 228 | void newEvent(QDateTime fh); |
229 | void newEvent(QDate dt); | 229 | void newEvent(QDate dt); |
230 | /** create new event without having a date hint. Takes current date as | 230 | /** create new event without having a date hint. Takes current date as |
231 | default hint. */ | 231 | default hint. */ |
232 | void newEvent(); | 232 | void newEvent(); |
233 | void newFloatingEvent(); | 233 | void newFloatingEvent(); |
234 | 234 | ||
235 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 235 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
236 | void showIncidence(Incidence *); | 236 | void showIncidence(Incidence *); |
237 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 237 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
238 | void editIncidence(Incidence *); | 238 | void editIncidence(Incidence *); |
239 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 239 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
240 | void deleteIncidence(Incidence *); | 240 | void deleteIncidence(Incidence *); |
241 | void cloneIncidence(Incidence *); | 241 | void cloneIncidence(Incidence *); |
242 | void cancelIncidence(Incidence *); | 242 | void cancelIncidence(Incidence *); |
243 | /** Create an editor for the supplied event. */ | 243 | /** Create an editor for the supplied event. */ |
244 | void editEvent(Event *); | 244 | void editEvent(Event *); |
245 | /** Delete the supplied event. */ | 245 | /** Delete the supplied event. */ |
246 | void deleteEvent(Event *); | 246 | void deleteEvent(Event *); |
247 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 247 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
248 | found. */ | 248 | found. */ |
249 | bool deleteEvent(const QString &uid); | 249 | bool deleteEvent(const QString &uid); |
250 | /** Create a read-only viewer dialog for the supplied event. */ | 250 | /** Create a read-only viewer dialog for the supplied event. */ |
251 | void showEvent(Event *); | 251 | void showEvent(Event *); |
252 | 252 | ||
253 | void editJournal(Journal *); | 253 | void editJournal(Journal *); |
254 | void showJournal(Journal *); | 254 | void showJournal(Journal *); |
255 | void deleteJournal(Journal *); | 255 | void deleteJournal(Journal *); |
256 | /** Create an editor dialog for a todo */ | 256 | /** Create an editor dialog for a todo */ |
257 | void editTodo(Todo *); | 257 | void editTodo(Todo *); |
258 | /** Create a read-only viewer dialog for the supplied todo */ | 258 | /** Create a read-only viewer dialog for the supplied todo */ |
259 | void showTodo(Todo *); | 259 | void showTodo(Todo *); |
260 | /** create new todo */ | 260 | /** create new todo */ |
261 | void newTodo(); | 261 | void newTodo(); |
262 | /** create new todo with a parent todo */ | 262 | /** create new todo with a parent todo */ |
263 | void newSubTodo(); | 263 | void newSubTodo(); |
264 | /** create new todo with a parent todo */ | 264 | /** create new todo with a parent todo */ |
265 | void newSubTodo(Todo *); | 265 | void newSubTodo(Todo *); |
266 | /** Delete todo */ | 266 | /** Delete todo */ |
267 | void deleteTodo(Todo *); | 267 | void deleteTodo(Todo *); |
268 | 268 | ||
269 | 269 | ||
270 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 270 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
271 | * emitted as result. */ | 271 | * emitted as result. */ |
272 | void checkClipboard(); | 272 | void checkClipboard(); |
273 | 273 | ||
274 | /** using the KConfig associated with the kapp variable, read in the | 274 | /** using the KConfig associated with the kapp variable, read in the |
275 | * settings from the config file. | 275 | * settings from the config file. |
276 | */ | 276 | */ |
277 | void readSettings(); | 277 | void readSettings(); |
278 | 278 | ||
279 | /** write current state to config file. */ | 279 | /** write current state to config file. */ |
280 | void writeSettings(); | 280 | void writeSettings(); |
281 | 281 | ||
282 | /** read settings for calendar filters */ | 282 | /** read settings for calendar filters */ |
283 | void readFilterSettings(KConfig *config); | 283 | void readFilterSettings(KConfig *config); |
284 | 284 | ||
285 | /** write settings for calendar filters */ | 285 | /** write settings for calendar filters */ |
286 | void writeFilterSettings(KConfig *config); | 286 | void writeFilterSettings(KConfig *config); |
287 | 287 | ||
288 | /** passes on the message that an event has changed to the currently | 288 | /** passes on the message that an event has changed to the currently |
289 | * activated view so that it can make appropriate display changes. */ | 289 | * activated view so that it can make appropriate display changes. */ |
290 | void changeEventDisplay(Event *, int); | 290 | void changeEventDisplay(Event *, int); |
291 | void changeIncidenceDisplay(Incidence *, int); | 291 | void changeIncidenceDisplay(Incidence *, int); |
292 | void changeTodoDisplay(Todo *, int); | 292 | void changeTodoDisplay(Todo *, int); |
293 | 293 | ||
294 | void eventAdded(Event *); | 294 | void eventAdded(Event *); |
295 | void eventChanged(Event *); | 295 | void eventChanged(Event *); |
296 | void eventToBeDeleted(Event *); | 296 | void eventToBeDeleted(Event *); |
297 | void eventDeleted(); | 297 | void eventDeleted(); |
298 | 298 | ||
299 | void todoAdded(Todo *); | 299 | void todoAdded(Todo *); |
300 | void todoChanged(Todo *); | 300 | void todoChanged(Todo *); |
301 | void todoToBeDeleted(Todo *); | 301 | void todoToBeDeleted(Todo *); |
302 | void todoDeleted(); | 302 | void todoDeleted(); |
303 | 303 | ||
304 | void updateView(const QDate &start, const QDate &end); | 304 | void updateView(const QDate &start, const QDate &end); |
305 | void updateView(); | 305 | void updateView(); |
306 | 306 | ||
307 | /** Full update of visible todo views */ | 307 | /** Full update of visible todo views */ |
308 | void updateTodoViews(); | 308 | void updateTodoViews(); |
309 | 309 | ||
310 | void updateUnmanagedViews(); | 310 | void updateUnmanagedViews(); |
311 | 311 | ||
312 | /** cut the current appointment to the clipboard */ | 312 | /** cut the current appointment to the clipboard */ |
313 | void edit_cut(); | 313 | void edit_cut(); |
314 | 314 | ||
315 | /** copy the current appointment(s) to the clipboard */ | 315 | /** copy the current appointment(s) to the clipboard */ |
316 | void edit_copy(); | 316 | void edit_copy(); |
317 | 317 | ||
318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
319 | void edit_paste(); | 319 | void edit_paste(); |
320 | 320 | ||
321 | /** edit viewing and configuration options. */ | 321 | /** edit viewing and configuration options. */ |
322 | void edit_options(); | 322 | void edit_options(); |
323 | /** | 323 | /** |
324 | Functions for printing, previewing a print, and setting up printing | 324 | Functions for printing, previewing a print, and setting up printing |
325 | parameters. | 325 | parameters. |
326 | */ | 326 | */ |
327 | void print(); | 327 | void print(); |
328 | void printSetup(); | 328 | void printSetup(); |
329 | void printPreview(); | 329 | void printPreview(); |
330 | 330 | ||
331 | /** Export as iCalendar file */ | 331 | /** Export as iCalendar file */ |
332 | void exportICalendar(); | 332 | void exportICalendar(); |
333 | 333 | ||
334 | /** Export as vCalendar file */ | 334 | /** Export as vCalendar file */ |
335 | bool exportVCalendar( QString fn); | 335 | bool exportVCalendar( QString fn); |
336 | 336 | ||
337 | /** pop up a dialog to show an existing appointment. */ | 337 | /** pop up a dialog to show an existing appointment. */ |
338 | void appointment_show(); | 338 | void appointment_show(); |
339 | /** | 339 | /** |
340 | * pop up an Appointment Dialog to edit an existing appointment.Get | 340 | * pop up an Appointment Dialog to edit an existing appointment.Get |
341 | * information on the appointment from the list of unique IDs that is | 341 | * information on the appointment from the list of unique IDs that is |
342 | * currently in the View, called currIds. | 342 | * currently in the View, called currIds. |
343 | */ | 343 | */ |
344 | void appointment_edit(); | 344 | void appointment_edit(); |
345 | /** | 345 | /** |
346 | * pop up dialog confirming deletion of currently selected event in the | 346 | * pop up dialog confirming deletion of currently selected event in the |
347 | * View. | 347 | * View. |
348 | */ | 348 | */ |
349 | void appointment_delete(); | 349 | void appointment_delete(); |
350 | 350 | ||
351 | /** mails the currently selected event to a particular user as a vCalendar | 351 | /** mails the currently selected event to a particular user as a vCalendar |
352 | attachment. */ | 352 | attachment. */ |
353 | void action_mail(); | 353 | void action_mail(); |
354 | 354 | ||
355 | /* frees a subtodo from it's relation */ | 355 | /* frees a subtodo from it's relation */ |
356 | void todo_unsub( Todo * ); | 356 | void todo_unsub( Todo * ); |
357 | void todo_resub( Todo * parent, Todo * sub ); | 357 | void todo_resub( Todo * parent, Todo * sub ); |
358 | 358 | ||
359 | /** Take ownership of selected event. */ | 359 | /** Take ownership of selected event. */ |
360 | void takeOverEvent(); | 360 | void takeOverEvent(); |
361 | 361 | ||
362 | /** Take ownership of all events in calendar. */ | 362 | /** Take ownership of all events in calendar. */ |
363 | void takeOverCalendar(); | 363 | void takeOverCalendar(); |
364 | 364 | ||
365 | /** query whether or not the calendar is "dirty". */ | 365 | /** query whether or not the calendar is "dirty". */ |
366 | bool isModified(); | 366 | bool isModified(); |
367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
368 | void setModified(bool modified=true); | 368 | void setModified(bool modified=true); |
369 | 369 | ||
370 | /** query if the calendar is read-only. */ | 370 | /** query if the calendar is read-only. */ |
371 | bool isReadOnly(); | 371 | bool isReadOnly(); |
372 | /** set state of calendar to read-only */ | 372 | /** set state of calendar to read-only */ |
373 | void setReadOnly(bool readOnly=true); | 373 | void setReadOnly(bool readOnly=true); |
374 | 374 | ||
375 | void eventUpdated(Incidence *); | 375 | void eventUpdated(Incidence *); |
376 | 376 | ||
377 | /* iTIP scheduling actions */ | 377 | /* iTIP scheduling actions */ |
378 | void schedule_publish(Incidence *incidence = 0); | 378 | void schedule_publish(Incidence *incidence = 0); |
379 | void schedule_request(Incidence *incidence = 0); | 379 | void schedule_request(Incidence *incidence = 0); |
380 | void schedule_refresh(Incidence *incidence = 0); | 380 | void schedule_refresh(Incidence *incidence = 0); |
381 | void schedule_cancel(Incidence *incidence = 0); | 381 | void schedule_cancel(Incidence *incidence = 0); |
382 | void schedule_add(Incidence *incidence = 0); | 382 | void schedule_add(Incidence *incidence = 0); |
383 | void schedule_reply(Incidence *incidence = 0); | 383 | void schedule_reply(Incidence *incidence = 0); |
384 | void schedule_counter(Incidence *incidence = 0); | 384 | void schedule_counter(Incidence *incidence = 0); |
385 | void schedule_declinecounter(Incidence *incidence = 0); | 385 | void schedule_declinecounter(Incidence *incidence = 0); |
386 | void schedule_publish_freebusy(int daysToPublish = 30); | 386 | void schedule_publish_freebusy(int daysToPublish = 30); |
387 | 387 | ||
388 | void openAddressbook(); | 388 | void openAddressbook(); |
389 | 389 | ||
390 | void editFilters(); | 390 | void editFilters(); |
391 | void toggleFilerEnabled(); | 391 | void toggleFilerEnabled(); |
392 | QPtrList<CalFilter> filters(); | 392 | QPtrList<CalFilter> filters(); |
393 | void toggleFilter(); | 393 | void toggleFilter(); |
394 | void showFilter(bool visible); | 394 | void showFilter(bool visible); |
395 | void updateFilter(); | 395 | void updateFilter(); |
396 | void filterEdited(); | 396 | void filterEdited(); |
397 | void selectFilter( int ); | 397 | void selectFilter( int ); |
398 | KOFilterView *filterView(); | 398 | KOFilterView *filterView(); |
399 | 399 | ||
400 | void showIntro(); | 400 | void showIntro(); |
401 | 401 | ||
402 | /** Move the curdatepient view date to today */ | 402 | /** Move the curdatepient view date to today */ |
403 | void goToday(); | 403 | void goToday(); |
404 | 404 | ||
405 | /** Move to the next date(s) in the current view */ | 405 | /** Move to the next date(s) in the current view */ |
406 | void goNext(); | 406 | void goNext(); |
407 | 407 | ||
408 | /** Move to the previous date(s) in the current view */ | 408 | /** Move to the previous date(s) in the current view */ |
409 | void goPrevious(); | 409 | void goPrevious(); |
410 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
411 | void goNextMonth(); | 411 | void goNextMonth(); |
412 | 412 | ||
413 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
414 | void goPreviousMonth(); | 414 | void goPreviousMonth(); |
415 | 415 | ||
416 | void toggleExpand(); | 416 | void toggleExpand(); |
417 | void toggleDateNavigatorWidget(); | 417 | void toggleDateNavigatorWidget(); |
418 | void toggleAllDaySize(); | 418 | void toggleAllDaySize(); |
419 | void dialogClosing(Incidence *); | 419 | void dialogClosing(Incidence *); |
420 | 420 | ||
421 | /** Look for new messages in the inbox */ | 421 | /** Look for new messages in the inbox */ |
422 | void lookForIncomingMessages(); | 422 | void lookForIncomingMessages(); |
423 | /** Look for new messages in the outbox */ | 423 | /** Look for new messages in the outbox */ |
424 | void lookForOutgoingMessages(); | 424 | void lookForOutgoingMessages(); |
425 | 425 | ||
426 | void processMainViewSelection( Incidence * ); | 426 | void processMainViewSelection( Incidence * ); |
427 | void processTodoListSelection( Incidence * ); | 427 | void processTodoListSelection( Incidence * ); |
428 | 428 | ||
429 | void processIncidenceSelection( Incidence * ); | 429 | void processIncidenceSelection( Incidence * ); |
430 | 430 | ||
431 | void purgeCompleted(); | 431 | void purgeCompleted(); |
432 | bool removeCompletedSubTodos( Todo* ); | 432 | bool removeCompletedSubTodos( Todo* ); |
433 | void slotCalendarChanged(); | 433 | void slotCalendarChanged(); |
434 | bool importBday(); | 434 | bool importBday(); |
435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
436 | bool importQtopia( const QString &categoriesFile, | 436 | bool importQtopia( const QString &categoriesFile, |
437 | const QString &datebookFile, | 437 | const QString &datebookFile, |
438 | const QString &tasklistFile ); | 438 | const QString &tasklistFile ); |
439 | void syncExternal( int mode ); | 439 | void syncExternal( int mode ); |
440 | void slotSelectPickerDate( QDate ) ; | 440 | void slotSelectPickerDate( QDate ) ; |
441 | void showDatePicker( ) ; | 441 | void showDatePicker( ) ; |
442 | void moveIncidence(Incidence *) ; | 442 | void moveIncidence(Incidence *) ; |
443 | void beamIncidence(Incidence *) ; | 443 | void beamIncidence(Incidence *) ; |
444 | void beamCalendar() ; | 444 | void beamCalendar() ; |
445 | void beamFilteredCalendar() ; | 445 | void beamFilteredCalendar() ; |
446 | void beamIncidenceList(QPtrList<Incidence>) ; | 446 | void beamIncidenceList(QPtrList<Incidence>) ; |
447 | void manageCategories(); | 447 | void manageCategories(); |
448 | int addCategories(); | 448 | int addCategories(); |
449 | void removeCategories(); | 449 | void removeCategories(); |
450 | void setSyncDevice( QString ); | 450 | void setSyncDevice( QString ); |
451 | void setSyncName( QString ); | 451 | void setSyncName( QString ); |
452 | protected slots: | 452 | protected slots: |
453 | void timerAlarm(); | 453 | void timerAlarm(); |
454 | void suspendAlarm(); | 454 | void suspendAlarm(); |
455 | void beamDone( Ir *ir ); | 455 | void beamDone( Ir *ir ); |
456 | /** Select a view or adapt the current view to display the specified dates. */ | 456 | /** Select a view or adapt the current view to display the specified dates. */ |
457 | void showDates( const KCal::DateList & ); | 457 | void showDates( const KCal::DateList & ); |
458 | void selectWeekNum ( int ); | 458 | void selectWeekNum ( int ); |
459 | 459 | ||
460 | public: | 460 | public: |
461 | // show a standard warning | 461 | // show a standard warning |
462 | // returns KMsgBox::yesNoCancel() | 462 | // returns KMsgBox::yesNoCancel() |
463 | int msgCalModified(); | 463 | int msgCalModified(); |
464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
465 | 465 | ||
466 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
467 | void setSyncManager(KSyncManager* manager); | 467 | void setSyncManager(KSyncManager* manager); |
468 | void setLoadedFileVersion(QDateTime); | 468 | void setLoadedFileVersion(QDateTime); |
469 | bool checkFileVersion(QString fn); | 469 | bool checkFileVersion(QString fn); |
470 | bool checkFileChanged(QString fn); | 470 | bool checkFileChanged(QString fn); |
471 | Event* getLastSyncEvent(); | 471 | Event* getLastSyncEvent(); |
472 | /** Adapt navigation units correpsonding to step size of navigation of the | 472 | /** Adapt navigation units correpsonding to step size of navigation of the |
473 | * current view. | 473 | * current view. |
474 | */ | 474 | */ |
475 | void adaptNavigationUnits(); | 475 | void adaptNavigationUnits(); |
476 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 476 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
477 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 477 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
478 | //Attendee* getYourAttendee(Event *event); | 478 | //Attendee* getYourAttendee(Event *event); |
479 | protected: | 479 | protected: |
480 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 480 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
481 | 481 | ||
482 | // returns KMsgBox::OKCandel() | 482 | // returns KMsgBox::OKCandel() |
483 | int msgItemDelete(); | 483 | int msgItemDelete(); |
484 | void showEventEditor(); | 484 | void showEventEditor(); |
485 | void showTodoEditor(); | 485 | void showTodoEditor(); |
486 | void writeLocale(); | 486 | void writeLocale(); |
487 | Todo *selectedTodo(); | 487 | Todo *selectedTodo(); |
488 | 488 | ||
489 | private: | 489 | private: |
490 | bool mSyncKDE; | ||
490 | KSyncManager* mSyncManager; | 491 | KSyncManager* mSyncManager; |
491 | AlarmDialog * mAlarmDialog; | 492 | AlarmDialog * mAlarmDialog; |
492 | QString mAlarmNotification; | 493 | QString mAlarmNotification; |
493 | QString mSuspendAlarmNotification; | 494 | QString mSuspendAlarmNotification; |
494 | QTimer* mSuspendTimer; | 495 | QTimer* mSuspendTimer; |
495 | QTimer* mAlarmTimer; | 496 | QTimer* mAlarmTimer; |
496 | QTimer* mRecheckAlarmTimer; | 497 | QTimer* mRecheckAlarmTimer; |
497 | void computeAlarm( QString ); | 498 | void computeAlarm( QString ); |
498 | void startAlarm( QString, QString ); | 499 | void startAlarm( QString, QString ); |
499 | void setSyncEventsReadOnly(); | 500 | void setSyncEventsReadOnly(); |
500 | 501 | ||
501 | QDateTime loadedFileVersion; | 502 | QDateTime loadedFileVersion; |
502 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 503 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
503 | void checkExternalId( Incidence * inc ); | 504 | void checkExternalId( Incidence * inc ); |
504 | int mGlobalSyncMode; | 505 | int mGlobalSyncMode; |
505 | QString mCurrentSyncDevice; | 506 | QString mCurrentSyncDevice; |
506 | QString mCurrentSyncName; | 507 | QString mCurrentSyncName; |
507 | KOBeamPrefs* beamDialog; | 508 | KOBeamPrefs* beamDialog; |
508 | void init(); | 509 | void init(); |
509 | int mDatePickerMode; | 510 | int mDatePickerMode; |
510 | bool mFlagEditDescription; | 511 | bool mFlagEditDescription; |
511 | QDateTime mLastCalendarSync; | 512 | QDateTime mLastCalendarSync; |
512 | void createPrinter(); | 513 | void createPrinter(); |
513 | 514 | ||
514 | void calendarModified( bool, Calendar * ); | 515 | void calendarModified( bool, Calendar * ); |
515 | 516 | ||
516 | CalPrinter *mCalPrinter; | 517 | CalPrinter *mCalPrinter; |
517 | 518 | ||
518 | QSplitter *mPanner; | 519 | QSplitter *mPanner; |
519 | QSplitter *mLeftSplitter; | 520 | QSplitter *mLeftSplitter; |
520 | QWidget *mLeftFrame; | 521 | QWidget *mLeftFrame; |
521 | QWidgetStack *mRightFrame; | 522 | QWidgetStack *mRightFrame; |
522 | 523 | ||
523 | KDatePicker* mDatePicker; | 524 | KDatePicker* mDatePicker; |
524 | QVBox* mDateFrame; | 525 | QVBox* mDateFrame; |
525 | NavigatorBar *mNavigatorBar; | 526 | NavigatorBar *mNavigatorBar; |
526 | 527 | ||
527 | KDateNavigator *mDateNavigator; // widget showing small month view. | 528 | KDateNavigator *mDateNavigator; // widget showing small month view. |
528 | 529 | ||
529 | KOFilterView *mFilterView; | 530 | KOFilterView *mFilterView; |
530 | 531 | ||
531 | ResourceView *mResourceView; | 532 | ResourceView *mResourceView; |
532 | 533 | ||
533 | // calendar object for this viewing instance | 534 | // calendar object for this viewing instance |
534 | Calendar *mCalendar; | 535 | Calendar *mCalendar; |
535 | 536 | ||
536 | CalendarResourceManager *mResourceManager; | 537 | CalendarResourceManager *mResourceManager; |
537 | 538 | ||
538 | FileStorage *mStorage; | 539 | FileStorage *mStorage; |
539 | 540 | ||
540 | DateNavigator *mNavigator; | 541 | DateNavigator *mNavigator; |
541 | 542 | ||
542 | KOViewManager *mViewManager; | 543 | KOViewManager *mViewManager; |
543 | KODialogManager *mDialogManager; | 544 | KODialogManager *mDialogManager; |
544 | 545 | ||
545 | // Calendar filters | 546 | // Calendar filters |
546 | QPtrList<CalFilter> mFilters; | 547 | QPtrList<CalFilter> mFilters; |
547 | 548 | ||
548 | // various housekeeping variables. | 549 | // various housekeeping variables. |
549 | bool mModified; // flag indicating if calendar is modified | 550 | bool mModified; // flag indicating if calendar is modified |
550 | bool mReadOnly; // flag indicating if calendar is read-only | 551 | bool mReadOnly; // flag indicating if calendar is read-only |
551 | QDate mSaveSingleDate; | 552 | QDate mSaveSingleDate; |
552 | 553 | ||
553 | Incidence *mSelectedIncidence; | 554 | Incidence *mSelectedIncidence; |
554 | Incidence *mMoveIncidence; | 555 | Incidence *mMoveIncidence; |
555 | KOTodoView *mTodoList; | 556 | KOTodoView *mTodoList; |
556 | KOEventEditor * mEventEditor; | 557 | KOEventEditor * mEventEditor; |
557 | KOTodoEditor * mTodoEditor; | 558 | KOTodoEditor * mTodoEditor; |
558 | KOEventViewerDialog * mEventViewerDialog; | 559 | KOEventViewerDialog * mEventViewerDialog; |
559 | void keyPressEvent ( QKeyEvent *e) ; | 560 | void keyPressEvent ( QKeyEvent *e) ; |
560 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 561 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
561 | }; | 562 | }; |
562 | 563 | ||
563 | 564 | ||
564 | class CalendarViewVisitor : public Incidence::Visitor | 565 | class CalendarViewVisitor : public Incidence::Visitor |
565 | { | 566 | { |
566 | public: | 567 | public: |
567 | CalendarViewVisitor() : mView( 0 ) {} | 568 | CalendarViewVisitor() : mView( 0 ) {} |
568 | 569 | ||
569 | bool act( Incidence *incidence, CalendarView *view ) | 570 | bool act( Incidence *incidence, CalendarView *view ) |
570 | { | 571 | { |
571 | mView = view; | 572 | mView = view; |
572 | return incidence->accept( *this ); | 573 | return incidence->accept( *this ); |
573 | } | 574 | } |
574 | 575 | ||
575 | protected: | 576 | protected: |
576 | CalendarView *mView; | 577 | CalendarView *mView; |
577 | }; | 578 | }; |
578 | 579 | ||
579 | class ShowIncidenceVisitor : public CalendarViewVisitor | 580 | class ShowIncidenceVisitor : public CalendarViewVisitor |
580 | { | 581 | { |
581 | protected: | 582 | protected: |
582 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 583 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
583 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 584 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
584 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 585 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
585 | }; | 586 | }; |
586 | 587 | ||
587 | class EditIncidenceVisitor : public CalendarViewVisitor | 588 | class EditIncidenceVisitor : public CalendarViewVisitor |
588 | { | 589 | { |
589 | protected: | 590 | protected: |
590 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 591 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
591 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 592 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
592 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 593 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
593 | }; | 594 | }; |
594 | 595 | ||
595 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 596 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
596 | { | 597 | { |
597 | protected: | 598 | protected: |
598 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 599 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
599 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 600 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
600 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 601 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
601 | }; | 602 | }; |
602 | 603 | ||
603 | #endif | 604 | #endif |