summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/korganizer/germantranslation.txt2
-rw-r--r--korganizer/koagendaview.cpp16
-rw-r--r--korganizer/koeventviewer.cpp5
-rw-r--r--korganizer/koeventviewerdialog.cpp1
-rw-r--r--libkcal/kincidenceformatter.cpp16
-rw-r--r--libkcal/todo.cpp7
6 files changed, 37 insertions, 10 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt
index 0538511..eec0b38 100644
--- a/bin/kdepim/korganizer/germantranslation.txt
+++ b/bin/kdepim/korganizer/germantranslation.txt
@@ -1110,103 +1110,103 @@
1110{ "Set complete","Setze auf erledigt" }, 1110{ "Set complete","Setze auf erledigt" },
1111{ "(cancelled)","(gecancelt)" }, 1111{ "(cancelled)","(gecancelt)" },
1112{ "Click on the week number to\nshow week in agenda view","Klicke auf die Wochennummer\num die Woche in der Agenda anzuzeigen" }, 1112{ "Click on the week number to\nshow week in agenda view","Klicke auf die Wochennummer\num die Woche in der Agenda anzuzeigen" },
1113{ " Local time "," Locale Zeit " }, 1113{ " Local time "," Locale Zeit " },
1114{ "Form2","Form2" }, 1114{ "Form2","Form2" },
1115{ "Filter enabled","Filter angeschaltet" }, 1115{ "Filter enabled","Filter angeschaltet" },
1116{ "Edit Filters","Ändere Filter" }, 1116{ "Edit Filters","Ändere Filter" },
1117{ "Print What's Next View...","Drucke What's Next Ansicht..." }, 1117{ "Print What's Next View...","Drucke What's Next Ansicht..." },
1118{ "Agenda","Agenda" }, 1118{ "Agenda","Agenda" },
1119{ " ("," (" }, 1119{ " ("," (" },
1120{ "<p><b>Due on:</b> %1</p>","<p><b>Fällig am:</b> %1</p>" }, 1120{ "<p><b>Due on:</b> %1</p>","<p><b>Fällig am:</b> %1</p>" },
1121{ "Print","Print" }, 1121{ "Print","Print" },
1122{ "&Setup Printer...","Drucker &Setup..." }, 1122{ "&Setup Printer...","Drucker &Setup..." },
1123{ "View Type","Zeige Typ" }, 1123{ "View Type","Zeige Typ" },
1124{ "Page &orientation:","Seiten Ausrichtung:" }, 1124{ "Page &orientation:","Seiten Ausrichtung:" },
1125{ "Use Default of Selected Style","Default des selektierten Stils" }, 1125{ "Use Default of Selected Style","Default des selektierten Stils" },
1126{ "Use Default Setting of Printer","Default Einstellung des Druckers" }, 1126{ "Use Default Setting of Printer","Default Einstellung des Druckers" },
1127{ "Portrait","Portrait" }, 1127{ "Portrait","Portrait" },
1128{ "Landscape","Landschaft" }, 1128{ "Landscape","Landschaft" },
1129{ "Print day","Drucke Tag" }, 1129{ "Print day","Drucke Tag" },
1130{ "CalPrintDay_Base","CalPrintDay_Base" }, 1130{ "CalPrintDay_Base","CalPrintDay_Base" },
1131{ "Date && Time Range","Datum && Zeitspanne" }, 1131{ "Date && Time Range","Datum && Zeitspanne" },
1132{ "&End date:","&Enddatum:" }, 1132{ "&End date:","&Enddatum:" },
1133{ "&Start date:","&Startdatum:" }, 1133{ "&Start date:","&Startdatum:" },
1134{ "Start &time:","Startzeit:" }, 1134{ "Start &time:","Startzeit:" },
1135{ "End ti&me:","Endzeit:" }, 1135{ "End ti&me:","Endzeit:" },
1136{ "E&xtend time range to include all events","Erweitere Zeitspanne um alle Termine einzuschliessen" }, 1136{ "E&xtend time range to include all events","Erweitere Zeitspanne um alle Termine einzuschliessen" },
1137{ "Include to&dos that are due on the printed day(s)","Inclusive To&dos, die an den selektierten Tagen fällig sind" }, 1137{ "Include to&dos that are due on the printed day(s)","Inclusive To&dos, die an den selektierten Tagen fällig sind" },
1138{ "Alt+D","Alt+D" }, 1138{ "Alt+D","Alt+D" },
1139{ "&Use colors","Nutze Farben" }, 1139{ "&Use colors","Nutze Farben" },
1140{ "Alt+U","Alt+U" }, 1140{ "Alt+U","Alt+U" },
1141{ "Print week","Drucke Woche" }, 1141{ "Print week","Drucke Woche" },
1142{ "CalPrintWeek_Base","CalPrintWeek_Base" }, 1142{ "CalPrintWeek_Base","CalPrintWeek_Base" },
1143{ "Use &colors","Nutze Farben" }, 1143{ "Use &colors","Nutze Farben" },
1144{ "Type of View","Typ der Ansicht" }, 1144{ "Type of View","Typ der Ansicht" },
1145{ "Print as &Filofax page","Drucke als &Filofax Seite" }, 1145{ "Print as &Filofax page","Drucke als &Filofax Seite" },
1146{ "Alt+F","Alt+F" }, 1146{ "Alt+F","Alt+F" },
1147{ "Print as &timetable view:","Drucke als Zeittabelle:" }, 1147{ "Print as &timetable view:","Drucke als Zeittabelle:" },
1148{ "Alt+T","Alt+T" }, 1148{ "Alt+T","Alt+T" },
1149{ "Print as split week view","Drucke als gesplittete Wochenansicht" }, 1149{ "Print as split week view","Drucke als gesplittete Wochenansicht" },
1150{ "Print month","Drucke Monat" }, 1150{ "Print month","Drucke Monat" },
1151{ "CalPrintMonth_Base","CalPrintMonth_Base" }, 1151{ "CalPrintMonth_Base","CalPrintMonth_Base" },
1152{ "&Start month:","&Startmonat:" }, 1152{ "&Start month:","&Startmonat:" },
1153{ "&End month:","&Endmonat:" }, 1153{ "&End month:","&Endmonat:" },
1154{ "Print week &numbers","Drucke Wochen Nummer(n)" }, 1154{ "Print week &numbers","Drucke Wochen Nummer(n)" },
1155{ "Print todos","Drucke Todos" }, 1155{ "Print todos","Drucke Todos" },
1156{ "CalPrintTodoConfig_Base","CalPrintTodoConfig_Base" }, 1156{ "CalPrintTodoConfig_Base","CalPrintTodoConfig_Base" },
1157{ "Include &description of the item","Inclusive Itembeschreibung" }, 1157{ "Include &description of the item","Inclusive Itembeschreibung" },
1158{ "Include d&ue date of the item","Inclusive Fälligkeitsdatum des Items" }, 1158{ "Include d&ue date of the item","Inclusive Fälligkeitsdatum des Items" },
1159{ "Include &priority of the item","Inclusive Priorität des Items" }, 1159{ "Include &priority of the item","Inclusive Priorität des Items" },
1160{ "Items to Print","Zu druckende Items" }, 1160{ "Items to Print","Zu druckende Items" },
1161{ "&From:","Von:" }, 1161{ "&From:","Von:" },
1162{ "&To:","Bis:" }, 1162{ "&To:","Bis:" },
1163{ "Print &all todo items","Drucke alle Todo Items" }, 1163{ "Print &all todo items","Drucke alle Todo Items" },
1164{ "Print only &uncompleted items","Drucke nur nicht erledigte Todos" }, 1164{ "Print only &uncompleted items","Drucke nur nicht erledigte Todos" },
1165{ "Only items due in the &range:","Nur Items in dem Zeitraum:" }, 1165{ "Only items due in the &range:","Nur Items in dem Zeitraum:" },
1166{ "Todo List","Todo Liste" }, 1166{ "Todo List","Todo Liste" },
1167{ "&Title:","&Titel:" }, 1167{ "&Title:","&Titel:" },
1168{ "Co&nnect subtodos with its parent","Verbinde Unter-Todos mit ihren Ober-Todos" }, 1168{ "Co&nnect subtodos with its parent","Verbinde Unter-Todos mit ihren Ober-Todos" },
1169{ "Todo list","Todo Liste" }, 1169{ "Todo list","Todo Liste" },
1170{ "&Print...","Drucke..." }, 1170{ "&Print...","Drucke..." },
1171{ "<qt>Printing on printer <b>%1</b></qt>","<qt>Drucke auf Drucker <b>%1</b></qt>" }, 1171{ "<qt>Printing on printer <b>%1</b></qt>","<qt>Drucke auf Drucker <b>%1</b></qt>" },
1172{ "[Unconfigured]","[Unkonfiguriert]" }, 1172{ "[Unconfigured]","[Unkonfiguriert]" },
1173{ "OK","OK" }, 1173{ "OK","OK" },
1174{ "FilterEditor","FilterEditor" }, 1174{ "FilterEditor","FilterEditor" },
1175{ "Include","Inclusive" }, 1175{ "Include","Inclusive" },
1176{ "Exclude","Exclusive" }, 1176{ "Exclude","Exclusive" },
1177{ "Edit Selection...","Editiere Auswahl" }, 1177{ "Edit Selection...","Editiere Auswahl" },
1178{ "recurring events","wiederholende Termine" }, 1178{ "recurring events","wiederholende Termine" },
1179{ "recurr. events","wiederh.Termine" }, 1179{ "recurr. events","wiederh.Termine" },
1180{ "completed to-dos","erledigte Todos" }, 1180{ "completed to-dos","erledigte Todos" },
1181{ "events","Termine" }, 1181{ "events","Termine" },
1182{ "todos","Todos" }, 1182{ "todos","Todos" },
1183{ "journals","Journale" }, 1183{ "journals","Journale" },
1184{ "public","öffentl." }, 1184{ "public","öffentl." },
1185{ "private","privat" }, 1185{ "private","privat" },
1186{ "confidential","vertraul." }, 1186{ "confidential","vertraul." },
1187{ "\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!","\nhat Unter-Todos.\nAlle erledigten Unter-Todos\nwerden auch gelöscht!" }, 1187{ "\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!","\nhat Unter-Todos.\nAlle erledigten Unter-Todos\nwerden auch gelöscht!" },
1188{ "Yesterday","Gestern" }, 1188{ "Yesterday","Gestern" },
1189{ "Day after tomorrow","Übermorgen" }, 1189{ "Day after tomorrow","Übermorgen" },
1190{ "Tomorrow","Morgen" }, 1190{ "Tomorrow","Morgen" },
1191{ "Day before yesterday","Vorgestern" }, 1191{ "Day before yesterday","Vorgestern" },
1192{ "Size %1","Größe %1" }, 1192{ "Size %1","Größe %1" },
1193{ "New Agendasize: %1","Neue Agendagröße: %1" }, 1193{ "New Agendasize: %1","Neue Agendagröße: %1" },
1194{ " (%1 y.)"," (%1 J.)" }, 1194{ " (%1 y.)"," (%1 J.)" },
1195{ "Allday:","Ganztägig:" }, 1195{ "Allday:","Ganztägig:" },
1196{ "compl.todos","erled.Todos" }, 1196{ "compl.todos","erled.Todos" },
1197{ "Day view","Tagesansicht" }, 1197{ "Day view","Tagesansicht" },
1198{ "Next days","Nächste Tage" }, 1198{ "Next days","Nächste Tage" },
1199{ "Next week","Nächste Woche" }, 1199{ "Next week","Nächste Woche" },
1200{ "Next two weeks","Nächste zwei Wochen" }, 1200{ "Next two weeks","Nächste zwei Wochen" },
1201{ "Next month","Nächster Monat" }, 1201{ "Next month","Nächster Monat" },
1202{ "Journal view","Journal" }, 1202{ "Journal view","Journal" },
1203{ "Display all opened","Zeige alle geöffnet" }, 1203{ "Display all opened","Zeige alle geöffnet" },
1204{ "Display all closed","Zeige alle geschlossen" }, 1204{ "Display all closed","Zeige alle geschlossen" },
1205{ "Display all flat","Zeige alle flach" }, 1205{ "Display all flat","Zeige alle flach" },
1206{ "","" }, 1206{ "<p><i>Completed on %1</i></p>","<p><i>Erledigt am %1</i></p>" },
1207{ "","" }, 1207{ "","" },
1208{ "","" }, 1208{ "","" },
1209{ "","" }, 1209{ "","" },
1210{ "","" }, 1210{ "","" },
1211{ "","" }, 1211{ "","" },
1212{ "","" }, 1212{ "","" },
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index e0a1a21..1864e22 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1056,208 +1056,214 @@ void KOAgendaView::fillAgenda()
1056 1056
1057 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1057 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1058 // Therefore, get all of them. 1058 // Therefore, get all of them.
1059 QPtrList<Todo> todos = calendar()->todos(); 1059 QPtrList<Todo> todos = calendar()->todos();
1060 1060
1061 mAgenda->setDateList(mSelectedDates); 1061 mAgenda->setDateList(mSelectedDates);
1062 1062
1063 QDate today = QDate::currentDate(); 1063 QDate today = QDate::currentDate();
1064 1064
1065 DateList::ConstIterator dit; 1065 DateList::ConstIterator dit;
1066 int curCol = 0; 1066 int curCol = 0;
1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1067 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1068 QDate currentDate = *dit; 1068 QDate currentDate = *dit;
1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1069 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1070 // << endl; 1070 // << endl;
1071 1071
1072 dayEvents = calendar()->events(currentDate,true); 1072 dayEvents = calendar()->events(currentDate,true);
1073 1073
1074 // Default values, which can never be reached 1074 // Default values, which can never be reached
1075 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1075 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1076 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1076 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1077 1077
1078 unsigned int numEvent; 1078 unsigned int numEvent;
1079 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1079 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1080 Event *event = dayEvents.at(numEvent); 1080 Event *event = dayEvents.at(numEvent);
1081 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1081 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1082 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1082 if ( event->uid().left(15) == QString("last-syncEvent-") )
1083 continue; 1083 continue;
1084 // kdDebug() << " Event: " << event->summary() << endl; 1084 // kdDebug() << " Event: " << event->summary() << endl;
1085 1085
1086 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1086 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1087 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1087 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1088 1088
1089 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1089 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1090 1090
1091 if (event->doesFloat()) { 1091 if (event->doesFloat()) {
1092 if (event->recurrence()->doesRecur()) { 1092 if (event->recurrence()->doesRecur()) {
1093 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1093 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1094 } else { 1094 } else {
1095 if (beginX <= 0 && curCol == 0) { 1095 if (beginX <= 0 && curCol == 0) {
1096 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1096 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1097 } else if (beginX == curCol) { 1097 } else if (beginX == curCol) {
1098 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1098 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1099 } 1099 }
1100 } 1100 }
1101 } else if (event->isMultiDay()) { 1101 } else if (event->isMultiDay()) {
1102 if ( event->doesRecur () ) { 1102 if ( event->doesRecur () ) {
1103 QDate dateit = currentDate; 1103 QDate dateit = currentDate;
1104 int count = 0; 1104 int count = 0;
1105 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1105 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1106 while (! event->recursOn( dateit ) && count <= max ) { 1106 while (! event->recursOn( dateit ) && count <= max ) {
1107 ++count; 1107 ++count;
1108 dateit = dateit.addDays( -1 ); 1108 dateit = dateit.addDays( -1 );
1109 } 1109 }
1110 bool ok; 1110 bool ok;
1111 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1111 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1112 if ( ok ) 1112 if ( ok )
1113 { 1113 {
1114 int secs = event->dtStart().secsTo( event->dtEnd() ); 1114 int secs = event->dtStart().secsTo( event->dtEnd() );
1115 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1115 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1116 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1116 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1117 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1117 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1118 1118
1119 } 1119 }
1120 } 1120 }
1121 int startY = mAgenda->timeToY(event->dtStart().time()); 1121 int startY = mAgenda->timeToY(event->dtStart().time());
1122 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1122 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1123 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1123 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1124 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1124 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1125 //qDebug("insert!!! "); 1125 //qDebug("insert!!! ");
1126 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1126 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1127 } 1127 }
1128 if (beginX == curCol) { 1128 if (beginX == curCol) {
1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1130 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1130 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1131 } else if (endX == curCol) { 1131 } else if (endX == curCol) {
1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1132 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1133 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1133 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1134 } else { 1134 } else {
1135 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1135 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1136 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1136 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1137 } 1137 }
1138 } else { 1138 } else {
1139 int startY = mAgenda->timeToY(event->dtStart().time()); 1139 int startY = mAgenda->timeToY(event->dtStart().time());
1140 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1140 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1141 if (endY < startY) endY = startY; 1141 if (endY < startY) endY = startY;
1142 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1142 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1143 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1143 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1144 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1144 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1145 } 1145 }
1146 } 1146 }
1147 // ---------- [display Todos -------------- 1147 // ---------- [display Todos --------------
1148 unsigned int numTodo; 1148 unsigned int numTodo;
1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1149 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1150 Todo *todo = todos.at(numTodo); 1150 Todo *todo = todos.at(numTodo);
1151 1151
1152 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1152 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1153 1153
1154 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1154 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1155 // Already completed items can be displayed on their original due date 1155 // Already completed items can be displayed on their original due date
1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1156 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1157 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1158 1158
1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1159 if ( ((todo->dtDue().date() == currentDate) && !overdue) || ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1160 ((currentDate == today) && overdue) ) { 1160 ((currentDate == today) && overdue) ) {
1161 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1161 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1162 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1162 if ( KOPrefs::instance()->mShowTodoInAgenda )
1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1163 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1164 } 1164 }
1165 else { 1165 else {
1166 1166 QDateTime dt;
1167 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1167 if ( todo->hasCompletedDate() )
1168 dt = todo->completed();
1169 else
1170 dt = todo->dtDue();;
1171
1172
1173 int endY = mAgenda->timeToY(dt.time()) - 1;
1168 int hi = (18/KOPrefs::instance()->mHourSize); 1174 int hi = (18/KOPrefs::instance()->mHourSize);
1169 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1175 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1170 int startY = endY -hi; 1176 int startY = endY -hi;
1171 1177
1172 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1178 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1173 1179
1174 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1180 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1175 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1181 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1176 } 1182 }
1177 } 1183 }
1178 } 1184 }
1179 // ---------- display Todos] -------------- 1185 // ---------- display Todos] --------------
1180 1186
1181 ++curCol; 1187 ++curCol;
1182 } 1188 }
1183 mAgenda->hideUnused(); 1189 mAgenda->hideUnused();
1184 mAllDayAgenda->hideUnused(); 1190 mAllDayAgenda->hideUnused();
1185 mAgenda->checkScrollBoundaries(); 1191 mAgenda->checkScrollBoundaries();
1186 1192
1187 deleteSelectedDateTime(); 1193 deleteSelectedDateTime();
1188 1194
1189 createDayLabels(); 1195 createDayLabels();
1190 emit incidenceSelected( 0 ); 1196 emit incidenceSelected( 0 );
1191 1197
1192 if ( globalFlagBlockAgenda == 2 ) { 1198 if ( globalFlagBlockAgenda == 2 ) {
1193 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1199 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1194 setStartHour( KOPrefs::instance()->mDayBegins ); 1200 setStartHour( KOPrefs::instance()->mDayBegins );
1195 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1201 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1196 setStartHour( QTime::currentTime ().hour() ); 1202 setStartHour( QTime::currentTime ().hour() );
1197 // qApp->processEvents(); 1203 // qApp->processEvents();
1198 } 1204 }
1199 qApp->processEvents(); 1205 qApp->processEvents();
1200 //qDebug("qApp->processEvents(); END "); 1206 //qDebug("qApp->processEvents(); END ");
1201 globalFlagBlockAgenda = 0; 1207 globalFlagBlockAgenda = 0;
1202 1208
1203 // mAgenda->hideUnused(); 1209 // mAgenda->hideUnused();
1204 //mAllDayAgenda->hideUnused(); 1210 //mAllDayAgenda->hideUnused();
1205 mAllDayAgenda->drawContentsToPainter(); 1211 mAllDayAgenda->drawContentsToPainter();
1206 mAgenda->drawContentsToPainter(); 1212 mAgenda->drawContentsToPainter();
1207 repaintAgenda(); 1213 repaintAgenda();
1208 // mAgenda->finishUpdate(); 1214 // mAgenda->finishUpdate();
1209 //mAllDayAgenda->finishUpdate(); 1215 //mAllDayAgenda->finishUpdate();
1210 1216
1211 // repaintAgenda(); 1217 // repaintAgenda();
1212 //qApp->processEvents(); 1218 //qApp->processEvents();
1213 // globalFlagBlockAgenda = 0; 1219 // globalFlagBlockAgenda = 0;
1214} 1220}
1215void KOAgendaView::repaintAgenda() 1221void KOAgendaView::repaintAgenda()
1216{ 1222{
1217 // mAllDayAgenda->drawContentsToPainter(); 1223 // mAllDayAgenda->drawContentsToPainter();
1218// mAllDayAgenda->viewport()->repaint( false ); 1224// mAllDayAgenda->viewport()->repaint( false );
1219// mAgenda->drawContentsToPainter(); 1225// mAgenda->drawContentsToPainter();
1220// mAgenda->viewport()->repaint( false ); 1226// mAgenda->viewport()->repaint( false );
1221// qApp->processEvents(); 1227// qApp->processEvents();
1222 1228
1223 //qDebug("KOAgendaView::repaintAgenda() "); 1229 //qDebug("KOAgendaView::repaintAgenda() ");
1224 //qApp->processEvents(); 1230 //qApp->processEvents();
1225 mAgenda->viewport()->repaint( false ); 1231 mAgenda->viewport()->repaint( false );
1226 mAllDayAgenda->viewport()->repaint( false ); 1232 mAllDayAgenda->viewport()->repaint( false );
1227 mAgenda->finishUpdate(); 1233 mAgenda->finishUpdate();
1228 mAllDayAgenda->finishUpdate(); 1234 mAllDayAgenda->finishUpdate();
1229} 1235}
1230 1236
1231 1237
1232void KOAgendaView::clearView() 1238void KOAgendaView::clearView()
1233{ 1239{
1234 // kdDebug() << "ClearView" << endl; 1240 // kdDebug() << "ClearView" << endl;
1235 mAllDayAgenda->clear(); 1241 mAllDayAgenda->clear();
1236 mAgenda->clear(); 1242 mAgenda->clear();
1237} 1243}
1238 1244
1239void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1245void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1240 const QDate &td) 1246 const QDate &td)
1241{ 1247{
1242#ifndef KORG_NOPRINTER 1248#ifndef KORG_NOPRINTER
1243 if (fd == td) 1249 if (fd == td)
1244 calPrinter->preview(CalPrinter::Day, fd, td); 1250 calPrinter->preview(CalPrinter::Day, fd, td);
1245 else 1251 else
1246 calPrinter->preview(CalPrinter::Week, fd, td); 1252 calPrinter->preview(CalPrinter::Week, fd, td);
1247#endif 1253#endif
1248} 1254}
1249 1255
1250// void KOAgendaView::updateMovedTodo() 1256// void KOAgendaView::updateMovedTodo()
1251// { 1257// {
1252// // updateConfig(); 1258// // updateConfig();
1253// // emit updateTodoViews(); 1259// // emit updateTodoViews();
1254// } 1260// }
1255 1261
1256void KOAgendaView::newEvent(int gx, int gy) 1262void KOAgendaView::newEvent(int gx, int gy)
1257{ 1263{
1258 if (!mSelectedDates.count()) return; 1264 if (!mSelectedDates.count()) return;
1259 1265
1260 QDate day = mSelectedDates[gx]; 1266 QDate day = mSelectedDates[gx];
1261 1267
1262 QTime time = mAgenda->gyToTime(gy); 1268 QTime time = mAgenda->gyToTime(gy);
1263 QDateTime dt(day,time); 1269 QDateTime dt(day,time);
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 2f0fa9e..36a2947 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -286,194 +286,199 @@ void KOEventViewer::appendEvent(Event *event, int mode )
286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true ); 286 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
287 287
288 } else { 288 } else {
289 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 289 addTag("p",i18n("<b>Last recurrence was on:</b>") );
290 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 290 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
291 } 291 }
292 } else { 292 } else {
293 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 293 mMailSubject += i18n(" - " )+event->dtStartStr( true );
294 294
295 } 295 }
296 296
297 297
298 if (event->isAlarmEnabled()) { 298 if (event->isAlarmEnabled()) {
299 Alarm *alarm =event->alarms().first() ; 299 Alarm *alarm =event->alarms().first() ;
300 QDateTime t = alarm->time(); 300 QDateTime t = alarm->time();
301 int min = t.secsTo( event->dtStart() )/60; 301 int min = t.secsTo( event->dtStart() )/60;
302 QString s =i18n("( %1 min before )").arg( min ); 302 QString s =i18n("( %1 min before )").arg( min );
303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 303 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 304 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
305 //addTag("p",s); 305 //addTag("p",s);
306 } 306 }
307 307
308 addTag("b",i18n("Access: ")); 308 addTag("b",i18n("Access: "));
309 mText.append(event->secrecyStr()+"<br>"); 309 mText.append(event->secrecyStr()+"<br>");
310 if (!event->description().isEmpty()) { 310 if (!event->description().isEmpty()) {
311 addTag("p",i18n("<b>Details: </b>")); 311 addTag("p",i18n("<b>Details: </b>"));
312 addTag("p",event->description()); 312 addTag("p",event->description());
313 } 313 }
314 314
315 formatCategories(event); 315 formatCategories(event);
316 316
317 formatReadOnly(event); 317 formatReadOnly(event);
318 formatAttendees(event); 318 formatAttendees(event);
319 319
320 setText(mText); 320 setText(mText);
321 //QWhatsThis::add(this,mText); 321 //QWhatsThis::add(this,mText);
322 322
323} 323}
324 324
325void KOEventViewer::appendTodo(Todo *event, int mode ) 325void KOEventViewer::appendTodo(Todo *event, int mode )
326{ 326{
327 mMailSubject = ""; 327 mMailSubject = "";
328 mCurrentIncidence = event; 328 mCurrentIncidence = event;
329 topLevelWidget()->setCaption(i18n("Todo Viewer")); 329 topLevelWidget()->setCaption(i18n("Todo Viewer"));
330 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 330 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
331 if (mode == 0 ) 331 if (mode == 0 )
332 addTag("h2",event->summary()); 332 addTag("h2",event->summary());
333 else { 333 else {
334 if ( mColorMode == 1 ) { 334 if ( mColorMode == 1 ) {
335 mText +="<font color=\"#00A000\">"; 335 mText +="<font color=\"#00A000\">";
336 } 336 }
337 if ( mColorMode == 2 ) { 337 if ( mColorMode == 2 ) {
338 mText +="<font color=\"#B00000\">"; 338 mText +="<font color=\"#B00000\">";
339 } 339 }
340 if ( mode == 1 ) { 340 if ( mode == 1 ) {
341 addTag("h2",i18n( "Local: " ) +event->summary()); 341 addTag("h2",i18n( "Local: " ) +event->summary());
342 } else { 342 } else {
343 addTag("h2",i18n( "Remote: " ) +event->summary()); 343 addTag("h2",i18n( "Remote: " ) +event->summary());
344 } 344 }
345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 345 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
346 if ( mColorMode ) 346 if ( mColorMode )
347 mText += "</font>"; 347 mText += "</font>";
348 } 348 }
349 mMailSubject += i18n( "Todo " )+ event->summary(); 349 mMailSubject += i18n( "Todo " )+ event->summary();
350 if (event->cancelled ()) { 350 if (event->cancelled ()) {
351 mText +="<font color=\"#B00000\">"; 351 mText +="<font color=\"#B00000\">";
352 addTag("i",i18n("This todo has been cancelled!")); 352 addTag("i",i18n("This todo has been cancelled!"));
353 mText.append("<br>"); 353 mText.append("<br>");
354 mText += "</font>"; 354 mText += "</font>";
355 mMailSubject += i18n("(cancelled)"); 355 mMailSubject += i18n("(cancelled)");
356 } 356 }
357 357
358 if (!event->location().isEmpty()) { 358 if (!event->location().isEmpty()) {
359 addTag("b",i18n("Location: ")); 359 addTag("b",i18n("Location: "));
360 mText.append(event->location()+"<br>"); 360 mText.append(event->location()+"<br>");
361 mMailSubject += i18n(" at ") + event->location(); 361 mMailSubject += i18n(" at ") + event->location();
362 } 362 }
363 if (event->hasStartDate()) { 363 if (event->hasStartDate()) {
364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 364 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
365 } 365 }
366 if (event->hasDueDate()) { 366 if (event->hasDueDate()) {
367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 367 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
368 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 368 mMailSubject += i18n(" - " )+event->dtDueStr( true );
369 } 369 }
370 addTag("b",i18n("Access: ")); 370 addTag("b",i18n("Access: "));
371 mText.append(event->secrecyStr()+"<br>"); 371 mText.append(event->secrecyStr()+"<br>");
372 if (!event->description().isEmpty()) { 372 if (!event->description().isEmpty()) {
373 addTag("p",i18n("<b>Details: </b>")); 373 addTag("p",i18n("<b>Details: </b>"));
374 addTag("p",event->description()); 374 addTag("p",event->description());
375 } 375 }
376 376
377 formatCategories(event); 377 formatCategories(event);
378 378
379 mText.append(i18n("<p><b>Priority:</b> %2</p>") 379 mText.append(i18n("<p><b>Priority:</b> %2</p>")
380 .arg(QString::number(event->priority()))); 380 .arg(QString::number(event->priority())));
381 381
382 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
383 mText.append(i18n("<p><i>Completed on %1</i></p>")
384 .arg( event->completedStr() ));
385 } else {
382 mText.append(i18n("<p><i>%1 % completed</i></p>") 386 mText.append(i18n("<p><i>%1 % completed</i></p>")
383 .arg(event->percentComplete())); 387 .arg(event->percentComplete()));
388 }
384 389
385 formatReadOnly(event); 390 formatReadOnly(event);
386 formatAttendees(event); 391 formatAttendees(event);
387 if ( event->relatedTo() ) { 392 if ( event->relatedTo() ) {
388 addTag("b",i18n("Parent todo: ")); 393 addTag("b",i18n("Parent todo: "));
389 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 394 mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
390 } 395 }
391 QPtrList<Incidence> Relations = event->relations(); 396 QPtrList<Incidence> Relations = event->relations();
392 Incidence *to; 397 Incidence *to;
393 if ( Relations.first() ) 398 if ( Relations.first() )
394 addTag("b",i18n("Sub todos:<br>")); 399 addTag("b",i18n("Sub todos:<br>"));
395 for (to=Relations.first();to;to=Relations.next()) { 400 for (to=Relations.first();to;to=Relations.next()) {
396 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 401 mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
397 402
398 } 403 }
399 setText(mText); 404 setText(mText);
400} 405}
401 406
402void KOEventViewer::formatCategories(Incidence *event) 407void KOEventViewer::formatCategories(Incidence *event)
403{ 408{
404 if (!event->categoriesStr().isEmpty()) { 409 if (!event->categoriesStr().isEmpty()) {
405 if (event->categories().count() == 1) { 410 if (event->categories().count() == 1) {
406 addTag("h3",i18n("Category")); 411 addTag("h3",i18n("Category"));
407 } else { 412 } else {
408 addTag("h3",i18n("Categories")); 413 addTag("h3",i18n("Categories"));
409 } 414 }
410 addTag("p",event->categoriesStr()); 415 addTag("p",event->categoriesStr());
411 } 416 }
412} 417}
413void KOEventViewer::formatAttendees(Incidence *event) 418void KOEventViewer::formatAttendees(Incidence *event)
414{ 419{
415 QPtrList<Attendee> attendees = event->attendees(); 420 QPtrList<Attendee> attendees = event->attendees();
416 if (attendees.count()) { 421 if (attendees.count()) {
417 422
418 423
419 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 424 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
420 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 425 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
421 addTag("h3",i18n("Organizer")); 426 addTag("h3",i18n("Organizer"));
422 mText.append("<ul><li>"); 427 mText.append("<ul><li>");
423#ifndef KORG_NOKABC 428#ifndef KORG_NOKABC
424 429
425#ifdef DESKTOP_VERSION 430#ifdef DESKTOP_VERSION
426 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 431 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
427 KABC::Addressee::List addressList; 432 KABC::Addressee::List addressList;
428 addressList = add_book->findByEmail(event->organizer()); 433 addressList = add_book->findByEmail(event->organizer());
429 KABC::Addressee o = addressList.first(); 434 KABC::Addressee o = addressList.first();
430 if (!o.isEmpty() && addressList.size()<2) { 435 if (!o.isEmpty() && addressList.size()<2) {
431 mText += "<a href=\"uid:" + o.uid() + "\">"; 436 mText += "<a href=\"uid:" + o.uid() + "\">";
432 mText += o.formattedName(); 437 mText += o.formattedName();
433 mText += "</a>\n"; 438 mText += "</a>\n";
434 } else { 439 } else {
435 mText.append(event->organizer()); 440 mText.append(event->organizer());
436 } 441 }
437#else //DESKTOP_VERSION 442#else //DESKTOP_VERSION
438 mText += "<a href=\"uid:organizer\">"; 443 mText += "<a href=\"uid:organizer\">";
439 mText += event->organizer(); 444 mText += event->organizer();
440 mText += "</a>\n"; 445 mText += "</a>\n";
441#endif //DESKTOP_VERSION 446#endif //DESKTOP_VERSION
442 447
443 448
444#else 449#else
445 mText.append(event->organizer()); 450 mText.append(event->organizer());
446#endif 451#endif
447 452
448 if (iconPath) { 453 if (iconPath) {
449 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 454 mText += " <a href=\"mailto:" + event->organizer() + "\">";
450 mText += "<IMG src=\"" + iconPath + "\">"; 455 mText += "<IMG src=\"" + iconPath + "\">";
451 mText += "</a>\n"; 456 mText += "</a>\n";
452 } 457 }
453 mText.append("</li></ul>"); 458 mText.append("</li></ul>");
454 459
455 addTag("h3",i18n("Attendees")); 460 addTag("h3",i18n("Attendees"));
456 Attendee *a; 461 Attendee *a;
457 mText.append("<ul>"); 462 mText.append("<ul>");
458 for(a=attendees.first();a;a=attendees.next()) { 463 for(a=attendees.first();a;a=attendees.next()) {
459#ifndef KORG_NOKABC 464#ifndef KORG_NOKABC
460#ifdef DESKTOP_VERSION 465#ifdef DESKTOP_VERSION
461 if (a->name().isEmpty()) { 466 if (a->name().isEmpty()) {
462 addressList = add_book->findByEmail(a->email()); 467 addressList = add_book->findByEmail(a->email());
463 KABC::Addressee o = addressList.first(); 468 KABC::Addressee o = addressList.first();
464 if (!o.isEmpty() && addressList.size()<2) { 469 if (!o.isEmpty() && addressList.size()<2) {
465 mText += "<a href=\"uid:" + o.uid() + "\">"; 470 mText += "<a href=\"uid:" + o.uid() + "\">";
466 mText += o.formattedName(); 471 mText += o.formattedName();
467 mText += "</a>\n"; 472 mText += "</a>\n";
468 } else { 473 } else {
469 mText += "<li>"; 474 mText += "<li>";
470 mText.append(a->email()); 475 mText.append(a->email());
471 mText += "\n"; 476 mText += "\n";
472 } 477 }
473 } else { 478 } else {
474 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 479 mText += "<li><a href=\"uid:" + a->uid() + "\">";
475 if (!a->name().isEmpty()) mText += a->name(); 480 if (!a->name().isEmpty()) mText += a->name();
476 else mText += a->email(); 481 else mText += a->email();
477 mText += "</a>\n"; 482 mText += "</a>\n";
478 } 483 }
479#else //DESKTOP_VERSION 484#else //DESKTOP_VERSION
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index 3979ed2..f6f7258 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -128,132 +128,133 @@ void KOEventViewerDialog::setEvent(Event *event)
128void KOEventViewerDialog::setIncidence(Incidence *in ) 128void KOEventViewerDialog::setIncidence(Incidence *in )
129{ 129{
130 if ( in->type() == "Event" ) 130 if ( in->type() == "Event" )
131 setEvent( (Event*) in ); 131 setEvent( (Event*) in );
132 else if ( in->type() =="Todo" ) 132 else if ( in->type() =="Todo" )
133 setTodo( (Todo*) in ); 133 setTodo( (Todo*) in );
134 else if ( in->type() =="Journal" ) 134 else if ( in->type() =="Journal" )
135 setJournal( (Journal*) in ); 135 setJournal( (Journal*) in );
136} 136}
137void KOEventViewerDialog::addIncidence(Incidence *in) 137void KOEventViewerDialog::addIncidence(Incidence *in)
138{ 138{
139 if ( in->type() == "Event" ) 139 if ( in->type() == "Event" )
140 addEvent( (Event*) in ); 140 addEvent( (Event*) in );
141 else if ( in->type() =="Todo" ) 141 else if ( in->type() =="Todo" )
142 mEventViewer->setTodo( (Todo*) in, false ); 142 mEventViewer->setTodo( (Todo*) in, false );
143 else if ( in->type() =="Journal" ) 143 else if ( in->type() =="Journal" )
144 mEventViewer->setJournal( (Journal*) in, false ); 144 mEventViewer->setJournal( (Journal*) in, false );
145 if ( mSyncMode ) { 145 if ( mSyncMode ) {
146 findButton( User1 )->setFocus(); 146 findButton( User1 )->setFocus();
147 setCaption(i18n("Conflict! Please choose entry")); 147 setCaption(i18n("Conflict! Please choose entry"));
148 } 148 }
149} 149}
150 150
151void KOEventViewerDialog::addEvent(Event *event) 151void KOEventViewerDialog::addEvent(Event *event)
152{ 152{
153 mEventViewer->addEvent(event); 153 mEventViewer->addEvent(event);
154 mIncidence = event; 154 mIncidence = event;
155 findButton( Close )->setFocus(); 155 findButton( Close )->setFocus();
156 if ( !mSyncMode ) { 156 if ( !mSyncMode ) {
157 findButton( User1 )->setText( i18n("Agenda")); 157 findButton( User1 )->setText( i18n("Agenda"));
158 } 158 }
159} 159}
160 160
161void KOEventViewerDialog::setTodo(Todo *event) 161void KOEventViewerDialog::setTodo(Todo *event)
162{ 162{
163 mEventViewer->setTodo(event); 163 mEventViewer->setTodo(event);
164 mIncidence = (Incidence*)event; 164 mIncidence = (Incidence*)event;
165 findButton( Close )->setFocus(); 165 findButton( Close )->setFocus();
166 if ( !mSyncMode ) { 166 if ( !mSyncMode ) {
167 findButton( User1 )->setText( i18n("Set complete")); 167 findButton( User1 )->setText( i18n("Set complete"));
168 } 168 }
169} 169}
170void KOEventViewerDialog::setJournal(Journal *j) 170void KOEventViewerDialog::setJournal(Journal *j)
171{ 171{
172 mEventViewer->setJournal(j); 172 mEventViewer->setJournal(j);
173 mIncidence = (Incidence*)j; 173 mIncidence = (Incidence*)j;
174 findButton( Close )->setFocus(); 174 findButton( Close )->setFocus();
175 if ( !mSyncMode ) { 175 if ( !mSyncMode ) {
176 findButton( User1 )->setText( i18n("Agenda")); 176 findButton( User1 )->setText( i18n("Agenda"));
177 } 177 }
178} 178}
179 179
180void KOEventViewerDialog::addText(QString text) 180void KOEventViewerDialog::addText(QString text)
181{ 181{
182 mEventViewer->addText(text); 182 mEventViewer->addText(text);
183 findButton( Close )->setFocus(); 183 findButton( Close )->setFocus();
184} 184}
185void KOEventViewerDialog::editIncidence() 185void KOEventViewerDialog::editIncidence()
186{ 186{
187 if ( mSyncMode ) { 187 if ( mSyncMode ) {
188 mSyncResult = 2; 188 mSyncResult = 2;
189 accept(); 189 accept();
190 return; 190 return;
191 } 191 }
192 if ( mIncidence ){ 192 if ( mIncidence ){
193#ifndef DESKTOP_VERSION 193#ifndef DESKTOP_VERSION
194 hide(); 194 hide();
195#endif 195#endif
196 emit editIncidence( mIncidence ); 196 emit editIncidence( mIncidence );
197 } 197 }
198} 198}
199void KOEventViewerDialog::showIncidence() 199void KOEventViewerDialog::showIncidence()
200{ 200{
201 201
202 if ( mSyncMode ) { 202 if ( mSyncMode ) {
203 mSyncResult = 1; 203 mSyncResult = 1;
204 accept(); 204 accept();
205 return; 205 return;
206 } 206 }
207 207
208 if ( mIncidence ){ 208 if ( mIncidence ){
209#ifndef DESKTOP_VERSION 209#ifndef DESKTOP_VERSION
210 hide(); 210 hide();
211#endif 211#endif
212 QDate date; 212 QDate date;
213 if ( mIncidence->type() == "Todo" ) { 213 if ( mIncidence->type() == "Todo" ) {
214 /* 214 /*
215 if ( ((Todo*)mIncidence)->hasDueDate() ) 215 if ( ((Todo*)mIncidence)->hasDueDate() )
216 date = ((Todo*)mIncidence)->dtDue().date(); 216 date = ((Todo*)mIncidence)->dtDue().date();
217 else { 217 else {
218 globalFlagBlockAgenda = 2; 218 globalFlagBlockAgenda = 2;
219 emit showAgendaView( false ); 219 emit showAgendaView( false );
220 return; 220 return;
221 } 221 }
222 */ 222 */
223 ((Todo*)mIncidence)->setCompleted( true ); 223 ((Todo*)mIncidence)->setCompleted( true );
224 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
224 hide(); 225 hide();
225 emit todoCompleted(((Todo*)mIncidence)); 226 emit todoCompleted(((Todo*)mIncidence));
226 return; 227 return;
227 228
228 } else 229 } else
229 date = mIncidence->dtStart().date(); 230 date = mIncidence->dtStart().date();
230 globalFlagBlockAgenda = 1; 231 globalFlagBlockAgenda = 1;
231 emit showAgendaView( false ); 232 emit showAgendaView( false );
232 globalFlagBlockAgenda = 2; 233 globalFlagBlockAgenda = 2;
233 emit jumpToTime( date ); 234 emit jumpToTime( date );
234 } 235 }
235} 236}
236void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 237void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
237{ 238{
238 switch ( e->key() ) { 239 switch ( e->key() ) {
239 240
240 case Qt::Key_A : 241 case Qt::Key_A :
241 case Qt::Key_L : 242 case Qt::Key_L :
242 showIncidence(); 243 showIncidence();
243 break; 244 break;
244 case Qt::Key_E : 245 case Qt::Key_E :
245 case Qt::Key_R : 246 case Qt::Key_R :
246 editIncidence(); 247 editIncidence();
247 break; 248 break;
248 case Qt::Key_C: 249 case Qt::Key_C:
249 case Qt::Key_Escape: 250 case Qt::Key_Escape:
250 close(); 251 close();
251 break; 252 break;
252 case Qt::Key_I: 253 case Qt::Key_I:
253 accept(); 254 accept();
254 break; 255 break;
255 default: 256 default:
256 break; 257 break;
257 } 258 }
258 259
259} 260}
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 2c45f21..c52f2b3 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -90,239 +90,249 @@ void KIncidenceFormatter::setEvent(Event *event)
90 mText.append(i18n("<p><b>From:</b> %1</p> ") 90 mText.append(i18n("<p><b>From:</b> %1</p> ")
91 .arg(event->dtStartStr( shortDate))); 91 .arg(event->dtStartStr( shortDate)));
92 mText.append(i18n("<p><b>To:</b> %1</p>") 92 mText.append(i18n("<p><b>To:</b> %1</p>")
93 .arg(event->dtEndStr(shortDate))); 93 .arg(event->dtEndStr(shortDate)));
94 } else { 94 } else {
95 mText.append(i18n("<p><b>On:</b> %1</p> ") 95 mText.append(i18n("<p><b>On:</b> %1</p> ")
96 .arg(event->dtStartDateStr( shortDate ))); 96 .arg(event->dtStartDateStr( shortDate )));
97 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 97 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
98 .arg(event->dtStartTimeStr()) 98 .arg(event->dtStartTimeStr())
99 .arg(event->dtEndTimeStr())); 99 .arg(event->dtEndTimeStr()));
100 } 100 }
101 } 101 }
102 102
103 if (event->recurrence()->doesRecur()) { 103 if (event->recurrence()->doesRecur()) {
104 104
105 QString recurText = event->recurrence()->recurrenceText(); 105 QString recurText = event->recurrence()->recurrenceText();
106 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 106 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
107 bool last; 107 bool last;
108 QDate start = QDate::currentDate(); 108 QDate start = QDate::currentDate();
109 QDate next; 109 QDate next;
110 next = event->recurrence()->getPreviousDate( start , &last ); 110 next = event->recurrence()->getPreviousDate( start , &last );
111 if ( !last ) { 111 if ( !last ) {
112 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 112 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
113 addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) ); 113 addTag("p",i18n("Next recurrence is on: ")+ KGlobal::locale()->formatDate( next, shortDate ) );
114 //addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 114 //addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
115 } else { 115 } else {
116 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 116 addTag("p",i18n("<b>Last recurrence was on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
118 } 118 }
119 } 119 }
120 120
121 121
122 if (event->isAlarmEnabled()) { 122 if (event->isAlarmEnabled()) {
123 Alarm *alarm =event->alarms().first() ; 123 Alarm *alarm =event->alarms().first() ;
124 QDateTime t = alarm->time(); 124 QDateTime t = alarm->time();
125 int min = t.secsTo( event->dtStart() )/60; 125 int min = t.secsTo( event->dtStart() )/60;
126 QString s =i18n("(%1 min before)").arg( min ); 126 QString s =i18n("(%1 min before)").arg( min );
127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 127 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 128 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
129 //addTag("p",s); 129 //addTag("p",s);
130 } 130 }
131 131
132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 132 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
133 // mText.append(event->secrecyStr()+"<br>"); 133 // mText.append(event->secrecyStr()+"<br>");
134 formatCategories(event); 134 formatCategories(event);
135 if (!event->description().isEmpty()) { 135 if (!event->description().isEmpty()) {
136 addTag("p",i18n("<b>Details: </b>")); 136 addTag("p",i18n("<b>Details: </b>"));
137 addTag("p",event->description()); 137 addTag("p",event->description());
138 } 138 }
139 139
140 140
141 formatReadOnly(event); 141 formatReadOnly(event);
142 formatAttendees(event); 142 formatAttendees(event);
143 143
144 144
145} 145}
146 146
147void KIncidenceFormatter::setTodo(Todo *event ) 147void KIncidenceFormatter::setTodo(Todo *event )
148{ 148{
149 int mode = 0; 149 int mode = 0;
150 mCurrentIncidence = event; 150 mCurrentIncidence = event;
151 bool shortDate = true; 151 bool shortDate = true;
152 if (mode == 0 ) 152 if (mode == 0 )
153 addTag("h3",event->summary()); 153 addTag("h3",event->summary());
154 else { 154 else {
155 if ( mColorMode == 1 ) { 155 if ( mColorMode == 1 ) {
156 mText +="<font color=\"#00A000\">"; 156 mText +="<font color=\"#00A000\">";
157 } 157 }
158 if ( mColorMode == 2 ) { 158 if ( mColorMode == 2 ) {
159 mText +="<font color=\"#B00000\">"; 159 mText +="<font color=\"#B00000\">";
160 } 160 }
161 if ( mode == 1 ) { 161 if ( mode == 1 ) {
162 addTag("h2",i18n( "Local: " ) +event->summary()); 162 addTag("h2",i18n( "Local: " ) +event->summary());
163 } else { 163 } else {
164 addTag("h2",i18n( "Remote: " ) +event->summary()); 164 addTag("h2",i18n( "Remote: " ) +event->summary());
165 } 165 }
166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 166 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
167 if ( mColorMode ) 167 if ( mColorMode )
168 mText += "</font>"; 168 mText += "</font>";
169 } 169 }
170 if (event->cancelled ()) { 170 if (event->cancelled ()) {
171 mText +="<font color=\"#B00000\">"; 171 mText +="<font color=\"#B00000\">";
172 addTag("i",i18n("This todo has been cancelled!")); 172 addTag("i",i18n("This todo has been cancelled!"));
173 mText.append("<br>"); 173 mText.append("<br>");
174 mText += "</font>"; 174 mText += "</font>";
175 } 175 }
176 176
177 if (!event->location().isEmpty()) { 177 if (!event->location().isEmpty()) {
178 addTag("b",i18n("Location: ")); 178 addTag("b",i18n("Location: "));
179 mText.append(event->location()+"<br>"); 179 mText.append(event->location()+"<br>");
180 } 180 }
181 if (event->hasDueDate()) { 181 if (event->hasDueDate()) {
182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 182 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
183 } 183 }
184 mText.append(i18n("<p><b>Priority:</b> %2</p>") 184 mText.append(i18n("<p><b>Priority:</b> %2</p>")
185 .arg(QString::number(event->priority()))); 185 .arg(QString::number(event->priority())));
186 186
187 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
188 mText.append(i18n("<p><i>Completed on %1</i></p>")
189 .arg( event->completedStr() ));
190 } else {
187 mText.append(i18n("<p><i>%1 % completed</i></p>") 191 mText.append(i18n("<p><i>%1 % completed</i></p>")
188 .arg(event->percentComplete())); 192 .arg(event->percentComplete()));
193 }
194
189 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 195 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
190 formatCategories(event); 196 formatCategories(event);
191 if (!event->description().isEmpty()) { 197 if (!event->description().isEmpty()) {
192 addTag("p",i18n("<b>Details: </b>")); 198 addTag("p",i18n("<b>Details: </b>"));
193 addTag("p",event->description()); 199 addTag("p",event->description());
194 } 200 }
195 201
196 202
197 203
198 formatReadOnly(event); 204 formatReadOnly(event);
199 formatAttendees(event); 205 formatAttendees(event);
200 206
201} 207}
202 208
203void KIncidenceFormatter::setJournal(Journal* ) 209void KIncidenceFormatter::setJournal(Journal* )
204{ 210{
205 211
206} 212}
207 213
208void KIncidenceFormatter::formatCategories(Incidence *event) 214void KIncidenceFormatter::formatCategories(Incidence *event)
209{ 215{
210 if (!event->categoriesStr().isEmpty()) { 216 if (!event->categoriesStr().isEmpty()) {
211 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 217 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() );
212 //mText.append(event->categoriesStr()); 218 //mText.append(event->categoriesStr());
213 } 219 }
214} 220}
215void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 221void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
216{ 222{
217 int number=text.contains("\n"); 223 int number=text.contains("\n");
218 QString str = "<" + tag + ">"; 224 QString str = "<" + tag + ">";
219 QString tmpText=text; 225 QString tmpText=text;
220 QString tmpStr=str; 226 QString tmpStr=str;
221 if(number !=-1) 227 if(number !=-1)
222 { 228 {
223 if (number > 0) { 229 if (number > 0) {
224 int pos=0; 230 int pos=0;
225 QString tmp; 231 QString tmp;
226 for(int i=0;i<=number;i++) { 232 for(int i=0;i<=number;i++) {
227 pos=tmpText.find("\n"); 233 pos=tmpText.find("\n");
228 tmp=tmpText.left(pos); 234 tmp=tmpText.left(pos);
229 tmpText=tmpText.right(tmpText.length()-pos-1); 235 tmpText=tmpText.right(tmpText.length()-pos-1);
230 tmpStr+=tmp+"<br>"; 236 tmpStr+=tmp+"<br>";
231 } 237 }
232 } 238 }
233 else tmpStr += tmpText; 239 else tmpStr += tmpText;
234 tmpStr+="</" + tag + ">"; 240 tmpStr+="</" + tag + ">";
235 mText.append(tmpStr); 241 mText.append(tmpStr);
236 } 242 }
237 else 243 else
238 { 244 {
239 str += text + "</" + tag + ">"; 245 str += text + "</" + tag + ">";
240 mText.append(str); 246 mText.append(str);
241 } 247 }
242} 248}
243 249
244void KIncidenceFormatter::formatAttendees(Incidence *event) 250void KIncidenceFormatter::formatAttendees(Incidence *event)
245{ 251{
246 QPtrList<Attendee> attendees = event->attendees(); 252 QPtrList<Attendee> attendees = event->attendees();
247 if (attendees.count()) { 253 if (attendees.count()) {
248 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 254 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
255 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
249 addTag("h3",i18n("Organizer")); 256 addTag("h3",i18n("Organizer"));
250 mText.append("<ul><li>"); 257 mText.append("<ul><li>");
251#if 0 258#if 0
252 //ndef KORG_NOKABC 259 //ndef KORG_NOKABC
253 260
254 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 261 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
255 KABC::Addressee::List addressList; 262 KABC::Addressee::List addressList;
256 addressList = add_book->findByEmail(event->organizer()); 263 addressList = add_book->findByEmail(event->organizer());
257 KABC::Addressee o = addressList.first(); 264 KABC::Addressee o = addressList.first();
258 if (!o.isEmpty() && addressList.size()<2) { 265 if (!o.isEmpty() && addressList.size()<2) {
259 mText += "<a href=\"uid:" + o.uid() + "\">"; 266 mText += "<a href=\"uid:" + o.uid() + "\">";
260 mText += o.formattedName(); 267 mText += o.formattedName();
261 mText += "</a>\n"; 268 mText += "</a>\n";
262 } else { 269 } else {
263 mText.append(event->organizer()); 270 mText.append(event->organizer());
264 } 271 }
265#else 272#else
266 mText.append(event->organizer()); 273 mText.append(event->organizer());
267#endif 274#endif
268 if (iconPath) { 275 if (iconPath) {
269 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 276 mText += " <a href=\"mailto:" + event->organizer() + "\">";
270 mText += "<IMG src=\"" + iconPath + "\">"; 277 mText += "<IMG src=\"" + iconPath + "\">";
271 mText += "</a>\n"; 278 mText += "</a>\n";
272 } 279 }
273 mText.append("</li></ul>"); 280 mText.append("</li></ul>");
274 281
275 addTag("h3",i18n("Attendees")); 282 addTag("h3",i18n("Attendees"));
276 Attendee *a; 283 Attendee *a;
277 mText.append("<ul>"); 284 mText.append("<ul>");
278 for(a=attendees.first();a;a=attendees.next()) { 285 for(a=attendees.first();a;a=attendees.next()) {
279#if 0 286#if 0
280//ndef KORG_NOKABC 287//ndef KORG_NOKABC
281 if (a->name().isEmpty()) { 288 if (a->name().isEmpty()) {
282 addressList = add_book->findByEmail(a->email()); 289 addressList = add_book->findByEmail(a->email());
283 KABC::Addressee o = addressList.first(); 290 KABC::Addressee o = addressList.first();
284 if (!o.isEmpty() && addressList.size()<2) { 291 if (!o.isEmpty() && addressList.size()<2) {
285 mText += "<a href=\"uid:" + o.uid() + "\">"; 292 mText += "<a href=\"uid:" + o.uid() + "\">";
286 mText += o.formattedName(); 293 mText += o.formattedName();
287 mText += "</a>\n"; 294 mText += "</a>\n";
288 } else { 295 } else {
289 mText += "<li>"; 296 mText += "<li>";
290 mText.append(a->email()); 297 mText.append(a->email());
291 mText += "\n"; 298 mText += "\n";
292 } 299 }
293 } else { 300 } else {
294 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 301 mText += "<li><a href=\"uid:" + a->uid() + "\">";
295 if (!a->name().isEmpty()) mText += a->name(); 302 if (!a->name().isEmpty()) mText += a->name();
296 else mText += a->email(); 303 else mText += a->email();
297 mText += "</a>\n"; 304 mText += "</a>\n";
298 } 305 }
299#else 306#else
300 //qDebug("nokabc "); 307 //qDebug("nokabc ");
301 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 308 mText += "<li><a href=\"uid:" + a->uid() + "\">";
302 if (!a->name().isEmpty()) mText += a->name(); 309 if (!a->name().isEmpty()) mText += a->name();
303 else mText += a->email(); 310 else mText += a->email();
304 mText += "</a>\n"; 311 mText += "</a>\n";
305#endif 312#endif
306 313
307 if (!a->email().isEmpty()) { 314 if (!a->email().isEmpty()) {
308 if (iconPath) { 315 if (iconPath) {
309 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 316 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
310 mText += "<IMG src=\"" + iconPath + "\">"; 317 if ( a->RSVP() )
318 mText += "<IMG src=\"" + iconPath + "\">";
319 else
320 mText += "<IMG src=\"" + NOiconPath + "\">";
311 mText += "</a>\n"; 321 mText += "</a>\n";
312 } 322 }
313 } 323 }
314 if (a->status() != Attendee::NeedsAction ) 324 if (a->status() != Attendee::NeedsAction )
315 mText +="[" + a->statusStr() + "] "; 325 mText +="[" + a->statusStr() + "] ";
316 if (a->role() == Attendee::Chair ) 326 if (a->role() == Attendee::Chair )
317 mText +="(" + a->roleStr().left(1) + ".)"; 327 mText +="(" + a->roleStr().left(1) + ".)";
318 } 328 }
319 mText.append("</li></ul>"); 329 mText.append("</li></ul>");
320 } 330 }
321} 331}
322 332
323void KIncidenceFormatter::formatReadOnly(Incidence *event) 333void KIncidenceFormatter::formatReadOnly(Incidence *event)
324{ 334{
325 if (event->isReadOnly()) { 335 if (event->isReadOnly()) {
326 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 336 addTag("p","<em>(" + i18n("read-only") + ")</em>");
327 } 337 }
328} 338}
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 3d2de61..7362bdf 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -195,180 +195,185 @@ QString Todo::dtDueStr(bool shortfmt) const
195} 195}
196 196
197bool Todo::hasDueDate() const 197bool Todo::hasDueDate() const
198{ 198{
199 return mHasDueDate; 199 return mHasDueDate;
200} 200}
201 201
202void Todo::setHasDueDate(bool f) 202void Todo::setHasDueDate(bool f)
203{ 203{
204 if (mReadOnly) return; 204 if (mReadOnly) return;
205 mHasDueDate = f; 205 mHasDueDate = f;
206 updated(); 206 updated();
207} 207}
208 208
209 209
210#if 0 210#if 0
211void Todo::setStatus(const QString &statStr) 211void Todo::setStatus(const QString &statStr)
212{ 212{
213 if (mReadOnly) return; 213 if (mReadOnly) return;
214 QString ss(statStr.upper()); 214 QString ss(statStr.upper());
215 215
216 if (ss == "X-ACTION") 216 if (ss == "X-ACTION")
217 mStatus = NEEDS_ACTION; 217 mStatus = NEEDS_ACTION;
218 else if (ss == "NEEDS ACTION") 218 else if (ss == "NEEDS ACTION")
219 mStatus = NEEDS_ACTION; 219 mStatus = NEEDS_ACTION;
220 else if (ss == "ACCEPTED") 220 else if (ss == "ACCEPTED")
221 mStatus = ACCEPTED; 221 mStatus = ACCEPTED;
222 else if (ss == "SENT") 222 else if (ss == "SENT")
223 mStatus = SENT; 223 mStatus = SENT;
224 else if (ss == "TENTATIVE") 224 else if (ss == "TENTATIVE")
225 mStatus = TENTATIVE; 225 mStatus = TENTATIVE;
226 else if (ss == "CONFIRMED") 226 else if (ss == "CONFIRMED")
227 mStatus = CONFIRMED; 227 mStatus = CONFIRMED;
228 else if (ss == "DECLINED") 228 else if (ss == "DECLINED")
229 mStatus = DECLINED; 229 mStatus = DECLINED;
230 else if (ss == "COMPLETED") 230 else if (ss == "COMPLETED")
231 mStatus = COMPLETED; 231 mStatus = COMPLETED;
232 else if (ss == "DELEGATED") 232 else if (ss == "DELEGATED")
233 mStatus = DELEGATED; 233 mStatus = DELEGATED;
234 234
235 updated(); 235 updated();
236} 236}
237 237
238void Todo::setStatus(int status) 238void Todo::setStatus(int status)
239{ 239{
240 if (mReadOnly) return; 240 if (mReadOnly) return;
241 mStatus = status; 241 mStatus = status;
242 updated(); 242 updated();
243} 243}
244 244
245int Todo::status() const 245int Todo::status() const
246{ 246{
247 return mStatus; 247 return mStatus;
248} 248}
249 249
250QString Todo::statusStr() const 250QString Todo::statusStr() const
251{ 251{
252 switch(mStatus) { 252 switch(mStatus) {
253 case NEEDS_ACTION: 253 case NEEDS_ACTION:
254 return QString("NEEDS ACTION"); 254 return QString("NEEDS ACTION");
255 break; 255 break;
256 case ACCEPTED: 256 case ACCEPTED:
257 return QString("ACCEPTED"); 257 return QString("ACCEPTED");
258 break; 258 break;
259 case SENT: 259 case SENT:
260 return QString("SENT"); 260 return QString("SENT");
261 break; 261 break;
262 case TENTATIVE: 262 case TENTATIVE:
263 return QString("TENTATIVE"); 263 return QString("TENTATIVE");
264 break; 264 break;
265 case CONFIRMED: 265 case CONFIRMED:
266 return QString("CONFIRMED"); 266 return QString("CONFIRMED");
267 break; 267 break;
268 case DECLINED: 268 case DECLINED:
269 return QString("DECLINED"); 269 return QString("DECLINED");
270 break; 270 break;
271 case COMPLETED: 271 case COMPLETED:
272 return QString("COMPLETED"); 272 return QString("COMPLETED");
273 break; 273 break;
274 case DELEGATED: 274 case DELEGATED:
275 return QString("DELEGATED"); 275 return QString("DELEGATED");
276 break; 276 break;
277 } 277 }
278 return QString(""); 278 return QString("");
279} 279}
280#endif 280#endif
281 281
282bool Todo::isCompleted() const 282bool Todo::isCompleted() const
283{ 283{
284 if (mPercentComplete == 100) return true; 284 if (mPercentComplete == 100) return true;
285 else return false; 285 else return false;
286} 286}
287 287
288void Todo::setCompleted(bool completed) 288void Todo::setCompleted(bool completed)
289{ 289{
290 if (completed) mPercentComplete = 100; 290 if (completed) mPercentComplete = 100;
291 else mPercentComplete = 0; 291 else {
292 mPercentComplete = 0;
293 mHasCompletedDate = false;
294 }
292 updated(); 295 updated();
293} 296}
294 297
295QDateTime Todo::completed() const 298QDateTime Todo::completed() const
296{ 299{
297 return mCompleted; 300 return mCompleted;
298} 301}
299 302
300QString Todo::completedStr() const 303QString Todo::completedStr() const
301{ 304{
302 return KGlobal::locale()->formatDateTime(mCompleted); 305 return KGlobal::locale()->formatDateTime(mCompleted);
303} 306}
304 307
305void Todo::setCompleted(const QDateTime &completed) 308void Todo::setCompleted(const QDateTime &completed)
306{ 309{
307 mHasCompletedDate = true; 310 mHasCompletedDate = true;
308 mPercentComplete = 100; 311 mPercentComplete = 100;
309 mCompleted = getEvenTime(completed); 312 mCompleted = getEvenTime(completed);
310 updated(); 313 updated();
311} 314}
312 315
313bool Todo::hasCompletedDate() const 316bool Todo::hasCompletedDate() const
314{ 317{
315 return mHasCompletedDate; 318 return mHasCompletedDate;
316} 319}
317 320
318int Todo::percentComplete() const 321int Todo::percentComplete() const
319{ 322{
320 return mPercentComplete; 323 return mPercentComplete;
321} 324}
322 325
323void Todo::setPercentComplete(int v) 326void Todo::setPercentComplete(int v)
324{ 327{
325 mPercentComplete = v; 328 mPercentComplete = v;
329 if ( v != 100 )
330 mHasCompletedDate = false;
326 updated(); 331 updated();
327} 332}
328QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 333QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
329{ 334{
330 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 335 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
331 *ok = false; 336 *ok = false;
332 return QDateTime (); 337 return QDateTime ();
333 } 338 }
334 QDateTime incidenceStart; 339 QDateTime incidenceStart;
335 incidenceStart = dtDue(); 340 incidenceStart = dtDue();
336 bool enabled = false; 341 bool enabled = false;
337 Alarm* alarm; 342 Alarm* alarm;
338 int off; 343 int off;
339 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 344 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
340 // if ( QDateTime::currentDateTime() > incidenceStart ){ 345 // if ( QDateTime::currentDateTime() > incidenceStart ){
341// *ok = false; 346// *ok = false;
342// return incidenceStart; 347// return incidenceStart;
343// } 348// }
344 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 349 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
345 if (alarm->enabled()) { 350 if (alarm->enabled()) {
346 if ( alarm->hasTime () ) { 351 if ( alarm->hasTime () ) {
347 if ( alarm->time() < alarmStart ) { 352 if ( alarm->time() < alarmStart ) {
348 alarmStart = alarm->time(); 353 alarmStart = alarm->time();
349 enabled = true; 354 enabled = true;
350 off = alarmStart.secsTo( incidenceStart ); 355 off = alarmStart.secsTo( incidenceStart );
351 } 356 }
352 357
353 } else { 358 } else {
354 int secs = alarm->startOffset().asSeconds(); 359 int secs = alarm->startOffset().asSeconds();
355 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 360 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
356 alarmStart = incidenceStart.addSecs( secs ); 361 alarmStart = incidenceStart.addSecs( secs );
357 enabled = true; 362 enabled = true;
358 off = -secs; 363 off = -secs;
359 } 364 }
360 } 365 }
361 } 366 }
362 } 367 }
363 if ( enabled ) { 368 if ( enabled ) {
364 if ( alarmStart > QDateTime::currentDateTime() ) { 369 if ( alarmStart > QDateTime::currentDateTime() ) {
365 *ok = true; 370 *ok = true;
366 * offset = off; 371 * offset = off;
367 return alarmStart; 372 return alarmStart;
368 } 373 }
369 } 374 }
370 *ok = false; 375 *ok = false;
371 return QDateTime (); 376 return QDateTime ();
372 377
373} 378}
374 379