-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 | |||
@@ -2715,18 +2715,88 @@ void CalendarView::changeEventDisplay(Event *which, int action) | |||
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 | ||