-rw-r--r-- | korganizer/komonthview.cpp | 159 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 3 |
4 files changed, 143 insertions, 25 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 770a42b..6646b98 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -398,4 +398,6 @@ void MonthViewCell::clear() | |||
398 | } | 398 | } |
399 | void MonthViewCell::updateCell() | 399 | |
400 | void MonthViewCell::startUpdateCell() | ||
400 | { | 401 | { |
402 | |||
401 | if ( !mMonthView->isUpdatePossible() ) | 403 | if ( !mMonthView->isUpdatePossible() ) |
@@ -420,3 +422,3 @@ void MonthViewCell::updateCell() | |||
420 | #endif | 422 | #endif |
421 | QString tipText(""); | 423 | mToolTip = ""; |
422 | //qApp->processEvents(); | 424 | //qApp->processEvents(); |
@@ -426,15 +428,14 @@ void MonthViewCell::updateCell() | |||
426 | mItemList->insertItem( item ); | 428 | mItemList->insertItem( item ); |
427 | tipText += mHolidayString+"\n"; | 429 | mToolTip += mHolidayString+"\n"; |
430 | } | ||
428 | } | 431 | } |
429 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | ||
430 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | ||
431 | Event *event; | ||
432 | for( event = events.first(); event; event = events.next() ) { // for event | ||
433 | 432 | ||
433 | void MonthViewCell::insertEvent(Event *event) | ||
434 | { | ||
434 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 435 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
435 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 436 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
436 | continue; | 437 | return; |
437 | else | 438 | else |
438 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 439 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
439 | continue; | 440 | return; |
440 | } | 441 | } |
@@ -467,3 +468,3 @@ void MonthViewCell::updateCell() | |||
467 | text = prefix + event->summary(); | 468 | text = prefix + event->summary(); |
468 | tipText += text; | 469 | mToolTip += text; |
469 | } else { | 470 | } else { |
@@ -471,3 +472,3 @@ void MonthViewCell::updateCell() | |||
471 | text = event->summary(); | 472 | text = event->summary(); |
472 | tipText += text; | 473 | mToolTip += text; |
473 | } | 474 | } |
@@ -476,3 +477,3 @@ void MonthViewCell::updateCell() | |||
476 | text += " " + event->summary(); | 477 | text += " " + event->summary(); |
477 | tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 478 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
478 | } | 479 | } |
@@ -520,10 +521,6 @@ void MonthViewCell::updateCell() | |||
520 | mItemList->insertItem( item ); | 521 | mItemList->insertItem( item ); |
521 | tipText += "\n"; | 522 | mToolTip += "\n"; |
522 | |||
523 | } | 523 | } |
524 | 524 | void MonthViewCell::insertTodo(Todo *todo) | |
525 | // insert due todos | 525 | { |
526 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | ||
527 | Todo *todo; | ||
528 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
529 | QString text; | 526 | QString text; |
@@ -564,7 +561,9 @@ void MonthViewCell::updateCell() | |||
564 | mItemList->insertItem( item ); | 561 | mItemList->insertItem( item ); |
565 | tipText += text+"\n"; | 562 | mToolTip += text+"\n"; |
566 | } | 563 | } |
564 | void MonthViewCell::finishUpdateCell() | ||
565 | { | ||
567 | #ifdef DESKTOP_VERSION | 566 | #ifdef DESKTOP_VERSION |
568 | if (tipText != "") | 567 | if (mToolTip != "") |
569 | QToolTip::add(this,tipText,toolTipGroup(),""); | 568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
570 | #endif | 569 | #endif |
@@ -586,2 +585,21 @@ void MonthViewCell::updateCell() | |||
586 | resizeEvent( 0 ); | 585 | resizeEvent( 0 ); |
586 | } | ||
587 | void MonthViewCell::updateCell() | ||
588 | { | ||
589 | if ( !mMonthView->isUpdatePossible() ) | ||
590 | return; | ||
591 | startUpdateCell(); | ||
592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | ||
593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | ||
594 | Event *event; | ||
595 | for( event = events.first(); event; event = events.next() ) { // for event | ||
596 | insertEvent(event); | ||
597 | } | ||
598 | // insert due todos | ||
599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | ||
600 | Todo *todo; | ||
601 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
602 | insertTodo( todo ); | ||
603 | } | ||
604 | finishUpdateCell(); | ||
587 | // if ( isVisible()) | 605 | // if ( isVisible()) |
@@ -592,3 +610,3 @@ void MonthViewCell::updateConfig() | |||
592 | { | 610 | { |
593 | 611 | qDebug("MonthViewCell::updateConfig() "); | |
594 | setFont( KOPrefs::instance()->mMonthViewFont ); | 612 | setFont( KOPrefs::instance()->mMonthViewFont ); |
@@ -960,2 +978,94 @@ void KOMonthView::updateView() | |||
960 | return; | 978 | return; |
979 | QTime ti; | ||
980 | ti.start(); | ||
981 | #if 1 | ||
982 | int i; | ||
983 | for( i = 0; i < mCells.count(); ++i ) { | ||
984 | mCells[i]->startUpdateCell(); | ||
985 | } | ||
986 | |||
987 | QPtrList<Event> events = calendar()->events(); | ||
988 | Event *event; | ||
989 | QDateTime dt; | ||
990 | bool ok; | ||
991 | int timeSpan = mCells.size()-1; | ||
992 | QDate endDate = mStartDate.addDays( timeSpan ); | ||
993 | for( event = events.first(); event; event = events.next() ) { // for event | ||
994 | if ( event->doesRecur() ) { | ||
995 | bool last; | ||
996 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | ||
997 | QDateTime incidenceEnd; | ||
998 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | ||
999 | bool invalid = false; | ||
1000 | while( true ) { | ||
1001 | if ( incidenceStart.isValid() ) { | ||
1002 | incidenceEnd = incidenceStart.addDays( eventlen ); | ||
1003 | int st = incidenceStart.date().daysTo( endDate ); | ||
1004 | if ( st >= 0 ) { // start before timeend | ||
1005 | int end = mStartDate.daysTo( incidenceEnd.date() ); | ||
1006 | if ( end >= 0 ) { // end after timestart --- got one! | ||
1007 | //normalize | ||
1008 | st = timeSpan - st; | ||
1009 | if ( st < 0 ) st = 0; | ||
1010 | if ( end > timeSpan ) end = timeSpan; | ||
1011 | int iii; | ||
1012 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | ||
1013 | for ( iii = st;iii<= end;++iii) | ||
1014 | mCells[iii]->insertEvent( event ); | ||
1015 | } | ||
1016 | } | ||
1017 | } else { | ||
1018 | if ( invalid ) | ||
1019 | break; | ||
1020 | invalid = true; | ||
1021 | //qDebug("invalid %s", event->summary().latin1()); | ||
1022 | incidenceStart = QDateTime( mStartDate ); | ||
1023 | } | ||
1024 | if ( last ) | ||
1025 | break; | ||
1026 | bool ok; | ||
1027 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | ||
1028 | if ( ! ok ) | ||
1029 | break; | ||
1030 | if ( incidenceStart.date() > endDate ) | ||
1031 | break; | ||
1032 | } | ||
1033 | } else { // no recur | ||
1034 | int st = event->dtStart().date().daysTo( endDate ); | ||
1035 | if ( st >= 0 ) { // start before timeend | ||
1036 | int end = mStartDate.daysTo( event->dtEnd().date() ); | ||
1037 | if ( end >= 0 ) { // end after timestart --- got one! | ||
1038 | //normalize | ||
1039 | st = timeSpan - st; | ||
1040 | if ( st < 0 ) st = 0; | ||
1041 | if ( end > timeSpan ) end = timeSpan; | ||
1042 | int iii; | ||
1043 | for ( iii = st;iii<= end;++iii) | ||
1044 | mCells[iii]->insertEvent( event ); | ||
1045 | } | ||
1046 | } | ||
1047 | } | ||
1048 | } | ||
1049 | // insert due todos | ||
1050 | QPtrList<Todo> todos = calendar()->todos( ); | ||
1051 | Todo *todo; | ||
1052 | for(todo = todos.first(); todo; todo = todos.next()) { | ||
1053 | //insertTodo( todo ); | ||
1054 | if ( todo->hasDueDate() ) { | ||
1055 | int day = mStartDate.daysTo( todo->dtDue().date() ); | ||
1056 | if ( day >= 0 && day < mCells.size() ) { | ||
1057 | mCells[day]->insertTodo( todo ); | ||
1058 | } | ||
1059 | } | ||
1060 | } | ||
1061 | |||
1062 | for( i = 0; i < mCells.count(); ++i ) { | ||
1063 | mCells[i]->finishUpdateCell(); | ||
1064 | } | ||
1065 | processSelectionChange(); | ||
1066 | mCells[0]->setFocus(); | ||
1067 | |||
1068 | |||
1069 | #else | ||
1070 | // old code | ||
961 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1071 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
@@ -970,2 +1080,5 @@ void KOMonthView::updateView() | |||
970 | mCells[0]->setFocus(); | 1080 | mCells[0]->setFocus(); |
1081 | #endif | ||
1082 | |||
1083 | qDebug("update time %d ", ti.elapsed()); | ||
971 | } | 1084 | } |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 50903b3..b84065e 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -139,2 +139,6 @@ class MonthViewCell : public QWidget | |||
139 | void updateCell(); | 139 | void updateCell(); |
140 | void startUpdateCell(); | ||
141 | void finishUpdateCell(); | ||
142 | void insertEvent(Event *); | ||
143 | void insertTodo(Todo *); | ||
140 | 144 | ||
@@ -160,2 +164,3 @@ class MonthViewCell : public QWidget | |||
160 | protected: | 164 | protected: |
165 | QString mToolTip; | ||
161 | void resizeEvent( QResizeEvent * ); | 166 | void resizeEvent( QResizeEvent * ); |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 0eba6a9..e75154b 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -589,2 +589,3 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | |||
589 | { | 589 | { |
590 | qDebug("CalendarLocal::rawEvents called "); | ||
590 | Event *event = 0; | 591 | Event *event = 0; |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 28402ae..f9e1e9e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -594,3 +594,3 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
594 | // workaround for bug in recurrence | 594 | // workaround for bug in recurrence |
595 | if ( count == 100 || year < 1980 || year > 5000 ) { | 595 | if ( count == 100 || year < 1000 || year > 5000 ) { |
596 | return QDateTime (); | 596 | return QDateTime (); |
@@ -610,3 +610,2 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
610 | incidenceStart = ((Todo*)this)->dtDue(); | 610 | incidenceStart = ((Todo*)this)->dtDue(); |
611 | |||
612 | } | 611 | } |