summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 947bb66..3aae076 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -917,194 +917,195 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
917 item->updateItem(); 917 item->updateItem();
918} 918}
919 919
920void KOAgendaView::showDates( const QDate &start, const QDate &end ) 920void KOAgendaView::showDates( const QDate &start, const QDate &end )
921{ 921{
922 // kdDebug() << "KOAgendaView::selectDates" << endl; 922 // kdDebug() << "KOAgendaView::selectDates" << endl;
923 923
924 mSelectedDates.clear(); 924 mSelectedDates.clear();
925 // qDebug("KOAgendaView::showDates "); 925 // qDebug("KOAgendaView::showDates ");
926 QDate d = start; 926 QDate d = start;
927 while (d <= end) { 927 while (d <= end) {
928 mSelectedDates.append(d); 928 mSelectedDates.append(d);
929 d = d.addDays( 1 ); 929 d = d.addDays( 1 );
930 } 930 }
931 931
932 // and update the view 932 // and update the view
933 fillAgenda(); 933 fillAgenda();
934} 934}
935 935
936 936
937void KOAgendaView::showEvents(QPtrList<Event>) 937void KOAgendaView::showEvents(QPtrList<Event>)
938{ 938{
939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
940} 940}
941 941
942void KOAgendaView::changeEventDisplay(Event *, int) 942void KOAgendaView::changeEventDisplay(Event *, int)
943{ 943{
944 // qDebug("KOAgendaView::changeEventDisplay "); 944 // qDebug("KOAgendaView::changeEventDisplay ");
945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
946 // this should be re-written to be MUCH smarter. Right now we 946 // this should be re-written to be MUCH smarter. Right now we
947 // are just playing dumb. 947 // are just playing dumb.
948 fillAgenda(); 948 fillAgenda();
949} 949}
950 950
951void KOAgendaView::fillAgenda(const QDate &) 951void KOAgendaView::fillAgenda(const QDate &)
952{ 952{
953 // qDebug("KOAgendaView::fillAgenda "); 953 // qDebug("KOAgendaView::fillAgenda ");
954 fillAgenda(); 954 fillAgenda();
955} 955}
956 956
957void KOAgendaView::fillAgenda() 957void KOAgendaView::fillAgenda()
958{ 958{
959 if ( globalFlagBlockStartup ) 959 if ( globalFlagBlockStartup )
960 return; 960 return;
961 if ( globalFlagBlockAgenda == 1 ) 961 if ( globalFlagBlockAgenda == 1 )
962 return; 962 return;
963 //if ( globalFlagBlockAgenda == 2 ) 963 //if ( globalFlagBlockAgenda == 2 )
964 //globalFlagBlockAgenda = 0; 964 //globalFlagBlockAgenda = 0;
965 // globalFlagBlockPainting = false; 965 // globalFlagBlockPainting = false;
966 if ( globalFlagBlockAgenda == 0 ) 966 if ( globalFlagBlockAgenda == 0 )
967 globalFlagBlockAgenda = 1; 967 globalFlagBlockAgenda = 1;
968 // clearView(); 968 // clearView();
969 //qDebug("fillAgenda()++++ "); 969 //qDebug("fillAgenda()++++ ");
970 globalFlagBlockAgendaItemPaint = 1; 970 globalFlagBlockAgendaItemPaint = 1;
971 mAllDayAgenda->changeColumns(mSelectedDates.count()); 971 mAllDayAgenda->changeColumns(mSelectedDates.count());
972 mAgenda->changeColumns(mSelectedDates.count()); 972 mAgenda->changeColumns(mSelectedDates.count());
973 qApp->processEvents(); 973 qApp->processEvents();
974 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 974 mEventIndicatorTop->changeColumns(mSelectedDates.count());
975 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 975 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
976 setHolidayMasks(); 976 setHolidayMasks();
977 977
978 //mAgenda->hideUnused(); 978 //mAgenda->hideUnused();
979 //mAllDayAgenda->hideUnused(); 979 //mAllDayAgenda->hideUnused();
980 980
981 // mAgenda->blockNextRepaint( false ); 981 // mAgenda->blockNextRepaint( false );
982 // mAgenda->viewport()->repaint(); 982 // mAgenda->viewport()->repaint();
983 // mAgenda->blockNextRepaint( true ); 983 // mAgenda->blockNextRepaint( true );
984 mMinY.resize(mSelectedDates.count()); 984 mMinY.resize(mSelectedDates.count());
985 mMaxY.resize(mSelectedDates.count()); 985 mMaxY.resize(mSelectedDates.count());
986 986
987 QPtrList<Event> dayEvents; 987 QPtrList<Event> dayEvents;
988 988
989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
990 // Therefore, get all of them. 990 // Therefore, get all of them.
991 QPtrList<Todo> todos = calendar()->todos(); 991 QPtrList<Todo> todos = calendar()->todos();
992 992
993 mAgenda->setDateList(mSelectedDates); 993 mAgenda->setDateList(mSelectedDates);
994 994
995 QDate today = QDate::currentDate(); 995 QDate today = QDate::currentDate();
996 996
997 DateList::ConstIterator dit; 997 DateList::ConstIterator dit;
998 int curCol = 0; 998 int curCol = 0;
999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1000 QDate currentDate = *dit; 1000 QDate currentDate = *dit;
1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1002 // << endl; 1002 // << endl;
1003 1003
1004 dayEvents = calendar()->events(currentDate,true); 1004 dayEvents = calendar()->events(currentDate,true);
1005 1005
1006 // Default values, which can never be reached 1006 // Default values, which can never be reached
1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1009 1009
1010 unsigned int numEvent; 1010 unsigned int numEvent;
1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1012 Event *event = dayEvents.at(numEvent); 1012 Event *event = dayEvents.at(numEvent);
1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(15) == QString("last-syncEvent-") ) 1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1014 continue; 1014 if ( event->uid().left(15) == QString("last-syncEvent-") )
1015 continue;
1015 // kdDebug() << " Event: " << event->summary() << endl; 1016 // kdDebug() << " Event: " << event->summary() << endl;
1016 1017
1017 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1018 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1018 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1019 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1019 1020
1020 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1021 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1021 1022
1022 if (event->doesFloat()) { 1023 if (event->doesFloat()) {
1023 if (event->recurrence()->doesRecur()) { 1024 if (event->recurrence()->doesRecur()) {
1024 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1025 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1025 } else { 1026 } else {
1026 if (beginX <= 0 && curCol == 0) { 1027 if (beginX <= 0 && curCol == 0) {
1027 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1028 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1028 } else if (beginX == curCol) { 1029 } else if (beginX == curCol) {
1029 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1030 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1030 } 1031 }
1031 } 1032 }
1032 } else if (event->isMultiDay()) { 1033 } else if (event->isMultiDay()) {
1033 if ( event->doesRecur () ) { 1034 if ( event->doesRecur () ) {
1034 QDate dateit = currentDate; 1035 QDate dateit = currentDate;
1035 int count = 0; 1036 int count = 0;
1036 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1037 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1037 while (! event->recursOn( dateit ) && count <= max ) { 1038 while (! event->recursOn( dateit ) && count <= max ) {
1038 ++count; 1039 ++count;
1039 dateit = dateit.addDays( -1 ); 1040 dateit = dateit.addDays( -1 );
1040 } 1041 }
1041 bool ok; 1042 bool ok;
1042 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1043 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1043 if ( ok ) 1044 if ( ok )
1044 { 1045 {
1045 int secs = event->dtStart().secsTo( event->dtEnd() ); 1046 int secs = event->dtStart().secsTo( event->dtEnd() );
1046 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1047 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1047 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1048 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1048 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1049 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1049 1050
1050 } 1051 }
1051 } 1052 }
1052 int startY = mAgenda->timeToY(event->dtStart().time()); 1053 int startY = mAgenda->timeToY(event->dtStart().time());
1053 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1054 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1054 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1055 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1055 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1056 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1056 //qDebug("insert!!! "); 1057 //qDebug("insert!!! ");
1057 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1058 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1058 } 1059 }
1059 if (beginX == curCol) { 1060 if (beginX == curCol) {
1060 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1061 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1061 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1062 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1062 } else if (endX == curCol) { 1063 } else if (endX == curCol) {
1063 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1064 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1064 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1065 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1065 } else { 1066 } else {
1066 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1067 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1068 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1068 } 1069 }
1069 } else { 1070 } else {
1070 int startY = mAgenda->timeToY(event->dtStart().time()); 1071 int startY = mAgenda->timeToY(event->dtStart().time());
1071 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1072 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1072 if (endY < startY) endY = startY; 1073 if (endY < startY) endY = startY;
1073 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1074 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1074 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1075 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1075 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1076 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1076 } 1077 }
1077 } 1078 }
1078 // ---------- [display Todos -------------- 1079 // ---------- [display Todos --------------
1079 unsigned int numTodo; 1080 unsigned int numTodo;
1080 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1081 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1081 Todo *todo = todos.at(numTodo); 1082 Todo *todo = todos.at(numTodo);
1082 1083
1083 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1084 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1084 1085
1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1086 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1086 // Already completed items can be displayed on their original due date 1087 // Already completed items can be displayed on their original due date
1087 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1088 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1088 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1089 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1089 1090
1090 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1091 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1091 ((currentDate == today) && overdue) ) { 1092 ((currentDate == today) && overdue) ) {
1092 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1093 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1093 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1094 if ( KOPrefs::instance()->mShowTodoInAgenda )
1094 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1095 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1095 } 1096 }
1096 else { 1097 else {
1097 1098
1098 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1099 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1099 int hi = (18/KOPrefs::instance()->mHourSize); 1100 int hi = (18/KOPrefs::instance()->mHourSize);
1100 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1101 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1101 int startY = endY -hi; 1102 int startY = endY -hi;
1102 1103
1103 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1104 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1104 1105
1105 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1106 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1106 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1107 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1107 } 1108 }
1108 } 1109 }
1109 } 1110 }
1110 // ---------- display Todos] -------------- 1111 // ---------- display Todos] --------------