summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-07-07 20:46:00 (UTC)
committer zautrix <zautrix>2005-07-07 20:46:00 (UTC)
commitde5621f2fd3924f27c05459ae555b3bd06c5e584 (patch) (unidiff)
tree589d19415e3c0ff6c08cec375db145242581c143 /korganizer/calendarview.cpp
parent766b53919de14b8faec22db32b6a750acde0b760 (diff)
downloadkdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.zip
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.gz
kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.bz2
fixxx
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp153
1 files changed, 95 insertions, 58 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index e766b8f..65750af 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -627,113 +627,170 @@ void CalendarView::init()
627 mRecheckAlarmTimer = new QTimer( this ); 627 mRecheckAlarmTimer = new QTimer( this );
628 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 628 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
629 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 629 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
630 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 630 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
631 mAlarmDialog = new AlarmDialog( this ); 631 mAlarmDialog = new AlarmDialog( this );
632 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 632 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
633 mAlarmDialog->setServerNotification( false ); 633 mAlarmDialog->setServerNotification( false );
634 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 634 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
635 635
636 636
637#ifndef DESKTOP_VERSION 637#ifndef DESKTOP_VERSION
638//US listen for arriving address resultsets 638//US listen for arriving address resultsets
639 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 639 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
640 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 640 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
641#endif 641#endif
642 mDateNavigator->setCalendar( mCalendar ); 642 mDateNavigator->setCalendar( mCalendar );
643} 643}
644 644
645 645
646CalendarView::~CalendarView() 646CalendarView::~CalendarView()
647{ 647{
648 // kdDebug() << "~CalendarView()" << endl; 648 // kdDebug() << "~CalendarView()" << endl;
649 //qDebug("CalendarView::~CalendarView() "); 649 //qDebug("CalendarView::~CalendarView() ");
650 delete mDialogManager; 650 delete mDialogManager;
651 delete mViewManager; 651 delete mViewManager;
652 delete mStorage; 652 delete mStorage;
653 delete mDateFrame ; 653 delete mDateFrame ;
654 delete mEventViewerDialog; 654 delete mEventViewerDialog;
655 //kdDebug() << "~CalendarView() done" << endl; 655 //kdDebug() << "~CalendarView() done" << endl;
656} 656}
657void CalendarView::nextConflict( bool all, bool allday ) 657void CalendarView::nextConflict( bool all, bool allday )
658{ 658{
659 QDate start = mNavigator->selectedDates().first().addDays(1); 659
660 QPtrList<Event> testlist = mCalendar->events();
661 Event * test = testlist.first();
662 while ( test ) {
663 test->setTagged( false );
664 }
665 QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0));
666 QDateTime conflict;
667 QDateTime retVal;
668 bool found = false;
669 Event * cE = 0;
670 QPtrList<Event> testlist2 = testlist;
671 while ( test ) {
672 Event * test2 = testlist2.first();
673 while ( test2 ) {
674 if ( !test2->isTagged() ) {
675 if ( test->isOverlapping ( test2, &retVal, true ) ) {
676 if ( ! found ) {
677 if ( retVal >= startDT ) {
678 conflict = retVal;
679 cE = test;
680 found = true;
681 }
682 } else {
683 if ( retVal >= startDT && retVal < conflict ) {
684 conflict = retVal;
685 cE = test;
686 }
687 }
688 }
689 }
690 test2 = testlist2.next();
691 }
692 test->setTagged( true );
693 test = testlist.next();
694 }
695 if ( found ) {
696 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
697 mViewManager->showDayView();
698 mNavigator->slotDaySelect( conflict.date() );
699 int hour = conflict.time().hour();
700 mViewManager->agendaView()->setStartHour( hour );
701 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
702 return;
703 }
704
705 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
706 qDebug("No conflict found ");
707 return;
708
709
710
711
712
713#if 0
714
715
660 QDate end = start.addDays( 365*2); 716 QDate end = start.addDays( 365*2);
661 while ( start < end ) { 717 while ( start < end ) {
662 QPtrList<Event> eventList = calendar()->events( start ); 718 QPtrList<Event> eventList = calendar()->events( start );
663 Event * ev = eventList.first(); 719 Event * ev = eventList.first();
664 QPtrList<Event> test = eventList; 720 QPtrList<Event> test = eventList;
665 while ( ev ) { 721 while ( ev ) {
666 //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); 722 //qDebug("found %d on %s ", eventList.count(), start.toString().latin1());
667 Event * t_ev = test.first(); 723 Event * t_ev = test.first();
668 QDateTime es = ev->dtStart(); 724 QDateTime es = ev->dtStart();
669 QDateTime ee = ev->dtEnd(); 725 QDateTime ee = ev->dtEnd();
670 if ( ev->doesFloat() ) 726 if ( ev->doesFloat() )
671 ee = ee.addDays( 1 ); 727 ee = ee.addDays( 1 );
672 if ( ! all ) { 728 if ( ! all ) {
673 if ( ev->doesFloat() != allday ) 729 if ( ev->doesFloat() != allday )
674 t_ev = 0; 730 t_ev = 0;
675 } 731 }
676 while ( t_ev ) { 732 while ( t_ev ) {
677 bool skip = false; 733 bool skip = false;
678 if ( ! all ) { 734 if ( ! all ) {
679 if ( t_ev->doesFloat() != allday ) 735 if ( t_ev->doesFloat() != allday )
680 skip = true; 736 skip = true;
681 } 737 }
682 if ( !skip && ev != t_ev ) { 738 if ( !skip && ev != t_ev ) {
683 QDateTime ets = t_ev->dtStart(); 739 QDateTime ets = t_ev->dtStart();
684 QDateTime ete = t_ev->dtEnd(); 740 QDateTime ete = t_ev->dtEnd();
685 if ( t_ev->doesFloat() ) 741 if ( t_ev->doesFloat() )
686 ete = ete.addDays( 1 ); 742 ete = ete.addDays( 1 );
687 //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); 743 //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() );
688 if ( es < ete && ets < ee ) { 744 if ( es < ete && ets < ee ) {
689 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 745 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
690 mViewManager->showDayView(); 746 mViewManager->showDayView();
691 mNavigator->slotDaySelect( start ); 747 mNavigator->slotDaySelect( start );
692 int hour = es.time().hour(); 748 int hour = es.time().hour();
693 if ( ets > es ) 749 if ( ets > es )
694 hour = ets.time().hour(); 750 hour = ets.time().hour();
695 mViewManager->agendaView()->setStartHour( hour ); 751 mViewManager->agendaView()->setStartHour( hour );
696 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); 752 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) );
697 return; 753 return;
698 } 754 }
699 } 755 }
700 t_ev = test.next(); 756 t_ev = test.next();
701 } 757 }
702 ev = eventList.next(); 758 ev = eventList.next();
703 } 759 }
704 start = start.addDays( 1 ); 760 start = start.addDays( 1 );
705 } 761 }
706 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); 762 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
707 qDebug("No conflict found "); 763 qDebug("No conflict found ");
764#endif
708} 765}
709 766
710void CalendarView::conflictAll() 767void CalendarView::conflictAll()
711{ 768{
712 nextConflict ( true, true ); 769 nextConflict ( true, true );
713} 770}
714void CalendarView::conflictAllday() 771void CalendarView::conflictAllday()
715{ 772{
716 nextConflict ( false, true ); 773 nextConflict ( false, true );
717} 774}
718void CalendarView::conflictNotAll() 775void CalendarView::conflictNotAll()
719{ 776{
720 nextConflict ( false, false ); 777 nextConflict ( false, false );
721} 778}
722 779
723void CalendarView::setCalReadOnly( int id, bool readO ) 780void CalendarView::setCalReadOnly( int id, bool readO )
724{ 781{
725 if ( readO ) { 782 if ( readO ) {
726 emit save(); 783 emit save();
727 } 784 }
728 mCalendar->setReadOnly( id, readO ); 785 mCalendar->setReadOnly( id, readO );
729} 786}
730void CalendarView::setScrollBarStep(int val ) 787void CalendarView::setScrollBarStep(int val )
731{ 788{
732#ifdef DESKTOP_VERSION 789#ifdef DESKTOP_VERSION
733 mDateScrollBar->setLineStep ( val ); 790 mDateScrollBar->setLineStep ( val );
734#endif 791#endif
735} 792}
736void CalendarView::scrollBarValue(int val ) 793void CalendarView::scrollBarValue(int val )
737{ 794{
738#ifdef DESKTOP_VERSION 795#ifdef DESKTOP_VERSION
739 if ( QApplication::desktop()->width() < 800 ) return; 796 if ( QApplication::desktop()->width() < 800 ) return;
@@ -2666,162 +2723,142 @@ void CalendarView::eventDeleted()
2666void CalendarView::changeTodoDisplay(Todo *which, int action) 2723void CalendarView::changeTodoDisplay(Todo *which, int action)
2667{ 2724{
2668 changeIncidenceDisplay((Incidence *)which, action); 2725 changeIncidenceDisplay((Incidence *)which, action);
2669 mDateNavigator->updateView(); //LR 2726 mDateNavigator->updateView(); //LR
2670 //mDialogManager->updateSearchDialog(); 2727 //mDialogManager->updateSearchDialog();
2671 2728
2672 if (which) { 2729 if (which) {
2673 mViewManager->updateWNview(); 2730 mViewManager->updateWNview();
2674 //mTodoList->updateView(); 2731 //mTodoList->updateView();
2675 } 2732 }
2676 2733
2677} 2734}
2678 2735
2679void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2736void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2680{ 2737{
2681 updateUnmanagedViews(); 2738 updateUnmanagedViews();
2682 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2739 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2683 if ( action == KOGlobals::EVENTDELETED ) { //delete 2740 if ( action == KOGlobals::EVENTDELETED ) { //delete
2684 mCalendar->checkAlarmForIncidence( 0, true ); 2741 mCalendar->checkAlarmForIncidence( 0, true );
2685 if ( mEventViewerDialog ) 2742 if ( mEventViewerDialog )
2686 mEventViewerDialog->hide(); 2743 mEventViewerDialog->hide();
2687 } 2744 }
2688 else 2745 else
2689 mCalendar->checkAlarmForIncidence( which , false ); 2746 mCalendar->checkAlarmForIncidence( which , false );
2690} 2747}
2691 2748
2692// most of the changeEventDisplays() right now just call the view's 2749// most of the changeEventDisplays() right now just call the view's
2693// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2750// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2694void CalendarView::changeEventDisplay(Event *which, int action) 2751void CalendarView::changeEventDisplay(Event *which, int action)
2695{ 2752{
2696 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2753 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2697 changeIncidenceDisplay((Incidence *)which, action); 2754 changeIncidenceDisplay((Incidence *)which, action);
2698
2699
2700 static bool clearallviews = false; 2755 static bool clearallviews = false;
2701 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2756 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2702 if ( clearallviews ) { 2757 if ( clearallviews ) {
2703 clearAllViews(); 2758 clearAllViews();
2704 clearallviews = false; 2759 clearallviews = false;
2705 } 2760 }
2706 return; 2761 return;
2707 } 2762 }
2708 clearallviews = true; 2763 clearallviews = true;
2709
2710
2711
2712 mDateNavigator->updateView(); 2764 mDateNavigator->updateView();
2713 //mDialogManager->updateSearchDialog(); 2765 //mDialogManager->updateSearchDialog();
2714
2715 if (which) { 2766 if (which) {
2716 // If there is an event view visible update the display 2767 // If there is an event view visible update the display
2717 mViewManager->currentView()->changeEventDisplay(which,action); 2768 mViewManager->currentView()->changeEventDisplay(which,action);
2718 // TODO: check, if update needed 2769 // TODO: check, if update needed
2719 // if (which->getTodoStatus()) { 2770 // if (which->getTodoStatus()) {
2720 mTodoList->updateView(); 2771 mTodoList->updateView();
2721 if ( action != KOGlobals::EVENTDELETED ) { 2772 if ( action != KOGlobals::EVENTDELETED ) {
2722 mConflictingEvent = which ; 2773 mConflictingEvent = which ;
2723 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); 2774 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) );
2724 } 2775 }
2725 // } 2776 // }
2726 } else { 2777 } else {
2727 mViewManager->currentView()->updateView(); 2778 mViewManager->currentView()->updateView();
2728 } 2779 }
2729} 2780}
2730void CalendarView::checkConflictForEvent() 2781void CalendarView::checkConflictForEvent()
2731{ 2782{
2732 2783
2733 if (!KOPrefs::instance()->mConfirm) 2784 if (!KOPrefs::instance()->mConfirm)
2734 return; 2785 return;
2735 if ( ! mConflictingEvent ) return; 2786 if ( ! mConflictingEvent ) return;
2736 if ( mConflictingEvent->doesFloat() ) { 2787 if ( mConflictingEvent->doesFloat() ) {
2737 mConflictingEvent = 0; 2788 mConflictingEvent = 0;
2738 return; 2789 return;
2739 } 2790 }
2740 bool all = false; 2791 QPtrList<Event> testlist = mCalendar->events();
2741 bool allday = false; 2792 Event * test = testlist.first();
2742 Event * ev = mConflictingEvent; 2793 QDateTime conflict;
2743 mConflictingEvent = 0; 2794 QDateTime retVal;
2744 QDate start = ev->dtStart().date(); 2795 bool found = false;
2745 QDate end = ev->dtEnd().date().addDays(1); 2796 Event * cE = 0;
2746 while ( start < end ) { 2797 while ( test ) {
2747 QPtrList<Event> test = calendar()->events( start ); 2798 if ( !test->doesFloat() ) {
2748 //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); 2799 if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) {
2749 Event * t_ev = test.first(); 2800 if ( ! found ) {
2750 QDateTime es = ev->dtStart(); 2801 conflict = retVal;
2751 QDateTime ee = ev->dtEnd(); 2802 cE = test;
2752 if ( ev->doesFloat() ) 2803 } else {
2753 ee = ee.addDays( 1 ); 2804 if ( retVal < conflict ) {
2754 if ( ! all ) { 2805 conflict = retVal;
2755 if ( ev->doesFloat() != allday ) 2806 cE = test;
2756 t_ev = 0; 2807 }
2757 }
2758 while ( t_ev ) {
2759 bool skip = false;
2760 if ( ! all ) {
2761 if ( t_ev->doesFloat() != allday )
2762 skip = true;
2763 }
2764 if ( !skip && ev != t_ev ) {
2765 QDateTime ets = t_ev->dtStart();
2766 QDateTime ete = t_ev->dtEnd();
2767 if ( t_ev->doesFloat() )
2768 ete = ete.addDays( 1 );
2769 //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() );
2770 if ( es < ete && ets < ee ) {
2771 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( ev->summary(),0 ) ).arg( KGlobal::formatMessage ( t_ev->summary(),0 )).arg(KGlobal::locale()->formatDate(start) ) ;
2772 qApp->processEvents();
2773 int km = KMessageBox::warningContinueCancel(this,mess,
2774 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2775 if ( km != KMessageBox::Continue )
2776 return;
2777
2778 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2779 mViewManager->showDayView();
2780 mNavigator->slotDaySelect( start );
2781 int hour = es.time().hour();
2782 if ( ets > es )
2783 hour = ets.time().hour();
2784 mViewManager->agendaView()->setStartHour( hour );
2785 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) );
2786 return;
2787 } 2808 }
2809 found = true;
2788 } 2810 }
2789 t_ev = test.next();
2790 } 2811 }
2791 start = start.addDays( 1 ); 2812 test = testlist.next();
2792 } 2813 }
2793 qDebug("No conflict found "); 2814 if ( found ) {
2794 2815 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
2816 qApp->processEvents();
2817 int km = KMessageBox::warningContinueCancel(this,mess,
2818 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2819 if ( km != KMessageBox::Continue )
2820 return;
2795 2821
2822 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2823 mViewManager->showDayView();
2824 mNavigator->slotDaySelect( conflict.date() );
2825 int hour = conflict.time().hour();
2826 mViewManager->agendaView()->setStartHour( hour );
2827 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2828 return;
2829 }
2830
2831 return;
2832
2796} 2833}
2797 2834
2798void CalendarView::updateTodoViews() 2835void CalendarView::updateTodoViews()
2799{ 2836{
2800 mTodoList->updateView(); 2837 mTodoList->updateView();
2801 mViewManager->currentView()->updateView(); 2838 mViewManager->currentView()->updateView();
2802 2839
2803} 2840}
2804 2841
2805 2842
2806 2843
2807void CalendarView::clearAllViews() 2844void CalendarView::clearAllViews()
2808{ 2845{
2809 mTodoList->clearList(); 2846 mTodoList->clearList();
2810 mViewManager->clearAllViews(); 2847 mViewManager->clearAllViews();
2811 SearchDialog * sd = mDialogManager->getSearchDialog(); 2848 SearchDialog * sd = mDialogManager->getSearchDialog();
2812 if ( sd ) { 2849 if ( sd ) {
2813 KOListView* kol = sd->listview(); 2850 KOListView* kol = sd->listview();
2814 if ( kol ) 2851 if ( kol )
2815 kol->clearList(); 2852 kol->clearList();
2816 } 2853 }
2817} 2854}
2818void CalendarView::updateView() 2855void CalendarView::updateView()
2819{ 2856{
2820 static bool clearallviews = false; 2857 static bool clearallviews = false;
2821 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2858 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2822 if ( clearallviews ) { 2859 if ( clearallviews ) {
2823 clearAllViews(); 2860 clearAllViews();
2824 clearallviews = false; 2861 clearallviews = false;
2825 } 2862 }
2826 return; 2863 return;
2827 } 2864 }