summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8269910..7566b22 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -603,853 +603,854 @@ void CalendarView::init()
603 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
604 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
606 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
608 608
609 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
610 610
611 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
614 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
615 mDateFrame->hide(); 615 mDateFrame->hide();
616 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
618 618
619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
620 620
621 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
622 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
623 623
624 mFlagEditDescription = false; 624 mFlagEditDescription = false;
625 625
626 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
627 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
628 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
632 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
634 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
636 636
637 637
638#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
639//US listen for arriving address resultsets 639//US listen for arriving address resultsets
640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
642#endif 642#endif
643 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
644} 644}
645 645
646 646
647CalendarView::~CalendarView() 647CalendarView::~CalendarView()
648{ 648{
649 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658 658
659 659
660void CalendarView::nextConflict( bool all, bool allday ) 660void CalendarView::nextConflict( bool all, bool allday )
661{ 661{
662 static bool block = false; 662 static bool block = false;
663 if ( block ) return; 663 if ( block ) return;
664 block = true; 664 block = true;
665 QPtrList<Event> testlist = mCalendar->events(); 665 QPtrList<Event> testlist = mCalendar->events();
666 Event * test = testlist.first(); 666 Event * test = testlist.first();
667 while ( test ) { 667 while ( test ) {
668 test->setTagged( false ); 668 test->setTagged( false );
669 test = testlist.next(); 669 test = testlist.next();
670 } 670 }
671 QTime st ( 0,0,0); 671 QTime st ( 0,0,0);
672 if ( mViewManager->currentView() == mViewManager->agendaView() ) 672 if ( mViewManager->currentView() == mViewManager->agendaView() )
673 st = mViewManager->agendaView()->agenda()->getEndTime(); 673 st = mViewManager->agendaView()->agenda()->getEndTime();
674 //qDebug("time %s ", st.toString().latin1()); 674 //qDebug("time %s ", st.toString().latin1());
675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
676 QDateTime conflict; 676 QDateTime conflict;
677 QDateTime retVal; 677 QDateTime retVal;
678 bool found = false; 678 bool found = false;
679 Event * cE = 0; 679 Event * cE = 0;
680 Event * cE2 = 0; 680 Event * cE2 = 0;
681 QPtrList<Event> testlist2 = testlist; 681 QPtrList<Event> testlist2 = testlist;
682 test = testlist.first(); 682 test = testlist.first();
683 bool skip = false; 683 bool skip = false;
684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
685 //QTime tm; 685 //QTime tm;
686 //tm.start(); 686 //tm.start();
687 while ( test ) { 687 while ( test ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 skip = false; 689 skip = false;
690 if ( !all ) skip = ( allday != test->doesFloat() ); 690 if ( !all ) skip = ( allday != test->doesFloat() );
691 if ( !skip ) { 691 if ( !skip ) {
692 if ( found ) 692 if ( found )
693 skip = !test->matchTime( &startDT, &conflict ); 693 skip = !test->matchTime( &startDT, &conflict );
694 else 694 else
695 skip = !test->matchTime( &startDT, 0 ); 695 skip = !test->matchTime( &startDT, 0 );
696 } 696 }
697 if ( !skip ) { 697 if ( !skip ) {
698 Event * test2 = testlist2.first(); 698 Event * test2 = testlist2.first();
699 while ( test2 ) { 699 while ( test2 ) {
700 skip = test2->isTagged(); 700 skip = test2->isTagged();
701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
702 if ( !skip ) { 702 if ( !skip ) {
703 if ( found ) 703 if ( found )
704 skip = !test2->matchTime( &startDT, &conflict ); 704 skip = !test2->matchTime( &startDT, &conflict );
705 else 705 else
706 skip = !test2->matchTime( &startDT, 0 ); 706 skip = !test2->matchTime( &startDT, 0 );
707 } 707 }
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
710 //qDebug("overlap "); 710 //qDebug("overlap ");
711 if ( ! found ) { 711 if ( ! found ) {
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 static bool firstTime = true; 840 static bool firstTime = true;
841 if ( firstTime ) { 841 if ( firstTime ) {
842 firstTime = false; 842 firstTime = false;
843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
844 } 844 }
845} 845}
846void CalendarView::checkAlarms() 846void CalendarView::checkAlarms()
847{ 847{
848 KConfig *config = KOGlobals::config(); 848 KConfig *config = KOGlobals::config();
849 config->setGroup( "AppRun" ); 849 config->setGroup( "AppRun" );
850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
851 int daysto = dt.daysTo( QDate::currentDate() ); 851 int daysto = dt.daysTo( QDate::currentDate() );
852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
853 dt = dt.addDays( days ); 853 dt = dt.addDays( days );
854 int secto = dt.secsTo( QDateTime::currentDateTime() ); 854 int secto = dt.secsTo( QDateTime::currentDateTime() );
855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
856 //qDebug("KO: Reading program stop %d ", secs); 856 //qDebug("KO: Reading program stop %d ", secs);
857 //secs -= ( 3600 * 24*3 ); // debug only 857 //secs -= ( 3600 * 24*3 ); // debug only
858 QDateTime latest = dt.addSecs ( secs ); 858 QDateTime latest = dt.addSecs ( secs );
859 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 859 qDebug("KO: Last termination on %s ", latest.toString().latin1());
860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
861 QPtrList<Incidence> el = mCalendar->rawIncidences(); 861 QPtrList<Incidence> el = mCalendar->rawIncidences();
862 QPtrList<Incidence> al; 862 QPtrList<Incidence> al;
863 Incidence* inL = el.first(); 863 Incidence* inL = el.first();
864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
866 while ( inL ) { 866 while ( inL ) {
867 bool ok = false; 867 bool ok = false;
868 int offset = 0; 868 int offset = 0;
869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
870 if ( ok ) { 870 if ( ok ) {
871 //qDebug("OK %s",next.toString().latin1()); 871 //qDebug("OK %s",next.toString().latin1());
872 if ( next < cur ) { 872 if ( next < cur ) {
873 al.append( inL ); 873 al.append( inL );
874 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 874 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
875 } 875 }
876 } 876 }
877 inL = el.next(); 877 inL = el.next();
878 } 878 }
879 if ( al.count() ) { 879 if ( al.count() ) {
880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
881 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 881 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
882 QVBoxLayout* lay = new QVBoxLayout( dia ); 882 QVBoxLayout* lay = new QVBoxLayout( dia );
883 lay->setSpacing( 0 ); 883 lay->setSpacing( 0 );
884 lay->setMargin( 0 ); 884 lay->setMargin( 0 );
885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
887 lay->addWidget( matb ); 887 lay->addWidget( matb );
888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
889 int wid = 210; 889 int wid = 210;
890 int x = QApplication::desktop()->width() - wid - 7; 890 int x = QApplication::desktop()->width() - wid - 7;
891 int y = QApplication::desktop()->height() - wid - 70; 891 int y = QApplication::desktop()->height() - wid - 70;
892 dia->setGeometry ( x,y,wid,wid); 892 dia->setGeometry ( x,y,wid,wid);
893 } else { 893 } else {
894 int si = 220; 894 int si = 220;
895 if ( QApplication::desktop()->width() > 470 ) 895 if ( QApplication::desktop()->width() > 470 )
896 si = 400; 896 si = 400;
897 dia->resize(si,si/2); 897 dia->resize(si,si/2);
898 } 898 }
899 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 899 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
900 dia->show(); 900 dia->show();
901 901
902 } 902 }
903#if 0 903#if 0
904 // for creating timetracker test data 904 // for creating timetracker test data
905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
906 Todo * nt; 906 Todo * nt;
907 mCalendar->close(); 907 mCalendar->close();
908 { 908 {
909 Todo * root1 = new Todo; 909 Todo * root1 = new Todo;
910 mCalendar->addTodo( root1 ); 910 mCalendar->addTodo( root1 );
911 root1->setSummary( "Project_1"); 911 root1->setSummary( "Project_1");
912 root1->setPriority( 1 ); 912 root1->setPriority( 1 );
913 root1->setDescription( "This is a test description of a root Project" ); 913 root1->setDescription( "This is a test description of a root Project" );
914 root1->setPercentComplete( 20 ); 914 root1->setPercentComplete( 20 );
915 updateView(); 915 updateView();
916 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 916 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
917 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); 917 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) );
918 918
919 nt = new Todo; 919 nt = new Todo;
920 mCalendar->addTodo( nt ); 920 mCalendar->addTodo( nt );
921 nt->setSummary( "Planning_Project_1"); 921 nt->setSummary( "Planning_Project_1");
922 nt->setPriority( 1 ); 922 nt->setPriority( 1 );
923 nt->setDescription( "This is a test description of Planning_Project_1" ); 923 nt->setDescription( "This is a test description of Planning_Project_1" );
924 nt->setPercentComplete( 20 ); 924 nt->setPercentComplete( 20 );
925 925
926 926
927 Todo * sub1 = nt; 927 Todo * sub1 = nt;
928 sub1->setRelatedTo( root1 ); 928 sub1->setRelatedTo( root1 );
929 929
930 nt = new Todo; 930 nt = new Todo;
931 mCalendar->addTodo( nt ); 931 mCalendar->addTodo( nt );
932 nt->setSummary( "Planning_Project_1: Lutz"); 932 nt->setSummary( "Planning_Project_1: Lutz");
933 nt->setPriority( 1 ); 933 nt->setPriority( 1 );
934 nt->setDescription( "This todo counts the actual work of a person on a project" ); 934 nt->setDescription( "This todo counts the actual work of a person on a project" );
935 nt->setPercentComplete( 20 ); 935 nt->setPercentComplete( 20 );
936 Todo * workLutz11 = nt; 936 Todo * workLutz11 = nt;
937 workLutz11->setRelatedTo( sub1 ); 937 workLutz11->setRelatedTo( sub1 );
938 938
939 nt = new Todo; 939 nt = new Todo;
940 mCalendar->addTodo( nt ); 940 mCalendar->addTodo( nt );
941 nt->setSummary( "Planning_Project_1: Norbert"); 941 nt->setSummary( "Planning_Project_1: Norbert");
942 nt->setPriority( 1 ); 942 nt->setPriority( 1 );
943 nt->setDescription( "This todo counts the actual work of a person on a project" ); 943 nt->setDescription( "This todo counts the actual work of a person on a project" );
944 nt->setPercentComplete( 20 ); 944 nt->setPercentComplete( 20 );
945 Todo * workNorbert11 = nt; 945 Todo * workNorbert11 = nt;
946 workNorbert11->setRelatedTo( sub1 ); 946 workNorbert11->setRelatedTo( sub1 );
947 947
948 nt = new Todo; 948 nt = new Todo;
949 mCalendar->addTodo( nt ); 949 mCalendar->addTodo( nt );
950 nt->setSummary( "Work on 1"); 950 nt->setSummary( "Work on 1");
951 nt->setPriority( 1 ); 951 nt->setPriority( 1 );
952 nt->setDescription( "This is a test description of Work Project_1" ); 952 nt->setDescription( "This is a test description of Work Project_1" );
953 nt->setPercentComplete( 20 ); 953 nt->setPercentComplete( 20 );
954 954
955 Todo * sub2 = nt; 955 Todo * sub2 = nt;
956 sub2->setRelatedTo( root1 ); 956 sub2->setRelatedTo( root1 );
957 957
958 958
959 nt = new Todo; 959 nt = new Todo;
960 mCalendar->addTodo( nt ); 960 mCalendar->addTodo( nt );
961 nt->setSummary( "Work on 1: Lutz"); 961 nt->setSummary( "Work on 1: Lutz");
962 nt->setPriority( 1 ); 962 nt->setPriority( 1 );
963 nt->setDescription( "This todo counts the actual work of a person on a project" ); 963 nt->setDescription( "This todo counts the actual work of a person on a project" );
964 nt->setPercentComplete( 20 ); 964 nt->setPercentComplete( 20 );
965 Todo * workLutz12 = nt; 965 Todo * workLutz12 = nt;
966 workLutz12->setRelatedTo( sub2 ); 966 workLutz12->setRelatedTo( sub2 );
967 967
968 nt = new Todo; 968 nt = new Todo;
969 mCalendar->addTodo( nt ); 969 mCalendar->addTodo( nt );
970 nt->setSummary( "Work on 1: Norbert"); 970 nt->setSummary( "Work on 1: Norbert");
971 nt->setPriority( 1 ); 971 nt->setPriority( 1 );
972 nt->setDescription( "This todo counts the actual work of a person on a project" ); 972 nt->setDescription( "This todo counts the actual work of a person on a project" );
973 nt->setPercentComplete( 20 ); 973 nt->setPercentComplete( 20 );
974 Todo * workNorbert12 = nt; 974 Todo * workNorbert12 = nt;
975 workNorbert12->setRelatedTo( sub2 ); 975 workNorbert12->setRelatedTo( sub2 );
976 976
977 int secLenRunning = 7200; 977 int secLenRunning = 7200;
978 int secLenPausing = 3600 * 3; 978 int secLenPausing = 3600 * 3;
979 int dayInterval = 1; 979 int dayInterval = 1;
980 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 980 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
981 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 981 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
982 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 982 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
983 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 983 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
984 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 984 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
985 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 985 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
986 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 986 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
987 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 987 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
988 988
989 } 989 }
990 990
991 { 991 {
992 Todo * root1 = new Todo; 992 Todo * root1 = new Todo;
993 mCalendar->addTodo( root1 ); 993 mCalendar->addTodo( root1 );
994 root1->setSummary( "Project_2"); 994 root1->setSummary( "Project_2");
995 root1->setPriority( 1 ); 995 root1->setPriority( 1 );
996 root1->setDescription( "This is a test description of a root Project 2" ); 996 root1->setDescription( "This is a test description of a root Project 2" );
997 root1->setPercentComplete( 20 ); 997 root1->setPercentComplete( 20 );
998 updateView(); 998 updateView();
999 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 999 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1000 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); 1000 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) );
1001 int secLenRunning = 7200; 1001 int secLenRunning = 7200;
1002 int secLenPausing = 3600 * 3; 1002 int secLenPausing = 3600 * 3;
1003 int dayInterval = 1; 1003 int dayInterval = 1;
1004 1004
1005 nt = new Todo; 1005 nt = new Todo;
1006 mCalendar->addTodo( nt ); 1006 mCalendar->addTodo( nt );
1007 nt->setSummary( "Planning_Project_2"); 1007 nt->setSummary( "Planning_Project_2");
1008 nt->setPriority( 1 ); 1008 nt->setPriority( 1 );
1009 nt->setDescription( "This is a test description of Planning_Project_2" ); 1009 nt->setDescription( "This is a test description of Planning_Project_2" );
1010 nt->setPercentComplete( 20 ); 1010 nt->setPercentComplete( 20 );
1011 1011
1012 1012
1013 Todo * sub1 = nt; 1013 Todo * sub1 = nt;
1014 sub1->setRelatedTo( root1 ); 1014 sub1->setRelatedTo( root1 );
1015 1015
1016 nt = new Todo; 1016 nt = new Todo;
1017 mCalendar->addTodo( nt ); 1017 mCalendar->addTodo( nt );
1018 nt->setSummary( "Planning_Project_2: Lutz"); 1018 nt->setSummary( "Planning_Project_2: Lutz");
1019 nt->setPriority( 1 ); 1019 nt->setPriority( 1 );
1020 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1020 nt->setDescription( "This todo counts the actual work of a person on a project" );
1021 nt->setPercentComplete( 20 ); 1021 nt->setPercentComplete( 20 );
1022 Todo * workLutz11 = nt; 1022 Todo * workLutz11 = nt;
1023 workLutz11->setRelatedTo( sub1 ); 1023 workLutz11->setRelatedTo( sub1 );
1024 1024
1025 nt = new Todo; 1025 nt = new Todo;
1026 mCalendar->addTodo( nt ); 1026 mCalendar->addTodo( nt );
1027 nt->setSummary( "Planning_Project_2: Norbert"); 1027 nt->setSummary( "Planning_Project_2: Norbert");
1028 nt->setPriority( 1 ); 1028 nt->setPriority( 1 );
1029 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1029 nt->setDescription( "This todo counts the actual work of a person on a project" );
1030 nt->setPercentComplete( 20 ); 1030 nt->setPercentComplete( 20 );
1031 Todo * workNorbert11 = nt; 1031 Todo * workNorbert11 = nt;
1032 workNorbert11->setRelatedTo( sub1 ); 1032 workNorbert11->setRelatedTo( sub1 );
1033 1033
1034 nt = new Todo; 1034 nt = new Todo;
1035 mCalendar->addTodo( nt ); 1035 mCalendar->addTodo( nt );
1036 nt->setSummary( "Work on 2"); 1036 nt->setSummary( "Work on 2");
1037 nt->setPriority( 1 ); 1037 nt->setPriority( 1 );
1038 nt->setDescription( "This is a test description of Work Project_2" ); 1038 nt->setDescription( "This is a test description of Work Project_2" );
1039 nt->setPercentComplete( 20 ); 1039 nt->setPercentComplete( 20 );
1040 1040
1041 Todo * sub2 = nt; 1041 Todo * sub2 = nt;
1042 sub2->setRelatedTo( root1 ); 1042 sub2->setRelatedTo( root1 );
1043 1043
1044 1044
1045 nt = new Todo; 1045 nt = new Todo;
1046 mCalendar->addTodo( nt ); 1046 mCalendar->addTodo( nt );
1047 nt->setSummary( "Work on 2: Lutz"); 1047 nt->setSummary( "Work on 2: Lutz");
1048 nt->setPriority( 1 ); 1048 nt->setPriority( 1 );
1049 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1049 nt->setDescription( "This todo counts the actual work of a person on a project" );
1050 nt->setPercentComplete( 20 ); 1050 nt->setPercentComplete( 20 );
1051 Todo * workLutz12 = nt; 1051 Todo * workLutz12 = nt;
1052 workLutz12->setRelatedTo( sub2 ); 1052 workLutz12->setRelatedTo( sub2 );
1053 1053
1054 nt = new Todo; 1054 nt = new Todo;
1055 mCalendar->addTodo( nt ); 1055 mCalendar->addTodo( nt );
1056 nt->setSummary( "Work on 2: Norbert"); 1056 nt->setSummary( "Work on 2: Norbert");
1057 nt->setPriority( 1 ); 1057 nt->setPriority( 1 );
1058 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1058 nt->setDescription( "This todo counts the actual work of a person on a project" );
1059 nt->setPercentComplete( 20 ); 1059 nt->setPercentComplete( 20 );
1060 Todo * workNorbert12 = nt; 1060 Todo * workNorbert12 = nt;
1061 workNorbert12->setRelatedTo( sub2 ); 1061 workNorbert12->setRelatedTo( sub2 );
1062 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1062 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1063 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1063 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1064 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1064 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1065 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1065 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1066 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1066 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1067 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1067 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1068 createRunningDate4Todo( workNorbert11, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1068 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1069 } 1069 }
1070 updateView(); 1070 updateView();
1071#endif 1071#endif
1072
1072} 1073}
1073void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1074void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1074{ 1075{
1075 static int ccc = 0; 1076 static int ccc = 0;
1076 ++ccc; 1077 ++ccc;
1077 QDateTime t_start = start; 1078 QDateTime t_start = start;
1078 runT->setPriority( 5 ); 1079 runT->setPriority( 5 );
1079 runT->setPercentComplete( 0 ); 1080 runT->setPercentComplete( 0 );
1080 int count = 0; 1081 int count = 0;
1081 int prio = 5; 1082 int prio = 5;
1082 int complete = 0; 1083 int complete = 0;
1083 while ( t_start < end ) { 1084 while ( t_start < end ) {
1084 ++count; 1085 ++count;
1085 if ( count > ccc ) { 1086 if ( count > ccc ) {
1086 count = 0; 1087 count = 0;
1087 --prio; 1088 --prio;
1088 if ( prio == 0 ) prio = 5; 1089 if ( prio == 0 ) prio = 5;
1089 complete += 20; 1090 complete += 20;
1090 if ( complete > 100 ) complete = 0; 1091 if ( complete > 100 ) complete = 0;
1091 runT->setPriority( prio ); 1092 runT->setPriority( prio );
1092 runT->setPercentComplete( complete ); 1093 runT->setPercentComplete( complete );
1093 } 1094 }
1094 runT->setRunning( true ); 1095 runT->setRunning( true );
1095 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1096 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1096 if ( dayInterval ) 1097 if ( dayInterval )
1097 t_start = t_start.addDays( dayInterval ); 1098 t_start = t_start.addDays( dayInterval );
1098 else { 1099 else {
1099 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1100 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1100 } 1101 }
1101 } 1102 }
1102} 1103}
1103 1104
1104void CalendarView::showDay( QDate d ) 1105void CalendarView::showDay( QDate d )
1105{ 1106{
1106 dateNavigator()->blockSignals( true ); 1107 dateNavigator()->blockSignals( true );
1107 dateNavigator()->selectDate( d ); 1108 dateNavigator()->selectDate( d );
1108 dateNavigator()->blockSignals( false ); 1109 dateNavigator()->blockSignals( false );
1109 mViewManager->showDayView(); 1110 mViewManager->showDayView();
1110 //dateNavigator()->selectDate( d ); 1111 //dateNavigator()->selectDate( d );
1111} 1112}
1112void CalendarView::timerAlarm() 1113void CalendarView::timerAlarm()
1113{ 1114{
1114 //qDebug("CalendarView::timerAlarm() "); 1115 //qDebug("CalendarView::timerAlarm() ");
1115 computeAlarm(mAlarmNotification ); 1116 computeAlarm(mAlarmNotification );
1116} 1117}
1117 1118
1118void CalendarView::suspendAlarm() 1119void CalendarView::suspendAlarm()
1119{ 1120{
1120 //qDebug(" CalendarView::suspendAlarm() "); 1121 //qDebug(" CalendarView::suspendAlarm() ");
1121 computeAlarm(mSuspendAlarmNotification ); 1122 computeAlarm(mSuspendAlarmNotification );
1122 1123
1123} 1124}
1124 1125
1125void CalendarView::startAlarm( QString mess , QString filename) 1126void CalendarView::startAlarm( QString mess , QString filename)
1126{ 1127{
1127 1128
1128 topLevelWidget()->showNormal(); 1129 topLevelWidget()->showNormal();
1129 topLevelWidget()->setActiveWindow(); 1130 topLevelWidget()->setActiveWindow();
1130 topLevelWidget()->raise(); 1131 topLevelWidget()->raise();
1131 1132
1132 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1133 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1133 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1134 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1134 1135
1135} 1136}
1136 1137
1137void CalendarView::checkNextTimerAlarm() 1138void CalendarView::checkNextTimerAlarm()
1138{ 1139{
1139 mCalendar->checkAlarmForIncidence( 0, true ); 1140 mCalendar->checkAlarmForIncidence( 0, true );
1140} 1141}
1141 1142
1142void CalendarView::computeAlarm( QString msg ) 1143void CalendarView::computeAlarm( QString msg )
1143{ 1144{
1144 1145
1145 QString mess = msg; 1146 QString mess = msg;
1146 QString mAlarmMessage = mess.mid( 9 ); 1147 QString mAlarmMessage = mess.mid( 9 );
1147 QString filename = MainWindow::resourcePath(); 1148 QString filename = MainWindow::resourcePath();
1148 filename += "koalarm.wav"; 1149 filename += "koalarm.wav";
1149 QString tempfilename; 1150 QString tempfilename;
1150 if ( mess.left( 13 ) == "suspend_alarm") { 1151 if ( mess.left( 13 ) == "suspend_alarm") {
1151 bool error = false; 1152 bool error = false;
1152 int len = mess.mid( 13 ).find("+++"); 1153 int len = mess.mid( 13 ).find("+++");
1153 if ( len < 2 ) 1154 if ( len < 2 )
1154 error = true; 1155 error = true;
1155 else { 1156 else {
1156 tempfilename = mess.mid( 13, len ); 1157 tempfilename = mess.mid( 13, len );
1157 if ( !QFile::exists( tempfilename ) ) 1158 if ( !QFile::exists( tempfilename ) )
1158 error = true; 1159 error = true;
1159 } 1160 }
1160 if ( ! error ) { 1161 if ( ! error ) {
1161 filename = tempfilename; 1162 filename = tempfilename;
1162 } 1163 }
1163 mAlarmMessage = mess.mid( 13+len+3 ); 1164 mAlarmMessage = mess.mid( 13+len+3 );
1164 //qDebug("suspend file %s ",tempfilename.latin1() ); 1165 //qDebug("suspend file %s ",tempfilename.latin1() );
1165 startAlarm( mAlarmMessage, filename); 1166 startAlarm( mAlarmMessage, filename);
1166 return; 1167 return;
1167 } 1168 }
1168 if ( mess.left( 11 ) == "timer_alarm") { 1169 if ( mess.left( 11 ) == "timer_alarm") {
1169 //mTimerTime = 0; 1170 //mTimerTime = 0;
1170 startAlarm( mess.mid( 11 ), filename ); 1171 startAlarm( mess.mid( 11 ), filename );
1171 return; 1172 return;
1172 } 1173 }
1173 if ( mess.left( 10 ) == "proc_alarm") { 1174 if ( mess.left( 10 ) == "proc_alarm") {
1174 bool error = false; 1175 bool error = false;
1175 int len = mess.mid( 10 ).find("+++"); 1176 int len = mess.mid( 10 ).find("+++");
1176 if ( len < 2 ) 1177 if ( len < 2 )
1177 error = true; 1178 error = true;
1178 else { 1179 else {
1179 tempfilename = mess.mid( 10, len ); 1180 tempfilename = mess.mid( 10, len );
1180 if ( !QFile::exists( tempfilename ) ) 1181 if ( !QFile::exists( tempfilename ) )
1181 error = true; 1182 error = true;
1182 } 1183 }
1183 if ( error ) { 1184 if ( error ) {
1184 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1185 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1185 mAlarmMessage += mess.mid( 10+len+3+9 ); 1186 mAlarmMessage += mess.mid( 10+len+3+9 );
1186 } else { 1187 } else {
1187 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1188 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1188 //qDebug("-----system command %s ",tempfilename.latin1() ); 1189 //qDebug("-----system command %s ",tempfilename.latin1() );
1189#ifndef _WIN32_ 1190#ifndef _WIN32_
1190 if ( vfork () == 0 ) { 1191 if ( vfork () == 0 ) {
1191 execl ( tempfilename.latin1(), 0 ); 1192 execl ( tempfilename.latin1(), 0 );
1192 return; 1193 return;
1193 } 1194 }
1194#else 1195#else
1195 QProcess* p = new QProcess(); 1196 QProcess* p = new QProcess();
1196 p->addArgument( tempfilename.latin1() ); 1197 p->addArgument( tempfilename.latin1() );
1197 p->start(); 1198 p->start();
1198 return; 1199 return;
1199#endif 1200#endif
1200 1201
1201 return; 1202 return;
1202 } 1203 }
1203 1204
1204 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1205 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1205 } 1206 }
1206 if ( mess.left( 11 ) == "audio_alarm") { 1207 if ( mess.left( 11 ) == "audio_alarm") {
1207 bool error = false; 1208 bool error = false;
1208 int len = mess.mid( 11 ).find("+++"); 1209 int len = mess.mid( 11 ).find("+++");
1209 if ( len < 2 ) 1210 if ( len < 2 )
1210 error = true; 1211 error = true;
1211 else { 1212 else {
1212 tempfilename = mess.mid( 11, len ); 1213 tempfilename = mess.mid( 11, len );
1213 if ( !QFile::exists( tempfilename ) ) 1214 if ( !QFile::exists( tempfilename ) )
1214 error = true; 1215 error = true;
1215 } 1216 }
1216 if ( ! error ) { 1217 if ( ! error ) {
1217 filename = tempfilename; 1218 filename = tempfilename;
1218 } 1219 }
1219 mAlarmMessage = mess.mid( 11+len+3+9 ); 1220 mAlarmMessage = mess.mid( 11+len+3+9 );
1220 //qDebug("audio file command %s ",tempfilename.latin1() ); 1221 //qDebug("audio file command %s ",tempfilename.latin1() );
1221 } 1222 }
1222 if ( mess.left( 9 ) == "cal_alarm") { 1223 if ( mess.left( 9 ) == "cal_alarm") {
1223 mAlarmMessage = mess.mid( 9 ) ; 1224 mAlarmMessage = mess.mid( 9 ) ;
1224 } 1225 }
1225 1226
1226 startAlarm( mAlarmMessage, filename ); 1227 startAlarm( mAlarmMessage, filename );
1227 1228
1228 1229
1229} 1230}
1230 1231
1231void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1232void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1232{ 1233{
1233 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1234 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1234 1235
1235 mSuspendAlarmNotification = noti; 1236 mSuspendAlarmNotification = noti;
1236 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1237 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1237 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1238 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1238 mSuspendTimer->start( ms , true ); 1239 mSuspendTimer->start( ms , true );
1239 1240
1240} 1241}
1241 1242
1242void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1243void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1243{ 1244{
1244 mNextAlarmDateTime = qdt; 1245 mNextAlarmDateTime = qdt;
1245 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1246 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1246 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1247 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1247#ifndef DESKTOP_VERSION 1248#ifndef DESKTOP_VERSION
1248 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1249 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1249#endif 1250#endif
1250 return; 1251 return;
1251 } 1252 }
1252 int maxSec; 1253 int maxSec;
1253 //maxSec = 5; //testing only 1254 //maxSec = 5; //testing only
1254 maxSec = 86400+3600; // one day+1hour 1255 maxSec = 86400+3600; // one day+1hour
1255 mAlarmNotification = noti; 1256 mAlarmNotification = noti;
1256 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1257 int sec = QDateTime::currentDateTime().secsTo( qdt );
1257 if ( sec > maxSec ) { 1258 if ( sec > maxSec ) {
1258 mRecheckAlarmTimer->start( maxSec * 1000 ); 1259 mRecheckAlarmTimer->start( maxSec * 1000 );
1259 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1260 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1260 return; 1261 return;
1261 } else { 1262 } else {
1262 mRecheckAlarmTimer->stop(); 1263 mRecheckAlarmTimer->stop();
1263 } 1264 }
1264 //qDebug("Alarm timer started with secs: %d ", sec); 1265 //qDebug("Alarm timer started with secs: %d ", sec);
1265 mAlarmTimer->start( sec *1000 , true ); 1266 mAlarmTimer->start( sec *1000 , true );
1266 1267
1267} 1268}
1268// called by mRecheckAlarmTimer to get next alarm 1269// called by mRecheckAlarmTimer to get next alarm
1269// we need this, because a QTimer has only a max range of 25 days 1270// we need this, because a QTimer has only a max range of 25 days
1270void CalendarView::recheckTimerAlarm() 1271void CalendarView::recheckTimerAlarm()
1271{ 1272{
1272 mAlarmTimer->stop(); 1273 mAlarmTimer->stop();
1273 mRecheckAlarmTimer->stop(); 1274 mRecheckAlarmTimer->stop();
1274 mCalendar->checkAlarmForIncidence( 0, true ); 1275 mCalendar->checkAlarmForIncidence( 0, true );
1275} 1276}
1276#ifndef DESKTOP_VERSION 1277#ifndef DESKTOP_VERSION
1277void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1278void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1278#else 1279#else
1279void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1280void CalendarView::removeAlarm(const QDateTime &, const QString & )
1280#endif 1281#endif
1281{ 1282{
1282 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1283 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1283 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1284 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1284#ifndef DESKTOP_VERSION 1285#ifndef DESKTOP_VERSION
1285 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1286 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1286#endif 1287#endif
1287 return; 1288 return;
1288 } 1289 }
1289 mAlarmTimer->stop(); 1290 mAlarmTimer->stop();
1290} 1291}
1291void CalendarView::selectWeekNum ( int num ) 1292void CalendarView::selectWeekNum ( int num )
1292{ 1293{
1293 dateNavigator()->blockSignals( true ); 1294 dateNavigator()->blockSignals( true );
1294 dateNavigator()->selectWeek( num ); 1295 dateNavigator()->selectWeek( num );
1295 dateNavigator()->blockSignals( false ); 1296 dateNavigator()->blockSignals( false );
1296 mViewManager->showWeekView(); 1297 mViewManager->showWeekView();
1297} 1298}
1298KOViewManager *CalendarView::viewManager() 1299KOViewManager *CalendarView::viewManager()
1299{ 1300{
1300 return mViewManager; 1301 return mViewManager;
1301} 1302}
1302 1303
1303KODialogManager *CalendarView::dialogManager() 1304KODialogManager *CalendarView::dialogManager()
1304{ 1305{
1305 return mDialogManager; 1306 return mDialogManager;
1306} 1307}
1307 1308
1308QDate CalendarView::startDate() 1309QDate CalendarView::startDate()
1309{ 1310{
1310 DateList dates = mNavigator->selectedDates(); 1311 DateList dates = mNavigator->selectedDates();
1311 1312
1312 return dates.first(); 1313 return dates.first();
1313} 1314}
1314 1315
1315QDate CalendarView::endDate() 1316QDate CalendarView::endDate()
1316{ 1317{
1317 DateList dates = mNavigator->selectedDates(); 1318 DateList dates = mNavigator->selectedDates();
1318 1319
1319 return dates.last(); 1320 return dates.last();
1320} 1321}
1321 1322
1322 1323
1323void CalendarView::createPrinter() 1324void CalendarView::createPrinter()
1324{ 1325{
1325#ifndef KORG_NOPRINTER 1326#ifndef KORG_NOPRINTER
1326 if (!mCalPrinter) { 1327 if (!mCalPrinter) {
1327 mCalPrinter = new CalPrinter(this, mCalendar); 1328 mCalPrinter = new CalPrinter(this, mCalendar);
1328 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1329 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1329 } 1330 }
1330#endif 1331#endif
1331} 1332}
1332 1333
1333 1334
1334//KOPrefs::instance()->mWriteBackFile 1335//KOPrefs::instance()->mWriteBackFile
1335//KOPrefs::instance()->mWriteBackExistingOnly 1336//KOPrefs::instance()->mWriteBackExistingOnly
1336 1337
1337// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1338// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1338// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1339// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1339// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1340// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1340// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1341// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1341// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1342// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1342// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1343// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1343 1344
1344int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1345int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1345{ 1346{
1346 1347
1347 // 0 equal 1348 // 0 equal
1348 // 1 take local 1349 // 1 take local
1349 // 2 take remote 1350 // 2 take remote
1350 // 3 cancel 1351 // 3 cancel
1351 QDateTime lastSync = mLastCalendarSync; 1352 QDateTime lastSync = mLastCalendarSync;
1352 QDateTime localMod = local->lastModified(); 1353 QDateTime localMod = local->lastModified();
1353 QDateTime remoteMod = remote->lastModified(); 1354 QDateTime remoteMod = remote->lastModified();
1354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1355 bool remCh, locCh; 1356 bool remCh, locCh;
1356 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1357 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1357 //if ( remCh ) 1358 //if ( remCh )
1358 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1359 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1359 locCh = ( localMod > mLastCalendarSync ); 1360 locCh = ( localMod > mLastCalendarSync );
1360 if ( !remCh && ! locCh ) { 1361 if ( !remCh && ! locCh ) {
1361 //qDebug("both not changed "); 1362 //qDebug("both not changed ");
1362 lastSync = localMod.addDays(1); 1363 lastSync = localMod.addDays(1);
1363 if ( mode <= SYNC_PREF_ASK ) 1364 if ( mode <= SYNC_PREF_ASK )
1364 return 0; 1365 return 0;
1365 } else { 1366 } else {
1366 if ( locCh ) { 1367 if ( locCh ) {
1367 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1368 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1368 lastSync = localMod.addDays( -1 ); 1369 lastSync = localMod.addDays( -1 );
1369 if ( !remCh ) 1370 if ( !remCh )
1370 remoteMod = ( lastSync.addDays( -1 ) ); 1371 remoteMod = ( lastSync.addDays( -1 ) );
1371 } else { 1372 } else {
1372 //qDebug(" not loc changed "); 1373 //qDebug(" not loc changed ");
1373 lastSync = localMod.addDays( 1 ); 1374 lastSync = localMod.addDays( 1 );
1374 if ( remCh ) 1375 if ( remCh )
1375 remoteMod =( lastSync.addDays( 1 ) ); 1376 remoteMod =( lastSync.addDays( 1 ) );
1376 1377
1377 } 1378 }
1378 } 1379 }
1379 full = true; 1380 full = true;
1380 if ( mode < SYNC_PREF_ASK ) 1381 if ( mode < SYNC_PREF_ASK )
1381 mode = SYNC_PREF_ASK; 1382 mode = SYNC_PREF_ASK;
1382 } else { 1383 } else {
1383 if ( localMod == remoteMod ) 1384 if ( localMod == remoteMod )
1384 // if ( local->revision() == remote->revision() ) 1385 // if ( local->revision() == remote->revision() )
1385 return 0; 1386 return 0;
1386 1387
1387 } 1388 }
1388 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1389 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1389 1390
1390 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1391 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1391 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1392 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1392 //full = true; //debug only 1393 //full = true; //debug only
1393 if ( full ) { 1394 if ( full ) {
1394 bool equ = false; 1395 bool equ = false;
1395 if ( local->typeID() == eventID ) { 1396 if ( local->typeID() == eventID ) {
1396 equ = (*((Event*) local) == *((Event*) remote)); 1397 equ = (*((Event*) local) == *((Event*) remote));
1397 } 1398 }
1398 else if ( local->typeID() == todoID ) 1399 else if ( local->typeID() == todoID )
1399 equ = (*((Todo*) local) == (*(Todo*) remote)); 1400 equ = (*((Todo*) local) == (*(Todo*) remote));
1400 else if ( local->typeID() == journalID ) 1401 else if ( local->typeID() == journalID )
1401 equ = (*((Journal*) local) == *((Journal*) remote)); 1402 equ = (*((Journal*) local) == *((Journal*) remote));
1402 if ( equ ) { 1403 if ( equ ) {
1403 //qDebug("equal "); 1404 //qDebug("equal ");
1404 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1405 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1405 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1406 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1406 } 1407 }
1407 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1408 if ( mode < SYNC_PREF_FORCE_LOCAL )
1408 return 0; 1409 return 0;
1409 1410
1410 }//else //debug only 1411 }//else //debug only
1411 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1412 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1412 } 1413 }
1413 int result; 1414 int result;
1414 bool localIsNew; 1415 bool localIsNew;
1415 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1416 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1416 1417
1417 1418
1418 // ************************************************ 1419 // ************************************************
1419 // ************************************************ 1420 // ************************************************
1420 // ************************************************ 1421 // ************************************************
1421 // We may have that lastSync > remoteMod AND lastSync > localMod 1422 // We may have that lastSync > remoteMod AND lastSync > localMod
1422 // BUT remoteMod != localMod 1423 // BUT remoteMod != localMod
1423 1424
1424 1425
1425 if ( full && mode < SYNC_PREF_NEWEST ) 1426 if ( full && mode < SYNC_PREF_NEWEST )
1426 mode = SYNC_PREF_ASK; 1427 mode = SYNC_PREF_ASK;
1427 1428
1428 switch( mode ) { 1429 switch( mode ) {
1429 case SYNC_PREF_LOCAL: 1430 case SYNC_PREF_LOCAL:
1430 if ( lastSync > remoteMod ) 1431 if ( lastSync > remoteMod )
1431 return 1; 1432 return 1;
1432 if ( lastSync > localMod ) 1433 if ( lastSync > localMod )
1433 return 2; 1434 return 2;
1434 return 1; 1435 return 1;
1435 break; 1436 break;
1436 case SYNC_PREF_REMOTE: 1437 case SYNC_PREF_REMOTE:
1437 if ( lastSync > localMod ) 1438 if ( lastSync > localMod )
1438 return 2; 1439 return 2;
1439 if ( lastSync > remoteMod ) 1440 if ( lastSync > remoteMod )
1440 return 1; 1441 return 1;
1441 return 2; 1442 return 2;
1442 break; 1443 break;
1443 case SYNC_PREF_NEWEST: 1444 case SYNC_PREF_NEWEST:
1444 if ( localMod >= remoteMod ) 1445 if ( localMod >= remoteMod )
1445 return 1; 1446 return 1;
1446 else 1447 else
1447 return 2; 1448 return 2;
1448 break; 1449 break;
1449 case SYNC_PREF_ASK: 1450 case SYNC_PREF_ASK:
1450 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1451 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1451 if ( lastSync > remoteMod && lastSync > localMod) 1452 if ( lastSync > remoteMod && lastSync > localMod)
1452 return 0; 1453 return 0;
1453 if ( lastSync > remoteMod ) 1454 if ( lastSync > remoteMod )
1454 return 1; 1455 return 1;
1455 if ( lastSync > localMod ) 1456 if ( lastSync > localMod )