-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 @@ -2719,4 +2719,8 @@ void CalendarView::changeEventDisplay(Event *which, int action) // if (which->getTodoStatus()) { mTodoList->updateView(); + if ( action != KOGlobals::EVENTDELETED ) { + mConflictingEvent = which ; + QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); + } // } } else { @@ -2724,5 +2728,71 @@ void CalendarView::changeEventDisplay(Event *which, int action) } } +void CalendarView::checkConflictForEvent() +{ + + if (!KOPrefs::instance()->mConfirm) + return; + if ( ! mConflictingEvent ) return; + if ( mConflictingEvent->doesFloat() ) { + mConflictingEvent = 0; + return; + } + bool all = false; + bool allday = false; + Event * ev = mConflictingEvent; + mConflictingEvent = 0; + QDate start = ev->dtStart().date(); + QDate end = ev->dtEnd().date().addDays(1); + while ( start < end ) { + QPtrList<Event> test = calendar()->events( start ); + //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); + Event * t_ev = test.first(); + QDateTime es = ev->dtStart(); + QDateTime ee = ev->dtEnd(); + if ( ev->doesFloat() ) + ee = ee.addDays( 1 ); + if ( ! all ) { + if ( ev->doesFloat() != allday ) + t_ev = 0; + } + while ( t_ev ) { + bool skip = false; + if ( ! all ) { + if ( t_ev->doesFloat() != allday ) + skip = true; + } + if ( !skip && ev != t_ev ) { + QDateTime ets = t_ev->dtStart(); + QDateTime ete = t_ev->dtEnd(); + if ( t_ev->doesFloat() ) + ete = ete.addDays( 1 ); + //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); + if ( es < ete && ets < ee ) { + 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) ) ; + qApp->processEvents(); + int km = KMessageBox::warningContinueCancel(this,mess, + i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); + if ( km != KMessageBox::Continue ) + return; + + if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) + mViewManager->showDayView(); + mNavigator->slotDaySelect( start ); + int hour = es.time().hour(); + if ( ets > es ) + hour = ets.time().hour(); + mViewManager->agendaView()->setStartHour( hour ); + topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); + return; + } + } + t_ev = test.next(); + } + start = start.addDays( 1 ); + } + qDebug("No conflict found "); + +} void CalendarView::updateTodoViews() |