author | zautrix <zautrix> | 2005-07-26 14:26:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-26 14:26:36 (UTC) |
commit | e1d72bb77c51ff7313b390f263bc1f10d20123b0 (patch) (unidiff) | |
tree | 35f6cb7936a6e05914bdb9329ece3143c8c9a2f7 /korganizer | |
parent | 08f8edb64a919e51ad6e1a62031569a629cffa0f (diff) | |
download | kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.zip kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.tar.gz kdepimpi-e1d72bb77c51ff7313b390f263bc1f10d20123b0.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 7 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 10 |
2 files changed, 11 insertions, 6 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9674921..3ab4bb4 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -362,769 +362,769 @@ CalendarView::CalendarView( Calendar *calendar, | |||
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 | 373 | ||
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 | QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); |
841 | } | 841 | } |
842 | void CalendarView::checkAlarms() | 842 | void CalendarView::checkAlarms() |
843 | { | 843 | { |
844 | 844 | ||
845 | 845 | ||
846 | KConfig *config = KOGlobals::config(); | 846 | KConfig *config = KOGlobals::config(); |
847 | config->setGroup( "AppRun" ); | 847 | config->setGroup( "AppRun" ); |
848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 848 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
849 | int daysto = dt.daysTo( QDate::currentDate() ); | 849 | int daysto = dt.daysTo( QDate::currentDate() ); |
850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); | 850 | int days = config->readNumEntry( "LatestProgramStopDays" , daysto); |
851 | dt = dt.addDays( days ); | 851 | dt = dt.addDays( days ); |
852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 852 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; | 853 | int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; |
854 | //qDebug("KO: Reading program stop %d ", secs); | 854 | //qDebug("KO: Reading program stop %d ", secs); |
855 | //secs -= ( 3600 * 24*3 ); // debug only | 855 | //secs -= ( 3600 * 24*3 ); // debug only |
856 | QDateTime latest = dt.addSecs ( secs ); | 856 | QDateTime latest = dt.addSecs ( secs ); |
857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 857 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 858 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 859 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
860 | QPtrList<Incidence> al; | 860 | QPtrList<Incidence> al; |
861 | Incidence* inL = el.first(); | 861 | Incidence* inL = el.first(); |
862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | 862 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); |
863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | 863 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); |
864 | while ( inL ) { | 864 | while ( inL ) { |
865 | bool ok = false; | 865 | bool ok = false; |
866 | int offset = 0; | 866 | int offset = 0; |
867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 867 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
868 | if ( ok ) { | 868 | if ( ok ) { |
869 | //qDebug("OK %s",next.toString().latin1()); | 869 | //qDebug("OK %s",next.toString().latin1()); |
870 | if ( next < cur ) { | 870 | if ( next < cur ) { |
871 | al.append( inL ); | 871 | al.append( inL ); |
872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 872 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | inL = el.next(); | 875 | inL = el.next(); |
876 | } | 876 | } |
877 | if ( al.count() ) { | 877 | if ( al.count() ) { |
878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 878 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 879 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
880 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 880 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
881 | lay->setSpacing( 0 ); | 881 | lay->setSpacing( 0 ); |
882 | lay->setMargin( 0 ); | 882 | lay->setMargin( 0 ); |
883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 883 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 884 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
885 | lay->addWidget( matb ); | 885 | lay->addWidget( matb ); |
886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 886 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
887 | int wid = 210; | 887 | int wid = 210; |
888 | int x = QApplication::desktop()->width() - wid - 7; | 888 | int x = QApplication::desktop()->width() - wid - 7; |
889 | int y = QApplication::desktop()->height() - wid - 70; | 889 | int y = QApplication::desktop()->height() - wid - 70; |
890 | dia->setGeometry ( x,y,wid,wid); | 890 | dia->setGeometry ( x,y,wid,wid); |
891 | } else { | 891 | } else { |
892 | int si = 220; | 892 | int si = 220; |
893 | if ( QApplication::desktop()->width() > 470 ) | 893 | if ( QApplication::desktop()->width() > 470 ) |
894 | si = 400; | 894 | si = 400; |
895 | dia->resize(si,si/2); | 895 | dia->resize(si,si/2); |
896 | } | 896 | } |
897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 897 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
898 | dia->show(); | 898 | dia->show(); |
899 | 899 | ||
900 | } | 900 | } |
901 | } | 901 | } |
902 | void CalendarView::showDay( QDate d ) | 902 | void CalendarView::showDay( QDate d ) |
903 | { | 903 | { |
904 | dateNavigator()->blockSignals( true ); | 904 | dateNavigator()->blockSignals( true ); |
905 | dateNavigator()->selectDate( d ); | 905 | dateNavigator()->selectDate( d ); |
906 | dateNavigator()->blockSignals( false ); | 906 | dateNavigator()->blockSignals( false ); |
907 | mViewManager->showDayView(); | 907 | mViewManager->showDayView(); |
908 | //dateNavigator()->selectDate( d ); | 908 | //dateNavigator()->selectDate( d ); |
909 | } | 909 | } |
910 | void CalendarView::timerAlarm() | 910 | void CalendarView::timerAlarm() |
911 | { | 911 | { |
912 | //qDebug("CalendarView::timerAlarm() "); | 912 | //qDebug("CalendarView::timerAlarm() "); |
913 | computeAlarm(mAlarmNotification ); | 913 | computeAlarm(mAlarmNotification ); |
914 | } | 914 | } |
915 | 915 | ||
916 | void CalendarView::suspendAlarm() | 916 | void CalendarView::suspendAlarm() |
917 | { | 917 | { |
918 | //qDebug(" CalendarView::suspendAlarm() "); | 918 | //qDebug(" CalendarView::suspendAlarm() "); |
919 | computeAlarm(mSuspendAlarmNotification ); | 919 | computeAlarm(mSuspendAlarmNotification ); |
920 | 920 | ||
921 | } | 921 | } |
922 | 922 | ||
923 | void CalendarView::startAlarm( QString mess , QString filename) | 923 | void CalendarView::startAlarm( QString mess , QString filename) |
924 | { | 924 | { |
925 | 925 | ||
926 | topLevelWidget()->showNormal(); | 926 | topLevelWidget()->showNormal(); |
927 | topLevelWidget()->setActiveWindow(); | 927 | topLevelWidget()->setActiveWindow(); |
928 | topLevelWidget()->raise(); | 928 | topLevelWidget()->raise(); |
929 | 929 | ||
930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 930 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); | 931 | QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); |
932 | 932 | ||
933 | } | 933 | } |
934 | 934 | ||
935 | void CalendarView::checkNextTimerAlarm() | 935 | void CalendarView::checkNextTimerAlarm() |
936 | { | 936 | { |
937 | mCalendar->checkAlarmForIncidence( 0, true ); | 937 | mCalendar->checkAlarmForIncidence( 0, true ); |
938 | } | 938 | } |
939 | 939 | ||
940 | void CalendarView::computeAlarm( QString msg ) | 940 | void CalendarView::computeAlarm( QString msg ) |
941 | { | 941 | { |
942 | 942 | ||
943 | QString mess = msg; | 943 | QString mess = msg; |
944 | QString mAlarmMessage = mess.mid( 9 ); | 944 | QString mAlarmMessage = mess.mid( 9 ); |
945 | QString filename = MainWindow::resourcePath(); | 945 | QString filename = MainWindow::resourcePath(); |
946 | filename += "koalarm.wav"; | 946 | filename += "koalarm.wav"; |
947 | QString tempfilename; | 947 | QString tempfilename; |
948 | if ( mess.left( 13 ) == "suspend_alarm") { | 948 | if ( mess.left( 13 ) == "suspend_alarm") { |
949 | bool error = false; | 949 | bool error = false; |
950 | int len = mess.mid( 13 ).find("+++"); | 950 | int len = mess.mid( 13 ).find("+++"); |
951 | if ( len < 2 ) | 951 | if ( len < 2 ) |
952 | error = true; | 952 | error = true; |
953 | else { | 953 | else { |
954 | tempfilename = mess.mid( 13, len ); | 954 | tempfilename = mess.mid( 13, len ); |
955 | if ( !QFile::exists( tempfilename ) ) | 955 | if ( !QFile::exists( tempfilename ) ) |
956 | error = true; | 956 | error = true; |
957 | } | 957 | } |
958 | if ( ! error ) { | 958 | if ( ! error ) { |
959 | filename = tempfilename; | 959 | filename = tempfilename; |
960 | } | 960 | } |
961 | mAlarmMessage = mess.mid( 13+len+3 ); | 961 | mAlarmMessage = mess.mid( 13+len+3 ); |
962 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 962 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
963 | startAlarm( mAlarmMessage, filename); | 963 | startAlarm( mAlarmMessage, filename); |
964 | return; | 964 | return; |
965 | } | 965 | } |
966 | if ( mess.left( 11 ) == "timer_alarm") { | 966 | if ( mess.left( 11 ) == "timer_alarm") { |
967 | //mTimerTime = 0; | 967 | //mTimerTime = 0; |
968 | startAlarm( mess.mid( 11 ), filename ); | 968 | startAlarm( mess.mid( 11 ), filename ); |
969 | return; | 969 | return; |
970 | } | 970 | } |
971 | if ( mess.left( 10 ) == "proc_alarm") { | 971 | if ( mess.left( 10 ) == "proc_alarm") { |
972 | bool error = false; | 972 | bool error = false; |
973 | int len = mess.mid( 10 ).find("+++"); | 973 | int len = mess.mid( 10 ).find("+++"); |
974 | if ( len < 2 ) | 974 | if ( len < 2 ) |
975 | error = true; | 975 | error = true; |
976 | else { | 976 | else { |
977 | tempfilename = mess.mid( 10, len ); | 977 | tempfilename = mess.mid( 10, len ); |
978 | if ( !QFile::exists( tempfilename ) ) | 978 | if ( !QFile::exists( tempfilename ) ) |
979 | error = true; | 979 | error = true; |
980 | } | 980 | } |
981 | if ( error ) { | 981 | if ( error ) { |
982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 982 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
983 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 983 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
984 | } else { | 984 | } else { |
985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 985 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
986 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 986 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
987 | #ifndef _WIN32_ | 987 | #ifndef _WIN32_ |
988 | if ( vfork () == 0 ) { | 988 | if ( vfork () == 0 ) { |
989 | execl ( tempfilename.latin1(), 0 ); | 989 | execl ( tempfilename.latin1(), 0 ); |
990 | return; | 990 | return; |
991 | } | 991 | } |
992 | #else | 992 | #else |
993 | QProcess* p = new QProcess(); | 993 | QProcess* p = new QProcess(); |
994 | p->addArgument( tempfilename.latin1() ); | 994 | p->addArgument( tempfilename.latin1() ); |
995 | p->start(); | 995 | p->start(); |
996 | return; | 996 | return; |
997 | #endif | 997 | #endif |
998 | 998 | ||
999 | return; | 999 | return; |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 1002 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
1003 | } | 1003 | } |
1004 | if ( mess.left( 11 ) == "audio_alarm") { | 1004 | if ( mess.left( 11 ) == "audio_alarm") { |
1005 | bool error = false; | 1005 | bool error = false; |
1006 | int len = mess.mid( 11 ).find("+++"); | 1006 | int len = mess.mid( 11 ).find("+++"); |
1007 | if ( len < 2 ) | 1007 | if ( len < 2 ) |
1008 | error = true; | 1008 | error = true; |
1009 | else { | 1009 | else { |
1010 | tempfilename = mess.mid( 11, len ); | 1010 | tempfilename = mess.mid( 11, len ); |
1011 | if ( !QFile::exists( tempfilename ) ) | 1011 | if ( !QFile::exists( tempfilename ) ) |
1012 | error = true; | 1012 | error = true; |
1013 | } | 1013 | } |
1014 | if ( ! error ) { | 1014 | if ( ! error ) { |
1015 | filename = tempfilename; | 1015 | filename = tempfilename; |
1016 | } | 1016 | } |
1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 1017 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 1018 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
1019 | } | 1019 | } |
1020 | if ( mess.left( 9 ) == "cal_alarm") { | 1020 | if ( mess.left( 9 ) == "cal_alarm") { |
1021 | mAlarmMessage = mess.mid( 9 ) ; | 1021 | mAlarmMessage = mess.mid( 9 ) ; |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | startAlarm( mAlarmMessage, filename ); | 1024 | startAlarm( mAlarmMessage, filename ); |
1025 | 1025 | ||
1026 | 1026 | ||
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 1029 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
1030 | { | 1030 | { |
1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1031 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1032 | 1032 | ||
1033 | mSuspendAlarmNotification = noti; | 1033 | mSuspendAlarmNotification = noti; |
1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 1034 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 1035 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
1036 | mSuspendTimer->start( ms , true ); | 1036 | mSuspendTimer->start( ms , true ); |
1037 | 1037 | ||
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 1040 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
1041 | { | 1041 | { |
1042 | mNextAlarmDateTime = qdt; | 1042 | mNextAlarmDateTime = qdt; |
1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1043 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1044 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1045 | #ifndef DESKTOP_VERSION | 1045 | #ifndef DESKTOP_VERSION |
1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); | 1046 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
1047 | #endif | 1047 | #endif |
1048 | return; | 1048 | return; |
1049 | } | 1049 | } |
1050 | int maxSec; | 1050 | int maxSec; |
1051 | //maxSec = 5; //testing only | 1051 | //maxSec = 5; //testing only |
1052 | maxSec = 86400+3600; // one day+1hour | 1052 | maxSec = 86400+3600; // one day+1hour |
1053 | mAlarmNotification = noti; | 1053 | mAlarmNotification = noti; |
1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 1054 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
1055 | if ( sec > maxSec ) { | 1055 | if ( sec > maxSec ) { |
1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 1056 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 1057 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
1058 | return; | 1058 | return; |
1059 | } else { | 1059 | } else { |
1060 | mRecheckAlarmTimer->stop(); | 1060 | mRecheckAlarmTimer->stop(); |
1061 | } | 1061 | } |
1062 | //qDebug("Alarm timer started with secs: %d ", sec); | 1062 | //qDebug("Alarm timer started with secs: %d ", sec); |
1063 | mAlarmTimer->start( sec *1000 , true ); | 1063 | mAlarmTimer->start( sec *1000 , true ); |
1064 | 1064 | ||
1065 | } | 1065 | } |
1066 | // called by mRecheckAlarmTimer to get next alarm | 1066 | // called by mRecheckAlarmTimer to get next alarm |
1067 | // we need this, because a QTimer has only a max range of 25 days | 1067 | // we need this, because a QTimer has only a max range of 25 days |
1068 | void CalendarView::recheckTimerAlarm() | 1068 | void CalendarView::recheckTimerAlarm() |
1069 | { | 1069 | { |
1070 | mAlarmTimer->stop(); | 1070 | mAlarmTimer->stop(); |
1071 | mRecheckAlarmTimer->stop(); | 1071 | mRecheckAlarmTimer->stop(); |
1072 | mCalendar->checkAlarmForIncidence( 0, true ); | 1072 | mCalendar->checkAlarmForIncidence( 0, true ); |
1073 | } | 1073 | } |
1074 | #ifndef DESKTOP_VERSION | 1074 | #ifndef DESKTOP_VERSION |
1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 1075 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
1076 | #else | 1076 | #else |
1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) | 1077 | void CalendarView::removeAlarm(const QDateTime &, const QString & ) |
1078 | #endif | 1078 | #endif |
1079 | { | 1079 | { |
1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 1080 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 1081 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
1082 | #ifndef DESKTOP_VERSION | 1082 | #ifndef DESKTOP_VERSION |
1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); | 1083 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); |
1084 | #endif | 1084 | #endif |
1085 | return; | 1085 | return; |
1086 | } | 1086 | } |
1087 | mAlarmTimer->stop(); | 1087 | mAlarmTimer->stop(); |
1088 | } | 1088 | } |
1089 | void CalendarView::selectWeekNum ( int num ) | 1089 | void CalendarView::selectWeekNum ( int num ) |
1090 | { | 1090 | { |
1091 | dateNavigator()->blockSignals( true ); | 1091 | dateNavigator()->blockSignals( true ); |
1092 | dateNavigator()->selectWeek( num ); | 1092 | dateNavigator()->selectWeek( num ); |
1093 | dateNavigator()->blockSignals( false ); | 1093 | dateNavigator()->blockSignals( false ); |
1094 | mViewManager->showWeekView(); | 1094 | mViewManager->showWeekView(); |
1095 | } | 1095 | } |
1096 | KOViewManager *CalendarView::viewManager() | 1096 | KOViewManager *CalendarView::viewManager() |
1097 | { | 1097 | { |
1098 | return mViewManager; | 1098 | return mViewManager; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | KODialogManager *CalendarView::dialogManager() | 1101 | KODialogManager *CalendarView::dialogManager() |
1102 | { | 1102 | { |
1103 | return mDialogManager; | 1103 | return mDialogManager; |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | QDate CalendarView::startDate() | 1106 | QDate CalendarView::startDate() |
1107 | { | 1107 | { |
1108 | DateList dates = mNavigator->selectedDates(); | 1108 | DateList dates = mNavigator->selectedDates(); |
1109 | 1109 | ||
1110 | return dates.first(); | 1110 | return dates.first(); |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | QDate CalendarView::endDate() | 1113 | QDate CalendarView::endDate() |
1114 | { | 1114 | { |
1115 | DateList dates = mNavigator->selectedDates(); | 1115 | DateList dates = mNavigator->selectedDates(); |
1116 | 1116 | ||
1117 | return dates.last(); | 1117 | return dates.last(); |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | 1120 | ||
1121 | void CalendarView::createPrinter() | 1121 | void CalendarView::createPrinter() |
1122 | { | 1122 | { |
1123 | #ifndef KORG_NOPRINTER | 1123 | #ifndef KORG_NOPRINTER |
1124 | if (!mCalPrinter) { | 1124 | if (!mCalPrinter) { |
1125 | mCalPrinter = new CalPrinter(this, mCalendar); | 1125 | mCalPrinter = new CalPrinter(this, mCalendar); |
1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 1126 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
1127 | } | 1127 | } |
1128 | #endif | 1128 | #endif |
1129 | } | 1129 | } |
1130 | 1130 | ||
@@ -2447,776 +2447,777 @@ void CalendarView::readSettings() | |||
2447 | } | 2447 | } |
2448 | mLeftFrame->setSizes(sizes); | 2448 | mLeftFrame->setSizes(sizes); |
2449 | sizes = config->readIntListEntry("Main Splitter Frame"); | 2449 | sizes = config->readIntListEntry("Main Splitter Frame"); |
2450 | resetval = 0; | 2450 | resetval = 0; |
2451 | maxVal = 0; | 2451 | maxVal = 0; |
2452 | if (sizes.count() != 2) { | 2452 | if (sizes.count() != 2) { |
2453 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2453 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2454 | resetval = mDateNavigator->sizeHint().width()+2; | 2454 | resetval = mDateNavigator->sizeHint().width()+2; |
2455 | } else { | 2455 | } else { |
2456 | resetval = mDateNavigator->sizeHint().height()+2; | 2456 | resetval = mDateNavigator->sizeHint().height()+2; |
2457 | } | 2457 | } |
2458 | } | 2458 | } |
2459 | if ( resetval ) { | 2459 | if ( resetval ) { |
2460 | sizes.clear(); | 2460 | sizes.clear(); |
2461 | if ( !KOPrefs::instance()->mVerticalScreen ) { | 2461 | if ( !KOPrefs::instance()->mVerticalScreen ) { |
2462 | maxVal = QApplication::desktop()->width() -10; | 2462 | maxVal = QApplication::desktop()->width() -10; |
2463 | } else { | 2463 | } else { |
2464 | maxVal = QApplication::desktop()->height()-10; | 2464 | maxVal = QApplication::desktop()->height()-10; |
2465 | } | 2465 | } |
2466 | sizes << resetval; | 2466 | sizes << resetval; |
2467 | if ( maxVal < resetval + resetval) | 2467 | if ( maxVal < resetval + resetval) |
2468 | resetval = maxVal - resetval; | 2468 | resetval = maxVal - resetval; |
2469 | sizes << resetval; | 2469 | sizes << resetval; |
2470 | } | 2470 | } |
2471 | mMainFrame->setSizes(sizes); | 2471 | mMainFrame->setSizes(sizes); |
2472 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 2472 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
2473 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 2473 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
2474 | else mNavigator->selectDates( dateCount ); | 2474 | else mNavigator->selectDates( dateCount ); |
2475 | // mViewManager->readSettings( config ); | 2475 | // mViewManager->readSettings( config ); |
2476 | updateConfig(); | 2476 | updateConfig(); |
2477 | globalFlagBlockAgenda = 2; | 2477 | globalFlagBlockAgenda = 2; |
2478 | mViewManager->readSettings( config ); | 2478 | mViewManager->readSettings( config ); |
2479 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); | 2479 | QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); |
2480 | } | 2480 | } |
2481 | 2481 | ||
2482 | void CalendarView::checkSuspendAlarm() | 2482 | void CalendarView::checkSuspendAlarm() |
2483 | { | 2483 | { |
2484 | if ( mSuspendTimer->isActive() ) { | 2484 | if ( mSuspendTimer->isActive() ) { |
2485 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); | 2485 | KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); |
2486 | } | 2486 | } |
2487 | } | 2487 | } |
2488 | void CalendarView::writeSettings() | 2488 | void CalendarView::writeSettings() |
2489 | { | 2489 | { |
2490 | // kdDebug() << "CalendarView::writeSettings" << endl; | 2490 | // kdDebug() << "CalendarView::writeSettings" << endl; |
2491 | 2491 | ||
2492 | KConfig *config = KOGlobals::config(); | 2492 | KConfig *config = KOGlobals::config(); |
2493 | 2493 | ||
2494 | mViewManager->writeSettings( config ); | 2494 | mViewManager->writeSettings( config ); |
2495 | mTodoList->saveLayout(config,QString("Todo Layout")); | 2495 | mTodoList->saveLayout(config,QString("Todo Layout")); |
2496 | mDialogManager->writeSettings( config ); | 2496 | mDialogManager->writeSettings( config ); |
2497 | //KOPrefs::instance()->usrWriteConfig(); | 2497 | //KOPrefs::instance()->usrWriteConfig(); |
2498 | KOPrefs::instance()->writeConfig(); | 2498 | KOPrefs::instance()->writeConfig(); |
2499 | 2499 | ||
2500 | writeFilterSettings(config); | 2500 | writeFilterSettings(config); |
2501 | config->setGroup( "AppRun" ); | 2501 | config->setGroup( "AppRun" ); |
2502 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 2502 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
2503 | int days = dt.daysTo( QDate::currentDate() ); | 2503 | int days = dt.daysTo( QDate::currentDate() ); |
2504 | dt = dt.addDays( days ); | 2504 | dt = dt.addDays( days ); |
2505 | int secs = dt.secsTo( QDateTime::currentDateTime() ); | 2505 | int secs = dt.secsTo( QDateTime::currentDateTime() ); |
2506 | config->writeEntry( "LatestProgramStopDays", days ); | 2506 | config->writeEntry( "LatestProgramStopDays", days ); |
2507 | config->writeEntry( "LatestProgramStopSecs", secs ); | 2507 | config->writeEntry( "LatestProgramStopSecs", secs ); |
2508 | //qDebug("KO: Writing stop time: %d ", secs); | 2508 | //qDebug("KO: Writing stop time: %d ", secs); |
2509 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); | 2509 | //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); |
2510 | //QDateTime latest = dt.addSecs ( secs ); | 2510 | //QDateTime latest = dt.addSecs ( secs ); |
2511 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); | 2511 | //qDebug("KO: Termination on %s ", latest.toString().latin1()); |
2512 | config->setGroup( "Views" ); | 2512 | config->setGroup( "Views" ); |
2513 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 2513 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
2514 | 2514 | ||
2515 | #if 0 | 2515 | #if 0 |
2516 | qDebug("********************* "); | 2516 | qDebug("********************* "); |
2517 | qDebug("Testcode secsto "); | 2517 | qDebug("Testcode secsto "); |
2518 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); | 2518 | QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); |
2519 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); | 2519 | QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); |
2520 | int secsto = dt_nodaylight.secsTo( dt_daylight ); | 2520 | int secsto = dt_nodaylight.secsTo( dt_daylight ); |
2521 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); | 2521 | QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); |
2522 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); | 2522 | qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); |
2523 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); | 2523 | qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); |
2524 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); | 2524 | qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); |
2525 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); | 2525 | qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); |
2526 | qDebug("********************* testcode end"); | 2526 | qDebug("********************* testcode end"); |
2527 | 2527 | ||
2528 | #endif | 2528 | #endif |
2529 | 2529 | ||
2530 | QValueList<int> listINT = mLeftFrame->sizes(); | 2530 | QValueList<int> listINT = mLeftFrame->sizes(); |
2531 | config->writeEntry("Left Splitter Frame",listINT); | 2531 | config->writeEntry("Left Splitter Frame",listINT); |
2532 | QValueList<int> listINT2 = mMainFrame->sizes(); | 2532 | QValueList<int> listINT2 = mMainFrame->sizes(); |
2533 | config->writeEntry("Main Splitter Frame",listINT2); | 2533 | config->writeEntry("Main Splitter Frame",listINT2); |
2534 | #ifdef DESKTOP_VERSION | 2534 | #ifdef DESKTOP_VERSION |
2535 | config->setGroup("WidgetLayout"); | 2535 | config->setGroup("WidgetLayout"); |
2536 | QStringList list ;//= config->readListEntry("MainLayout"); | 2536 | QStringList list ;//= config->readListEntry("MainLayout"); |
2537 | int x,y,w,h; | 2537 | int x,y,w,h; |
2538 | QWidget* wid; | 2538 | QWidget* wid; |
2539 | wid = topLevelWidget(); | 2539 | wid = topLevelWidget(); |
2540 | x = wid->geometry().x(); | 2540 | x = wid->geometry().x(); |
2541 | y = wid->geometry().y(); | 2541 | y = wid->geometry().y(); |
2542 | w = wid->width(); | 2542 | w = wid->width(); |
2543 | h = wid->height(); | 2543 | h = wid->height(); |
2544 | list.clear(); | 2544 | list.clear(); |
2545 | list << QString::number( x ); | 2545 | list << QString::number( x ); |
2546 | list << QString::number( y ); | 2546 | list << QString::number( y ); |
2547 | list << QString::number( w ); | 2547 | list << QString::number( w ); |
2548 | list << QString::number( h ); | 2548 | list << QString::number( h ); |
2549 | config->writeEntry("MainLayout",list ); | 2549 | config->writeEntry("MainLayout",list ); |
2550 | 2550 | ||
2551 | wid = mEventEditor; | 2551 | wid = mEventEditor; |
2552 | x = wid->geometry().x(); | 2552 | x = wid->geometry().x(); |
2553 | y = wid->geometry().y(); | 2553 | y = wid->geometry().y(); |
2554 | w = wid->width(); | 2554 | w = wid->width(); |
2555 | h = wid->height(); | 2555 | h = wid->height(); |
2556 | list.clear(); | 2556 | list.clear(); |
2557 | list << QString::number( x ); | 2557 | list << QString::number( x ); |
2558 | list << QString::number( y ); | 2558 | list << QString::number( y ); |
2559 | list << QString::number( w ); | 2559 | list << QString::number( w ); |
2560 | list << QString::number( h ); | 2560 | list << QString::number( h ); |
2561 | config->writeEntry("EditEventLayout",list ); | 2561 | config->writeEntry("EditEventLayout",list ); |
2562 | 2562 | ||
2563 | wid = mTodoEditor; | 2563 | wid = mTodoEditor; |
2564 | x = wid->geometry().x(); | 2564 | x = wid->geometry().x(); |
2565 | y = wid->geometry().y(); | 2565 | y = wid->geometry().y(); |
2566 | w = wid->width(); | 2566 | w = wid->width(); |
2567 | h = wid->height(); | 2567 | h = wid->height(); |
2568 | list.clear(); | 2568 | list.clear(); |
2569 | list << QString::number( x ); | 2569 | list << QString::number( x ); |
2570 | list << QString::number( y ); | 2570 | list << QString::number( y ); |
2571 | list << QString::number( w ); | 2571 | list << QString::number( w ); |
2572 | list << QString::number( h ); | 2572 | list << QString::number( h ); |
2573 | config->writeEntry("EditTodoLayout",list ); | 2573 | config->writeEntry("EditTodoLayout",list ); |
2574 | wid = getEventViewerDialog(); | 2574 | wid = getEventViewerDialog(); |
2575 | x = wid->geometry().x(); | 2575 | x = wid->geometry().x(); |
2576 | y = wid->geometry().y(); | 2576 | y = wid->geometry().y(); |
2577 | w = wid->width(); | 2577 | w = wid->width(); |
2578 | h = wid->height(); | 2578 | h = wid->height(); |
2579 | list.clear(); | 2579 | list.clear(); |
2580 | list << QString::number( x ); | 2580 | list << QString::number( x ); |
2581 | list << QString::number( y ); | 2581 | list << QString::number( y ); |
2582 | list << QString::number( w ); | 2582 | list << QString::number( w ); |
2583 | list << QString::number( h ); | 2583 | list << QString::number( h ); |
2584 | config->writeEntry("ViewerLayout",list ); | 2584 | config->writeEntry("ViewerLayout",list ); |
2585 | wid = mDialogManager->getSearchDialog(); | 2585 | wid = mDialogManager->getSearchDialog(); |
2586 | if ( wid ) { | 2586 | if ( wid ) { |
2587 | x = wid->geometry().x(); | 2587 | x = wid->geometry().x(); |
2588 | y = wid->geometry().y(); | 2588 | y = wid->geometry().y(); |
2589 | w = wid->width(); | 2589 | w = wid->width(); |
2590 | h = wid->height(); | 2590 | h = wid->height(); |
2591 | list.clear(); | 2591 | list.clear(); |
2592 | list << QString::number( x ); | 2592 | list << QString::number( x ); |
2593 | list << QString::number( y ); | 2593 | list << QString::number( y ); |
2594 | list << QString::number( w ); | 2594 | list << QString::number( w ); |
2595 | list << QString::number( h ); | 2595 | list << QString::number( h ); |
2596 | config->writeEntry("SearchLayout",list ); | 2596 | config->writeEntry("SearchLayout",list ); |
2597 | } | 2597 | } |
2598 | #endif | 2598 | #endif |
2599 | 2599 | ||
2600 | 2600 | ||
2601 | config->sync(); | 2601 | config->sync(); |
2602 | } | 2602 | } |
2603 | 2603 | ||
2604 | void CalendarView::readFilterSettings(KConfig *config) | 2604 | void CalendarView::readFilterSettings(KConfig *config) |
2605 | { | 2605 | { |
2606 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2606 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2607 | 2607 | ||
2608 | mFilters.clear(); | 2608 | mFilters.clear(); |
2609 | 2609 | ||
2610 | config->setGroup("General"); | 2610 | config->setGroup("General"); |
2611 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2611 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2612 | 2612 | ||
2613 | QStringList::ConstIterator it = filterList.begin(); | 2613 | QStringList::ConstIterator it = filterList.begin(); |
2614 | QStringList::ConstIterator end = filterList.end(); | 2614 | QStringList::ConstIterator end = filterList.end(); |
2615 | while(it != end) { | 2615 | while(it != end) { |
2616 | // kdDebug() << " filter: " << (*it) << endl; | 2616 | // kdDebug() << " filter: " << (*it) << endl; |
2617 | 2617 | ||
2618 | CalFilter *filter; | 2618 | CalFilter *filter; |
2619 | filter = new CalFilter(*it); | 2619 | filter = new CalFilter(*it); |
2620 | config->setGroup("Filter_" + (*it).utf8()); | 2620 | config->setGroup("Filter_" + (*it).utf8()); |
2621 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2621 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2622 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2622 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2623 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2623 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2624 | mFilters.append(filter); | 2624 | mFilters.append(filter); |
2625 | 2625 | ||
2626 | ++it; | 2626 | ++it; |
2627 | } | 2627 | } |
2628 | 2628 | ||
2629 | if (mFilters.count() == 0) { | 2629 | if (mFilters.count() == 0) { |
2630 | CalFilter *filter = new CalFilter(i18n("Default")); | 2630 | CalFilter *filter = new CalFilter(i18n("Default")); |
2631 | mFilters.append(filter); | 2631 | mFilters.append(filter); |
2632 | } | 2632 | } |
2633 | mFilterView->updateFilters(); | 2633 | mFilterView->updateFilters(); |
2634 | config->setGroup("FilterView"); | 2634 | config->setGroup("FilterView"); |
2635 | 2635 | ||
2636 | mFilterView->blockSignals(true); | 2636 | mFilterView->blockSignals(true); |
2637 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2637 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2638 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2638 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2639 | mFilterView->blockSignals(false); | 2639 | mFilterView->blockSignals(false); |
2640 | // We do it manually to avoid it being done twice by the above calls | 2640 | // We do it manually to avoid it being done twice by the above calls |
2641 | updateFilter(); | 2641 | updateFilter(); |
2642 | } | 2642 | } |
2643 | 2643 | ||
2644 | void CalendarView::writeFilterSettings(KConfig *config) | 2644 | void CalendarView::writeFilterSettings(KConfig *config) |
2645 | { | 2645 | { |
2646 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2646 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2647 | 2647 | ||
2648 | QStringList filterList; | 2648 | QStringList filterList; |
2649 | 2649 | ||
2650 | CalFilter *filter = mFilters.first(); | 2650 | CalFilter *filter = mFilters.first(); |
2651 | while(filter) { | 2651 | while(filter) { |
2652 | // kdDebug() << " fn: " << filter->name() << endl; | 2652 | // kdDebug() << " fn: " << filter->name() << endl; |
2653 | filterList << filter->name(); | 2653 | filterList << filter->name(); |
2654 | config->setGroup("Filter_" + filter->name().utf8()); | 2654 | config->setGroup("Filter_" + filter->name().utf8()); |
2655 | config->writeEntry("Criteria",filter->criteria()); | 2655 | config->writeEntry("Criteria",filter->criteria()); |
2656 | config->writeEntry("CategoryList",filter->categoryList()); | 2656 | config->writeEntry("CategoryList",filter->categoryList()); |
2657 | filter = mFilters.next(); | 2657 | filter = mFilters.next(); |
2658 | } | 2658 | } |
2659 | config->setGroup("General"); | 2659 | config->setGroup("General"); |
2660 | config->writeEntry("CalendarFilters",filterList); | 2660 | config->writeEntry("CalendarFilters",filterList); |
2661 | 2661 | ||
2662 | config->setGroup("FilterView"); | 2662 | config->setGroup("FilterView"); |
2663 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2663 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2664 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2664 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2665 | } | 2665 | } |
2666 | 2666 | ||
2667 | 2667 | ||
2668 | void CalendarView::goToday() | 2668 | void CalendarView::goToday() |
2669 | { | 2669 | { |
2670 | if ( mViewManager->currentView()->isMonthView() ) | 2670 | if ( mViewManager->currentView()->isMonthView() ) |
2671 | mNavigator->selectTodayMonth(); | 2671 | mNavigator->selectTodayMonth(); |
2672 | else | 2672 | else |
2673 | mNavigator->selectToday(); | 2673 | mNavigator->selectToday(); |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | void CalendarView::goNext() | 2676 | void CalendarView::goNext() |
2677 | { | 2677 | { |
2678 | mNavigator->selectNext(); | 2678 | mNavigator->selectNext(); |
2679 | } | 2679 | } |
2680 | 2680 | ||
2681 | void CalendarView::goPrevious() | 2681 | void CalendarView::goPrevious() |
2682 | { | 2682 | { |
2683 | mNavigator->selectPrevious(); | 2683 | mNavigator->selectPrevious(); |
2684 | } | 2684 | } |
2685 | void CalendarView::goNextMonth() | 2685 | void CalendarView::goNextMonth() |
2686 | { | 2686 | { |
2687 | mNavigator->selectNextMonth(); | 2687 | mNavigator->selectNextMonth(); |
2688 | } | 2688 | } |
2689 | 2689 | ||
2690 | void CalendarView::goPreviousMonth() | 2690 | void CalendarView::goPreviousMonth() |
2691 | { | 2691 | { |
2692 | mNavigator->selectPreviousMonth(); | 2692 | mNavigator->selectPreviousMonth(); |
2693 | } | 2693 | } |
2694 | 2694 | ||
2695 | void CalendarView::updateConfig() | 2695 | void CalendarView::updateConfig() |
2696 | { | 2696 | { |
2697 | if ( KOPrefs::instance()->mUseAppColors ) | 2697 | if ( KOPrefs::instance()->mUseAppColors ) |
2698 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2698 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2699 | emit configChanged(); | 2699 | emit configChanged(); |
2700 | mTodoList->updateConfig(); | 2700 | mTodoList->updateConfig(); |
2701 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2701 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2702 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2702 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2703 | // To make the "fill window" configurations work | 2703 | // To make the "fill window" configurations work |
2704 | //mViewManager->raiseCurrentView(); | 2704 | //mViewManager->raiseCurrentView(); |
2705 | } | 2705 | } |
2706 | 2706 | ||
2707 | 2707 | ||
2708 | void CalendarView::eventChanged(Event *event) | 2708 | void CalendarView::eventChanged(Event *event) |
2709 | { | 2709 | { |
2710 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2710 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2711 | //updateUnmanagedViews(); | 2711 | //updateUnmanagedViews(); |
2712 | } | 2712 | } |
2713 | 2713 | ||
2714 | void CalendarView::eventAdded(Event *event) | 2714 | void CalendarView::eventAdded(Event *event) |
2715 | { | 2715 | { |
2716 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2716 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2717 | } | 2717 | } |
2718 | 2718 | ||
2719 | void CalendarView::eventToBeDeleted(Event *) | 2719 | void CalendarView::eventToBeDeleted(Event *) |
2720 | { | 2720 | { |
2721 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2721 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2722 | } | 2722 | } |
2723 | 2723 | ||
2724 | void CalendarView::eventDeleted() | 2724 | void CalendarView::eventDeleted() |
2725 | { | 2725 | { |
2726 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2726 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2727 | } | 2727 | } |
2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2728 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2729 | { | 2729 | { |
2730 | changeIncidenceDisplay((Incidence *)which, action); | 2730 | changeIncidenceDisplay((Incidence *)which, action); |
2731 | mDateNavigator->updateView(); //LR | 2731 | mDateNavigator->updateView(); //LR |
2732 | //mDialogManager->updateSearchDialog(); | 2732 | //mDialogManager->updateSearchDialog(); |
2733 | 2733 | ||
2734 | if (which) { | 2734 | if (which) { |
2735 | mViewManager->updateWNview(); | 2735 | mViewManager->updateWNview(); |
2736 | //mTodoList->updateView(); | 2736 | //mTodoList->updateView(); |
2737 | } | 2737 | } |
2738 | 2738 | ||
2739 | } | 2739 | } |
2740 | 2740 | ||
2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2741 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2742 | { | 2742 | { |
2743 | updateUnmanagedViews(); | 2743 | updateUnmanagedViews(); |
2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2744 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2745 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2746 | mCalendar->checkAlarmForIncidence( 0, true ); | 2746 | mCalendar->checkAlarmForIncidence( 0, true ); |
2747 | if ( mEventViewerDialog ) | 2747 | if ( mEventViewerDialog ) |
2748 | mEventViewerDialog->hide(); | 2748 | mEventViewerDialog->hide(); |
2749 | } | 2749 | } |
2750 | else | 2750 | else |
2751 | mCalendar->checkAlarmForIncidence( which , false ); | 2751 | mCalendar->checkAlarmForIncidence( which , false ); |
2752 | } | 2752 | } |
2753 | 2753 | ||
2754 | // most of the changeEventDisplays() right now just call the view's | 2754 | // most of the changeEventDisplays() right now just call the view's |
2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2755 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2756 | void CalendarView::changeEventDisplay(Event *which, int action) | 2756 | void CalendarView::changeEventDisplay(Event *which, int action) |
2757 | { | 2757 | { |
2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2758 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2759 | changeIncidenceDisplay((Incidence *)which, action); | 2759 | changeIncidenceDisplay((Incidence *)which, action); |
2760 | static bool clearallviews = false; | 2760 | static bool clearallviews = false; |
2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2761 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2762 | if ( clearallviews ) { | 2762 | if ( clearallviews ) { |
2763 | clearAllViews(); | 2763 | clearAllViews(); |
2764 | clearallviews = false; | 2764 | clearallviews = false; |
2765 | } | 2765 | } |
2766 | return; | 2766 | return; |
2767 | } | 2767 | } |
2768 | clearallviews = true; | 2768 | clearallviews = true; |
2769 | mDateNavigator->updateView(); | 2769 | mDateNavigator->updateView(); |
2770 | //mDialogManager->updateSearchDialog(); | 2770 | //mDialogManager->updateSearchDialog(); |
2771 | if (which) { | 2771 | if (which) { |
2772 | // If there is an event view visible update the display | 2772 | // If there is an event view visible update the display |
2773 | mViewManager->currentView()->changeEventDisplay(which,action); | 2773 | mViewManager->currentView()->changeEventDisplay(which,action); |
2774 | // TODO: check, if update needed | 2774 | // TODO: check, if update needed |
2775 | // if (which->getTodoStatus()) { | 2775 | // if (which->getTodoStatus()) { |
2776 | mTodoList->updateView(); | 2776 | mTodoList->updateView(); |
2777 | if ( action != KOGlobals::EVENTDELETED ) { | 2777 | if ( action != KOGlobals::EVENTDELETED ) { |
2778 | mConflictingEvent = which ; | 2778 | mConflictingEvent = which ; |
2779 | int time = 1000; | 2779 | int time = 1000; |
2780 | #ifdef DESKTOP_VERSION | 2780 | #ifdef DESKTOP_VERSION |
2781 | time = 500; | 2781 | time = 500; |
2782 | #endif | 2782 | #endif |
2783 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); | 2783 | QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); |
2784 | } | 2784 | } |
2785 | // } | 2785 | // } |
2786 | } else { | 2786 | } else { |
2787 | mViewManager->currentView()->updateView(); | 2787 | mViewManager->currentView()->updateView(); |
2788 | } | 2788 | } |
2789 | } | 2789 | } |
2790 | void CalendarView::checkConflictForEvent() | 2790 | void CalendarView::checkConflictForEvent() |
2791 | { | 2791 | { |
2792 | 2792 | ||
2793 | if (!KOPrefs::instance()->mConfirm) | 2793 | if (!KOPrefs::instance()->mConfirm) |
2794 | return; | 2794 | return; |
2795 | if ( ! mConflictingEvent ) return; | 2795 | if ( ! mConflictingEvent ) return; |
2796 | QDateTime current = QDateTime::currentDateTime(); | 2796 | QDateTime current = QDateTime::currentDateTime(); |
2797 | if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { | 2797 | if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { |
2798 | mConflictingEvent = 0; | 2798 | mConflictingEvent = 0; |
2799 | return; | 2799 | return; |
2800 | } | 2800 | } |
2801 | QPtrList<Event> testlist = mCalendar->events(); | 2801 | QPtrList<Event> testlist = mCalendar->events(); |
2802 | Event * test = testlist.first(); | 2802 | Event * test = testlist.first(); |
2803 | QDateTime conflict; | 2803 | QDateTime conflict; |
2804 | QDateTime retVal; | 2804 | QDateTime retVal; |
2805 | bool found = false; | 2805 | bool found = false; |
2806 | Event * cE = 0; | 2806 | Event * cE = 0; |
2807 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); | 2807 | topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); |
2808 | while ( test ) { | 2808 | while ( test ) { |
2809 | qApp->processEvents(); | 2809 | qApp->processEvents(); |
2810 | bool skip = false; | 2810 | bool skip = false; |
2811 | if ( found ) | 2811 | if ( found ) |
2812 | skip = !test->matchTime( ¤t, &conflict ); | 2812 | skip = !test->matchTime( ¤t, &conflict ); |
2813 | else | 2813 | else |
2814 | skip = !test->matchTime( ¤t, 0 ); | 2814 | skip = !test->matchTime( ¤t, 0 ); |
2815 | if ( !skip && !test->doesFloat() ) { | 2815 | if ( !skip && !test->doesFloat() ) { |
2816 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { | 2816 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2817 | if ( ! found ) { | 2817 | if ( ! found ) { |
2818 | conflict = retVal; | 2818 | conflict = retVal; |
2819 | cE = test; | 2819 | cE = test; |
2820 | } else { | 2820 | } else { |
2821 | if ( retVal < conflict ) { | 2821 | if ( retVal < conflict ) { |
2822 | conflict = retVal; | 2822 | conflict = retVal; |
2823 | cE = test; | 2823 | cE = test; |
2824 | } | 2824 | } |
2825 | } | 2825 | } |
2826 | found = true; | 2826 | found = true; |
2827 | } | 2827 | } |
2828 | } | 2828 | } |
2829 | test = testlist.next(); | 2829 | test = testlist.next(); |
2830 | } | 2830 | } |
2831 | topLevelWidget()->setCaption( i18n("KO/Pi") ); | ||
2831 | if ( found ) { | 2832 | if ( found ) { |
2832 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2833 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2833 | qApp->processEvents(); | 2834 | qApp->processEvents(); |
2834 | int km = KMessageBox::warningContinueCancel(this,mess, | 2835 | int km = KMessageBox::warningContinueCancel(this,mess, |
2835 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2836 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2836 | if ( km != KMessageBox::Continue ) | 2837 | if ( km != KMessageBox::Continue ) { |
2837 | return; | 2838 | return; |
2838 | 2839 | } | |
2839 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2840 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2840 | mViewManager->showDayView(); | 2841 | mViewManager->showDayView(); |
2841 | mNavigator->slotDaySelect( conflict.date() ); | 2842 | mNavigator->slotDaySelect( conflict.date() ); |
2842 | int hour = conflict.time().hour(); | 2843 | int hour = conflict.time().hour(); |
2843 | mViewManager->agendaView()->setStartHour( hour ); | 2844 | mViewManager->agendaView()->setStartHour( hour ); |
2844 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2845 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2845 | } else | 2846 | } else |
2846 | topLevelWidget()->setCaption( i18n("No conflict found") ); | 2847 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
2847 | mConflictingEvent = 0; | 2848 | mConflictingEvent = 0; |
2848 | return; | 2849 | return; |
2849 | 2850 | ||
2850 | } | 2851 | } |
2851 | 2852 | ||
2852 | void CalendarView::updateTodoViews() | 2853 | void CalendarView::updateTodoViews() |
2853 | { | 2854 | { |
2854 | mTodoList->updateView(); | 2855 | mTodoList->updateView(); |
2855 | mViewManager->currentView()->updateView(); | 2856 | mViewManager->currentView()->updateView(); |
2856 | 2857 | ||
2857 | } | 2858 | } |
2858 | 2859 | ||
2859 | 2860 | ||
2860 | 2861 | ||
2861 | void CalendarView::clearAllViews() | 2862 | void CalendarView::clearAllViews() |
2862 | { | 2863 | { |
2863 | mTodoList->clearList(); | 2864 | mTodoList->clearList(); |
2864 | mViewManager->clearAllViews(); | 2865 | mViewManager->clearAllViews(); |
2865 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2866 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2866 | if ( sd ) { | 2867 | if ( sd ) { |
2867 | KOListView* kol = sd->listview(); | 2868 | KOListView* kol = sd->listview(); |
2868 | if ( kol ) | 2869 | if ( kol ) |
2869 | kol->clearList(); | 2870 | kol->clearList(); |
2870 | } | 2871 | } |
2871 | } | 2872 | } |
2872 | void CalendarView::updateView() | 2873 | void CalendarView::updateView() |
2873 | { | 2874 | { |
2874 | static bool clearallviews = false; | 2875 | static bool clearallviews = false; |
2875 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2876 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2876 | if ( clearallviews ) { | 2877 | if ( clearallviews ) { |
2877 | clearAllViews(); | 2878 | clearAllViews(); |
2878 | clearallviews = false; | 2879 | clearallviews = false; |
2879 | } | 2880 | } |
2880 | return; | 2881 | return; |
2881 | } | 2882 | } |
2882 | clearallviews = true; | 2883 | clearallviews = true; |
2883 | DateList tmpList = mNavigator->selectedDates(); | 2884 | DateList tmpList = mNavigator->selectedDates(); |
2884 | 2885 | ||
2885 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2886 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2886 | mTodoList->updateView(); | 2887 | mTodoList->updateView(); |
2887 | // We assume that the navigator only selects consecutive days. | 2888 | // We assume that the navigator only selects consecutive days. |
2888 | updateView( tmpList.first(), tmpList.last() ); | 2889 | updateView( tmpList.first(), tmpList.last() ); |
2889 | } | 2890 | } |
2890 | 2891 | ||
2891 | void CalendarView::updateUnmanagedViews() | 2892 | void CalendarView::updateUnmanagedViews() |
2892 | { | 2893 | { |
2893 | mDateNavigator->updateDayMatrix(); | 2894 | mDateNavigator->updateDayMatrix(); |
2894 | } | 2895 | } |
2895 | 2896 | ||
2896 | int CalendarView::msgItemDelete(const QString name) | 2897 | int CalendarView::msgItemDelete(const QString name) |
2897 | { | 2898 | { |
2898 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2899 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2899 | i18n("This item will be\npermanently deleted."), | 2900 | i18n("This item will be\npermanently deleted."), |
2900 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2901 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2901 | } | 2902 | } |
2902 | 2903 | ||
2903 | 2904 | ||
2904 | void CalendarView::edit_cut() | 2905 | void CalendarView::edit_cut() |
2905 | { | 2906 | { |
2906 | Event *anEvent=0; | 2907 | Event *anEvent=0; |
2907 | 2908 | ||
2908 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2909 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2909 | 2910 | ||
2910 | if (mViewManager->currentView()->isEventView()) { | 2911 | if (mViewManager->currentView()->isEventView()) { |
2911 | if ( incidence && incidence->typeID() == eventID ) { | 2912 | if ( incidence && incidence->typeID() == eventID ) { |
2912 | anEvent = static_cast<Event *>(incidence); | 2913 | anEvent = static_cast<Event *>(incidence); |
2913 | } | 2914 | } |
2914 | } | 2915 | } |
2915 | 2916 | ||
2916 | if (!anEvent) { | 2917 | if (!anEvent) { |
2917 | KNotifyClient::beep(); | 2918 | KNotifyClient::beep(); |
2918 | return; | 2919 | return; |
2919 | } | 2920 | } |
2920 | DndFactory factory( mCalendar ); | 2921 | DndFactory factory( mCalendar ); |
2921 | factory.cutIncidence(anEvent); | 2922 | factory.cutIncidence(anEvent); |
2922 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2923 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2923 | } | 2924 | } |
2924 | 2925 | ||
2925 | void CalendarView::edit_copy() | 2926 | void CalendarView::edit_copy() |
2926 | { | 2927 | { |
2927 | Event *anEvent=0; | 2928 | Event *anEvent=0; |
2928 | 2929 | ||
2929 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2930 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2930 | 2931 | ||
2931 | if (mViewManager->currentView()->isEventView()) { | 2932 | if (mViewManager->currentView()->isEventView()) { |
2932 | if ( incidence && incidence->typeID() == eventID ) { | 2933 | if ( incidence && incidence->typeID() == eventID ) { |
2933 | anEvent = static_cast<Event *>(incidence); | 2934 | anEvent = static_cast<Event *>(incidence); |
2934 | } | 2935 | } |
2935 | } | 2936 | } |
2936 | 2937 | ||
2937 | if (!anEvent) { | 2938 | if (!anEvent) { |
2938 | KNotifyClient::beep(); | 2939 | KNotifyClient::beep(); |
2939 | return; | 2940 | return; |
2940 | } | 2941 | } |
2941 | DndFactory factory( mCalendar ); | 2942 | DndFactory factory( mCalendar ); |
2942 | factory.copyIncidence(anEvent); | 2943 | factory.copyIncidence(anEvent); |
2943 | } | 2944 | } |
2944 | 2945 | ||
2945 | void CalendarView::edit_paste() | 2946 | void CalendarView::edit_paste() |
2946 | { | 2947 | { |
2947 | QDate date = mNavigator->selectedDates().first(); | 2948 | QDate date = mNavigator->selectedDates().first(); |
2948 | 2949 | ||
2949 | DndFactory factory( mCalendar ); | 2950 | DndFactory factory( mCalendar ); |
2950 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2951 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2951 | 2952 | ||
2952 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2953 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2953 | } | 2954 | } |
2954 | void CalendarView::edit_global_options() | 2955 | void CalendarView::edit_global_options() |
2955 | { | 2956 | { |
2956 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2957 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2957 | emit save(); | 2958 | emit save(); |
2958 | emit saveStopTimer(); | 2959 | emit saveStopTimer(); |
2959 | mDialogManager->showGlobalOptionsDialog(); | 2960 | mDialogManager->showGlobalOptionsDialog(); |
2960 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2961 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2961 | emit saveStopTimer(); | 2962 | emit saveStopTimer(); |
2962 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2963 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2963 | i18n("Timezone settings"),i18n("Reload"))) { | 2964 | i18n("Timezone settings"),i18n("Reload"))) { |
2964 | qDebug("KO: TZ reload cancelled "); | 2965 | qDebug("KO: TZ reload cancelled "); |
2965 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2966 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2966 | return; | 2967 | return; |
2967 | } | 2968 | } |
2968 | qDebug("KO: Timezone change "); | 2969 | qDebug("KO: Timezone change "); |
2969 | loadCalendars(); | 2970 | loadCalendars(); |
2970 | setModified(true); | 2971 | setModified(true); |
2971 | } | 2972 | } |
2972 | else | 2973 | else |
2973 | qDebug("KO: No tz change "); | 2974 | qDebug("KO: No tz change "); |
2974 | } | 2975 | } |
2975 | void CalendarView::edit_options() | 2976 | void CalendarView::edit_options() |
2976 | { | 2977 | { |
2977 | mDialogManager->showOptionsDialog(); | 2978 | mDialogManager->showOptionsDialog(); |
2978 | } | 2979 | } |
2979 | 2980 | ||
2980 | 2981 | ||
2981 | void CalendarView::slotSelectPickerDate( QDate d) | 2982 | void CalendarView::slotSelectPickerDate( QDate d) |
2982 | { | 2983 | { |
2983 | mDateFrame->hide(); | 2984 | mDateFrame->hide(); |
2984 | if ( mDatePickerMode == 1 ) { | 2985 | if ( mDatePickerMode == 1 ) { |
2985 | mNavigator->slotDaySelect( d ); | 2986 | mNavigator->slotDaySelect( d ); |
2986 | } else if ( mDatePickerMode == 2 ) { | 2987 | } else if ( mDatePickerMode == 2 ) { |
2987 | if ( mMoveIncidence->typeID() == todoID ) { | 2988 | if ( mMoveIncidence->typeID() == todoID ) { |
2988 | Todo * to = (Todo *) mMoveIncidence; | 2989 | Todo * to = (Todo *) mMoveIncidence; |
2989 | QTime tim; | 2990 | QTime tim; |
2990 | int len = 0; | 2991 | int len = 0; |
2991 | if ( to->hasStartDate() && to->hasDueDate() ) | 2992 | if ( to->hasStartDate() && to->hasDueDate() ) |
2992 | len = to->dtStart().secsTo( to->dtDue()); | 2993 | len = to->dtStart().secsTo( to->dtDue()); |
2993 | if ( to->hasDueDate() ) | 2994 | if ( to->hasDueDate() ) |
2994 | tim = to->dtDue().time(); | 2995 | tim = to->dtDue().time(); |
2995 | else { | 2996 | else { |
2996 | tim = QTime ( 0,0,0 ); | 2997 | tim = QTime ( 0,0,0 ); |
2997 | to->setFloats( true ); | 2998 | to->setFloats( true ); |
2998 | to->setHasDueDate( true ); | 2999 | to->setHasDueDate( true ); |
2999 | } | 3000 | } |
3000 | QDateTime dt ( d,tim ); | 3001 | QDateTime dt ( d,tim ); |
3001 | to->setDtDue( dt ); | 3002 | to->setDtDue( dt ); |
3002 | 3003 | ||
3003 | if ( to->hasStartDate() ) { | 3004 | if ( to->hasStartDate() ) { |
3004 | if ( len>0 ) | 3005 | if ( len>0 ) |
3005 | to->setDtStart(to->dtDue().addSecs( -len )); | 3006 | to->setDtStart(to->dtDue().addSecs( -len )); |
3006 | else | 3007 | else |
3007 | if (to->dtStart() > to->dtDue() ) | 3008 | if (to->dtStart() > to->dtDue() ) |
3008 | to->setDtStart(to->dtDue().addDays( -3 )); | 3009 | to->setDtStart(to->dtDue().addDays( -3 )); |
3009 | } | 3010 | } |
3010 | 3011 | ||
3011 | todoChanged( to ); | 3012 | todoChanged( to ); |
3012 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3013 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3013 | if ( mMoveIncidence->doesRecur() ) { | 3014 | if ( mMoveIncidence->doesRecur() ) { |
3014 | #if 0 | 3015 | #if 0 |
3015 | // PENDING implement this | 3016 | // PENDING implement this |
3016 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3017 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3017 | mCalendar()->addIncidence( newInc ); | 3018 | mCalendar()->addIncidence( newInc ); |
3018 | if ( mMoveIncidence->typeID() == todoID ) | 3019 | if ( mMoveIncidence->typeID() == todoID ) |
3019 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3020 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3020 | else | 3021 | else |
3021 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3022 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3022 | mMoveIncidence = newInc; | 3023 | mMoveIncidence = newInc; |
3023 | 3024 | ||
3024 | #endif | 3025 | #endif |
3025 | } | 3026 | } |
3026 | QTime tim = mMoveIncidence->dtStart().time(); | 3027 | QTime tim = mMoveIncidence->dtStart().time(); |
3027 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3028 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3028 | QDateTime dt ( d,tim ); | 3029 | QDateTime dt ( d,tim ); |
3029 | mMoveIncidence->setDtStart( dt ); | 3030 | mMoveIncidence->setDtStart( dt ); |
3030 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3031 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3031 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3032 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3032 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3033 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3033 | QTime tim = mMoveIncidence->dtStart().time(); | 3034 | QTime tim = mMoveIncidence->dtStart().time(); |
3034 | QDateTime dt ( d,tim ); | 3035 | QDateTime dt ( d,tim ); |
3035 | mMoveIncidence->setDtStart( dt ); | 3036 | mMoveIncidence->setDtStart( dt ); |
3036 | updateView(); | 3037 | updateView(); |
3037 | } | 3038 | } |
3038 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3039 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3039 | } | 3040 | } |
3040 | } | 3041 | } |
3041 | 3042 | ||
3042 | void CalendarView::removeCategories() | 3043 | void CalendarView::removeCategories() |
3043 | { | 3044 | { |
3044 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3045 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3045 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3046 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3046 | QStringList catIncList; | 3047 | QStringList catIncList; |
3047 | QStringList newCatList; | 3048 | QStringList newCatList; |
3048 | Incidence* inc = incList.first(); | 3049 | Incidence* inc = incList.first(); |
3049 | uint i; | 3050 | uint i; |
3050 | while ( inc ) { | 3051 | while ( inc ) { |
3051 | newCatList.clear(); | 3052 | newCatList.clear(); |
3052 | catIncList = inc->categories() ; | 3053 | catIncList = inc->categories() ; |
3053 | for( i = 0; i< catIncList.count(); ++i ) { | 3054 | for( i = 0; i< catIncList.count(); ++i ) { |
3054 | if ( catList.contains (catIncList[i])) | 3055 | if ( catList.contains (catIncList[i])) |
3055 | newCatList.append( catIncList[i] ); | 3056 | newCatList.append( catIncList[i] ); |
3056 | } | 3057 | } |
3057 | newCatList.sort(); | 3058 | newCatList.sort(); |
3058 | inc->setCategories( newCatList.join(",") ); | 3059 | inc->setCategories( newCatList.join(",") ); |
3059 | inc = incList.next(); | 3060 | inc = incList.next(); |
3060 | } | 3061 | } |
3061 | } | 3062 | } |
3062 | 3063 | ||
3063 | int CalendarView::addCategories() | 3064 | int CalendarView::addCategories() |
3064 | { | 3065 | { |
3065 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3066 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3066 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3067 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3067 | QStringList catIncList; | 3068 | QStringList catIncList; |
3068 | Incidence* inc = incList.first(); | 3069 | Incidence* inc = incList.first(); |
3069 | uint i; | 3070 | uint i; |
3070 | int count = 0; | 3071 | int count = 0; |
3071 | while ( inc ) { | 3072 | while ( inc ) { |
3072 | catIncList = inc->categories() ; | 3073 | catIncList = inc->categories() ; |
3073 | for( i = 0; i< catIncList.count(); ++i ) { | 3074 | for( i = 0; i< catIncList.count(); ++i ) { |
3074 | if ( !catList.contains (catIncList[i])) { | 3075 | if ( !catList.contains (catIncList[i])) { |
3075 | catList.append( catIncList[i] ); | 3076 | catList.append( catIncList[i] ); |
3076 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3077 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3077 | ++count; | 3078 | ++count; |
3078 | } | 3079 | } |
3079 | } | 3080 | } |
3080 | inc = incList.next(); | 3081 | inc = incList.next(); |
3081 | } | 3082 | } |
3082 | catList.sort(); | 3083 | catList.sort(); |
3083 | KOPrefs::instance()->mCustomCategories = catList; | 3084 | KOPrefs::instance()->mCustomCategories = catList; |
3084 | return count; | 3085 | return count; |
3085 | } | 3086 | } |
3086 | 3087 | ||
3087 | void CalendarView::editCategories() | 3088 | void CalendarView::editCategories() |
3088 | { | 3089 | { |
3089 | qDebug("CalendarView::editCategories() "); | 3090 | qDebug("CalendarView::editCategories() "); |
3090 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3091 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3091 | ced.exec(); | 3092 | ced.exec(); |
3092 | } | 3093 | } |
3093 | void CalendarView::manageCategories() | 3094 | void CalendarView::manageCategories() |
3094 | { | 3095 | { |
3095 | KOCatPrefs* cp = new KOCatPrefs(); | 3096 | KOCatPrefs* cp = new KOCatPrefs(); |
3096 | cp->show(); | 3097 | cp->show(); |
3097 | int w =cp->sizeHint().width() ; | 3098 | int w =cp->sizeHint().width() ; |
3098 | int h = cp->sizeHint().height() ; | 3099 | int h = cp->sizeHint().height() ; |
3099 | int dw = QApplication::desktop()->width(); | 3100 | int dw = QApplication::desktop()->width(); |
3100 | int dh = QApplication::desktop()->height(); | 3101 | int dh = QApplication::desktop()->height(); |
3101 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3102 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3102 | if ( !cp->exec() ) { | 3103 | if ( !cp->exec() ) { |
3103 | delete cp; | 3104 | delete cp; |
3104 | return; | 3105 | return; |
3105 | } | 3106 | } |
3106 | int count = 0; | 3107 | int count = 0; |
3107 | if ( cp->addCat() ) { | 3108 | if ( cp->addCat() ) { |
3108 | count = addCategories(); | 3109 | count = addCategories(); |
3109 | if ( count ) { | 3110 | if ( count ) { |
3110 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3111 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3111 | writeSettings(); | 3112 | writeSettings(); |
3112 | } else | 3113 | } else |
3113 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3114 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3114 | } else { | 3115 | } else { |
3115 | removeCategories(); | 3116 | removeCategories(); |
3116 | updateView(); | 3117 | updateView(); |
3117 | } | 3118 | } |
3118 | delete cp; | 3119 | delete cp; |
3119 | } | 3120 | } |
3120 | 3121 | ||
3121 | void CalendarView::beamIncidence(Incidence * Inc) | 3122 | void CalendarView::beamIncidence(Incidence * Inc) |
3122 | { | 3123 | { |
3123 | QPtrList<Incidence> delSel ; | 3124 | QPtrList<Incidence> delSel ; |
3124 | delSel.append(Inc); | 3125 | delSel.append(Inc); |
3125 | beamIncidenceList( delSel ); | 3126 | beamIncidenceList( delSel ); |
3126 | } | 3127 | } |
3127 | void CalendarView::beamCalendar() | 3128 | void CalendarView::beamCalendar() |
3128 | { | 3129 | { |
3129 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3130 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3130 | //qDebug("beamCalendar() "); | 3131 | //qDebug("beamCalendar() "); |
3131 | beamIncidenceList( delSel ); | 3132 | beamIncidenceList( delSel ); |
3132 | } | 3133 | } |
3133 | void CalendarView::beamFilteredCalendar() | 3134 | void CalendarView::beamFilteredCalendar() |
3134 | { | 3135 | { |
3135 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3136 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3136 | //qDebug("beamFilteredCalendar() "); | 3137 | //qDebug("beamFilteredCalendar() "); |
3137 | beamIncidenceList( delSel ); | 3138 | beamIncidenceList( delSel ); |
3138 | } | 3139 | } |
3139 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3140 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3140 | { | 3141 | { |
3141 | 3142 | ||
3142 | KOBeamPrefs beamDialog; | 3143 | KOBeamPrefs beamDialog; |
3143 | if ( beamDialog.exec () == QDialog::Rejected ) | 3144 | if ( beamDialog.exec () == QDialog::Rejected ) |
3144 | return; | 3145 | return; |
3145 | #ifdef DESKTOP_VERSION | 3146 | #ifdef DESKTOP_VERSION |
3146 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3147 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3147 | #else | 3148 | #else |
3148 | QString fn = "/tmp/kopibeamfile"; | 3149 | QString fn = "/tmp/kopibeamfile"; |
3149 | #endif | 3150 | #endif |
3150 | QString mes; | 3151 | QString mes; |
3151 | bool createbup = true; | 3152 | bool createbup = true; |
3152 | if ( createbup ) { | 3153 | if ( createbup ) { |
3153 | QString description = "\n"; | 3154 | QString description = "\n"; |
3154 | CalendarLocal* cal = new CalendarLocal(); | 3155 | CalendarLocal* cal = new CalendarLocal(); |
3155 | if ( beamDialog.beamLocal() ) | 3156 | if ( beamDialog.beamLocal() ) |
3156 | cal->setLocalTime(); | 3157 | cal->setLocalTime(); |
3157 | else | 3158 | else |
3158 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3159 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3159 | Incidence *incidence = delSel.first(); | 3160 | Incidence *incidence = delSel.first(); |
3160 | bool addText = false; | 3161 | bool addText = false; |
3161 | if ( delSel.count() < 10 ) | 3162 | if ( delSel.count() < 10 ) |
3162 | addText = true; | 3163 | addText = true; |
3163 | else { | 3164 | else { |
3164 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3165 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3165 | } | 3166 | } |
3166 | while ( incidence ) { | 3167 | while ( incidence ) { |
3167 | Incidence *in = incidence->clone(); | 3168 | Incidence *in = incidence->clone(); |
3168 | if ( ! in->summary().isEmpty() ) { | 3169 | if ( ! in->summary().isEmpty() ) { |
3169 | in->setDescription(""); | 3170 | in->setDescription(""); |
3170 | } else { | 3171 | } else { |
3171 | in->setSummary( in->description().left(20)); | 3172 | in->setSummary( in->description().left(20)); |
3172 | in->setDescription(""); | 3173 | in->setDescription(""); |
3173 | } | 3174 | } |
3174 | if ( addText ) | 3175 | if ( addText ) |
3175 | description += in->summary() + "\n"; | 3176 | description += in->summary() + "\n"; |
3176 | cal->addIncidence( in ); | 3177 | cal->addIncidence( in ); |
3177 | incidence = delSel.next(); | 3178 | incidence = delSel.next(); |
3178 | } | 3179 | } |
3179 | if ( beamDialog.beamVcal() ) { | 3180 | if ( beamDialog.beamVcal() ) { |
3180 | fn += ".vcs"; | 3181 | fn += ".vcs"; |
3181 | FileStorage storage( cal, fn, new VCalFormat ); | 3182 | FileStorage storage( cal, fn, new VCalFormat ); |
3182 | storage.save(); | 3183 | storage.save(); |
3183 | } else { | 3184 | } else { |
3184 | fn += ".ics"; | 3185 | fn += ".ics"; |
3185 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3186 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3186 | storage.save(); | 3187 | storage.save(); |
3187 | } | 3188 | } |
3188 | delete cal; | 3189 | delete cal; |
3189 | mes = i18n("KO/Pi: Ready for beaming"); | 3190 | mes = i18n("KO/Pi: Ready for beaming"); |
3190 | topLevelWidget()->setCaption(mes); | 3191 | topLevelWidget()->setCaption(mes); |
3191 | KApplication::convert2latin1( fn ); | 3192 | KApplication::convert2latin1( fn ); |
3192 | #ifndef DESKTOP_VERSION | 3193 | #ifndef DESKTOP_VERSION |
3193 | Ir *ir = new Ir( this ); | 3194 | Ir *ir = new Ir( this ); |
3194 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3195 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3195 | ir->send( fn, description, "text/x-vCalendar" ); | 3196 | ir->send( fn, description, "text/x-vCalendar" ); |
3196 | #endif | 3197 | #endif |
3197 | } | 3198 | } |
3198 | } | 3199 | } |
3199 | 3200 | ||
3200 | #ifndef DESKTOP_VERSION | 3201 | #ifndef DESKTOP_VERSION |
3201 | void CalendarView::beamDone( Ir *ir ) | 3202 | void CalendarView::beamDone( Ir *ir ) |
3202 | { | 3203 | { |
3203 | delete ir; | 3204 | delete ir; |
3204 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3205 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3205 | topLevelWidget()->raise(); | 3206 | topLevelWidget()->raise(); |
3206 | } | 3207 | } |
3207 | #else | 3208 | #else |
3208 | void CalendarView::beamDone( Ir *){;} | 3209 | void CalendarView::beamDone( Ir *){;} |
3209 | #endif | 3210 | #endif |
3210 | void CalendarView::moveIncidence(Incidence * inc ) | 3211 | void CalendarView::moveIncidence(Incidence * inc ) |
3211 | { | 3212 | { |
3212 | if ( !inc ) return; | 3213 | if ( !inc ) return; |
3213 | showDatePickerPopup(); | 3214 | showDatePickerPopup(); |
3214 | mDatePickerMode = 2; | 3215 | mDatePickerMode = 2; |
3215 | mMoveIncidence = inc ; | 3216 | mMoveIncidence = inc ; |
3216 | QDate da; | 3217 | QDate da; |
3217 | if ( mMoveIncidence->typeID() == todoID ) { | 3218 | if ( mMoveIncidence->typeID() == todoID ) { |
3218 | Todo * to = (Todo *) mMoveIncidence; | 3219 | Todo * to = (Todo *) mMoveIncidence; |
3219 | if ( to->hasDueDate() ) | 3220 | if ( to->hasDueDate() ) |
3220 | da = to->dtDue().date(); | 3221 | da = to->dtDue().date(); |
3221 | else | 3222 | else |
3222 | da = QDate::currentDate(); | 3223 | da = QDate::currentDate(); |
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp index 7ce3f1f..6a6fff9 100644 --- a/korganizer/kofilterview.cpp +++ b/korganizer/kofilterview.cpp | |||
@@ -1,486 +1,490 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcheckbox.h> | 24 | #include <qcheckbox.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qdialog.h> | 29 | #include <qdialog.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | 32 | ||
33 | 33 | ||
34 | #include <libkcal/calfilter.h> | 34 | #include <libkcal/calfilter.h> |
35 | 35 | ||
36 | #include "kofilterview.h" | 36 | #include "kofilterview.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #include <kiconloader.h> | 38 | #include <kiconloader.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <kglobalsettings.h> | 40 | #include <kglobalsettings.h> |
41 | #include <kcolorbutton.h> | 41 | #include <kcolorbutton.h> |
42 | #include <kmessagebox.h> | 42 | #include <kmessagebox.h> |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | ||
47 | 47 | ||
48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, | 48 | KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, |
49 | const char* name,WFlags fl ) | 49 | const char* name,WFlags fl ) |
50 | : KOFilterView_base(parent,name,fl) | 50 | : KOFilterView_base(parent,name,fl) |
51 | { | 51 | { |
52 | mFilters = filterList; | 52 | mFilters = filterList; |
53 | 53 | ||
54 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); | 54 | connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); |
55 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); | 55 | connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); |
56 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); | 56 | connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); |
57 | } | 57 | } |
58 | 58 | ||
59 | KOFilterView::~KOFilterView() | 59 | KOFilterView::~KOFilterView() |
60 | { | 60 | { |
61 | // no need to delete child widgets, Qt does it all for us | 61 | // no need to delete child widgets, Qt does it all for us |
62 | } | 62 | } |
63 | 63 | ||
64 | bool KOFilterView::filtersEnabled() | 64 | bool KOFilterView::filtersEnabled() |
65 | { | 65 | { |
66 | return mEnabledCheck->isChecked(); | 66 | return mEnabledCheck->isChecked(); |
67 | } | 67 | } |
68 | 68 | ||
69 | void KOFilterView::setFiltersEnabled(bool set) | 69 | void KOFilterView::setFiltersEnabled(bool set) |
70 | { | 70 | { |
71 | mEnabledCheck->setChecked(set); | 71 | mEnabledCheck->setChecked(set); |
72 | emit filterChanged(); | 72 | emit filterChanged(); |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
76 | void KOFilterView::updateFilters() | 76 | void KOFilterView::updateFilters() |
77 | { | 77 | { |
78 | mSelectionCombo->clear(); | 78 | mSelectionCombo->clear(); |
79 | 79 | ||
80 | CalFilter *filter = mFilters->first(); | 80 | CalFilter *filter = mFilters->first(); |
81 | while(filter) { | 81 | while(filter) { |
82 | mSelectionCombo->insertItem(filter->name()); | 82 | mSelectionCombo->insertItem(filter->name()); |
83 | filter = mFilters->next(); | 83 | filter = mFilters->next(); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | CalFilter *KOFilterView::selectedFilter() | 87 | CalFilter *KOFilterView::selectedFilter() |
88 | { | 88 | { |
89 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); | 89 | CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); |
90 | return f; | 90 | return f; |
91 | } | 91 | } |
92 | 92 | ||
93 | void KOFilterView::setSelectedFilter(QString filterName) | 93 | void KOFilterView::setSelectedFilter(QString filterName) |
94 | { | 94 | { |
95 | int filter_num = mSelectionCombo->count(); | 95 | int filter_num = mSelectionCombo->count(); |
96 | int i; | 96 | int i; |
97 | for (i=0;i<filter_num;i++) { | 97 | for (i=0;i<filter_num;i++) { |
98 | if (mSelectionCombo->text(i)==filterName) | 98 | if (mSelectionCombo->text(i)==filterName) |
99 | mSelectionCombo->setCurrentItem(i); | 99 | mSelectionCombo->setCurrentItem(i); |
100 | } | 100 | } |
101 | emit filterChanged(); | 101 | emit filterChanged(); |
102 | } | 102 | } |
103 | void KOFilterView::setSelectedFilter( int fil ) | 103 | void KOFilterView::setSelectedFilter( int fil ) |
104 | { | 104 | { |
105 | if ( fil >= mSelectionCombo->count() ) | 105 | if ( fil >= mSelectionCombo->count() ) |
106 | return; | 106 | return; |
107 | mSelectionCombo->setCurrentItem( fil ); | 107 | mSelectionCombo->setCurrentItem( fil ); |
108 | emit filterChanged(); | 108 | emit filterChanged(); |
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | KOCalEditView::KOCalEditView(QWidget* parent, | 113 | KOCalEditView::KOCalEditView(QWidget* parent, |
114 | const char* name ) | 114 | const char* name ) |
115 | : QScrollView(parent,name) | 115 | : QScrollView(parent,name) |
116 | { | 116 | { |
117 | mw = 0; | 117 | mw = 0; |
118 | setResizePolicy( AutoOneFit ); | 118 | setResizePolicy( AutoOneFit ); |
119 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); | 119 | setFrameStyle ( QFrame::Panel | QFrame::Plain ); |
120 | setLineWidth ( 1 ); | 120 | setLineWidth ( 1 ); |
121 | setMidLineWidth ( 1 ); | 121 | setMidLineWidth ( 1 ); |
122 | setFocusPolicy(NoFocus); | 122 | setFocusPolicy(NoFocus); |
123 | } | 123 | } |
124 | 124 | ||
125 | KOCalEditView::~KOCalEditView() | 125 | KOCalEditView::~KOCalEditView() |
126 | { | 126 | { |
127 | // no need to delete child widgets, Qt does it all for us | 127 | // no need to delete child widgets, Qt does it all for us |
128 | } | 128 | } |
129 | void KOCalEditView::selectCal(int id ,bool b) | 129 | void KOCalEditView::selectCal(int id ,bool b) |
130 | { | 130 | { |
131 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; | 131 | KOPrefs::instance()->getCalendar( id )->isEnabled = b; |
132 | emit calendarEnabled ( id, b ); | 132 | emit calendarEnabled ( id, b ); |
133 | emit needsUpdate(); | 133 | emit needsUpdate(); |
134 | 134 | ||
135 | } | 135 | } |
136 | void KOCalEditView::selectStdCal( int id ) | 136 | void KOCalEditView::selectStdCal( int id ) |
137 | { | 137 | { |
138 | KOCalRadioButton* it = mStdandardB.first(); | 138 | KOCalRadioButton* it = mStdandardB.first(); |
139 | while ( it ) { | 139 | while ( it ) { |
140 | it->blockSignals( true ); | 140 | it->blockSignals( true ); |
141 | it->setChecked( it->num() == id ); | 141 | it->setChecked( it->num() == id ); |
142 | it->blockSignals( false ); | 142 | it->blockSignals( false ); |
143 | it = mStdandardB.next(); | 143 | it = mStdandardB.next(); |
144 | } | 144 | } |
145 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 145 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
146 | while ( kkf ) { | 146 | while ( kkf ) { |
147 | kkf->isStandard = (kkf->mCalNumber == id ); | 147 | kkf->isStandard = (kkf->mCalNumber == id ); |
148 | kkf = KOPrefs::instance()->mCalendars.next(); | 148 | kkf = KOPrefs::instance()->mCalendars.next(); |
149 | } | 149 | } |
150 | emit setCalendarDefault ( id ); | 150 | emit setCalendarDefault ( id ); |
151 | } | 151 | } |
152 | 152 | ||
153 | void KOCalEditView::selectCalAlarm(int id ,bool b ) | 153 | void KOCalEditView::selectCalAlarm(int id ,bool b ) |
154 | { | 154 | { |
155 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; | 155 | KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; |
156 | emit alarmEnabled ( id , b ); | 156 | emit alarmEnabled ( id , b ); |
157 | emit needsUpdate(); | 157 | emit needsUpdate(); |
158 | } | 158 | } |
159 | void KOCalEditView::selectReadOnly(int id ,bool b ) | 159 | void KOCalEditView::selectReadOnly(int id ,bool b ) |
160 | { | 160 | { |
161 | 161 | ||
162 | emit calendarReadonly ( id , b ); | 162 | emit calendarReadonly ( id , b ); |
163 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; | 163 | KOPrefs::instance()->getCalendar( id )->isReadOnly = b; |
164 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { | 164 | if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { |
165 | findNewStandard(); | 165 | findNewStandard(); |
166 | } | 166 | } |
167 | if ( !b ){ | 167 | if ( !b ){ |
168 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 168 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
169 | while ( kkf ) { | 169 | while ( kkf ) { |
170 | if (kkf->isReadOnly && kkf->isStandard ) { | 170 | if (kkf->isReadOnly && kkf->isStandard ) { |
171 | selectStdCal( id ); | 171 | selectStdCal( id ); |
172 | break; | 172 | break; |
173 | } | 173 | } |
174 | kkf = KOPrefs::instance()->mCalendars.next(); | 174 | kkf = KOPrefs::instance()->mCalendars.next(); |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | mStdandardB.at(id-1)->setEnabled( !b ); | 178 | mStdandardB.at(id-1)->setEnabled( !b ); |
179 | emit needsUpdate(); | 179 | emit needsUpdate(); |
180 | 180 | ||
181 | } | 181 | } |
182 | void KOCalEditView::findNewStandard() | 182 | void KOCalEditView::findNewStandard() |
183 | { | 183 | { |
184 | bool found = false; | 184 | bool found = false; |
185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 185 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
186 | while ( kkf ) { | 186 | while ( kkf ) { |
187 | if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { | 187 | if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { |
188 | found = true; | 188 | found = true; |
189 | selectStdCal( kkf->mCalNumber ); | 189 | selectStdCal( kkf->mCalNumber ); |
190 | break; | 190 | break; |
191 | } | 191 | } |
192 | kkf = KOPrefs::instance()->mCalendars.next(); | 192 | kkf = KOPrefs::instance()->mCalendars.next(); |
193 | } | 193 | } |
194 | if ( !found ) { | 194 | if ( !found ) { |
195 | KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), | 195 | KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), |
196 | i18n("Houston, we have a problem!") ); | 196 | i18n("Houston, we have a problem!") ); |
197 | 197 | ||
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | void KOCalEditView::setColor( const QColor& c, int id ) | 201 | void KOCalEditView::setColor( const QColor& c, int id ) |
202 | { | 202 | { |
203 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; | 203 | KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; |
204 | emit needsUpdate(); | 204 | emit needsUpdate(); |
205 | } | 205 | } |
206 | void KOCalEditView::deleteCal( int id ) | 206 | void KOCalEditView::deleteCal( int id ) |
207 | { | 207 | { |
208 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); | 208 | KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); |
209 | QString name = kkf->mName; | 209 | QString name = kkf->mName; |
210 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); | 210 | QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); |
211 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; | 211 | if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; |
212 | bool findnewstd = kkf->isStandard; | 212 | bool findnewstd = kkf->isStandard; |
213 | emit removeCalendar ( id ); | 213 | emit removeCalendar ( id ); |
214 | KOPrefs::instance()->mCalendars.remove ( kkf ); | 214 | KOPrefs::instance()->mCalendars.remove ( kkf ); |
215 | if ( findnewstd ) findNewStandard(); | 215 | if ( findnewstd ) findNewStandard(); |
216 | emit needsUpdate(); | 216 | emit needsUpdate(); |
217 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 217 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
218 | } | 218 | } |
219 | void KOCalEditView::infoCal( int id ) | 219 | void KOCalEditView::infoCal( int id ) |
220 | { | 220 | { |
221 | QString name = KOPrefs::instance()->getCalendar( id )->mName; | 221 | QString name = KOPrefs::instance()->getCalendar( id )->mName; |
222 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); | 222 | QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); |
223 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { | 223 | if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { |
224 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { | 224 | if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { |
225 | emit calendarAdded( id ); | 225 | emit calendarAdded( id ); |
226 | emit needsUpdate(); | 226 | emit needsUpdate(); |
227 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 227 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
228 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 228 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
229 | } | 229 | } |
230 | } | 230 | } |
231 | else | 231 | else |
232 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); | 232 | KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); |
233 | } | 233 | } |
234 | void KOCalEditView::readConfig() | 234 | void KOCalEditView::readConfig() |
235 | { | 235 | { |
236 | 236 | ||
237 | mStdandardB.clear(); | 237 | mStdandardB.clear(); |
238 | mEnabledB.clear(); | 238 | mEnabledB.clear(); |
239 | mAlarmB.clear(); | 239 | mAlarmB.clear(); |
240 | mROB.clear(); | 240 | mROB.clear(); |
241 | 241 | ||
242 | if ( mw ) delete mw; | 242 | if ( mw ) delete mw; |
243 | mw = new QWidget ( viewport() ); | 243 | mw = new QWidget ( viewport() ); |
244 | addChild(mw); | 244 | addChild(mw); |
245 | int ii = 0; | 245 | int ii = 0; |
246 | mainLayout = new QGridLayout ( mw , 2, 8 ); | 246 | mainLayout = new QGridLayout ( mw , 2, 8 ); |
247 | mainLayout->setMargin( 2 ); | 247 | mainLayout->setMargin( 2 ); |
248 | mainLayout->setSpacing( 2 ); | 248 | mainLayout->setSpacing( 2 ); |
249 | QPushButton * addButT = new QPushButton ( mw ); | 249 | QPushButton * addButT = new QPushButton ( mw ); |
250 | addButT->setFocusPolicy(NoFocus); | 250 | addButT->setFocusPolicy(NoFocus); |
251 | mainLayout->addWidget( addButT,0,0 ); | 251 | mainLayout->addWidget( addButT,0,0 ); |
252 | addButT->setText( "D"); | 252 | addButT->setText( "D"); |
253 | connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); | 253 | connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); |
254 | //addBut->setPixmap ( SmallIcon("greenhook16")); | 254 | //addBut->setPixmap ( SmallIcon("greenhook16")); |
255 | QPushButton *addBut = new QPushButton ( mw ); | 255 | QPushButton *addBut = new QPushButton ( mw ); |
256 | addBut->setFocusPolicy(NoFocus); | 256 | addBut->setFocusPolicy(NoFocus); |
257 | mainLayout->addWidget( addBut,0,++ii ); | 257 | mainLayout->addWidget( addBut,0,++ii ); |
258 | addBut->setPixmap ( SmallIcon("eye")); | 258 | addBut->setPixmap ( SmallIcon("eye")); |
259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); | 259 | connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); |
260 | int max = addBut->sizeHint().height(); | 260 | int max = addBut->sizeHint().height(); |
261 | addBut->setMaximumWidth( max ); | 261 | addBut->setMaximumWidth( max ); |
262 | addButT->setFixedSize( QSize( max, max ) ); | 262 | addButT->setFixedSize( QSize( max, max ) ); |
263 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); | 263 | QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); |
264 | mainLayout->addWidget( lab,0,++ii ); | 264 | mainLayout->addWidget( lab,0,++ii ); |
265 | //lab = new QLabel ( i18n(" "), mw ); | 265 | //lab = new QLabel ( i18n(" "), mw ); |
266 | //mainLayout->addWidget( lab,0,++ii ); | 266 | //mainLayout->addWidget( lab,0,++ii ); |
267 | //lab->setFixedWidth( 1 ); | 267 | //lab->setFixedWidth( 1 ); |
268 | addBut = new QPushButton ( mw ); | 268 | addBut = new QPushButton ( mw ); |
269 | addBut->setFocusPolicy(NoFocus); | 269 | addBut->setFocusPolicy(NoFocus); |
270 | mainLayout->addWidget( addBut,0,++ii ); | 270 | mainLayout->addWidget( addBut,0,++ii ); |
271 | addBut->setPixmap ( SmallIcon("bell")); | 271 | addBut->setPixmap ( SmallIcon("bell")); |
272 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); | 272 | connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); |
273 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 273 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
274 | 274 | ||
275 | addBut = new QPushButton ( mw ); | 275 | addBut = new QPushButton ( mw ); |
276 | addBut->setFocusPolicy(NoFocus); | 276 | addBut->setFocusPolicy(NoFocus); |
277 | mainLayout->addWidget( addBut,0,++ii ); | 277 | mainLayout->addWidget( addBut,0,++ii ); |
278 | addBut->setPixmap ( SmallIcon("pencil")); | 278 | addBut->setPixmap ( SmallIcon("pencil")); |
279 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); | 279 | connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); |
280 | addBut->setMaximumWidth( addBut->sizeHint().height() ); | 280 | addBut->setMaximumWidth( addBut->sizeHint().height() ); |
281 | lab = new QLabel ( "", mw ); | 281 | lab = new QLabel ( "", mw ); |
282 | mainLayout->addWidget( lab,0,++ii ); | 282 | mainLayout->addWidget( lab,0,++ii ); |
283 | 283 | ||
284 | addBut = new QPushButton ( mw ); | 284 | addBut = new QPushButton ( mw ); |
285 | addBut->setFocusPolicy(NoFocus); | 285 | addBut->setFocusPolicy(NoFocus); |
286 | mainLayout->addWidget( addBut,0,++ii ); | 286 | mainLayout->addWidget( addBut,0,++ii ); |
287 | addBut->setPixmap ( SmallIcon("plus")); | 287 | addBut->setPixmap ( SmallIcon("plus")); |
288 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); | 288 | connect(addBut,SIGNAL(clicked()),SLOT(addCal())); |
289 | 289 | ||
290 | lab = new QLabel ( " ", mw ); | 290 | lab = new QLabel ( " ", mw ); |
291 | mainLayout->addWidget( lab,0,++ii ); | 291 | mainLayout->addWidget( lab,0,++ii ); |
292 | 292 | ||
293 | 293 | ||
294 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 294 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
295 | int row = 1; | 295 | int row = 1; |
296 | bool errorLoadStandard = false; | 296 | bool errorLoadStandard = false; |
297 | while ( kkf ) { | 297 | while ( kkf ) { |
298 | int iii = 0; | 298 | int iii = 0; |
299 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); | 299 | KOCalRadioButton* rb = new KOCalRadioButton( mw ); |
300 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); | 300 | mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); |
301 | rb->setChecked( kkf->isStandard ); | 301 | rb->setChecked( kkf->isStandard ); |
302 | if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) | 302 | if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) |
303 | errorLoadStandard = true; | 303 | errorLoadStandard = true; |
304 | rb->setNum( kkf->mCalNumber ); | 304 | rb->setNum( kkf->mCalNumber ); |
305 | connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); | 305 | connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); |
306 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 306 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
307 | rb->setEnabled( false ); | 307 | rb->setEnabled( false ); |
308 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); | 308 | KOCalCheckButton* cb = new KOCalCheckButton( mw ); |
309 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); | 309 | mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); |
310 | cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); | 310 | cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); |
311 | cb->setNum( kkf->mCalNumber ); | 311 | cb->setNum( kkf->mCalNumber ); |
312 | if ( kkf->mErrorOnLoad ) | 312 | if ( kkf->mErrorOnLoad ) |
313 | cb->setEnabled( false ); | 313 | cb->setEnabled( false ); |
314 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); | 314 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); |
315 | KOCalButton* name = new KOCalButton( mw ); | 315 | KOCalButton* name = new KOCalButton( mw ); |
316 | name->setNum( kkf->mCalNumber ); | 316 | name->setNum( kkf->mCalNumber ); |
317 | name->setText( kkf->mName ); | 317 | name->setText( kkf->mName ); |
318 | mainLayout->addWidget( name,row,++iii ); | 318 | mainLayout->addWidget( name,row,++iii ); |
319 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); | 319 | connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); |
320 | //lab = new QLabel (" ", mw ); | 320 | //lab = new QLabel (" ", mw ); |
321 | //mainLayout->addWidget( lab,row,++iii ); | 321 | //mainLayout->addWidget( lab,row,++iii ); |
322 | cb = new KOCalCheckButton( mw ); | 322 | cb = new KOCalCheckButton( mw ); |
323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); | 323 | mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); |
324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); | 324 | cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); |
325 | cb->setNum( kkf->mCalNumber ); | 325 | cb->setNum( kkf->mCalNumber ); |
326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); | 326 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); |
327 | if ( kkf->mErrorOnLoad ) | 327 | if ( kkf->mErrorOnLoad ) |
328 | cb->setEnabled( false ); | 328 | cb->setEnabled( false ); |
329 | cb = new KOCalCheckButton( mw ); | 329 | cb = new KOCalCheckButton( mw ); |
330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); | 330 | mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); |
331 | cb->setChecked( kkf->isReadOnly ); | 331 | cb->setChecked( kkf->isReadOnly ); |
332 | cb->setNum( kkf->mCalNumber ); | 332 | cb->setNum( kkf->mCalNumber ); |
333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); | 333 | connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); |
334 | if ( kkf->mErrorOnLoad ) | 334 | if ( kkf->mErrorOnLoad ) |
335 | cb->setEnabled( false ); | 335 | cb->setEnabled( false ); |
336 | if ( row > 1) { | 336 | if ( row > 1) { |
337 | KColorButton *colb = new KColorButton( mw ); | 337 | KColorButton *colb = new KColorButton( mw ); |
338 | mainLayout->addWidget( colb,row,++iii ); | 338 | mainLayout->addWidget( colb,row,++iii ); |
339 | colb->setID( kkf->mCalNumber ); | 339 | colb->setID( kkf->mCalNumber ); |
340 | colb->setColor( kkf->mDefaultColor ); | 340 | colb->setColor( kkf->mDefaultColor ); |
341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); | 341 | connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); |
342 | KOCalButton* calb = new KOCalButton( mw ); | 342 | KOCalButton* calb = new KOCalButton( mw ); |
343 | mainLayout->addWidget( calb,row,++iii ); | 343 | mainLayout->addWidget( calb,row,++iii ); |
344 | calb->setNum( kkf->mCalNumber ); | 344 | calb->setNum( kkf->mCalNumber ); |
345 | calb->setPixmap ( SmallIcon("minus")); | 345 | calb->setPixmap ( SmallIcon("minus")); |
346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); | 346 | connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); |
347 | int hei = calb->sizeHint().height(); | 347 | int hei = calb->sizeHint().height(); |
348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); | 348 | //calb->setMaximumSize( hei*9/10, hei*9/10 ); |
349 | } | 349 | } |
350 | ++row; | 350 | ++row; |
351 | kkf = KOPrefs::instance()->mCalendars.next(); | 351 | kkf = KOPrefs::instance()->mCalendars.next(); |
352 | } | 352 | } |
353 | if ( errorLoadStandard ) | 353 | if ( errorLoadStandard ) |
354 | findNewStandard(); | 354 | findNewStandard(); |
355 | lab = new QLabel ( "", mw ); | 355 | lab = new QLabel ( "", mw ); |
356 | mainLayout->addWidget( lab,row,0 ); | 356 | mainLayout->addWidget( lab,row,0 ); |
357 | mw->show(); | 357 | mw->show(); |
358 | 358 | ||
359 | } | 359 | } |
360 | 360 | ||
361 | void KOCalEditView::defaultInfo() | 361 | void KOCalEditView::defaultInfo() |
362 | { | 362 | { |
363 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); | 363 | KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); |
364 | } | 364 | } |
365 | void KOCalEditView::addCal() | 365 | void KOCalEditView::addCal() |
366 | { | 366 | { |
367 | bool tryagain = true; | 367 | bool tryagain = true; |
368 | QString name, file; | 368 | QString name, file = KGlobalSettings::calendarDir()+"newCal.ics"; |
369 | while ( tryagain ) { | 369 | while ( tryagain ) { |
370 | KONewCalPrefs prefs ( this ); | 370 | KONewCalPrefs prefs ( this ); |
371 | prefs.nameE->setText( name ); | 371 | prefs.nameE->setText( name ); |
372 | prefs.url->setURL( file ); | 372 | prefs.url->setURL( file ); |
373 | if ( ! prefs.exec() ) | 373 | if ( ! prefs.exec() ) |
374 | return; | 374 | return; |
375 | name = prefs.calName(); | 375 | name = prefs.calName(); |
376 | file = prefs.calFileName(); | 376 | file = prefs.calFileName(); |
377 | tryagain = false; | 377 | tryagain = false; |
378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 378 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
379 | while ( kkf ) { | 379 | while ( kkf ) { |
380 | if ( kkf->mName == name ) { | 380 | if ( kkf->mName == name ) { |
381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); | 381 | KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); |
382 | name = ""; | 382 | name = ""; |
383 | tryagain = true; | 383 | tryagain = true; |
384 | break; | 384 | break; |
385 | } | 385 | } |
386 | if ( kkf->mFileName == file ) { | 386 | if ( kkf->mFileName == file ) { |
387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); | 387 | KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); |
388 | tryagain = true; | 388 | tryagain = true; |
389 | file = ""; | 389 | file = KGlobalSettings::calendarDir()+"newCal.ics"; |
390 | break; | 390 | break; |
391 | } | 391 | } |
392 | kkf = KOPrefs::instance()->mCalendars.next(); | 392 | kkf = KOPrefs::instance()->mCalendars.next(); |
393 | } | ||
394 | QFileInfo fi ( file ); | ||
395 | if ( fi.isDir() ) { | ||
396 | tryagain = true; | ||
393 | } | 397 | } |
394 | } | 398 | } |
395 | addCalendar ( name, file ); | 399 | addCalendar ( name, file ); |
396 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); | 400 | QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); |
397 | } | 401 | } |
398 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) | 402 | int KOCalEditView::addCalendar( QString name, QString file, bool ask ) |
399 | { | 403 | { |
400 | 404 | ||
401 | QFileInfo fi ( file ); | 405 | QFileInfo fi ( file ); |
402 | QString absFile = file; | 406 | QString absFile = file; |
403 | bool isRelative = false; | 407 | bool isRelative = false; |
404 | if ( fi.isRelative() ) { | 408 | if ( fi.isRelative() ) { |
405 | isRelative = true; | 409 | isRelative = true; |
406 | absFile = KGlobalSettings::calendarDir()+file; | 410 | absFile = KGlobalSettings::calendarDir()+file; |
407 | fi.setFile( absFile ); | 411 | fi.setFile( absFile ); |
408 | } else { | 412 | } else { |
409 | QString cd = KGlobalSettings::calendarDir(); | 413 | QString cd = KGlobalSettings::calendarDir(); |
410 | if ( file.left( cd.length() ) == cd ) { | 414 | if ( file.left( cd.length() ) == cd ) { |
411 | isRelative = true; | 415 | isRelative = true; |
412 | file = fi.fileName (); | 416 | file = fi.fileName (); |
413 | fi.setFile( absFile ); | 417 | fi.setFile( absFile ); |
414 | } | 418 | } |
415 | } | 419 | } |
416 | if (!fi.exists() ) { | 420 | if (!fi.exists() ) { |
417 | if ( ask ) | 421 | if ( ask ) |
418 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) | 422 | if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No ) |
419 | return 0; | 423 | return 0; |
420 | QFile fileIn( absFile ); | 424 | QFile fileIn( absFile ); |
421 | if (!fileIn.open( IO_WriteOnly ) ) { | 425 | if (!fileIn.open( IO_WriteOnly ) ) { |
422 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); | 426 | KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); |
423 | return 0; | 427 | return 0; |
424 | } | 428 | } |
425 | QTextStream tsIn( &fileIn ); | 429 | QTextStream tsIn( &fileIn ); |
426 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 430 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
427 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; | 431 | tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; |
428 | fileIn.close(); | 432 | fileIn.close(); |
429 | } | 433 | } |
430 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); | 434 | KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); |
431 | kkf->mName = name; | 435 | kkf->mName = name; |
432 | kkf->mFileName = absFile; | 436 | kkf->mFileName = absFile; |
433 | kkf->mSavedFileName = file; | 437 | kkf->mSavedFileName = file; |
434 | kkf->isRelative = isRelative; | 438 | kkf->isRelative = isRelative; |
435 | emit calendarAdded( kkf->mCalNumber ); | 439 | emit calendarAdded( kkf->mCalNumber ); |
436 | if ( ask ) | 440 | if ( ask ) |
437 | emit needsUpdate(); | 441 | emit needsUpdate(); |
438 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); | 442 | QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); |
439 | return kkf->mCalNumber; | 443 | return kkf->mCalNumber; |
440 | } | 444 | } |
441 | int KOCalEditView::getBirtdayID() | 445 | int KOCalEditView::getBirtdayID() |
442 | { | 446 | { |
443 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 447 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
444 | while ( kkf ) { | 448 | while ( kkf ) { |
445 | if ( kkf->mName == i18n("Birthdays") ) | 449 | if ( kkf->mName == i18n("Birthdays") ) |
446 | return kkf->mCalNumber; | 450 | return kkf->mCalNumber; |
447 | kkf = KOPrefs::instance()->mCalendars.next(); | 451 | kkf = KOPrefs::instance()->mCalendars.next(); |
448 | } | 452 | } |
449 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); | 453 | QString file = locateLocal( "data", "korganizer/birthdays.ics" ); |
450 | return addCalendar( i18n("Birthdays"), file, false ); | 454 | return addCalendar( i18n("Birthdays"), file, false ); |
451 | } | 455 | } |
452 | 456 | ||
453 | void KOCalEditView::enableAll() | 457 | void KOCalEditView::enableAll() |
454 | { | 458 | { |
455 | toggleList( mEnabledB ); | 459 | toggleList( mEnabledB ); |
456 | } | 460 | } |
457 | void KOCalEditView::enableAlarm() | 461 | void KOCalEditView::enableAlarm() |
458 | { | 462 | { |
459 | toggleList( mAlarmB ); | 463 | toggleList( mAlarmB ); |
460 | } | 464 | } |
461 | void KOCalEditView::disableRO() | 465 | void KOCalEditView::disableRO() |
462 | { | 466 | { |
463 | toggleList( mROB, false ); | 467 | toggleList( mROB, false ); |
464 | } | 468 | } |
465 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) | 469 | void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) |
466 | { | 470 | { |
467 | bool dis = !enable; | 471 | bool dis = !enable; |
468 | KOCalCheckButton* it = list.first(); | 472 | KOCalCheckButton* it = list.first(); |
469 | while ( it ) { | 473 | while ( it ) { |
470 | if ( !it->isChecked() == enable && it->isEnabled() ) { | 474 | if ( !it->isChecked() == enable && it->isEnabled() ) { |
471 | dis = !dis; | 475 | dis = !dis; |
472 | break; | 476 | break; |
473 | } | 477 | } |
474 | it = list.next(); | 478 | it = list.next(); |
475 | } | 479 | } |
476 | it = list.first(); | 480 | it = list.first(); |
477 | while ( it ) { | 481 | while ( it ) { |
478 | if ( it->isEnabled() ) | 482 | if ( it->isEnabled() ) |
479 | it->setChecked(dis); | 483 | it->setChecked(dis); |
480 | it = list.next(); | 484 | it = list.next(); |
481 | } | 485 | } |
482 | } | 486 | } |
483 | void KOCalEditView::deleteAll() | 487 | void KOCalEditView::deleteAll() |
484 | { | 488 | { |
485 | qDebug("delteAll"); | 489 | qDebug("delteAll"); |
486 | } | 490 | } |