summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3a16fe6..73aa733 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -214,49 +214,49 @@ CalendarView::CalendarView( CalendarResources *calendar,
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 238 mNextAlarmDateTime = QDateTime::currentDateTime();
239 setFocusPolicy ( WheelFocus ); 239 setFocusPolicy ( WheelFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
@@ -621,48 +621,49 @@ void CalendarView::computeAlarm( QString msg )
621 //qDebug("audio file command %s ",tempfilename.latin1() ); 621 //qDebug("audio file command %s ",tempfilename.latin1() );
622 } 622 }
623 if ( mess.left( 9 ) == "cal_alarm") { 623 if ( mess.left( 9 ) == "cal_alarm") {
624 mAlarmMessage = mess.mid( 9 ) ; 624 mAlarmMessage = mess.mid( 9 ) ;
625 } 625 }
626 626
627 startAlarm( mAlarmMessage, filename ); 627 startAlarm( mAlarmMessage, filename );
628 628
629 629
630} 630}
631 631
632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 635
636 mSuspendAlarmNotification = noti; 636 mSuspendAlarmNotification = noti;
637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
639 mSuspendTimer->start( ms , true ); 639 mSuspendTimer->start( ms , true );
640 640
641} 641}
642 642
643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
644{ 644{
645 mNextAlarmDateTime = qdt;
645 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 646 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
646 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 647 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
647#ifndef DESKTOP_VERSION 648#ifndef DESKTOP_VERSION
648 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 649 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
649#endif 650#endif
650 return; 651 return;
651 } 652 }
652 int maxSec; 653 int maxSec;
653 //maxSec = 5; //testing only 654 //maxSec = 5; //testing only
654 maxSec = 86400+3600; // one day+1hour 655 maxSec = 86400+3600; // one day+1hour
655 mAlarmNotification = noti; 656 mAlarmNotification = noti;
656 int sec = QDateTime::currentDateTime().secsTo( qdt ); 657 int sec = QDateTime::currentDateTime().secsTo( qdt );
657 if ( sec > maxSec ) { 658 if ( sec > maxSec ) {
658 mRecheckAlarmTimer->start( maxSec * 1000 ); 659 mRecheckAlarmTimer->start( maxSec * 1000 );
659 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 660 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
660 return; 661 return;
661 } else { 662 } else {
662 mRecheckAlarmTimer->stop(); 663 mRecheckAlarmTimer->stop();
663 } 664 }
664 //qDebug("Alarm timer started with secs: %d ", sec); 665 //qDebug("Alarm timer started with secs: %d ", sec);
665 mAlarmTimer->start( sec *1000 , true ); 666 mAlarmTimer->start( sec *1000 , true );
666 667
667} 668}
668// called by mRecheckAlarmTimer to get next alarm 669// called by mRecheckAlarmTimer to get next alarm
@@ -4043,24 +4044,39 @@ void CalendarView::undo_delete()
4043void CalendarView::slotViewerClosed() 4044void CalendarView::slotViewerClosed()
4044{ 4045{
4045 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4046 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4046} 4047}
4047 4048
4048void CalendarView::resetFocus() 4049void CalendarView::resetFocus()
4049{ 4050{
4050 if ( mViewerCallerIsSearchDialog ) { 4051 if ( mViewerCallerIsSearchDialog ) {
4051 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4052 if ( mDialogManager->getSearchDialog()->isVisible() ){
4052 mDialogManager->getSearchDialog()->raise(); 4053 mDialogManager->getSearchDialog()->raise();
4053 mDialogManager->getSearchDialog()->setActiveWindow(); 4054 mDialogManager->getSearchDialog()->setActiveWindow();
4054 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4055 mDialogManager->getSearchDialog()->listview()->resetFocus();
4055 } else 4056 } else
4056 mViewerCallerIsSearchDialog = false; 4057 mViewerCallerIsSearchDialog = false;
4057 } 4058 }
4058 if ( !mViewerCallerIsSearchDialog ) { 4059 if ( !mViewerCallerIsSearchDialog ) {
4059 //mViewManager->currentView()->setFocus(); 4060 //mViewManager->currentView()->setFocus();
4060 //qDebug("sssssssssssssssset focus "); 4061 //qDebug("sssssssssssssssset focus ");
4061 topLevelWidget()->raise(); 4062 topLevelWidget()->raise();
4062 setActiveWindow(); 4063 setActiveWindow();
4063 //setFocus(); 4064 //setFocus();
4064 } 4065 }
4065 mViewerCallerIsSearchDialog = false; 4066 mViewerCallerIsSearchDialog = false;
4066} 4067}
4068
4069void CalendarView::showNextAlarms()
4070{
4071 QString message;
4072 if ( mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4073 QString sum = mCalendar->nextSummary();
4074 QDateTime nextA = mNextAlarmDateTime;
4075 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4076 message = i18n("The next alarm is on:\n%1\nat: %2\n\n%3\n(%4)").arg( KGlobal::locale()->formatDate(nextA.date() , false)).arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4077 } else {
4078 message = i18n("There is no next alarm.");
4079
4080 }
4081 KMessageBox::information( this, message);
4082}