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