-rw-r--r-- | bin/kdepim/WhatsNew.txt | 1 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 72 | ||||
-rw-r--r-- | libkcal/event.cpp | 20 | ||||
-rw-r--r-- | libkcal/event.h | 1 |
4 files changed, 71 insertions, 23 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 1f06f1e..c0d63e5 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt @@ -1,15 +1,16 @@ Info about the changes in new versions of KDE-Pim/Pi ********** VERSION 2.1.16 ************ Fixed a problem with the menu bar in KO/Pi and using the "Menu" hardware key on the Zaurus. Added columns for datetime in todo view: Last modified, created and last modified subtodo Fixed a bug in agenda view displaying recurring multiday events which are longer than two days. +Made conflict detection up to 4 times faster. ********** VERSION 2.1.15 ************ Fixed two layout problems on the Z: Made the with of the newly added buttons on the Quick-Todo smaller. Made listweek layout in 2 columns on the Z760 in portait screen and full menubar visible. diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index a9e402e..427d71b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -654,17 +654,19 @@ CalendarView::~CalendarView() delete mDateFrame ; delete mEventViewerDialog; //kdDebug() << "~CalendarView() done" << endl; } void CalendarView::nextConflict( bool all, bool allday ) { - + static bool block = false; + if ( block ) return; + block = true; QPtrList<Event> testlist = mCalendar->events(); Event * test = testlist.first(); while ( test ) { test->setTagged( false ); test = testlist.next(); } QTime st ( 0,0,0); if ( mViewManager->currentView() == mViewManager->agendaView() ) @@ -675,64 +677,79 @@ void CalendarView::nextConflict( bool all, bool allday ) QDateTime retVal; bool found = false; Event * cE = 0; Event * cE2 = 0; QPtrList<Event> testlist2 = testlist; test = testlist.first(); bool skip = false; topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); + //QTime tm; + //tm.start(); while ( test ) { qApp->processEvents(); skip = false; if ( !all ) skip = ( allday != test->doesFloat() ); if ( !skip ) { + if ( found ) + skip = !test->matchTime( &startDT, &conflict ); + else + skip = !test->matchTime( &startDT, 0 ); + } + if ( !skip ) { Event * test2 = testlist2.first(); while ( test2 ) { - skip = false; - if ( !all ) skip = ( allday != test2->doesFloat() ); + skip = test2->isTagged(); + if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); + if ( !skip ) { + if ( found ) + skip = !test2->matchTime( &startDT, &conflict ); + else + skip = !test2->matchTime( &startDT, 0 ); + } if ( !skip ) { - if ( !test2->isTagged() ) { - if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { - //qDebug("overlap "); - if ( ! found ) { - if ( retVal >= startDT ) { - conflict = retVal; - cE = test; - cE2 = test2; - found = true; - } - } else { - if ( retVal >= startDT && retVal < conflict ) { - conflict = retVal; - cE = test; - cE2 = test2; - } + if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { + //qDebug("overlap "); + if ( ! found ) { + if ( retVal >= startDT ) { + conflict = retVal; + cE = test; + cE2 = test2; + found = true; + } + } else { + if ( retVal >= startDT && retVal < conflict ) { + conflict = retVal; + cE = test; + cE2 = test2; } } } } test2 = testlist2.next(); } } test->setTagged( true ); test = testlist.next(); } + //qDebug("Search time : %d", tm.elapsed()); if ( found ) { if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) mViewManager->showDayView(); mNavigator->slotDaySelect( conflict.date() ); int hour = conflict.time().hour(); mViewManager->agendaView()->setStartHour( hour ); topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); + block = false; return; } topLevelWidget()->setCaption( i18n("No conflict found") ); qDebug("No conflict found "); + block = false; return; } void CalendarView::conflictAll() { nextConflict ( true, true ); } void CalendarView::conflictAllday() @@ -2767,27 +2784,36 @@ void CalendarView::changeEventDisplay(Event *which, int action) } } void CalendarView::checkConflictForEvent() { if (!KOPrefs::instance()->mConfirm) return; if ( ! mConflictingEvent ) return; - topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); + QDateTime current = QDateTime::currentDateTime(); + if ( ! mConflictingEvent->matchTime( ¤t, 0 ) ) { + mConflictingEvent = 0; + return; + } QPtrList<Event> testlist = mCalendar->events(); Event * test = testlist.first(); QDateTime conflict; QDateTime retVal; bool found = false; Event * cE = 0; - QDateTime current = QDateTime::currentDateTime(); + topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); while ( test ) { - qApp->processEvents(); - if ( !test->doesFloat() ) { + qApp->processEvents(); + bool skip = false; + if ( found ) + skip = !test->matchTime( ¤t, &conflict ); + else + skip = !test->matchTime( ¤t, 0 ); + if ( !skip && !test->doesFloat() ) { if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { if ( ! found ) { conflict = retVal; cE = test; } else { if ( retVal < conflict ) { conflict = retVal; cE = test; diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 5285559..ad66639 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp @@ -166,16 +166,36 @@ Event::Transparency Event::transparency() const return mTransparency; } void Event::setDuration(int seconds) { setHasEndDate(false); Incidence::setDuration(seconds); } +bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) +{ + if ( ! doesRecur() ) { + if ( doesFloat() ) { + if ( mDtEnd.addDays( 1 ) < *startDT) + return false; + if ( endDT && mDtStart > * endDT) + return false; + } else { + if ( mDtEnd < *startDT ) + return false; + if ( endDT && mDtStart > * endDT) + return false; + } + } else { + if ( endDT && mDtStart > * endDT) + return false; + } + return true; +} bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) { if ( testEvent == this ) return false; if ( ! doesRecur() && !testEvent->doesRecur() ) { QDateTime te; if ( testEvent->doesFloat() ) te = testEvent->mDtEnd.addDays( 1 ); diff --git a/libkcal/event.h b/libkcal/event.h index e6055a5..2da9770 100644 --- a/libkcal/event.h +++ b/libkcal/event.h @@ -33,16 +33,17 @@ namespace KCal { class Event : public Incidence { public: enum Transparency { Opaque, Transparent }; typedef ListBase<Event> List; Event(); Event(const Event &); ~Event(); + bool matchTime(QDateTime*startDT, QDateTime* endDT); QCString type() const { return "Event"; } IncTypeID typeID() const { return eventID; } Incidence *clone(); QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; /** for setting an event's ending date/time with a QDateTime. */ |