-rw-r--r-- | korganizer/calendarview.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9a114d0..e766b8f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2689,70 +2689,140 @@ void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | |||
2689 | mCalendar->checkAlarmForIncidence( which , false ); | 2689 | mCalendar->checkAlarmForIncidence( which , false ); |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | // most of the changeEventDisplays() right now just call the view's | 2692 | // 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. | 2693 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2694 | void CalendarView::changeEventDisplay(Event *which, int action) | 2694 | void CalendarView::changeEventDisplay(Event *which, int action) |
2695 | { | 2695 | { |
2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2697 | changeIncidenceDisplay((Incidence *)which, action); | 2697 | changeIncidenceDisplay((Incidence *)which, action); |
2698 | 2698 | ||
2699 | 2699 | ||
2700 | static bool clearallviews = false; | 2700 | static bool clearallviews = false; |
2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2702 | if ( clearallviews ) { | 2702 | if ( clearallviews ) { |
2703 | clearAllViews(); | 2703 | clearAllViews(); |
2704 | clearallviews = false; | 2704 | clearallviews = false; |
2705 | } | 2705 | } |
2706 | return; | 2706 | return; |
2707 | } | 2707 | } |
2708 | clearallviews = true; | 2708 | clearallviews = true; |
2709 | 2709 | ||
2710 | 2710 | ||
2711 | 2711 | ||
2712 | mDateNavigator->updateView(); | 2712 | mDateNavigator->updateView(); |
2713 | //mDialogManager->updateSearchDialog(); | 2713 | //mDialogManager->updateSearchDialog(); |
2714 | 2714 | ||
2715 | if (which) { | 2715 | if (which) { |
2716 | // If there is an event view visible update the display | 2716 | // If there is an event view visible update the display |
2717 | mViewManager->currentView()->changeEventDisplay(which,action); | 2717 | mViewManager->currentView()->changeEventDisplay(which,action); |
2718 | // TODO: check, if update needed | 2718 | // TODO: check, if update needed |
2719 | // if (which->getTodoStatus()) { | 2719 | // if (which->getTodoStatus()) { |
2720 | mTodoList->updateView(); | 2720 | mTodoList->updateView(); |
2721 | if ( action != KOGlobals::EVENTDELETED ) { | ||
2722 | mConflictingEvent = which ; | ||
2723 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | ||
2724 | } | ||
2721 | // } | 2725 | // } |
2722 | } else { | 2726 | } else { |
2723 | mViewManager->currentView()->updateView(); | 2727 | mViewManager->currentView()->updateView(); |
2724 | } | 2728 | } |
2725 | } | 2729 | } |
2730 | void CalendarView::checkConflictForEvent() | ||
2731 | { | ||
2732 | |||
2733 | if (!KOPrefs::instance()->mConfirm) | ||
2734 | return; | ||
2735 | if ( ! mConflictingEvent ) return; | ||
2736 | if ( mConflictingEvent->doesFloat() ) { | ||
2737 | mConflictingEvent = 0; | ||
2738 | return; | ||
2739 | } | ||
2740 | bool all = false; | ||
2741 | bool allday = false; | ||
2742 | Event * ev = mConflictingEvent; | ||
2743 | mConflictingEvent = 0; | ||
2744 | QDate start = ev->dtStart().date(); | ||
2745 | QDate end = ev->dtEnd().date().addDays(1); | ||
2746 | while ( start < end ) { | ||
2747 | QPtrList<Event> test = calendar()->events( start ); | ||
2748 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
2749 | Event * t_ev = test.first(); | ||
2750 | QDateTime es = ev->dtStart(); | ||
2751 | QDateTime ee = ev->dtEnd(); | ||
2752 | if ( ev->doesFloat() ) | ||
2753 | ee = ee.addDays( 1 ); | ||
2754 | if ( ! all ) { | ||
2755 | if ( ev->doesFloat() != allday ) | ||
2756 | t_ev = 0; | ||
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 | } | ||
2788 | } | ||
2789 | t_ev = test.next(); | ||
2790 | } | ||
2791 | start = start.addDays( 1 ); | ||
2792 | } | ||
2793 | qDebug("No conflict found "); | ||
2794 | |||
2726 | 2795 | ||
2796 | } | ||
2727 | 2797 | ||
2728 | void CalendarView::updateTodoViews() | 2798 | void CalendarView::updateTodoViews() |
2729 | { | 2799 | { |
2730 | mTodoList->updateView(); | 2800 | mTodoList->updateView(); |
2731 | mViewManager->currentView()->updateView(); | 2801 | mViewManager->currentView()->updateView(); |
2732 | 2802 | ||
2733 | } | 2803 | } |
2734 | 2804 | ||
2735 | 2805 | ||
2736 | 2806 | ||
2737 | void CalendarView::clearAllViews() | 2807 | void CalendarView::clearAllViews() |
2738 | { | 2808 | { |
2739 | mTodoList->clearList(); | 2809 | mTodoList->clearList(); |
2740 | mViewManager->clearAllViews(); | 2810 | mViewManager->clearAllViews(); |
2741 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2811 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2742 | if ( sd ) { | 2812 | if ( sd ) { |
2743 | KOListView* kol = sd->listview(); | 2813 | KOListView* kol = sd->listview(); |
2744 | if ( kol ) | 2814 | if ( kol ) |
2745 | kol->clearList(); | 2815 | kol->clearList(); |
2746 | } | 2816 | } |
2747 | } | 2817 | } |
2748 | void CalendarView::updateView() | 2818 | void CalendarView::updateView() |
2749 | { | 2819 | { |
2750 | static bool clearallviews = false; | 2820 | static bool clearallviews = false; |
2751 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2821 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2752 | if ( clearallviews ) { | 2822 | if ( clearallviews ) { |
2753 | clearAllViews(); | 2823 | clearAllViews(); |
2754 | clearallviews = false; | 2824 | clearallviews = false; |
2755 | } | 2825 | } |
2756 | return; | 2826 | return; |
2757 | } | 2827 | } |
2758 | clearallviews = true; | 2828 | clearallviews = true; |