summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index a9d42f0..28649d9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -712,257 +712,261 @@ void CalendarView::nextConflict( bool all, bool allday )
712 if ( retVal >= startDT ) { 712 if ( retVal >= startDT ) {
713 conflict = retVal; 713 conflict = retVal;
714 cE = test; 714 cE = test;
715 cE2 = test2; 715 cE2 = test2;
716 found = true; 716 found = true;
717 } 717 }
718 } else { 718 } else {
719 if ( retVal >= startDT && retVal < conflict ) { 719 if ( retVal >= startDT && retVal < conflict ) {
720 conflict = retVal; 720 conflict = retVal;
721 cE = test; 721 cE = test;
722 cE2 = test2; 722 cE2 = test2;
723 } 723 }
724 } 724 }
725 } 725 }
726 } 726 }
727 test2 = testlist2.next(); 727 test2 = testlist2.next();
728 } 728 }
729 } 729 }
730 test->setTagged( true ); 730 test->setTagged( true );
731 test = testlist.next(); 731 test = testlist.next();
732 } 732 }
733 //qDebug("Search time : %d", tm.elapsed()); 733 //qDebug("Search time : %d", tm.elapsed());
734 if ( found ) { 734 if ( found ) {
735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
736 mViewManager->showDayView(); 736 mViewManager->showDayView();
737 mNavigator->slotDaySelect( conflict.date() ); 737 mNavigator->slotDaySelect( conflict.date() );
738 int hour = conflict.time().hour(); 738 int hour = conflict.time().hour();
739 mViewManager->agendaView()->setStartHour( hour ); 739 mViewManager->agendaView()->setStartHour( hour );
740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
741 block = false; 741 block = false;
742 return; 742 return;
743 } 743 }
744 744
745 topLevelWidget()->setCaption( i18n("No conflict found") ); 745 topLevelWidget()->setCaption( i18n("No conflict found") );
746 //qDebug("No conflict found "); 746 //qDebug("No conflict found ");
747 block = false; 747 block = false;
748 return; 748 return;
749} 749}
750 750
751void CalendarView::conflictAll() 751void CalendarView::conflictAll()
752{ 752{
753 nextConflict ( true, true ); 753 nextConflict ( true, true );
754} 754}
755void CalendarView::conflictAllday() 755void CalendarView::conflictAllday()
756{ 756{
757 nextConflict ( false, true ); 757 nextConflict ( false, true );
758} 758}
759void CalendarView::conflictNotAll() 759void CalendarView::conflictNotAll()
760{ 760{
761 nextConflict ( false, false ); 761 nextConflict ( false, false );
762} 762}
763 763
764void CalendarView::setCalReadOnly( int id, bool readO ) 764void CalendarView::setCalReadOnly( int id, bool readO )
765{ 765{
766 if ( readO ) { 766 if ( readO ) {
767 emit save(); 767 emit save();
768 } 768 }
769 mCalendar->setReadOnly( id, readO ); 769 mCalendar->setReadOnly( id, readO );
770} 770}
771void CalendarView::setScrollBarStep(int val ) 771void CalendarView::setScrollBarStep(int val )
772{ 772{
773#ifdef DESKTOP_VERSION 773#ifdef DESKTOP_VERSION
774 mDateScrollBar->setLineStep ( val ); 774 mDateScrollBar->setLineStep ( val );
775#endif 775#endif
776} 776}
777void CalendarView::scrollBarValue(int val ) 777void CalendarView::scrollBarValue(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 if ( QApplication::desktop()->width() < 800 ) return; 780 if ( QApplication::desktop()->width() < 800 ) return;
781 static bool block = false; 781 static bool block = false;
782 if ( block ) return; 782 if ( block ) return;
783 block = true; 783 block = true;
784 int count = mNavigator->selectedDates().count(); 784 int count = mNavigator->selectedDates().count();
785 int day = mNavigator->selectedDates().first().dayOfYear(); 785 int day = mNavigator->selectedDates().first().dayOfYear();
786 int stepdays = val; 786 int stepdays = val;
787 if ( mDateScrollBar->lineStep () <= count ) { 787 if ( mDateScrollBar->lineStep () <= count ) {
788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
789 //qDebug("VAL %d ",val ); 789 //qDebug("VAL %d ",val );
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void CalendarView::checkFiles()
826{ 826{
827 QString message; 827 QString message;
828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
829 KopiCalendarFile * cal = calendars.first(); 829 KopiCalendarFile * cal = calendars.first();
830 while ( cal ) { 830 while ( cal ) {
831 if ( cal->mErrorOnLoad ) { 831 if ( cal->mErrorOnLoad ) {
832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
833 } 833 }
834 cal = calendars.next(); 834 cal = calendars.next();
835 } 835 }
836 if ( !message.isEmpty() ) { 836 if ( !message.isEmpty() ) {
837 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); 837 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);
838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
839 } 839 }
840 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 840 static bool firstTime = true;
841 if ( firstTime ) {
842 firstTime = false;
843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
844 }
841} 845}
842void CalendarView::checkAlarms() 846void CalendarView::checkAlarms()
843{ 847{
844 848
845 849
846 KConfig *config = KOGlobals::config(); 850 KConfig *config = KOGlobals::config();
847 config->setGroup( "AppRun" ); 851 config->setGroup( "AppRun" );
848 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 852 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
849 int daysto = dt.daysTo( QDate::currentDate() ); 853 int daysto = dt.daysTo( QDate::currentDate() );
850 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 854 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
851 dt = dt.addDays( days ); 855 dt = dt.addDays( days );
852 int secto = dt.secsTo( QDateTime::currentDateTime() ); 856 int secto = dt.secsTo( QDateTime::currentDateTime() );
853 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 857 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
854 //qDebug("KO: Reading program stop %d ", secs); 858 //qDebug("KO: Reading program stop %d ", secs);
855 //secs -= ( 3600 * 24*3 ); // debug only 859 //secs -= ( 3600 * 24*3 ); // debug only
856 QDateTime latest = dt.addSecs ( secs ); 860 QDateTime latest = dt.addSecs ( secs );
857 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 861 qDebug("KO: Last termination on %s ", latest.toString().latin1());
858 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 862 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
859 QPtrList<Incidence> el = mCalendar->rawIncidences(); 863 QPtrList<Incidence> el = mCalendar->rawIncidences();
860 QPtrList<Incidence> al; 864 QPtrList<Incidence> al;
861 Incidence* inL = el.first(); 865 Incidence* inL = el.first();
862 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 866 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
863 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 867 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
864 while ( inL ) { 868 while ( inL ) {
865 bool ok = false; 869 bool ok = false;
866 int offset = 0; 870 int offset = 0;
867 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 871 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
868 if ( ok ) { 872 if ( ok ) {
869 //qDebug("OK %s",next.toString().latin1()); 873 //qDebug("OK %s",next.toString().latin1());
870 if ( next < cur ) { 874 if ( next < cur ) {
871 al.append( inL ); 875 al.append( inL );
872 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 876 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
873 } 877 }
874 } 878 }
875 inL = el.next(); 879 inL = el.next();
876 } 880 }
877 if ( al.count() ) { 881 if ( al.count() ) {
878 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 882 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
879 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 883 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
880 QVBoxLayout* lay = new QVBoxLayout( dia ); 884 QVBoxLayout* lay = new QVBoxLayout( dia );
881 lay->setSpacing( 0 ); 885 lay->setSpacing( 0 );
882 lay->setMargin( 0 ); 886 lay->setMargin( 0 );
883 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 887 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
884 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 888 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
885 lay->addWidget( matb ); 889 lay->addWidget( matb );
886 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 890 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
887 int wid = 210; 891 int wid = 210;
888 int x = QApplication::desktop()->width() - wid - 7; 892 int x = QApplication::desktop()->width() - wid - 7;
889 int y = QApplication::desktop()->height() - wid - 70; 893 int y = QApplication::desktop()->height() - wid - 70;
890 dia->setGeometry ( x,y,wid,wid); 894 dia->setGeometry ( x,y,wid,wid);
891 } else { 895 } else {
892 int si = 220; 896 int si = 220;
893 if ( QApplication::desktop()->width() > 470 ) 897 if ( QApplication::desktop()->width() > 470 )
894 si = 400; 898 si = 400;
895 dia->resize(si,si/2); 899 dia->resize(si,si/2);
896 } 900 }
897 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 901 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
898 dia->show(); 902 dia->show();
899 903
900 } 904 }
901} 905}
902void CalendarView::showDay( QDate d ) 906void CalendarView::showDay( QDate d )
903{ 907{
904 dateNavigator()->blockSignals( true ); 908 dateNavigator()->blockSignals( true );
905 dateNavigator()->selectDate( d ); 909 dateNavigator()->selectDate( d );
906 dateNavigator()->blockSignals( false ); 910 dateNavigator()->blockSignals( false );
907 mViewManager->showDayView(); 911 mViewManager->showDayView();
908 //dateNavigator()->selectDate( d ); 912 //dateNavigator()->selectDate( d );
909} 913}
910void CalendarView::timerAlarm() 914void CalendarView::timerAlarm()
911{ 915{
912 //qDebug("CalendarView::timerAlarm() "); 916 //qDebug("CalendarView::timerAlarm() ");
913 computeAlarm(mAlarmNotification ); 917 computeAlarm(mAlarmNotification );
914} 918}
915 919
916void CalendarView::suspendAlarm() 920void CalendarView::suspendAlarm()
917{ 921{
918 //qDebug(" CalendarView::suspendAlarm() "); 922 //qDebug(" CalendarView::suspendAlarm() ");
919 computeAlarm(mSuspendAlarmNotification ); 923 computeAlarm(mSuspendAlarmNotification );
920 924
921} 925}
922 926
923void CalendarView::startAlarm( QString mess , QString filename) 927void CalendarView::startAlarm( QString mess , QString filename)
924{ 928{
925 929
926 topLevelWidget()->showNormal(); 930 topLevelWidget()->showNormal();
927 topLevelWidget()->setActiveWindow(); 931 topLevelWidget()->setActiveWindow();
928 topLevelWidget()->raise(); 932 topLevelWidget()->raise();
929 933
930 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 934 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
931 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 935 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
932 936
933} 937}
934 938
935void CalendarView::checkNextTimerAlarm() 939void CalendarView::checkNextTimerAlarm()
936{ 940{
937 mCalendar->checkAlarmForIncidence( 0, true ); 941 mCalendar->checkAlarmForIncidence( 0, true );
938} 942}
939 943
940void CalendarView::computeAlarm( QString msg ) 944void CalendarView::computeAlarm( QString msg )
941{ 945{
942 946
943 QString mess = msg; 947 QString mess = msg;
944 QString mAlarmMessage = mess.mid( 9 ); 948 QString mAlarmMessage = mess.mid( 9 );
945 QString filename = MainWindow::resourcePath(); 949 QString filename = MainWindow::resourcePath();
946 filename += "koalarm.wav"; 950 filename += "koalarm.wav";
947 QString tempfilename; 951 QString tempfilename;
948 if ( mess.left( 13 ) == "suspend_alarm") { 952 if ( mess.left( 13 ) == "suspend_alarm") {
949 bool error = false; 953 bool error = false;
950 int len = mess.mid( 13 ).find("+++"); 954 int len = mess.mid( 13 ).find("+++");
951 if ( len < 2 ) 955 if ( len < 2 )
952 error = true; 956 error = true;
953 else { 957 else {
954 tempfilename = mess.mid( 13, len ); 958 tempfilename = mess.mid( 13, len );
955 if ( !QFile::exists( tempfilename ) ) 959 if ( !QFile::exists( tempfilename ) )
956 error = true; 960 error = true;
957 } 961 }
958 if ( ! error ) { 962 if ( ! error ) {
959 filename = tempfilename; 963 filename = tempfilename;
960 } 964 }
961 mAlarmMessage = mess.mid( 13+len+3 ); 965 mAlarmMessage = mess.mid( 13+len+3 );
962 //qDebug("suspend file %s ",tempfilename.latin1() ); 966 //qDebug("suspend file %s ",tempfilename.latin1() );
963 startAlarm( mAlarmMessage, filename); 967 startAlarm( mAlarmMessage, filename);
964 return; 968 return;
965 } 969 }
966 if ( mess.left( 11 ) == "timer_alarm") { 970 if ( mess.left( 11 ) == "timer_alarm") {
967 //mTimerTime = 0; 971 //mTimerTime = 0;
968 startAlarm( mess.mid( 11 ), filename ); 972 startAlarm( mess.mid( 11 ), filename );