author | zautrix <zautrix> | 2004-07-03 16:49:55 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-03 16:49:55 (UTC) |
commit | 1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (patch) (unidiff) | |
tree | ae690b33cbe50291a610842e24de33f9d766f2f2 /korganizer/calendarview.cpp | |
parent | e3b89230f065c48c84b48c88edb6eb088374c487 (diff) | |
download | kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.zip kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.gz kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.bz2 |
Alarm Bugfix. Added connection to KM. Cleaned up main.
-rw-r--r-- | korganizer/calendarview.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index bf98ad4..c3c3d47 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -434,87 +434,94 @@ void CalendarView::init() | |||
434 | SLOT(checkClipboard())); | 434 | SLOT(checkClipboard())); |
435 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 435 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
436 | SLOT( processTodoListSelection( Incidence * ) ) ); | 436 | SLOT( processTodoListSelection( Incidence * ) ) ); |
437 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 437 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
438 | 438 | ||
439 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 439 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
440 | 440 | ||
441 | mDateFrame = new QVBox(0,0,WType_Popup); | 441 | mDateFrame = new QVBox(0,0,WType_Popup); |
442 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 442 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
443 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 443 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
444 | mDateFrame->setLineWidth(3); | 444 | mDateFrame->setLineWidth(3); |
445 | mDateFrame->hide(); | 445 | mDateFrame->hide(); |
446 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 446 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
447 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 447 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
448 | 448 | ||
449 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 449 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
450 | 450 | ||
451 | mEventEditor = mDialogManager->getEventEditor(); | 451 | mEventEditor = mDialogManager->getEventEditor(); |
452 | mTodoEditor = mDialogManager->getTodoEditor(); | 452 | mTodoEditor = mDialogManager->getTodoEditor(); |
453 | 453 | ||
454 | mFlagEditDescription = false; | 454 | mFlagEditDescription = false; |
455 | 455 | ||
456 | mSuspendTimer = new QTimer( this ); | 456 | mSuspendTimer = new QTimer( this ); |
457 | mAlarmTimer = new QTimer( this ); | 457 | mAlarmTimer = new QTimer( this ); |
458 | mRecheckAlarmTimer = new QTimer( this ); | ||
459 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | ||
458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 460 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 461 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
460 | mAlarmDialog = new AlarmDialog( this ); | 462 | mAlarmDialog = new AlarmDialog( this ); |
461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 463 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
462 | mAlarmDialog->setServerNotification( false ); | 464 | mAlarmDialog->setServerNotification( false ); |
463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 465 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
464 | } | 466 | } |
465 | 467 | ||
466 | 468 | ||
467 | CalendarView::~CalendarView() | 469 | CalendarView::~CalendarView() |
468 | { | 470 | { |
469 | // kdDebug() << "~CalendarView()" << endl; | 471 | // kdDebug() << "~CalendarView()" << endl; |
470 | //qDebug("CalendarView::~CalendarView() "); | 472 | //qDebug("CalendarView::~CalendarView() "); |
471 | delete mDialogManager; | 473 | delete mDialogManager; |
472 | delete mViewManager; | 474 | delete mViewManager; |
473 | delete mStorage; | 475 | delete mStorage; |
474 | delete mDateFrame ; | 476 | delete mDateFrame ; |
475 | delete beamDialog; | 477 | delete beamDialog; |
476 | //kdDebug() << "~CalendarView() done" << endl; | 478 | //kdDebug() << "~CalendarView() done" << endl; |
477 | } | 479 | } |
478 | void CalendarView::timerAlarm() | 480 | void CalendarView::timerAlarm() |
479 | { | 481 | { |
480 | //qDebug("CalendarView::timerAlarm() "); | 482 | //qDebug("CalendarView::timerAlarm() "); |
481 | computeAlarm(mAlarmNotification ); | 483 | computeAlarm(mAlarmNotification ); |
482 | } | 484 | } |
483 | 485 | ||
484 | void CalendarView::suspendAlarm() | 486 | void CalendarView::suspendAlarm() |
485 | { | 487 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 488 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 489 | computeAlarm(mSuspendAlarmNotification ); |
488 | 490 | ||
489 | } | 491 | } |
490 | 492 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 493 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 494 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 495 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
496 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | ||
494 | 497 | ||
495 | } | 498 | } |
496 | 499 | ||
500 | void CalendarView::checkNextTimerAlarm() | ||
501 | { | ||
502 | mCalendar->checkAlarmForIncidence( 0, true ); | ||
503 | } | ||
497 | 504 | ||
498 | void CalendarView::computeAlarm( QString msg ) | 505 | void CalendarView::computeAlarm( QString msg ) |
499 | { | 506 | { |
500 | 507 | ||
501 | QString mess = msg; | 508 | QString mess = msg; |
502 | QString mAlarmMessage = mess.mid( 9 ); | 509 | QString mAlarmMessage = mess.mid( 9 ); |
503 | QString filename = MainWindow::resourcePath(); | 510 | QString filename = MainWindow::resourcePath(); |
504 | filename += "koalarm.wav"; | 511 | filename += "koalarm.wav"; |
505 | QString tempfilename; | 512 | QString tempfilename; |
506 | if ( mess.left( 13 ) == "suspend_alarm") { | 513 | if ( mess.left( 13 ) == "suspend_alarm") { |
507 | bool error = false; | 514 | bool error = false; |
508 | int len = mess.mid( 13 ).find("+++"); | 515 | int len = mess.mid( 13 ).find("+++"); |
509 | if ( len < 2 ) | 516 | if ( len < 2 ) |
510 | error = true; | 517 | error = true; |
511 | else { | 518 | else { |
512 | tempfilename = mess.mid( 13, len ); | 519 | tempfilename = mess.mid( 13, len ); |
513 | if ( !QFile::exists( tempfilename ) ) | 520 | if ( !QFile::exists( tempfilename ) ) |
514 | error = true; | 521 | error = true; |
515 | } | 522 | } |
516 | if ( ! error ) { | 523 | if ( ! error ) { |
517 | filename = tempfilename; | 524 | filename = tempfilename; |
518 | } | 525 | } |
519 | mAlarmMessage = mess.mid( 13+len+3 ); | 526 | mAlarmMessage = mess.mid( 13+len+3 ); |
520 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 527 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
@@ -583,54 +590,72 @@ void CalendarView::computeAlarm( QString msg ) | |||
583 | 590 | ||
584 | 591 | ||
585 | } | 592 | } |
586 | 593 | ||
587 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 594 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
588 | { | 595 | { |
589 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 596 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
590 | 597 | ||
591 | mSuspendAlarmNotification = noti; | 598 | mSuspendAlarmNotification = noti; |
592 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 599 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
593 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 600 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
594 | mSuspendTimer->start( ms , true ); | 601 | mSuspendTimer->start( ms , true ); |
595 | 602 | ||
596 | } | 603 | } |
597 | 604 | ||
598 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 605 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
599 | { | 606 | { |
600 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 607 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
601 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 608 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
602 | #ifndef DESKTOP_VERSION | 609 | #ifndef DESKTOP_VERSION |
603 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 610 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
604 | #endif | 611 | #endif |
605 | return; | 612 | return; |
606 | } | 613 | } |
614 | int maxSec; | ||
615 | //maxSec = 5; //testing only | ||
616 | maxSec = 86400+3600; // one day+1hour | ||
607 | mAlarmNotification = noti; | 617 | mAlarmNotification = noti; |
608 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 618 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
609 | //qDebug("Alarm timer started with secs: %d ", ms/1000); | 619 | if ( sec > maxSec ) { |
610 | mAlarmTimer->start( ms , true ); | 620 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
621 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | ||
622 | return; | ||
623 | } else { | ||
624 | mRecheckAlarmTimer->stop(); | ||
625 | } | ||
626 | //qDebug("Alarm timer started with secs: %d ", sec); | ||
627 | mAlarmTimer->start( sec *1000 , true ); | ||
611 | 628 | ||
612 | } | 629 | } |
630 | // called by mRecheckAlarmTimer to get next alarm | ||
631 | // we need this, because a QTimer has only a max range of 25 days | ||
632 | void CalendarView::recheckTimerAlarm() | ||
633 | { | ||
634 | mAlarmTimer->stop(); | ||
635 | mRecheckAlarmTimer->stop(); | ||
636 | mCalendar->checkAlarmForIncidence( 0, true ); | ||
637 | } | ||
613 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 638 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
614 | { | 639 | { |
615 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 640 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
616 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 641 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
617 | #ifndef DESKTOP_VERSION | 642 | #ifndef DESKTOP_VERSION |
618 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 643 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
619 | #endif | 644 | #endif |
620 | return; | 645 | return; |
621 | } | 646 | } |
622 | mAlarmTimer->stop(); | 647 | mAlarmTimer->stop(); |
623 | } | 648 | } |
624 | void CalendarView::selectWeekNum ( int num ) | 649 | void CalendarView::selectWeekNum ( int num ) |
625 | { | 650 | { |
626 | dateNavigator()->selectWeek( num ); | 651 | dateNavigator()->selectWeek( num ); |
627 | mViewManager->showWeekView(); | 652 | mViewManager->showWeekView(); |
628 | } | 653 | } |
629 | KOViewManager *CalendarView::viewManager() | 654 | KOViewManager *CalendarView::viewManager() |
630 | { | 655 | { |
631 | return mViewManager; | 656 | return mViewManager; |
632 | } | 657 | } |
633 | 658 | ||
634 | KODialogManager *CalendarView::dialogManager() | 659 | KODialogManager *CalendarView::dialogManager() |
635 | { | 660 | { |
636 | return mDialogManager; | 661 | return mDialogManager; |