summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 70a1d2d..678143d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -453,48 +453,49 @@ void CalendarView::init()
453 if ( QApplication::desktop()->width() < 800 ) 453 if ( QApplication::desktop()->width() < 800 )
454 mDateScrollBar->hide(); 454 mDateScrollBar->hide();
455#endif 455#endif
456 //mainBoxLayout->addWidget (mLeftFrame); 456 //mainBoxLayout->addWidget (mLeftFrame);
457 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 457 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
458 "CalendarView::DateNavigator" ); 458 "CalendarView::DateNavigator" );
459#if 0 459#if 0
460 // FIXME 460 // FIXME
461 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 461 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
462 "CalendarView::DateNavigator", QDate::currentDate()); 462 "CalendarView::DateNavigator", QDate::currentDate());
463#endif 463#endif
464 // mDateNavigator->blockSignals( true ); 464 // mDateNavigator->blockSignals( true );
465 //leftFrameLayout->addWidget( mDateNavigator ); 465 //leftFrameLayout->addWidget( mDateNavigator );
466 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 466 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
467 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 467 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
468 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 468 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
469 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 469 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
470 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 471 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 474 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
475 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 475 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
477 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 478 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
478 479
479 mTodoList->setNavigator( mNavigator ); 480 mTodoList->setNavigator( mNavigator );
480#if 0 481#if 0
481 if ( QApplication::desktop()->width() < 480 ) { 482 if ( QApplication::desktop()->width() < 480 ) {
482 leftFrameLayout->addWidget(mFilterView); 483 leftFrameLayout->addWidget(mFilterView);
483 leftFrameLayout->addWidget(mTodoList, 2 ); 484 leftFrameLayout->addWidget(mTodoList, 2 );
484 485
485 } else { 486 } else {
486 leftFrameLayout->addWidget(mTodoList,2 ); 487 leftFrameLayout->addWidget(mTodoList,2 );
487 leftFrameLayout->addWidget(mFilterView ); 488 leftFrameLayout->addWidget(mFilterView );
488 } 489 }
489#endif 490#endif
490 mFilterView->hide(); 491 mFilterView->hide();
491 mCalEditView->hide(); 492 mCalEditView->hide();
492 QWidget *rightBox = new QWidget( mMainFrame ); 493 QWidget *rightBox = new QWidget( mMainFrame );
493 //mainBoxLayout->addWidget ( rightBox, 10 ); 494 //mainBoxLayout->addWidget ( rightBox, 10 );
494 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 495 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
495 mRightFrame = new QWidgetStack( rightBox ); 496 mRightFrame = new QWidgetStack( rightBox );
496 rightLayout->addWidget( mRightFrame, 10 ); 497 rightLayout->addWidget( mRightFrame, 10 );
497 498
498 //mLeftFrame = (QWidget *)leftFrame; 499 //mLeftFrame = (QWidget *)leftFrame;
499 if ( KOPrefs::instance()->mVerticalScreen ) { 500 if ( KOPrefs::instance()->mVerticalScreen ) {
500 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 501 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
@@ -660,65 +661,69 @@ void CalendarView::setScrollBarStep(int val )
660#endif 661#endif
661} 662}
662void CalendarView::scrollBarValue(int val ) 663void CalendarView::scrollBarValue(int val )
663{ 664{
664#ifdef DESKTOP_VERSION 665#ifdef DESKTOP_VERSION
665 if ( QApplication::desktop()->width() < 800 ) return; 666 if ( QApplication::desktop()->width() < 800 ) return;
666 static bool block = false; 667 static bool block = false;
667 if ( block ) return; 668 if ( block ) return;
668 block = true; 669 block = true;
669 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 670 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
670 //qDebug("VAL %d ",val ); 671 //qDebug("VAL %d ",val );
671 int count = mNavigator->selectedDates().count(); 672 int count = mNavigator->selectedDates().count();
672 int year = mNavigator->selectedDates().first().year(); 673 int year = mNavigator->selectedDates().first().year();
673 int day = mNavigator->selectedDates().first().dayOfYear(); 674 int day = mNavigator->selectedDates().first().dayOfYear();
674 if ( val == day -1 ) { 675 if ( val == day -1 ) {
675 block = false; 676 block = false;
676 return; 677 return;
677 } 678 }
678 QDate d ( year,1,1 ); 679 QDate d ( year,1,1 );
679 mNavigator->selectDates( d.addDays( val ), count ); 680 mNavigator->selectDates( d.addDays( val ), count );
680 block = false; 681 block = false;
681#endif 682#endif
682 683
683} 684}
684 685void CalendarView::checkFiles()
685void CalendarView::checkAlarms()
686{ 686{
687
688 QString message; 687 QString message;
689 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 688 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
690 KopiCalendarFile * cal = calendars.first(); 689 KopiCalendarFile * cal = calendars.first();
691 while ( cal ) { 690 while ( cal ) {
692 if ( cal->mErrorOnLoad ) { 691 if ( cal->mErrorOnLoad ) {
693 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 692 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
694 } 693 }
695 cal = calendars.next(); 694 cal = calendars.next();
696 } 695 }
697 if ( !message.isEmpty() ) { 696 if ( !message.isEmpty() ) {
698 message = KGlobal::formatMessage( i18n("The loading of one or more calendar failed:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 697 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);
699 KMessageBox::error(this,message); 698 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
700 } 699 }
700 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
701}
702void CalendarView::checkAlarms()
703{
704
705
701 KConfig *config = KOGlobals::config(); 706 KConfig *config = KOGlobals::config();
702 config->setGroup( "AppRun" ); 707 config->setGroup( "AppRun" );
703 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 708 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
704 int daysto = dt.daysTo( QDate::currentDate() ); 709 int daysto = dt.daysTo( QDate::currentDate() );
705 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 710 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
706 dt = dt.addDays( days ); 711 dt = dt.addDays( days );
707 int secto = dt.secsTo( QDateTime::currentDateTime() ); 712 int secto = dt.secsTo( QDateTime::currentDateTime() );
708 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 713 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
709 //qDebug("KO: Reading program stop %d ", secs); 714 //qDebug("KO: Reading program stop %d ", secs);
710 //secs -= ( 3600 * 24*3 ); // debug only 715 //secs -= ( 3600 * 24*3 ); // debug only
711 QDateTime latest = dt.addSecs ( secs ); 716 QDateTime latest = dt.addSecs ( secs );
712 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 717 qDebug("KO: Last termination on %s ", latest.toString().latin1());
713 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 718 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
714 QPtrList<Incidence> el = mCalendar->rawIncidences(); 719 QPtrList<Incidence> el = mCalendar->rawIncidences();
715 QPtrList<Incidence> al; 720 QPtrList<Incidence> al;
716 Incidence* inL = el.first(); 721 Incidence* inL = el.first();
717 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 722 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
718 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 723 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
719 while ( inL ) { 724 while ( inL ) {
720 bool ok = false; 725 bool ok = false;
721 int offset = 0; 726 int offset = 0;
722 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 727 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
723 if ( ok ) { 728 if ( ok ) {
724 //qDebug("OK %s",next.toString().latin1()); 729 //qDebug("OK %s",next.toString().latin1());