summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt1
-rw-r--r--korganizer/calendarview.cpp72
-rw-r--r--libkcal/event.cpp20
-rw-r--r--libkcal/event.h1
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
@@ -7,2 +7,3 @@ Added columns for datetime in todo view: Last modified, created and last modifie
Fixed a bug in agenda view displaying recurring multiday events which are longer than two days.
+Made conflict detection up to 4 times faster.
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index a9e402e..427d71b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -661,3 +661,5 @@ void CalendarView::nextConflict( bool all, bool allday )
{
-
+ static bool block = false;
+ if ( block ) return;
+ block = true;
QPtrList<Event> testlist = mCalendar->events();
@@ -682,2 +684,4 @@ void CalendarView::nextConflict( bool all, bool allday )
topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
+ //QTime tm;
+ //tm.start();
while ( test ) {
@@ -687,23 +691,33 @@ void CalendarView::nextConflict( bool all, bool allday )
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;
}
@@ -718,2 +732,3 @@ void CalendarView::nextConflict( bool all, bool allday )
}
+ //qDebug("Search time : %d", tm.elapsed());
if ( found ) {
@@ -725,2 +740,3 @@ void CalendarView::nextConflict( bool all, bool allday )
topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
+ block = false;
return;
@@ -730,2 +746,3 @@ void CalendarView::nextConflict( bool all, bool allday )
qDebug("No conflict found ");
+ block = false;
return;
@@ -2774,3 +2791,7 @@ void CalendarView::checkConflictForEvent()
if ( ! mConflictingEvent ) return;
- topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
+ QDateTime current = QDateTime::currentDateTime();
+ if ( ! mConflictingEvent->matchTime( &current, 0 ) ) {
+ mConflictingEvent = 0;
+ return;
+ }
QPtrList<Event> testlist = mCalendar->events();
@@ -2781,6 +2802,11 @@ void CalendarView::checkConflictForEvent()
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( &current, &conflict );
+ else
+ skip = !test->matchTime( &current, 0 );
+ if ( !skip && !test->doesFloat() ) {
if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index 5285559..ad66639 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -173,2 +173,22 @@ void Event::setDuration(int 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 )
diff --git a/libkcal/event.h b/libkcal/event.h
index e6055a5..2da9770 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -40,2 +40,3 @@ class Event : public Incidence
~Event();
+ bool matchTime(QDateTime*startDT, QDateTime* endDT);