author | zautrix <zautrix> | 2005-07-29 09:42:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-29 09:42:43 (UTC) |
commit | 8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d (patch) (unidiff) | |
tree | 89646a8417d381dbebe158530fd0212d092b9365 | |
parent | ea12a774c5a36a4bd96ac53c36e92560989e3cbc (diff) | |
download | kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.zip kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.tar.gz kdepimpi-8feb7e617f1aa5cd5bb04d9a69d05409c3c4c60d.tar.bz2 |
chechalarm fix
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a9d42f0..28649d9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -328,1025 +328,1029 @@ class KOCatPrefs : public QDialog | |||
328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 328 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
329 | lay->addWidget( cancel ); | 329 | lay->addWidget( cancel ); |
330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 330 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 331 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
332 | resize( 200, 200 ); | 332 | resize( 200, 200 ); |
333 | } | 333 | } |
334 | 334 | ||
335 | bool addCat() { return addCatBut->isChecked(); } | 335 | bool addCat() { return addCatBut->isChecked(); } |
336 | private: | 336 | private: |
337 | QRadioButton* addCatBut; | 337 | QRadioButton* addCatBut; |
338 | }; | 338 | }; |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | CalendarView::CalendarView( CalendarResources *calendar, | 342 | CalendarView::CalendarView( CalendarResources *calendar, |
343 | QWidget *parent, const char *name ) | 343 | QWidget *parent, const char *name ) |
344 | : CalendarViewBase( parent, name ), | 344 | : CalendarViewBase( parent, name ), |
345 | mCalendar( calendar ), | 345 | mCalendar( calendar ), |
346 | mResourceManager( calendar->resourceManager() ) | 346 | mResourceManager( calendar->resourceManager() ) |
347 | { | 347 | { |
348 | 348 | ||
349 | mEventEditor = 0; | 349 | mEventEditor = 0; |
350 | mTodoEditor = 0; | 350 | mTodoEditor = 0; |
351 | 351 | ||
352 | init(); | 352 | init(); |
353 | } | 353 | } |
354 | 354 | ||
355 | CalendarView::CalendarView( Calendar *calendar, | 355 | CalendarView::CalendarView( Calendar *calendar, |
356 | QWidget *parent, const char *name ) | 356 | QWidget *parent, const char *name ) |
357 | : CalendarViewBase( parent, name ), | 357 | : CalendarViewBase( parent, name ), |
358 | mCalendar( calendar ), | 358 | mCalendar( calendar ), |
359 | mResourceManager( 0 ) | 359 | mResourceManager( 0 ) |
360 | { | 360 | { |
361 | 361 | ||
362 | mEventEditor = 0; | 362 | mEventEditor = 0; |
363 | mTodoEditor = 0; | 363 | mTodoEditor = 0; |
364 | init(); | 364 | init(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 369 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
370 | setFocusPolicy (NoFocus ); | 370 | setFocusPolicy (NoFocus ); |
371 | mViewerCallerIsSearchDialog = false; | 371 | mViewerCallerIsSearchDialog = false; |
372 | mBlockShowDates = false; | 372 | mBlockShowDates = false; |
373 | mConflictingEvent = 0; | 373 | mConflictingEvent = 0; |
374 | mDatePickerMode = 0; | 374 | mDatePickerMode = 0; |
375 | mCurrentSyncDevice = ""; | 375 | mCurrentSyncDevice = ""; |
376 | mViewManager = new KOViewManager( this ); | 376 | mViewManager = new KOViewManager( this ); |
377 | mDialogManager = new KODialogManager( this ); | 377 | mDialogManager = new KODialogManager( this ); |
378 | mEventViewerDialog = 0; | 378 | mEventViewerDialog = 0; |
379 | mModified = false; | 379 | mModified = false; |
380 | mReadOnly = false; | 380 | mReadOnly = false; |
381 | mSelectedIncidence = 0; | 381 | mSelectedIncidence = 0; |
382 | mCalPrinter = 0; | 382 | mCalPrinter = 0; |
383 | mFilters.setAutoDelete(true); | 383 | mFilters.setAutoDelete(true); |
384 | 384 | ||
385 | mCalendar->registerObserver( this ); | 385 | mCalendar->registerObserver( this ); |
386 | // TODO: Make sure that view is updated, when calendar is changed. | 386 | // TODO: Make sure that view is updated, when calendar is changed. |
387 | 387 | ||
388 | mStorage = new FileStorage( mCalendar ); | 388 | mStorage = new FileStorage( mCalendar ); |
389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 389 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
390 | 390 | ||
391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 391 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
392 | #ifndef KORG_NOSPLITTER | 392 | #ifndef KORG_NOSPLITTER |
393 | // create the main layout frames. | 393 | // create the main layout frames. |
394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 394 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
395 | topLayout->addWidget(mPanner); | 395 | topLayout->addWidget(mPanner); |
396 | 396 | ||
397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 397 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
398 | "CalendarView::LeftFrame"); | 398 | "CalendarView::LeftFrame"); |
399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 399 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
400 | 400 | ||
401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 401 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
402 | "CalendarView::DateNavigator" ); | 402 | "CalendarView::DateNavigator" ); |
403 | 403 | ||
404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 404 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 405 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
406 | mTodoList->setNavigator( mNavigator ); | 406 | mTodoList->setNavigator( mNavigator ); |
407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 407 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
408 | 408 | ||
409 | #ifdef KORG_NORESOURCEVIEW | 409 | #ifdef KORG_NORESOURCEVIEW |
410 | mResourceView = 0; | 410 | mResourceView = 0; |
411 | #else | 411 | #else |
412 | if ( mResourceManager ) { | 412 | if ( mResourceManager ) { |
413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 413 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
414 | mResourceView->updateView(); | 414 | mResourceView->updateView(); |
415 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 415 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
416 | SLOT( updateView() ) ); | 416 | SLOT( updateView() ) ); |
417 | } else { | 417 | } else { |
418 | mResourceView = 0; | 418 | mResourceView = 0; |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | QWidget *rightBox = new QWidget( mPanner ); | 421 | QWidget *rightBox = new QWidget( mPanner ); |
422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 422 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
423 | 423 | ||
424 | mRightFrame = new QWidgetStack( rightBox ); | 424 | mRightFrame = new QWidgetStack( rightBox ); |
425 | rightLayout->addWidget( mRightFrame, 1 ); | 425 | rightLayout->addWidget( mRightFrame, 1 ); |
426 | 426 | ||
427 | mLeftFrame = mLeftSplitter; | 427 | mLeftFrame = mLeftSplitter; |
428 | #else | 428 | #else |
429 | //QWidget *mainBox = new QWidget( this ); | 429 | //QWidget *mainBox = new QWidget( this ); |
430 | //QWidget *leftFrame = new QWidget( mainBox ); | 430 | //QWidget *leftFrame = new QWidget( mainBox ); |
431 | //QBoxLayout * mainBoxLayout; | 431 | //QBoxLayout * mainBoxLayout; |
432 | if ( KOPrefs::instance()->mVerticalScreen ) { | 432 | if ( KOPrefs::instance()->mVerticalScreen ) { |
433 | //mainBoxLayout = new QVBoxLayout(mainBox); | 433 | //mainBoxLayout = new QVBoxLayout(mainBox); |
434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 434 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 435 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 436 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 437 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 438 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
439 | } else { | 439 | } else { |
440 | //mainBoxLayout = new QHBoxLayout(mainBox); | 440 | //mainBoxLayout = new QHBoxLayout(mainBox); |
441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 441 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 442 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 443 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 444 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 445 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
446 | } | 446 | } |
447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 447 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
448 | //QBoxLayout * leftFrameLayout; | 448 | //QBoxLayout * leftFrameLayout; |
449 | topLayout->addWidget( mMainFrame ); | 449 | topLayout->addWidget( mMainFrame ); |
450 | #ifdef DESKTOP_VERSION | 450 | #ifdef DESKTOP_VERSION |
451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); | 451 | mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); |
452 | topLayout->addWidget( mDateScrollBar ); | 452 | topLayout->addWidget( mDateScrollBar ); |
453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); | 453 | connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); |
454 | if ( QApplication::desktop()->width() < 800 ) | 454 | if ( QApplication::desktop()->width() < 800 ) |
455 | mDateScrollBar->hide(); | 455 | mDateScrollBar->hide(); |
456 | #endif | 456 | #endif |
457 | //mainBoxLayout->addWidget (mLeftFrame); | 457 | //mainBoxLayout->addWidget (mLeftFrame); |
458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 458 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
459 | "CalendarView::DateNavigator" ); | 459 | "CalendarView::DateNavigator" ); |
460 | #if 0 | 460 | #if 0 |
461 | // FIXME | 461 | // FIXME |
462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 462 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
463 | "CalendarView::DateNavigator", QDate::currentDate()); | 463 | "CalendarView::DateNavigator", QDate::currentDate()); |
464 | #endif | 464 | #endif |
465 | // mDateNavigator->blockSignals( true ); | 465 | // mDateNavigator->blockSignals( true ); |
466 | //leftFrameLayout->addWidget( mDateNavigator ); | 466 | //leftFrameLayout->addWidget( mDateNavigator ); |
467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 467 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 468 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 469 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); | 470 | connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); |
471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); | 471 | connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); |
472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); | 472 | connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); |
473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); | 473 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); |
474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); | 474 | connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); |
475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); | 475 | connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); |
476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); | 476 | connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); |
477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); | 477 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); |
478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); | 478 | connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); |
479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); | 479 | connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); |
480 | 480 | ||
481 | mTodoList->setNavigator( mNavigator ); | 481 | mTodoList->setNavigator( mNavigator ); |
482 | #if 0 | 482 | #if 0 |
483 | if ( QApplication::desktop()->width() < 480 ) { | 483 | if ( QApplication::desktop()->width() < 480 ) { |
484 | leftFrameLayout->addWidget(mFilterView); | 484 | leftFrameLayout->addWidget(mFilterView); |
485 | leftFrameLayout->addWidget(mTodoList, 2 ); | 485 | leftFrameLayout->addWidget(mTodoList, 2 ); |
486 | 486 | ||
487 | } else { | 487 | } else { |
488 | leftFrameLayout->addWidget(mTodoList,2 ); | 488 | leftFrameLayout->addWidget(mTodoList,2 ); |
489 | leftFrameLayout->addWidget(mFilterView ); | 489 | leftFrameLayout->addWidget(mFilterView ); |
490 | } | 490 | } |
491 | #endif | 491 | #endif |
492 | mFilterView->hide(); | 492 | mFilterView->hide(); |
493 | mCalEditView->hide(); | 493 | mCalEditView->hide(); |
494 | QWidget *rightBox = new QWidget( mMainFrame ); | 494 | QWidget *rightBox = new QWidget( mMainFrame ); |
495 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 495 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 496 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
497 | mRightFrame = new QWidgetStack( rightBox ); | 497 | mRightFrame = new QWidgetStack( rightBox ); |
498 | rightLayout->addWidget( mRightFrame, 10 ); | 498 | rightLayout->addWidget( mRightFrame, 10 ); |
499 | 499 | ||
500 | //mLeftFrame = (QWidget *)leftFrame; | 500 | //mLeftFrame = (QWidget *)leftFrame; |
501 | if ( KOPrefs::instance()->mVerticalScreen ) { | 501 | if ( KOPrefs::instance()->mVerticalScreen ) { |
502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 502 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 503 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 504 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 505 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
506 | } else { | 506 | } else { |
507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 507 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 508 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 509 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
510 | } | 510 | } |
511 | if ( !KOPrefs::instance()->mShowDateNavigator) | 511 | if ( !KOPrefs::instance()->mShowDateNavigator) |
512 | mDateNavigator->hide(); | 512 | mDateNavigator->hide(); |
513 | //qDebug("Calendarview Size %d %d ", width(), height()); | 513 | //qDebug("Calendarview Size %d %d ", width(), height()); |
514 | #endif | 514 | #endif |
515 | 515 | ||
516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 516 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
517 | SLOT( showDates( const KCal::DateList & ) ) ); | 517 | SLOT( showDates( const KCal::DateList & ) ) ); |
518 | 518 | ||
519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 519 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 520 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
521 | 521 | ||
522 | 522 | ||
523 | 523 | ||
524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 524 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 525 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 527 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 528 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
529 | 529 | ||
530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 530 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
531 | mNavigator, SLOT( selectPreviousYear() ) ); | 531 | mNavigator, SLOT( selectPreviousYear() ) ); |
532 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 532 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
533 | mNavigator, SLOT( selectNextYear() ) ); | 533 | mNavigator, SLOT( selectNextYear() ) ); |
534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 534 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
535 | mNavigator, SLOT( selectPreviousMonth() ) ); | 535 | mNavigator, SLOT( selectPreviousMonth() ) ); |
536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 536 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
537 | mNavigator, SLOT( selectNextMonth() ) ); | 537 | mNavigator, SLOT( selectNextMonth() ) ); |
538 | 538 | ||
539 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 539 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
540 | mNavigator, SLOT( selectPrevious() ) ); | 540 | mNavigator, SLOT( selectPrevious() ) ); |
541 | connect( mDateNavigator, SIGNAL( goNext() ), | 541 | connect( mDateNavigator, SIGNAL( goNext() ), |
542 | mNavigator, SLOT( selectNext() ) ); | 542 | mNavigator, SLOT( selectNext() ) ); |
543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 543 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 544 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
545 | 545 | ||
546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 546 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 547 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
548 | #if 0 | 548 | #if 0 |
549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 549 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
550 | SLOT( incidenceAdded( Incidence *) ) ); | 550 | SLOT( incidenceAdded( Incidence *) ) ); |
551 | #endif | 551 | #endif |
552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 552 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
553 | 553 | ||
554 | connect( this, SIGNAL( configChanged() ), | 554 | connect( this, SIGNAL( configChanged() ), |
555 | mDateNavigator, SLOT( updateConfig() ) ); | 555 | mDateNavigator, SLOT( updateConfig() ) ); |
556 | 556 | ||
557 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 557 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
558 | SLOT( newTodo() ) ); | 558 | SLOT( newTodo() ) ); |
559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 559 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
560 | SLOT( newSubTodo( Todo * ) ) ); | 560 | SLOT( newSubTodo( Todo * ) ) ); |
561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 561 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
562 | SLOT( editTodo( Todo * ) ) ); | 562 | SLOT( editTodo( Todo * ) ) ); |
563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 563 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
564 | SLOT( showTodo( Todo *) ) ); | 564 | SLOT( showTodo( Todo *) ) ); |
565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 565 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
566 | SLOT( deleteTodo( Todo *) ) ); | 566 | SLOT( deleteTodo( Todo *) ) ); |
567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 567 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 568 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
569 | SLOT( purgeCompleted() ) ); | 569 | SLOT( purgeCompleted() ) ); |
570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 570 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
571 | SIGNAL( todoModified( Todo *, int ) ) ); | 571 | SIGNAL( todoModified( Todo *, int ) ) ); |
572 | 572 | ||
573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 573 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 574 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 575 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
576 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 576 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
577 | 577 | ||
578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 578 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
579 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 579 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 580 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
581 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 581 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
582 | 582 | ||
583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 583 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
584 | this, SLOT ( todo_unsub( Todo * ) ) ); | 584 | this, SLOT ( todo_unsub( Todo * ) ) ); |
585 | 585 | ||
586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 586 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 587 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 588 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
589 | SLOT( updateTodo( Todo *, int ) ) ); | 589 | SLOT( updateTodo( Todo *, int ) ) ); |
590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 590 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 591 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
592 | 592 | ||
593 | 593 | ||
594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 594 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 595 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 597 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | 602 | ||
603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 603 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
604 | SLOT(checkClipboard())); | 604 | SLOT(checkClipboard())); |
605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 605 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
606 | SLOT( processTodoListSelection( Incidence * ) ) ); | 606 | SLOT( processTodoListSelection( Incidence * ) ) ); |
607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 607 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
608 | 608 | ||
609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 609 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
610 | 610 | ||
611 | mDateFrame = new QVBox(0,0,WType_Popup); | 611 | mDateFrame = new QVBox(0,0,WType_Popup); |
612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 612 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 613 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
614 | mDateFrame->setLineWidth(3); | 614 | mDateFrame->setLineWidth(3); |
615 | mDateFrame->hide(); | 615 | mDateFrame->hide(); |
616 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 616 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 617 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
618 | 618 | ||
619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 619 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
620 | 620 | ||
621 | mEventEditor = mDialogManager->getEventEditor(); | 621 | mEventEditor = mDialogManager->getEventEditor(); |
622 | mTodoEditor = mDialogManager->getTodoEditor(); | 622 | mTodoEditor = mDialogManager->getTodoEditor(); |
623 | 623 | ||
624 | mFlagEditDescription = false; | 624 | mFlagEditDescription = false; |
625 | 625 | ||
626 | mSuspendTimer = new QTimer( this ); | 626 | mSuspendTimer = new QTimer( this ); |
627 | mAlarmTimer = new QTimer( this ); | 627 | mAlarmTimer = new QTimer( this ); |
628 | mRecheckAlarmTimer = new QTimer( this ); | 628 | mRecheckAlarmTimer = new QTimer( this ); |
629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 629 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 630 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 631 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
632 | mAlarmDialog = new AlarmDialog( this ); | 632 | mAlarmDialog = new AlarmDialog( this ); |
633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 633 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
634 | mAlarmDialog->setServerNotification( false ); | 634 | mAlarmDialog->setServerNotification( false ); |
635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 635 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
636 | 636 | ||
637 | 637 | ||
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | //US listen for arriving address resultsets | 639 | //US listen for arriving address resultsets |
640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 640 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 641 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
642 | #endif | 642 | #endif |
643 | mDateNavigator->setCalendar( mCalendar ); | 643 | mDateNavigator->setCalendar( mCalendar ); |
644 | } | 644 | } |
645 | 645 | ||
646 | 646 | ||
647 | CalendarView::~CalendarView() | 647 | CalendarView::~CalendarView() |
648 | { | 648 | { |
649 | // kdDebug() << "~CalendarView()" << endl; | 649 | // kdDebug() << "~CalendarView()" << endl; |
650 | //qDebug("CalendarView::~CalendarView() "); | 650 | //qDebug("CalendarView::~CalendarView() "); |
651 | delete mDialogManager; | 651 | delete mDialogManager; |
652 | delete mViewManager; | 652 | delete mViewManager; |
653 | delete mStorage; | 653 | delete mStorage; |
654 | delete mDateFrame ; | 654 | delete mDateFrame ; |
655 | delete mEventViewerDialog; | 655 | delete mEventViewerDialog; |
656 | //kdDebug() << "~CalendarView() done" << endl; | 656 | //kdDebug() << "~CalendarView() done" << endl; |
657 | } | 657 | } |
658 | 658 | ||
659 | 659 | ||
660 | void CalendarView::nextConflict( bool all, bool allday ) | 660 | void CalendarView::nextConflict( bool all, bool allday ) |
661 | { | 661 | { |
662 | static bool block = false; | 662 | static bool block = false; |
663 | if ( block ) return; | 663 | if ( block ) return; |
664 | block = true; | 664 | block = true; |
665 | QPtrList<Event> testlist = mCalendar->events(); | 665 | QPtrList<Event> testlist = mCalendar->events(); |
666 | Event * test = testlist.first(); | 666 | Event * test = testlist.first(); |
667 | while ( test ) { | 667 | while ( test ) { |
668 | test->setTagged( false ); | 668 | test->setTagged( false ); |
669 | test = testlist.next(); | 669 | test = testlist.next(); |
670 | } | 670 | } |
671 | QTime st ( 0,0,0); | 671 | QTime st ( 0,0,0); |
672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) | 672 | if ( mViewManager->currentView() == mViewManager->agendaView() ) |
673 | st = mViewManager->agendaView()->agenda()->getEndTime(); | 673 | st = mViewManager->agendaView()->agenda()->getEndTime(); |
674 | //qDebug("time %s ", st.toString().latin1()); | 674 | //qDebug("time %s ", st.toString().latin1()); |
675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); | 675 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); |
676 | QDateTime conflict; | 676 | QDateTime conflict; |
677 | QDateTime retVal; | 677 | QDateTime retVal; |
678 | bool found = false; | 678 | bool found = false; |
679 | Event * cE = 0; | 679 | Event * cE = 0; |
680 | Event * cE2 = 0; | 680 | Event * cE2 = 0; |
681 | QPtrList<Event> testlist2 = testlist; | 681 | QPtrList<Event> testlist2 = testlist; |
682 | test = testlist.first(); | 682 | test = testlist.first(); |
683 | bool skip = false; | 683 | bool skip = false; |
684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 684 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
685 | //QTime tm; | 685 | //QTime tm; |
686 | //tm.start(); | 686 | //tm.start(); |
687 | while ( test ) { | 687 | while ( test ) { |
688 | qApp->processEvents(); | 688 | qApp->processEvents(); |
689 | skip = false; | 689 | skip = false; |
690 | if ( !all ) skip = ( allday != test->doesFloat() ); | 690 | if ( !all ) skip = ( allday != test->doesFloat() ); |
691 | if ( !skip ) { | 691 | if ( !skip ) { |
692 | if ( found ) | 692 | if ( found ) |
693 | skip = !test->matchTime( &startDT, &conflict ); | 693 | skip = !test->matchTime( &startDT, &conflict ); |
694 | else | 694 | else |
695 | skip = !test->matchTime( &startDT, 0 ); | 695 | skip = !test->matchTime( &startDT, 0 ); |
696 | } | 696 | } |
697 | if ( !skip ) { | 697 | if ( !skip ) { |
698 | Event * test2 = testlist2.first(); | 698 | Event * test2 = testlist2.first(); |
699 | while ( test2 ) { | 699 | while ( test2 ) { |
700 | skip = test2->isTagged(); | 700 | skip = test2->isTagged(); |
701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); | 701 | if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); |
702 | if ( !skip ) { | 702 | if ( !skip ) { |
703 | if ( found ) | 703 | if ( found ) |
704 | skip = !test2->matchTime( &startDT, &conflict ); | 704 | skip = !test2->matchTime( &startDT, &conflict ); |
705 | else | 705 | else |
706 | skip = !test2->matchTime( &startDT, 0 ); | 706 | skip = !test2->matchTime( &startDT, 0 ); |
707 | } | 707 | } |
708 | if ( !skip ) { | 708 | if ( !skip ) { |
709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { | 709 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
710 | //qDebug("overlap "); | 710 | //qDebug("overlap "); |
711 | if ( ! found ) { | 711 | if ( ! found ) { |
712 | if ( retVal >= startDT ) { | 712 | if ( retVal >= startDT ) { |
713 | conflict = retVal; | 713 | conflict = retVal; |
714 | cE = test; | 714 | cE = test; |
715 | cE2 = test2; | 715 | cE2 = test2; |
716 | found = true; | 716 | found = true; |
717 | } | 717 | } |
718 | } else { | 718 | } else { |
719 | if ( retVal >= startDT && retVal < conflict ) { | 719 | if ( retVal >= startDT && retVal < conflict ) { |
720 | conflict = retVal; | 720 | conflict = retVal; |
721 | cE = test; | 721 | cE = test; |
722 | cE2 = test2; | 722 | cE2 = test2; |
723 | } | 723 | } |
724 | } | 724 | } |
725 | } | 725 | } |
726 | } | 726 | } |
727 | test2 = testlist2.next(); | 727 | test2 = testlist2.next(); |
728 | } | 728 | } |
729 | } | 729 | } |
730 | test->setTagged( true ); | 730 | test->setTagged( true ); |
731 | test = testlist.next(); | 731 | test = testlist.next(); |
732 | } | 732 | } |
733 | //qDebug("Search time : %d", tm.elapsed()); | 733 | //qDebug("Search time : %d", tm.elapsed()); |
734 | if ( found ) { | 734 | if ( found ) { |
735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 735 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
736 | mViewManager->showDayView(); | 736 | mViewManager->showDayView(); |
737 | mNavigator->slotDaySelect( conflict.date() ); | 737 | mNavigator->slotDaySelect( conflict.date() ); |
738 | int hour = conflict.time().hour(); | 738 | int hour = conflict.time().hour(); |
739 | mViewManager->agendaView()->setStartHour( hour ); | 739 | mViewManager->agendaView()->setStartHour( hour ); |
740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); | 740 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
741 | block = false; | 741 | block = false; |
742 | return; | 742 | return; |
743 | } | 743 | } |
744 | 744 | ||
745 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 745 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
746 | //qDebug("No conflict found "); | 746 | //qDebug("No conflict found "); |
747 | block = false; | 747 | block = false; |
748 | return; | 748 | return; |
749 | } | 749 | } |
750 | 750 | ||
751 | void CalendarView::conflictAll() | 751 | void CalendarView::conflictAll() |
752 | { | 752 | { |
753 | nextConflict ( true, true ); | 753 | nextConflict ( true, true ); |
754 | } | 754 | } |
755 | void CalendarView::conflictAllday() | 755 | void CalendarView::conflictAllday() |
756 | { | 756 | { |
757 | nextConflict ( false, true ); | 757 | nextConflict ( false, true ); |
758 | } | 758 | } |
759 | void CalendarView::conflictNotAll() | 759 | void CalendarView::conflictNotAll() |
760 | { | 760 | { |
761 | nextConflict ( false, false ); | 761 | nextConflict ( false, false ); |
762 | } | 762 | } |
763 | 763 | ||
764 | void CalendarView::setCalReadOnly( int id, bool readO ) | 764 | void CalendarView::setCalReadOnly( int id, bool readO ) |
765 | { | 765 | { |
766 | if ( readO ) { | 766 | if ( readO ) { |
767 | emit save(); | 767 | emit save(); |
768 | } | 768 | } |
769 | mCalendar->setReadOnly( id, readO ); | 769 | mCalendar->setReadOnly( id, readO ); |
770 | } | 770 | } |
771 | void CalendarView::setScrollBarStep(int val ) | 771 | void CalendarView::setScrollBarStep(int val ) |
772 | { | 772 | { |
773 | #ifdef DESKTOP_VERSION | 773 | #ifdef DESKTOP_VERSION |
774 | mDateScrollBar->setLineStep ( val ); | 774 | mDateScrollBar->setLineStep ( val ); |
775 | #endif | 775 | #endif |
776 | } | 776 | } |
777 | void CalendarView::scrollBarValue(int val ) | 777 | void CalendarView::scrollBarValue(int val ) |
778 | { | 778 | { |
779 | #ifdef DESKTOP_VERSION | 779 | #ifdef DESKTOP_VERSION |
780 | if ( QApplication::desktop()->width() < 800 ) return; | 780 | if ( QApplication::desktop()->width() < 800 ) return; |
781 | static bool block = false; | 781 | static bool block = false; |
782 | if ( block ) return; | 782 | if ( block ) return; |
783 | block = true; | 783 | block = true; |
784 | int count = mNavigator->selectedDates().count(); | 784 | int count = mNavigator->selectedDates().count(); |
785 | int day = mNavigator->selectedDates().first().dayOfYear(); | 785 | int day = mNavigator->selectedDates().first().dayOfYear(); |
786 | int stepdays = val; | 786 | int stepdays = val; |
787 | if ( mDateScrollBar->lineStep () <= count ) { | 787 | if ( mDateScrollBar->lineStep () <= count ) { |
788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 788 | //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
789 | //qDebug("VAL %d ",val ); | 789 | //qDebug("VAL %d ",val ); |
790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); | 790 | stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); |
791 | stepdays = day+stepdays; | 791 | stepdays = day+stepdays; |
792 | if ( stepdays < 0 ) stepdays = 0; | 792 | if ( stepdays < 0 ) stepdays = 0; |
793 | } | 793 | } |
794 | if ( stepdays == day ) { | 794 | if ( stepdays == day ) { |
795 | block = false; | 795 | block = false; |
796 | return; | 796 | return; |
797 | } | 797 | } |
798 | int year = mNavigator->selectedDates().first().year(); | 798 | int year = mNavigator->selectedDates().first().year(); |
799 | QDate d ( year,1,1 ); | 799 | QDate d ( year,1,1 ); |
800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); | 800 | mNavigator->selectDates( d.addDays( stepdays-1) , count ); |
801 | block = false; | 801 | block = false; |
802 | #endif | 802 | #endif |
803 | 803 | ||
804 | } | 804 | } |
805 | void CalendarView::updateView(const QDate &start, const QDate &end) | 805 | void CalendarView::updateView(const QDate &start, const QDate &end) |
806 | { | 806 | { |
807 | #ifdef DESKTOP_VERSION | 807 | #ifdef DESKTOP_VERSION |
808 | if ( ! mDateScrollBar->draggingSlider () ) { | 808 | if ( ! mDateScrollBar->draggingSlider () ) { |
809 | int dof = start.dayOfYear(); | 809 | int dof = start.dayOfYear(); |
810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); | 810 | //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); |
811 | if ( dof != mDateScrollBar->value() ) { | 811 | if ( dof != mDateScrollBar->value() ) { |
812 | mDateScrollBar->blockSignals( true ); | 812 | mDateScrollBar->blockSignals( true ); |
813 | mDateScrollBar->setValue( start.dayOfYear()); | 813 | mDateScrollBar->setValue( start.dayOfYear()); |
814 | mDateScrollBar->blockSignals( false ); | 814 | mDateScrollBar->blockSignals( false ); |
815 | } | 815 | } |
816 | } | 816 | } |
817 | #endif | 817 | #endif |
818 | mTodoList->updateView(); | 818 | mTodoList->updateView(); |
819 | mViewManager->updateView(start, end); | 819 | mViewManager->updateView(start, end); |
820 | //mDateNavigator->updateView(); | 820 | //mDateNavigator->updateView(); |
821 | } | 821 | } |
822 | 822 | ||
823 | 823 | ||
824 | 824 | ||
825 | void CalendarView::checkFiles() | 825 | void CalendarView::checkFiles() |
826 | { | 826 | { |
827 | QString message; | 827 | QString message; |
828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 828 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
829 | KopiCalendarFile * cal = calendars.first(); | 829 | KopiCalendarFile * cal = calendars.first(); |
830 | while ( cal ) { | 830 | while ( cal ) { |
831 | if ( cal->mErrorOnLoad ) { | 831 | if ( cal->mErrorOnLoad ) { |
832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; | 832 | message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; |
833 | } | 833 | } |
834 | cal = calendars.next(); | 834 | cal = calendars.next(); |
835 | } | 835 | } |
836 | if ( !message.isEmpty() ) { | 836 | if ( !message.isEmpty() ) { |
837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); | 837 | message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); |
838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); | 838 | KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); |
839 | } | 839 | } |
840 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | 840 | static bool firstTime = true; |
841 | if ( firstTime ) { | ||
842 | firstTime = false; | ||
843 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); | ||
844 | } | ||
841 | } | 845 | } |
842 | void CalendarView::checkAlarms() | 846 | void CalendarView::checkAlarms() |
843 | { | 847 | { |
844 | 848 | ||
845 | 849 | ||
846 | KConfig *config = KOGlobals::config(); | 850 | KConfig *config = KOGlobals::config(); |
847 | config->setGroup( "AppRun" ); | 851 | config->setGroup( "AppRun" ); |
848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 852 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
849 | int daysto = dt.daysTo( QDate::currentDate() ); | 853 | int daysto = dt.daysTo( QDate::currentDate() ); |
850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 854 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
851 | dt = dt.addDays( days ); | 855 | dt = dt.addDays( days ); |
852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 856 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 857 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
854 | //qDebug("KO: Reading program stop %d ", secs); | 858 | //qDebug("KO: Reading program stop %d ", secs); |
855 | //secs -= ( 3600 * 24*3 ); // debug only | 859 | //secs -= ( 3600 * 24*3 ); // debug only |
856 | QDateTime latest = dt.addSecs ( secs ); | 860 | QDateTime latest = dt.addSecs ( secs ); |
857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 861 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 862 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 863 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
860 | QPtrList<Incidence> al; | 864 | QPtrList<Incidence> al; |
861 | Incidence* inL = el.first(); | 865 | Incidence* inL = el.first(); |
862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 866 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 867 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
864 | while ( inL ) { | 868 | while ( inL ) { |
865 | bool ok = false; | 869 | bool ok = false; |
866 | int offset = 0; | 870 | int offset = 0; |
867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 871 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
868 | if ( ok ) { | 872 | if ( ok ) { |
869 | //qDebug("OK %s",next.toString().latin1()); | 873 | //qDebug("OK %s",next.toString().latin1()); |
870 | if ( next < cur ) { | 874 | if ( next < cur ) { |
871 | al.append( inL ); | 875 | al.append( inL ); |
872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 876 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
873 | } | 877 | } |
874 | } | 878 | } |
875 | inL = el.next(); | 879 | inL = el.next(); |
876 | } | 880 | } |
877 | if ( al.count() ) { | 881 | if ( al.count() ) { |
878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 882 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 883 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
880 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 884 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
881 | lay->setSpacing( 0 ); | 885 | lay->setSpacing( 0 ); |
882 | lay->setMargin( 0 ); | 886 | lay->setMargin( 0 ); |
883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 887 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 888 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
885 | lay->addWidget( matb ); | 889 | lay->addWidget( matb ); |
886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 890 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
887 | int wid = 210; | 891 | int wid = 210; |
888 | int x = QApplication::desktop()->width() - wid - 7; | 892 | int x = QApplication::desktop()->width() - wid - 7; |
889 | int y = QApplication::desktop()->height() - wid - 70; | 893 | int y = QApplication::desktop()->height() - wid - 70; |
890 | dia->setGeometry ( x,y,wid,wid); | 894 | dia->setGeometry ( x,y,wid,wid); |
891 | } else { | 895 | } else { |
892 | int si = 220; | 896 | int si = 220; |
893 | if ( QApplication::desktop()->width() > 470 ) | 897 | if ( QApplication::desktop()->width() > 470 ) |
894 | si = 400; | 898 | si = 400; |
895 | dia->resize(si,si/2); | 899 | dia->resize(si,si/2); |
896 | } | 900 | } |
897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 901 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
898 | dia->show(); | 902 | dia->show(); |
899 | 903 | ||
900 | } | 904 | } |
901 | } | 905 | } |
902 | void CalendarView::showDay( QDate d ) | 906 | void CalendarView::showDay( QDate d ) |
903 | { | 907 | { |
904 | dateNavigator()->blockSignals( true ); | 908 | dateNavigator()->blockSignals( true ); |
905 | dateNavigator()->selectDate( d ); | 909 | dateNavigator()->selectDate( d ); |
906 | dateNavigator()->blockSignals( false ); | 910 | dateNavigator()->blockSignals( false ); |
907 | mViewManager->showDayView(); | 911 | mViewManager->showDayView(); |
908 | //dateNavigator()->selectDate( d ); | 912 | //dateNavigator()->selectDate( d ); |
909 | } | 913 | } |
910 | void CalendarView::timerAlarm() | 914 | void CalendarView::timerAlarm() |
911 | { | 915 | { |
912 | //qDebug("CalendarView::timerAlarm() "); | 916 | //qDebug("CalendarView::timerAlarm() "); |
913 | computeAlarm(mAlarmNotification ); | 917 | computeAlarm(mAlarmNotification ); |
914 | } | 918 | } |
915 | 919 | ||
916 | void CalendarView::suspendAlarm() | 920 | void CalendarView::suspendAlarm() |
917 | { | 921 | { |
918 | //qDebug(" CalendarView::suspendAlarm() "); | 922 | //qDebug(" CalendarView::suspendAlarm() "); |
919 | computeAlarm(mSuspendAlarmNotification ); | 923 | computeAlarm(mSuspendAlarmNotification ); |
920 | 924 | ||
921 | } | 925 | } |
922 | 926 | ||
923 | void CalendarView::startAlarm( QString mess , QString filename) | 927 | void CalendarView::startAlarm( QString mess , QString filename) |
924 | { | 928 | { |
925 | 929 | ||
926 | topLevelWidget()->showNormal(); | 930 | topLevelWidget()->showNormal(); |
927 | topLevelWidget()->setActiveWindow(); | 931 | topLevelWidget()->setActiveWindow(); |
928 | topLevelWidget()->raise(); | 932 | topLevelWidget()->raise(); |
929 | 933 | ||
930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 934 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 935 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
932 | 936 | ||
933 | } | 937 | } |
934 | 938 | ||
935 | void CalendarView::checkNextTimerAlarm() | 939 | void CalendarView::checkNextTimerAlarm() |
936 | { | 940 | { |
937 | mCalendar->checkAlarmForIncidence( 0, true ); | 941 | mCalendar->checkAlarmForIncidence( 0, true ); |
938 | } | 942 | } |
939 | 943 | ||
940 | void CalendarView::computeAlarm( QString msg ) | 944 | void CalendarView::computeAlarm( QString msg ) |
941 | { | 945 | { |
942 | 946 | ||
943 | QString mess = msg; | 947 | QString mess = msg; |
944 | QString mAlarmMessage = mess.mid( 9 ); | 948 | QString mAlarmMessage = mess.mid( 9 ); |
945 | QString filename = MainWindow::resourcePath(); | 949 | QString filename = MainWindow::resourcePath(); |
946 | filename += "koalarm.wav"; | 950 | filename += "koalarm.wav"; |
947 | QString tempfilename; | 951 | QString tempfilename; |
948 | if ( mess.left( 13 ) == "suspend_alarm") { | 952 | if ( mess.left( 13 ) == "suspend_alarm") { |
949 | bool error = false; | 953 | bool error = false; |
950 | int len = mess.mid( 13 ).find("+++"); | 954 | int len = mess.mid( 13 ).find("+++"); |
951 | if ( len < 2 ) | 955 | if ( len < 2 ) |
952 | error = true; | 956 | error = true; |
953 | else { | 957 | else { |
954 | tempfilename = mess.mid( 13, len ); | 958 | tempfilename = mess.mid( 13, len ); |
955 | if ( !QFile::exists( tempfilename ) ) | 959 | if ( !QFile::exists( tempfilename ) ) |
956 | error = true; | 960 | error = true; |
957 | } | 961 | } |
958 | if ( ! error ) { | 962 | if ( ! error ) { |
959 | filename = tempfilename; | 963 | filename = tempfilename; |
960 | } | 964 | } |
961 | mAlarmMessage = mess.mid( 13+len+3 ); | 965 | mAlarmMessage = mess.mid( 13+len+3 ); |
962 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 966 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
963 | startAlarm( mAlarmMessage, filename); | 967 | startAlarm( mAlarmMessage, filename); |
964 | return; | 968 | return; |
965 | } | 969 | } |
966 | if ( mess.left( 11 ) == "timer_alarm") { | 970 | if ( mess.left( 11 ) == "timer_alarm") { |
967 | //mTimerTime = 0; | 971 | //mTimerTime = 0; |
968 | startAlarm( mess.mid( 11 ), filename ); | 972 | startAlarm( mess.mid( 11 ), filename ); |
969 | return; | 973 | return; |
970 | } | 974 | } |
971 | if ( mess.left( 10 ) == "proc_alarm") { | 975 | if ( mess.left( 10 ) == "proc_alarm") { |
972 | bool error = false; | 976 | bool error = false; |
973 | int len = mess.mid( 10 ).find("+++"); | 977 | int len = mess.mid( 10 ).find("+++"); |
974 | if ( len < 2 ) | 978 | if ( len < 2 ) |
975 | error = true; | 979 | error = true; |
976 | else { | 980 | else { |
977 | tempfilename = mess.mid( 10, len ); | 981 | tempfilename = mess.mid( 10, len ); |
978 | if ( !QFile::exists( tempfilename ) ) | 982 | if ( !QFile::exists( tempfilename ) ) |
979 | error = true; | 983 | error = true; |
980 | } | 984 | } |
981 | if ( error ) { | 985 | if ( error ) { |
982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 986 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
983 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 987 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
984 | } else { | 988 | } else { |
985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 989 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
986 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 990 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
987 | #ifndef _WIN32_ | 991 | #ifndef _WIN32_ |
988 | if ( vfork () == 0 ) { | 992 | if ( vfork () == 0 ) { |
989 | execl ( tempfilename.latin1(), 0 ); | 993 | execl ( tempfilename.latin1(), 0 ); |
990 | return; | 994 | return; |
991 | } | 995 | } |
992 | #else | 996 | #else |
993 | QProcess* p = new QProcess(); | 997 | QProcess* p = new QProcess(); |
994 | p->addArgument( tempfilename.latin1() ); | 998 | p->addArgument( tempfilename.latin1() ); |
995 | p->start(); | 999 | p->start(); |
996 | return; | 1000 | return; |
997 | #endif | 1001 | #endif |
998 | 1002 | ||
999 | return; | 1003 | return; |
1000 | } | 1004 | } |
1001 | 1005 | ||
1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1006 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1003 | } | 1007 | } |
1004 | if ( mess.left( 11 ) == "audio_alarm") { | 1008 | if ( mess.left( 11 ) == "audio_alarm") { |
1005 | bool error = false; | 1009 | bool error = false; |
1006 | int len = mess.mid( 11 ).find("+++"); | 1010 | int len = mess.mid( 11 ).find("+++"); |
1007 | if ( len < 2 ) | 1011 | if ( len < 2 ) |
1008 | error = true; | 1012 | error = true; |
1009 | else { | 1013 | else { |
1010 | tempfilename = mess.mid( 11, len ); | 1014 | tempfilename = mess.mid( 11, len ); |
1011 | if ( !QFile::exists( tempfilename ) ) | 1015 | if ( !QFile::exists( tempfilename ) ) |
1012 | error = true; | 1016 | error = true; |
1013 | } | 1017 | } |
1014 | if ( ! error ) { | 1018 | if ( ! error ) { |
1015 | filename = tempfilename; | 1019 | filename = tempfilename; |
1016 | } | 1020 | } |
1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1021 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1022 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1019 | } | 1023 | } |
1020 | if ( mess.left( 9 ) == "cal_alarm") { | 1024 | if ( mess.left( 9 ) == "cal_alarm") { |
1021 | mAlarmMessage = mess.mid( 9 ) ; | 1025 | mAlarmMessage = mess.mid( 9 ) ; |
1022 | } | 1026 | } |
1023 | 1027 | ||
1024 | startAlarm( mAlarmMessage, filename ); | 1028 | startAlarm( mAlarmMessage, filename ); |
1025 | 1029 | ||
1026 | 1030 | ||
1027 | } | 1031 | } |
1028 | 1032 | ||
1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1033 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1030 | { | 1034 | { |
1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1035 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1032 | 1036 | ||
1033 | mSuspendAlarmNotification = noti; | 1037 | mSuspendAlarmNotification = noti; |
1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1038 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1039 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1036 | mSuspendTimer->start( ms , true ); | 1040 | mSuspendTimer->start( ms , true ); |
1037 | 1041 | ||
1038 | } | 1042 | } |
1039 | 1043 | ||
1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1044 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1041 | { | 1045 | { |
1042 | mNextAlarmDateTime = qdt; | 1046 | mNextAlarmDateTime = qdt; |
1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1047 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1048 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1045 | #ifndef DESKTOP_VERSION | 1049 | #ifndef DESKTOP_VERSION |
1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1050 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1047 | #endif | 1051 | #endif |
1048 | return; | 1052 | return; |
1049 | } | 1053 | } |
1050 | int maxSec; | 1054 | int maxSec; |
1051 | //maxSec = 5; //testing only | 1055 | //maxSec = 5; //testing only |
1052 | maxSec = 86400+3600; // one day+1hour | 1056 | maxSec = 86400+3600; // one day+1hour |
1053 | mAlarmNotification = noti; | 1057 | mAlarmNotification = noti; |
1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1058 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1055 | if ( sec > maxSec ) { | 1059 | if ( sec > maxSec ) { |
1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1060 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1061 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1058 | return; | 1062 | return; |
1059 | } else { | 1063 | } else { |
1060 | mRecheckAlarmTimer->stop(); | 1064 | mRecheckAlarmTimer->stop(); |
1061 | } | 1065 | } |
1062 | //qDebug("Alarm timer started with secs: %d ", sec); | 1066 | //qDebug("Alarm timer started with secs: %d ", sec); |
1063 | mAlarmTimer->start( sec *1000 , true ); | 1067 | mAlarmTimer->start( sec *1000 , true ); |
1064 | 1068 | ||
1065 | } | 1069 | } |
1066 | // called by mRecheckAlarmTimer to get next alarm | 1070 | // called by mRecheckAlarmTimer to get next alarm |
1067 | // we need this, because a QTimer has only a max range of 25 days | 1071 | // we need this, because a QTimer has only a max range of 25 days |
1068 | void CalendarView::recheckTimerAlarm() | 1072 | void CalendarView::recheckTimerAlarm() |
1069 | { | 1073 | { |
1070 | mAlarmTimer->stop(); | 1074 | mAlarmTimer->stop(); |
1071 | mRecheckAlarmTimer->stop(); | 1075 | mRecheckAlarmTimer->stop(); |
1072 | mCalendar->checkAlarmForIncidence( 0, true ); | 1076 | mCalendar->checkAlarmForIncidence( 0, true ); |
1073 | } | 1077 | } |
1074 | #ifndef DESKTOP_VERSION | 1078 | #ifndef DESKTOP_VERSION |
1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1079 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1076 | #else | 1080 | #else |
1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1081 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1078 | #endif | 1082 | #endif |
1079 | { | 1083 | { |
1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1084 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1085 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1082 | #ifndef DESKTOP_VERSION | 1086 | #ifndef DESKTOP_VERSION |
1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1087 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1084 | #endif | 1088 | #endif |
1085 | return; | 1089 | return; |
1086 | } | 1090 | } |
1087 | mAlarmTimer->stop(); | 1091 | mAlarmTimer->stop(); |
1088 | } | 1092 | } |
1089 | void CalendarView::selectWeekNum ( int num ) | 1093 | void CalendarView::selectWeekNum ( int num ) |
1090 | { | 1094 | { |
1091 | dateNavigator()->blockSignals( true ); | 1095 | dateNavigator()->blockSignals( true ); |
1092 | dateNavigator()->selectWeek( num ); | 1096 | dateNavigator()->selectWeek( num ); |
1093 | dateNavigator()->blockSignals( false ); | 1097 | dateNavigator()->blockSignals( false ); |
1094 | mViewManager->showWeekView(); | 1098 | mViewManager->showWeekView(); |
1095 | } | 1099 | } |
1096 | KOViewManager *CalendarView::viewManager() | 1100 | KOViewManager *CalendarView::viewManager() |
1097 | { | 1101 | { |
1098 | return mViewManager; | 1102 | return mViewManager; |
1099 | } | 1103 | } |
1100 | 1104 | ||
1101 | KODialogManager *CalendarView::dialogManager() | 1105 | KODialogManager *CalendarView::dialogManager() |
1102 | { | 1106 | { |
1103 | return mDialogManager; | 1107 | return mDialogManager; |
1104 | } | 1108 | } |
1105 | 1109 | ||
1106 | QDate CalendarView::startDate() | 1110 | QDate CalendarView::startDate() |
1107 | { | 1111 | { |
1108 | DateList dates = mNavigator->selectedDates(); | 1112 | DateList dates = mNavigator->selectedDates(); |
1109 | 1113 | ||
1110 | return dates.first(); | 1114 | return dates.first(); |
1111 | } | 1115 | } |
1112 | 1116 | ||
1113 | QDate CalendarView::endDate() | 1117 | QDate CalendarView::endDate() |
1114 | { | 1118 | { |
1115 | DateList dates = mNavigator->selectedDates(); | 1119 | DateList dates = mNavigator->selectedDates(); |
1116 | 1120 | ||
1117 | return dates.last(); | 1121 | return dates.last(); |
1118 | } | 1122 | } |
1119 | 1123 | ||
1120 | 1124 | ||
1121 | void CalendarView::createPrinter() | 1125 | void CalendarView::createPrinter() |
1122 | { | 1126 | { |
1123 | #ifndef KORG_NOPRINTER | 1127 | #ifndef KORG_NOPRINTER |
1124 | if (!mCalPrinter) { | 1128 | if (!mCalPrinter) { |
1125 | mCalPrinter = new CalPrinter(this, mCalendar); | 1129 | mCalPrinter = new CalPrinter(this, mCalendar); |
1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1130 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1127 | } | 1131 | } |
1128 | #endif | 1132 | #endif |
1129 | } | 1133 | } |
1130 | 1134 | ||
1131 | 1135 | ||
1132 | //KOPrefs::instance()->mWriteBackFile | 1136 | //KOPrefs::instance()->mWriteBackFile |
1133 | //KOPrefs::instance()->mWriteBackExistingOnly | 1137 | //KOPrefs::instance()->mWriteBackExistingOnly |
1134 | 1138 | ||
1135 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 1139 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
1136 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 1140 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
1137 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 1141 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
1138 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 1142 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
1139 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 1143 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
1140 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 1144 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
1141 | 1145 | ||
1142 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 1146 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
1143 | { | 1147 | { |
1144 | 1148 | ||
1145 | // 0 equal | 1149 | // 0 equal |
1146 | // 1 take local | 1150 | // 1 take local |
1147 | // 2 take remote | 1151 | // 2 take remote |
1148 | // 3 cancel | 1152 | // 3 cancel |
1149 | QDateTime lastSync = mLastCalendarSync; | 1153 | QDateTime lastSync = mLastCalendarSync; |
1150 | QDateTime localMod = local->lastModified(); | 1154 | QDateTime localMod = local->lastModified(); |
1151 | QDateTime remoteMod = remote->lastModified(); | 1155 | QDateTime remoteMod = remote->lastModified(); |
1152 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1156 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1153 | bool remCh, locCh; | 1157 | bool remCh, locCh; |
1154 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 1158 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
1155 | //if ( remCh ) | 1159 | //if ( remCh ) |
1156 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 1160 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
1157 | locCh = ( localMod > mLastCalendarSync ); | 1161 | locCh = ( localMod > mLastCalendarSync ); |
1158 | if ( !remCh && ! locCh ) { | 1162 | if ( !remCh && ! locCh ) { |
1159 | //qDebug("both not changed "); | 1163 | //qDebug("both not changed "); |
1160 | lastSync = localMod.addDays(1); | 1164 | lastSync = localMod.addDays(1); |
1161 | if ( mode <= SYNC_PREF_ASK ) | 1165 | if ( mode <= SYNC_PREF_ASK ) |
1162 | return 0; | 1166 | return 0; |
1163 | } else { | 1167 | } else { |
1164 | if ( locCh ) { | 1168 | if ( locCh ) { |
1165 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 1169 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
1166 | lastSync = localMod.addDays( -1 ); | 1170 | lastSync = localMod.addDays( -1 ); |
1167 | if ( !remCh ) | 1171 | if ( !remCh ) |
1168 | remoteMod = ( lastSync.addDays( -1 ) ); | 1172 | remoteMod = ( lastSync.addDays( -1 ) ); |
1169 | } else { | 1173 | } else { |
1170 | //qDebug(" not loc changed "); | 1174 | //qDebug(" not loc changed "); |
1171 | lastSync = localMod.addDays( 1 ); | 1175 | lastSync = localMod.addDays( 1 ); |
1172 | if ( remCh ) | 1176 | if ( remCh ) |
1173 | remoteMod =( lastSync.addDays( 1 ) ); | 1177 | remoteMod =( lastSync.addDays( 1 ) ); |
1174 | 1178 | ||
1175 | } | 1179 | } |
1176 | } | 1180 | } |
1177 | full = true; | 1181 | full = true; |
1178 | if ( mode < SYNC_PREF_ASK ) | 1182 | if ( mode < SYNC_PREF_ASK ) |
1179 | mode = SYNC_PREF_ASK; | 1183 | mode = SYNC_PREF_ASK; |
1180 | } else { | 1184 | } else { |
1181 | if ( localMod == remoteMod ) | 1185 | if ( localMod == remoteMod ) |
1182 | // if ( local->revision() == remote->revision() ) | 1186 | // if ( local->revision() == remote->revision() ) |
1183 | return 0; | 1187 | return 0; |
1184 | 1188 | ||
1185 | } | 1189 | } |
1186 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 1190 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
1187 | 1191 | ||
1188 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 1192 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
1189 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 1193 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
1190 | //full = true; //debug only | 1194 | //full = true; //debug only |
1191 | if ( full ) { | 1195 | if ( full ) { |
1192 | bool equ = false; | 1196 | bool equ = false; |
1193 | if ( local->typeID() == eventID ) { | 1197 | if ( local->typeID() == eventID ) { |
1194 | equ = (*((Event*) local) == *((Event*) remote)); | 1198 | equ = (*((Event*) local) == *((Event*) remote)); |
1195 | } | 1199 | } |
1196 | else if ( local->typeID() == todoID ) | 1200 | else if ( local->typeID() == todoID ) |
1197 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 1201 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
1198 | else if ( local->typeID() == journalID ) | 1202 | else if ( local->typeID() == journalID ) |
1199 | equ = (*((Journal*) local) == *((Journal*) remote)); | 1203 | equ = (*((Journal*) local) == *((Journal*) remote)); |
1200 | if ( equ ) { | 1204 | if ( equ ) { |
1201 | //qDebug("equal "); | 1205 | //qDebug("equal "); |
1202 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1206 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1203 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 1207 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
1204 | } | 1208 | } |
1205 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 1209 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
1206 | return 0; | 1210 | return 0; |
1207 | 1211 | ||
1208 | }//else //debug only | 1212 | }//else //debug only |
1209 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 1213 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
1210 | } | 1214 | } |
1211 | int result; | 1215 | int result; |
1212 | bool localIsNew; | 1216 | bool localIsNew; |
1213 | //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() ); | 1217 | //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() ); |
1214 | 1218 | ||
1215 | 1219 | ||
1216 | // ************************************************ | 1220 | // ************************************************ |
1217 | // ************************************************ | 1221 | // ************************************************ |
1218 | // ************************************************ | 1222 | // ************************************************ |
1219 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1223 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1220 | // BUT remoteMod != localMod | 1224 | // BUT remoteMod != localMod |
1221 | 1225 | ||
1222 | 1226 | ||
1223 | if ( full && mode < SYNC_PREF_NEWEST ) | 1227 | if ( full && mode < SYNC_PREF_NEWEST ) |
1224 | mode = SYNC_PREF_ASK; | 1228 | mode = SYNC_PREF_ASK; |
1225 | 1229 | ||
1226 | switch( mode ) { | 1230 | switch( mode ) { |
1227 | case SYNC_PREF_LOCAL: | 1231 | case SYNC_PREF_LOCAL: |
1228 | if ( lastSync > remoteMod ) | 1232 | if ( lastSync > remoteMod ) |
1229 | return 1; | 1233 | return 1; |
1230 | if ( lastSync > localMod ) | 1234 | if ( lastSync > localMod ) |
1231 | return 2; | 1235 | return 2; |
1232 | return 1; | 1236 | return 1; |
1233 | break; | 1237 | break; |
1234 | case SYNC_PREF_REMOTE: | 1238 | case SYNC_PREF_REMOTE: |
1235 | if ( lastSync > localMod ) | 1239 | if ( lastSync > localMod ) |
1236 | return 2; | 1240 | return 2; |
1237 | if ( lastSync > remoteMod ) | 1241 | if ( lastSync > remoteMod ) |
1238 | return 1; | 1242 | return 1; |
1239 | return 2; | 1243 | return 2; |
1240 | break; | 1244 | break; |
1241 | case SYNC_PREF_NEWEST: | 1245 | case SYNC_PREF_NEWEST: |
1242 | if ( localMod >= remoteMod ) | 1246 | if ( localMod >= remoteMod ) |
1243 | return 1; | 1247 | return 1; |
1244 | else | 1248 | else |
1245 | return 2; | 1249 | return 2; |
1246 | break; | 1250 | break; |
1247 | case SYNC_PREF_ASK: | 1251 | case SYNC_PREF_ASK: |
1248 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1252 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1249 | if ( lastSync > remoteMod && lastSync > localMod) | 1253 | if ( lastSync > remoteMod && lastSync > localMod) |
1250 | return 0; | 1254 | return 0; |
1251 | if ( lastSync > remoteMod ) | 1255 | if ( lastSync > remoteMod ) |
1252 | return 1; | 1256 | return 1; |
1253 | if ( lastSync > localMod ) | 1257 | if ( lastSync > localMod ) |
1254 | return 2; | 1258 | return 2; |
1255 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1259 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1256 | localIsNew = localMod >= remoteMod; | 1260 | localIsNew = localMod >= remoteMod; |
1257 | if ( localIsNew ) | 1261 | if ( localIsNew ) |
1258 | getEventViewerDialog()->setColorMode( 1 ); | 1262 | getEventViewerDialog()->setColorMode( 1 ); |
1259 | else | 1263 | else |
1260 | getEventViewerDialog()->setColorMode( 2 ); | 1264 | getEventViewerDialog()->setColorMode( 2 ); |
1261 | getEventViewerDialog()->setIncidence(local); | 1265 | getEventViewerDialog()->setIncidence(local); |
1262 | if ( localIsNew ) | 1266 | if ( localIsNew ) |
1263 | getEventViewerDialog()->setColorMode( 2 ); | 1267 | getEventViewerDialog()->setColorMode( 2 ); |
1264 | else | 1268 | else |
1265 | getEventViewerDialog()->setColorMode( 1 ); | 1269 | getEventViewerDialog()->setColorMode( 1 ); |
1266 | getEventViewerDialog()->addIncidence(remote); | 1270 | getEventViewerDialog()->addIncidence(remote); |
1267 | getEventViewerDialog()->setColorMode( 0 ); | 1271 | getEventViewerDialog()->setColorMode( 0 ); |
1268 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1272 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1269 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1273 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1270 | getEventViewerDialog()->showMe(); | 1274 | getEventViewerDialog()->showMe(); |
1271 | result = getEventViewerDialog()->executeS( localIsNew ); | 1275 | result = getEventViewerDialog()->executeS( localIsNew ); |
1272 | return result; | 1276 | return result; |
1273 | 1277 | ||
1274 | break; | 1278 | break; |
1275 | case SYNC_PREF_FORCE_LOCAL: | 1279 | case SYNC_PREF_FORCE_LOCAL: |
1276 | return 1; | 1280 | return 1; |
1277 | break; | 1281 | break; |
1278 | case SYNC_PREF_FORCE_REMOTE: | 1282 | case SYNC_PREF_FORCE_REMOTE: |
1279 | return 2; | 1283 | return 2; |
1280 | break; | 1284 | break; |
1281 | 1285 | ||
1282 | default: | 1286 | default: |
1283 | // SYNC_PREF_TAKE_BOTH not implemented | 1287 | // SYNC_PREF_TAKE_BOTH not implemented |
1284 | break; | 1288 | break; |
1285 | } | 1289 | } |
1286 | return 0; | 1290 | return 0; |
1287 | } | 1291 | } |
1288 | Event* CalendarView::getLastSyncEvent() | 1292 | Event* CalendarView::getLastSyncEvent() |
1289 | { | 1293 | { |
1290 | Event* lse; | 1294 | Event* lse; |
1291 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1295 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1292 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1296 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1293 | if (!lse) { | 1297 | if (!lse) { |
1294 | lse = new Event(); | 1298 | lse = new Event(); |
1295 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1299 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1296 | QString sum = ""; | 1300 | QString sum = ""; |
1297 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1301 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1298 | sum = "E: "; | 1302 | sum = "E: "; |
1299 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1303 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1300 | lse->setDtStart( mLastCalendarSync ); | 1304 | lse->setDtStart( mLastCalendarSync ); |
1301 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1305 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1302 | lse->setCategories( i18n("SyncEvent") ); | 1306 | lse->setCategories( i18n("SyncEvent") ); |
1303 | lse->setReadOnly( true ); | 1307 | lse->setReadOnly( true ); |
1304 | mCalendar->addEvent( lse ); | 1308 | mCalendar->addEvent( lse ); |
1305 | } | 1309 | } |
1306 | 1310 | ||
1307 | return lse; | 1311 | return lse; |
1308 | 1312 | ||
1309 | } | 1313 | } |
1310 | 1314 | ||
1311 | // we check, if the to delete event has a id for a profile | 1315 | // we check, if the to delete event has a id for a profile |
1312 | // if yes, we set this id in the profile to delete | 1316 | // if yes, we set this id in the profile to delete |
1313 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1317 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1314 | { | 1318 | { |
1315 | if ( lastSync.count() == 0 ) { | 1319 | if ( lastSync.count() == 0 ) { |
1316 | //qDebug(" lastSync.count() == 0"); | 1320 | //qDebug(" lastSync.count() == 0"); |
1317 | return; | 1321 | return; |
1318 | } | 1322 | } |
1319 | if ( toDelete->typeID() == journalID ) | 1323 | if ( toDelete->typeID() == journalID ) |
1320 | return; | 1324 | return; |
1321 | 1325 | ||
1322 | Event* eve = lastSync.first(); | 1326 | Event* eve = lastSync.first(); |
1323 | 1327 | ||
1324 | while ( eve ) { | 1328 | while ( eve ) { |
1325 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1329 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1326 | if ( !id.isEmpty() ) { | 1330 | if ( !id.isEmpty() ) { |
1327 | QString des = eve->description(); | 1331 | QString des = eve->description(); |
1328 | QString pref = "e"; | 1332 | QString pref = "e"; |
1329 | if ( toDelete->typeID() == todoID ) | 1333 | if ( toDelete->typeID() == todoID ) |
1330 | pref = "t"; | 1334 | pref = "t"; |
1331 | des += pref+ id + ","; | 1335 | des += pref+ id + ","; |
1332 | eve->setReadOnly( false ); | 1336 | eve->setReadOnly( false ); |
1333 | eve->setDescription( des ); | 1337 | eve->setDescription( des ); |
1334 | //qDebug("setdes %s ", des.latin1()); | 1338 | //qDebug("setdes %s ", des.latin1()); |
1335 | eve->setReadOnly( true ); | 1339 | eve->setReadOnly( true ); |
1336 | } | 1340 | } |
1337 | eve = lastSync.next(); | 1341 | eve = lastSync.next(); |
1338 | } | 1342 | } |
1339 | 1343 | ||
1340 | } | 1344 | } |
1341 | void CalendarView::checkExternalId( Incidence * inc ) | 1345 | void CalendarView::checkExternalId( Incidence * inc ) |
1342 | { | 1346 | { |
1343 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1347 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1344 | checkExternSyncEvent( lastSync, inc ); | 1348 | checkExternSyncEvent( lastSync, inc ); |
1345 | 1349 | ||
1346 | } | 1350 | } |
1347 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1351 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1348 | { | 1352 | { |
1349 | bool syncOK = true; | 1353 | bool syncOK = true; |
1350 | int addedEvent = 0; | 1354 | int addedEvent = 0; |
1351 | int addedEventR = 0; | 1355 | int addedEventR = 0; |
1352 | int deletedEventR = 0; | 1356 | int deletedEventR = 0; |