-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 | |||
@@ -452,12 +452,14 @@ void CalendarView::init() | |||
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 ); |
@@ -488,15 +490,20 @@ void CalendarView::suspendAlarm() | |||
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 ); |
@@ -601,18 +608,36 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | |||
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() ); |