-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 @@ -457,2 +457,4 @@ void CalendarView::init() mAlarmTimer = new QTimer( this ); + mRecheckAlarmTimer = new QTimer( this ); + connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); @@ -493,2 +495,3 @@ void CalendarView::startAlarm( QString mess , QString filename) mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); + QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); @@ -496,2 +499,6 @@ void CalendarView::startAlarm( QString mess , QString filename) +void CalendarView::checkNextTimerAlarm() +{ + mCalendar->checkAlarmForIncidence( 0, true ); +} @@ -606,8 +613,26 @@ void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) } + int maxSec; + //maxSec = 5; //testing only + maxSec = 86400+3600; // one day+1hour mAlarmNotification = noti; - int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; - //qDebug("Alarm timer started with secs: %d ", ms/1000); - mAlarmTimer->start( ms , true ); + int sec = QDateTime::currentDateTime().secsTo( qdt ); + if ( sec > maxSec ) { + mRecheckAlarmTimer->start( maxSec * 1000 ); + // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); + return; + } else { + mRecheckAlarmTimer->stop(); + } + //qDebug("Alarm timer started with secs: %d ", sec); + mAlarmTimer->start( sec *1000 , true ); } +// called by mRecheckAlarmTimer to get next alarm +// we need this, because a QTimer has only a max range of 25 days +void CalendarView::recheckTimerAlarm() +{ + mAlarmTimer->stop(); + mRecheckAlarmTimer->stop(); + mCalendar->checkAlarmForIncidence( 0, true ); +} void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |