summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp3
-rw-r--r--korganizer/kotodoview.cpp29
-rw-r--r--korganizer/kotodoviewitem.cpp30
3 files changed, 39 insertions, 23 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index bbc43e4..42a6f7c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1068,193 +1068,192 @@ void KOAgendaView::fillAgenda()
1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1069 QDate currentDate = *dit; 1069 QDate currentDate = *dit;
1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1071 // << endl; 1071 // << endl;
1072 1072
1073 dayEvents = calendar()->events(currentDate,true); 1073 dayEvents = calendar()->events(currentDate,true);
1074 1074
1075 // Default values, which can never be reached 1075 // Default values, which can never be reached
1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1078 1078
1079 unsigned int numEvent; 1079 unsigned int numEvent;
1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1081 Event *event = dayEvents.at(numEvent); 1081 Event *event = dayEvents.at(numEvent);
1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1083 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1083 if ( event->uid().left(15) == QString("last-syncEvent-") )
1084 continue; 1084 continue;
1085 // kdDebug() << " Event: " << event->summary() << endl; 1085 // kdDebug() << " Event: " << event->summary() << endl;
1086 1086
1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1089 1089
1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1091 1091
1092 if (event->doesFloat()) { 1092 if (event->doesFloat()) {
1093 if (event->recurrence()->doesRecur()) { 1093 if (event->recurrence()->doesRecur()) {
1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1095 } else { 1095 } else {
1096 if (beginX <= 0 && curCol == 0) { 1096 if (beginX <= 0 && curCol == 0) {
1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1098 } else if (beginX == curCol) { 1098 } else if (beginX == curCol) {
1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1100 } 1100 }
1101 } 1101 }
1102 } else if (event->isMultiDay()) { 1102 } else if (event->isMultiDay()) {
1103 if ( event->doesRecur () ) { 1103 if ( event->doesRecur () ) {
1104 QDate dateit = currentDate; 1104 QDate dateit = currentDate;
1105 int count = 0; 1105 int count = 0;
1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1107 while (! event->recursOn( dateit ) && count <= max ) { 1107 while (! event->recursOn( dateit ) && count <= max ) {
1108 ++count; 1108 ++count;
1109 dateit = dateit.addDays( -1 ); 1109 dateit = dateit.addDays( -1 );
1110 } 1110 }
1111 bool ok; 1111 bool ok;
1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1113 if ( ok ) 1113 if ( ok )
1114 { 1114 {
1115 int secs = event->dtStart().secsTo( event->dtEnd() ); 1115 int secs = event->dtStart().secsTo( event->dtEnd() );
1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1118 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1118 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1119 1119
1120 } 1120 }
1121 } 1121 }
1122 int startY = mAgenda->timeToY(event->dtStart().time()); 1122 int startY = mAgenda->timeToY(event->dtStart().time());
1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1124 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1124 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1126 //qDebug("insert!!! "); 1126 //qDebug("insert!!! ");
1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1128 } 1128 }
1129 if (beginX == curCol) { 1129 if (beginX == curCol) {
1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1132 } else if (endX == curCol) { 1132 } else if (endX == curCol) {
1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1135 } else { 1135 } else {
1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1138 } 1138 }
1139 } else { 1139 } else {
1140 int startY = mAgenda->timeToY(event->dtStart().time()); 1140 int startY = mAgenda->timeToY(event->dtStart().time());
1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1142 if (endY < startY) endY = startY; 1142 if (endY < startY) endY = startY;
1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1146 } 1146 }
1147 } 1147 }
1148 // ---------- [display Todos -------------- 1148 // ---------- [display Todos --------------
1149 unsigned int numTodo; 1149 unsigned int numTodo;
1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1151 Todo *todo = todos.at(numTodo); 1151 Todo *todo = todos.at(numTodo);
1152 1152
1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1154 1154
1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1156 // Already completed items can be displayed on their original due date 1156 // Already completed items can be displayed on their original due date
1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1159 bool fillIn = false; 1159 bool fillIn = false;
1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1161 fillIn = true; 1161 fillIn = true;
1162 if ( ! fillIn && !todo->hasCompletedDate() ) 1162 if ( ! fillIn && !todo->hasCompletedDate() )
1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1164 qDebug("refill todo ");
1165 if ( fillIn ) { 1164 if ( fillIn ) {
1166 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1165 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1167 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1166 if ( KOPrefs::instance()->mShowTodoInAgenda )
1168 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1169 } 1168 }
1170 else { 1169 else {
1171 QDateTime dt; 1170 QDateTime dt;
1172 if ( todo->hasCompletedDate() ) 1171 if ( todo->hasCompletedDate() )
1173 dt = todo->completed(); 1172 dt = todo->completed();
1174 else 1173 else
1175 dt = todo->dtDue();; 1174 dt = todo->dtDue();;
1176 1175
1177 1176
1178 int endY = mAgenda->timeToY(dt.time()) - 1; 1177 int endY = mAgenda->timeToY(dt.time()) - 1;
1179 int hi = (18/KOPrefs::instance()->mHourSize); 1178 int hi = (18/KOPrefs::instance()->mHourSize);
1180 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1179 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1181 int startY = endY -hi; 1180 int startY = endY -hi;
1182 1181
1183 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1182 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1184 1183
1185 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1186 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1187 } 1186 }
1188 } 1187 }
1189 } 1188 }
1190 // ---------- display Todos] -------------- 1189 // ---------- display Todos] --------------
1191 1190
1192 ++curCol; 1191 ++curCol;
1193 } 1192 }
1194 mAgenda->hideUnused(); 1193 mAgenda->hideUnused();
1195 mAllDayAgenda->hideUnused(); 1194 mAllDayAgenda->hideUnused();
1196 mAgenda->checkScrollBoundaries(); 1195 mAgenda->checkScrollBoundaries();
1197 1196
1198 deleteSelectedDateTime(); 1197 deleteSelectedDateTime();
1199 1198
1200 createDayLabels(); 1199 createDayLabels();
1201 emit incidenceSelected( 0 ); 1200 emit incidenceSelected( 0 );
1202 1201
1203 if ( globalFlagBlockAgenda == 2 ) { 1202 if ( globalFlagBlockAgenda == 2 ) {
1204 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1203 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1205 setStartHour( KOPrefs::instance()->mDayBegins ); 1204 setStartHour( KOPrefs::instance()->mDayBegins );
1206 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1205 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1207 setStartHour( QTime::currentTime ().hour() ); 1206 setStartHour( QTime::currentTime ().hour() );
1208 // qApp->processEvents(); 1207 // qApp->processEvents();
1209 } 1208 }
1210 qApp->processEvents(); 1209 qApp->processEvents();
1211 //qDebug("qApp->processEvents(); END "); 1210 //qDebug("qApp->processEvents(); END ");
1212 globalFlagBlockAgenda = 0; 1211 globalFlagBlockAgenda = 0;
1213 1212
1214 // mAgenda->hideUnused(); 1213 // mAgenda->hideUnused();
1215 //mAllDayAgenda->hideUnused(); 1214 //mAllDayAgenda->hideUnused();
1216 mAllDayAgenda->drawContentsToPainter(); 1215 mAllDayAgenda->drawContentsToPainter();
1217 mAgenda->drawContentsToPainter(); 1216 mAgenda->drawContentsToPainter();
1218 repaintAgenda(); 1217 repaintAgenda();
1219 // mAgenda->finishUpdate(); 1218 // mAgenda->finishUpdate();
1220 //mAllDayAgenda->finishUpdate(); 1219 //mAllDayAgenda->finishUpdate();
1221 1220
1222 // repaintAgenda(); 1221 // repaintAgenda();
1223 //qApp->processEvents(); 1222 //qApp->processEvents();
1224 // globalFlagBlockAgenda = 0; 1223 // globalFlagBlockAgenda = 0;
1225} 1224}
1226void KOAgendaView::repaintAgenda() 1225void KOAgendaView::repaintAgenda()
1227{ 1226{
1228 // mAllDayAgenda->drawContentsToPainter(); 1227 // mAllDayAgenda->drawContentsToPainter();
1229// mAllDayAgenda->viewport()->repaint( false ); 1228// mAllDayAgenda->viewport()->repaint( false );
1230// mAgenda->drawContentsToPainter(); 1229// mAgenda->drawContentsToPainter();
1231// mAgenda->viewport()->repaint( false ); 1230// mAgenda->viewport()->repaint( false );
1232// qApp->processEvents(); 1231// qApp->processEvents();
1233 1232
1234 //qDebug("KOAgendaView::repaintAgenda() "); 1233 //qDebug("KOAgendaView::repaintAgenda() ");
1235 //qApp->processEvents(); 1234 //qApp->processEvents();
1236 mAgenda->viewport()->repaint( false ); 1235 mAgenda->viewport()->repaint( false );
1237 mAllDayAgenda->viewport()->repaint( false ); 1236 mAllDayAgenda->viewport()->repaint( false );
1238 mAgenda->finishUpdate(); 1237 mAgenda->finishUpdate();
1239 mAllDayAgenda->finishUpdate(); 1238 mAllDayAgenda->finishUpdate();
1240} 1239}
1241 1240
1242 1241
1243void KOAgendaView::clearView() 1242void KOAgendaView::clearView()
1244{ 1243{
1245 // kdDebug() << "ClearView" << endl; 1244 // kdDebug() << "ClearView" << endl;
1246 mAllDayAgenda->clear(); 1245 mAllDayAgenda->clear();
1247 mAgenda->clear(); 1246 mAgenda->clear();
1248} 1247}
1249 1248
1250void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1249void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1251 const QDate &td) 1250 const QDate &td)
1252{ 1251{
1253#ifndef KORG_NOPRINTER 1252#ifndef KORG_NOPRINTER
1254 if (fd == td) 1253 if (fd == td)
1255 calPrinter->preview(CalPrinter::Day, fd, td); 1254 calPrinter->preview(CalPrinter::Day, fd, td);
1256 else 1255 else
1257 calPrinter->preview(CalPrinter::Week, fd, td); 1256 calPrinter->preview(CalPrinter::Week, fd, td);
1258#endif 1257#endif
1259} 1258}
1260 1259
@@ -1415,136 +1414,136 @@ void KOAgendaView::setHolidayMasks()
1415#ifndef KORG_NOPLUGINS 1414#ifndef KORG_NOPLUGINS
1416 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1417 !KOCore::self()->holiday(date).isEmpty(); 1416 !KOCore::self()->holiday(date).isEmpty();
1418#endif 1417#endif
1419 bool showDay = showSaturday || showSunday || showHoliday; 1418 bool showDay = showSaturday || showSunday || showHoliday;
1420 1419
1421 if (showDay) { 1420 if (showDay) {
1422 mHolidayMask.at(i) = true; 1421 mHolidayMask.at(i) = true;
1423 } else { 1422 } else {
1424 mHolidayMask.at(i) = false; 1423 mHolidayMask.at(i) = false;
1425 } 1424 }
1426 } 1425 }
1427 1426
1428 mAgenda->setHolidayMask(&mHolidayMask); 1427 mAgenda->setHolidayMask(&mHolidayMask);
1429 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1428 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1430} 1429}
1431 1430
1432void KOAgendaView::setContentsPos(int y) 1431void KOAgendaView::setContentsPos(int y)
1433{ 1432{
1434 mAgenda->setContentsPos(0,y); 1433 mAgenda->setContentsPos(0,y);
1435} 1434}
1436 1435
1437void KOAgendaView::setExpandedButton( bool expanded ) 1436void KOAgendaView::setExpandedButton( bool expanded )
1438{ 1437{
1439 if ( expanded ) { 1438 if ( expanded ) {
1440 mExpandButton->setPixmap( mExpandedPixmap ); 1439 mExpandButton->setPixmap( mExpandedPixmap );
1441 } else { 1440 } else {
1442 mExpandButton->setPixmap( mNotExpandedPixmap ); 1441 mExpandButton->setPixmap( mNotExpandedPixmap );
1443 } 1442 }
1444} 1443}
1445 1444
1446void KOAgendaView::clearSelection() 1445void KOAgendaView::clearSelection()
1447{ 1446{
1448 mAgenda->deselectItem(); 1447 mAgenda->deselectItem();
1449 mAllDayAgenda->deselectItem(); 1448 mAllDayAgenda->deselectItem();
1450} 1449}
1451 1450
1452void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1453 int gxEnd, int gyEnd) 1452 int gxEnd, int gyEnd)
1454{ 1453{
1455 mTimeSpanInAllDay = true; 1454 mTimeSpanInAllDay = true;
1456 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1457} 1456}
1458 1457
1459 1458
1460 1459
1461 1460
1462void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1463 int gxEnd, int gyEnd) 1462 int gxEnd, int gyEnd)
1464{ 1463{
1465 if (!mSelectedDates.count()) return; 1464 if (!mSelectedDates.count()) return;
1466 1465
1467 QDate dayStart = mSelectedDates[gxStart]; 1466 QDate dayStart = mSelectedDates[gxStart];
1468 QDate dayEnd = mSelectedDates[gxEnd]; 1467 QDate dayEnd = mSelectedDates[gxEnd];
1469 1468
1470 QTime timeStart = mAgenda->gyToTime(gyStart); 1469 QTime timeStart = mAgenda->gyToTime(gyStart);
1471 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1472 1471
1473 QDateTime dtStart(dayStart,timeStart); 1472 QDateTime dtStart(dayStart,timeStart);
1474 QDateTime dtEnd(dayEnd,timeEnd); 1473 QDateTime dtEnd(dayEnd,timeEnd);
1475 1474
1476 mTimeSpanBegin = dtStart; 1475 mTimeSpanBegin = dtStart;
1477 mTimeSpanEnd = dtEnd; 1476 mTimeSpanEnd = dtEnd;
1478 1477
1479} 1478}
1480 1479
1481void KOAgendaView::deleteSelectedDateTime() 1480void KOAgendaView::deleteSelectedDateTime()
1482{ 1481{
1483 mTimeSpanBegin.setDate(QDate()); 1482 mTimeSpanBegin.setDate(QDate());
1484 mTimeSpanEnd.setDate(QDate()); 1483 mTimeSpanEnd.setDate(QDate());
1485 mTimeSpanInAllDay = false; 1484 mTimeSpanInAllDay = false;
1486} 1485}
1487 1486
1488void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1487void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1489{ 1488{
1490 e->ignore(); 1489 e->ignore();
1491} 1490}
1492 1491
1493void KOAgendaView::scrollOneHourUp() 1492void KOAgendaView::scrollOneHourUp()
1494{ 1493{
1495 1494
1496 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1497} 1496}
1498void KOAgendaView::scrollOneHourDown() 1497void KOAgendaView::scrollOneHourDown()
1499{ 1498{
1500 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1501} 1500}
1502 1501
1503void KOAgendaView::setStartHour( int h ) 1502void KOAgendaView::setStartHour( int h )
1504{ 1503{
1505 mAgenda->setStartHour( h ); 1504 mAgenda->setStartHour( h );
1506 1505
1507} 1506}
1508 1507
1509void KOAgendaView::updateTodo( Todo * t, int ) 1508void KOAgendaView::updateTodo( Todo * t, int )
1510{ 1509{
1511 1510
1512 bool remove = false; 1511 bool remove = false;
1513 bool removeAD = false; 1512 bool removeAD = false;
1514 QDate da; 1513 QDate da;
1515 if ( t->hasCompletedDate() ) 1514 if ( t->hasCompletedDate() )
1516 da = t->completed().date(); 1515 da = t->completed().date();
1517 else 1516 else
1518 da = t->dtDue().date(); 1517 da = t->dtDue().date();
1519 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1518 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1520 remove = true; 1519 remove = true;
1521 removeAD = true; 1520 removeAD = true;
1522 } 1521 }
1523 else { 1522 else {
1524 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1523 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1525 if ( overdue && 1524 if ( overdue &&
1526 QDate::currentDate() >= mSelectedDates.first() && 1525 QDate::currentDate() >= mSelectedDates.first() &&
1527 QDate::currentDate() <= mSelectedDates.last()) { 1526 QDate::currentDate() <= mSelectedDates.last()) {
1528 removeAD = false; 1527 removeAD = false;
1529 remove = true; 1528 remove = true;
1530 } 1529 }
1531 else { 1530 else {
1532 1531
1533 if ( da < mSelectedDates.first() || 1532 if ( da < mSelectedDates.first() ||
1534 da > mSelectedDates.last() ) { 1533 da > mSelectedDates.last() ) {
1535 remove = true; 1534 remove = true;
1536 removeAD = true; 1535 removeAD = true;
1537 } else { 1536 } else {
1538 remove = t->doesFloat() && !t->hasCompletedDate(); 1537 remove = t->doesFloat() && !t->hasCompletedDate();
1539 removeAD = !remove; 1538 removeAD = !remove;
1540 } 1539 }
1541 } 1540 }
1542 } 1541 }
1543 int days = mSelectedDates.first().daysTo( da ); 1542 int days = mSelectedDates.first().daysTo( da );
1544 // qDebug("daysto %d ", days ); 1543 // qDebug("daysto %d ", days );
1545 mAgenda->updateTodo( t , days, remove); 1544 mAgenda->updateTodo( t , days, remove);
1546 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1545 if ( KOPrefs::instance()->mShowTodoInAgenda )
1547 mAllDayAgenda->updateTodo( t , days, removeAD); 1546 mAllDayAgenda->updateTodo( t , days, removeAD);
1548 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1547 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1549 1548
1550} 1549}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 14e8b5c..902f3f4 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -764,203 +764,212 @@ void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
764 case 2: 764 case 2:
765 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 765 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
766 case 3: 766 case 3:
767 moveTodo(); 767 moveTodo();
768 break; 768 break;
769 case 8: 769 case 8:
770 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 770 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
771 default: 771 default:
772 mItemPopupMenu->popup(QCursor::pos()); 772 mItemPopupMenu->popup(QCursor::pos());
773 } 773 }
774 } else mPopupMenu->popup(QCursor::pos()); 774 } else mPopupMenu->popup(QCursor::pos());
775} 775}
776void KOTodoView::newTodo() 776void KOTodoView::newTodo()
777{ 777{
778 emit newTodoSignal(); 778 emit newTodoSignal();
779} 779}
780 780
781void KOTodoView::newSubTodo() 781void KOTodoView::newSubTodo()
782{ 782{
783 if (mActiveItem) { 783 if (mActiveItem) {
784 emit newSubTodoSignal(mActiveItem->todo()); 784 emit newSubTodoSignal(mActiveItem->todo());
785 } 785 }
786} 786}
787void KOTodoView::unparentTodo() 787void KOTodoView::unparentTodo()
788{ 788{
789 if (mActiveItem) { 789 if (mActiveItem) {
790 emit unparentTodoSignal(mActiveItem->todo()); 790 emit unparentTodoSignal(mActiveItem->todo());
791 } 791 }
792} 792}
793 793
794void KOTodoView::reparentTodo() 794void KOTodoView::reparentTodo()
795{ 795{
796 if (mActiveItem) { 796 if (mActiveItem) {
797 qDebug("KOTodoView::reparentTodo() "); 797 qDebug("KOTodoView::reparentTodo() ");
798 topLevelWidget()->setCaption(i18n("Click on new parent item")); 798 topLevelWidget()->setCaption(i18n("Click on new parent item"));
799 pendingSubtodo = mActiveItem; 799 pendingSubtodo = mActiveItem;
800 } 800 }
801} 801}
802void KOTodoView::editTodo() 802void KOTodoView::editTodo()
803{ 803{
804 if (mActiveItem) { 804 if (mActiveItem) {
805 emit editTodoSignal(mActiveItem->todo()); 805 emit editTodoSignal(mActiveItem->todo());
806 } 806 }
807} 807}
808void KOTodoView::cloneTodo() 808void KOTodoView::cloneTodo()
809{ 809{
810 if (mActiveItem) { 810 if (mActiveItem) {
811 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 811 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
812 } 812 }
813} 813}
814void KOTodoView::cancelTodo() 814void KOTodoView::cancelTodo()
815{ 815{
816 if (mActiveItem) { 816 if (mActiveItem) {
817 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 817 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
818 } 818 }
819} 819}
820void KOTodoView::moveTodo() 820void KOTodoView::moveTodo()
821{ 821{
822 if (mActiveItem) { 822 if (mActiveItem) {
823 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 823 emit moveTodoSignal((Incidence*)mActiveItem->todo());
824 } 824 }
825} 825}
826void KOTodoView::beamTodo() 826void KOTodoView::beamTodo()
827{ 827{
828 if (mActiveItem) { 828 if (mActiveItem) {
829 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 829 emit beamTodoSignal((Incidence*)mActiveItem->todo());
830 } 830 }
831} 831}
832 832
833 833
834void KOTodoView::showTodo() 834void KOTodoView::showTodo()
835{ 835{
836 if (mActiveItem) { 836 if (mActiveItem) {
837 emit showTodoSignal(mActiveItem->todo()); 837 emit showTodoSignal(mActiveItem->todo());
838 } 838 }
839} 839}
840 840
841void KOTodoView::deleteTodo() 841void KOTodoView::deleteTodo()
842{ 842{
843 if (mActiveItem) { 843 if (mActiveItem) {
844 emit deleteTodoSignal(mActiveItem->todo()); 844 emit deleteTodoSignal(mActiveItem->todo());
845 } 845 }
846} 846}
847 847
848void KOTodoView::setNewPriority(int index) 848void KOTodoView::setNewPriority(int index)
849{ 849{
850 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 850 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
851 mActiveItem->todo()->setPriority(mPriority[index]); 851 mActiveItem->todo()->setPriority(mPriority[index]);
852 mActiveItem->construct(); 852 mActiveItem->construct();
853 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 853 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
854 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 854 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
855 } 855 }
856} 856}
857 857
858void KOTodoView::setNewPercentage(int index) 858void KOTodoView::setNewPercentage(int index)
859{ 859{
860 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 860 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
861 if (mPercentage[index] == 100) { 861
862 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 862 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
863 } else { 863 mActiveItem->setOn( true );
864 mActiveItem->todo()->setCompleted(false); 864 return;
865 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
866 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
867 if ( par && par->isOn() )
868 par->setOn( false );
869 }
870 if (mPercentage[index] == 100) {
871 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
872 } else {
873 mActiveItem->todo()->setCompleted(false);
874 }
875 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
876 mActiveItem->construct();
877 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
878 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
865 } 879 }
866 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
867 mActiveItem->construct();
868 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
869 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
870 }
871} 880}
872 881
873 882
874QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 883QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
875{ 884{
876 QPopupMenu* tempMenu = new QPopupMenu (this); 885 QPopupMenu* tempMenu = new QPopupMenu (this);
877 QStringList checkedCategories = todoItem->todo()->categories (); 886 QStringList checkedCategories = todoItem->todo()->categories ();
878 887
879 tempMenu->setCheckable (true); 888 tempMenu->setCheckable (true);
880 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 889 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
881 it != KOPrefs::instance()->mCustomCategories.end (); 890 it != KOPrefs::instance()->mCustomCategories.end ();
882 ++it) { 891 ++it) {
883 int index = tempMenu->insertItem (*it); 892 int index = tempMenu->insertItem (*it);
884 mCategory[index] = *it; 893 mCategory[index] = *it;
885 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 894 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
886 } 895 }
887 896
888 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 897 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
889 return tempMenu; 898 return tempMenu;
890 899
891 900
892} 901}
893void KOTodoView::changedCategories(int index) 902void KOTodoView::changedCategories(int index)
894{ 903{
895 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 904 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
896 QStringList categories = mActiveItem->todo()->categories (); 905 QStringList categories = mActiveItem->todo()->categories ();
897 if (categories.find (mCategory[index]) != categories.end ()) 906 if (categories.find (mCategory[index]) != categories.end ())
898 categories.remove (mCategory[index]); 907 categories.remove (mCategory[index]);
899 else 908 else
900 categories.insert (categories.end(), mCategory[index]); 909 categories.insert (categories.end(), mCategory[index]);
901 categories.sort (); 910 categories.sort ();
902 mActiveItem->todo()->setCategories (categories); 911 mActiveItem->todo()->setCategories (categories);
903 mActiveItem->construct(); 912 mActiveItem->construct();
904 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 913 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
905 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 914 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
906 } 915 }
907} 916}
908void KOTodoView::itemDoubleClicked(QListViewItem *item) 917void KOTodoView::itemDoubleClicked(QListViewItem *item)
909{ 918{
910 if ( pendingSubtodo != 0 ) { 919 if ( pendingSubtodo != 0 ) {
911 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 920 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
912 } 921 }
913 pendingSubtodo = 0; 922 pendingSubtodo = 0;
914 if (!item) { 923 if (!item) {
915 newTodo(); 924 newTodo();
916 return; 925 return;
917 } 926 }
918 if ( KOPrefs::instance()->mEditOnDoubleClick ) 927 if ( KOPrefs::instance()->mEditOnDoubleClick )
919 editItem( item ); 928 editItem( item );
920 else 929 else
921 showItem( item , QPoint(), 0 ); 930 showItem( item , QPoint(), 0 );
922} 931}
923void KOTodoView::itemClicked(QListViewItem *item) 932void KOTodoView::itemClicked(QListViewItem *item)
924{ 933{
925 934
926 if (!item) { 935 if (!item) {
927 if ( pendingSubtodo != 0 ) { 936 if ( pendingSubtodo != 0 ) {
928 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 937 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
929 } 938 }
930 pendingSubtodo = 0; 939 pendingSubtodo = 0;
931 return; 940 return;
932 } 941 }
933 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 942 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
934 if ( pendingSubtodo != 0 ) { 943 if ( pendingSubtodo != 0 ) {
935 bool allowReparent = true; 944 bool allowReparent = true;
936 QListViewItem *par = item; 945 QListViewItem *par = item;
937 while ( par ) { 946 while ( par ) {
938 if ( par == pendingSubtodo ) { 947 if ( par == pendingSubtodo ) {
939 allowReparent = false; 948 allowReparent = false;
940 break; 949 break;
941 } 950 }
942 par = par->parent(); 951 par = par->parent();
943 } 952 }
944 if ( !allowReparent ) { 953 if ( !allowReparent ) {
945 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 954 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
946 qDebug("Recursive reparenting not possible "); 955 qDebug("Recursive reparenting not possible ");
947 pendingSubtodo = 0; 956 pendingSubtodo = 0;
948 } else { 957 } else {
949 Todo* newParent = todoItem->todo(); 958 Todo* newParent = todoItem->todo();
950 Todo* newSub = pendingSubtodo->todo(); 959 Todo* newSub = pendingSubtodo->todo();
951 pendingSubtodo = 0; 960 pendingSubtodo = 0;
952 emit reparentTodoSignal( newParent,newSub ); 961 emit reparentTodoSignal( newParent,newSub );
953 return; 962 return;
954 } 963 }
955 } 964 }
956#if 0 965#if 0
957 // handled by the item itself 966 // handled by the item itself
958 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 967 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
959 qDebug("com %d ",completed ); 968 qDebug("com %d ",completed );
960 qDebug("itemclicked "); 969 qDebug("itemclicked ");
961 if (todoItem->isOn()) { 970 if (todoItem->isOn()) {
962 qDebug("on "); 971 qDebug("on ");
963 if (!completed) { 972 if (!completed) {
964 qDebug("set true "); 973 qDebug("set true ");
965 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 974 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
966 } 975 }
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 2822237..1edddac 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -110,235 +110,243 @@ void KOTodoViewItem::construct()
110 } 110 }
111 } else { 111 } else {
112 setText(3,""); 112 setText(3,"");
113 setText(4,""); 113 setText(4,"");
114 } 114 }
115 setSortKey(3,keyd); 115 setSortKey(3,keyd);
116 setSortKey(4,keyt); 116 setSortKey(4,keyt);
117 117
118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 118 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 119 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
120 120
121 121
122 122
123 if (mTodo->hasStartDate()) { 123 if (mTodo->hasStartDate()) {
124 setText(5, mTodo->dtStartDateStr()); 124 setText(5, mTodo->dtStartDateStr());
125 QDate d = mTodo->dtStart().date(); 125 QDate d = mTodo->dtStart().date();
126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 126 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
127 127
128 if (mTodo->doesFloat()) { 128 if (mTodo->doesFloat()) {
129 setText(6,""); 129 setText(6,"");
130 } 130 }
131 else { 131 else {
132 setText(6,mTodo->dtStartTimeStr()); 132 setText(6,mTodo->dtStartTimeStr());
133 QTime t = mTodo->dtStart().time(); 133 QTime t = mTodo->dtStart().time();
134 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 134 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
135 135
136 } 136 }
137 } else { 137 } else {
138 setText(5,""); 138 setText(5,"");
139 setText(6,""); 139 setText(6,"");
140 } 140 }
141 setSortKey(5,skeyd); 141 setSortKey(5,skeyd);
142 setSortKey(6,skeyt); 142 setSortKey(6,skeyt);
143 143
144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 144 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
145 setText(8,mTodo->categoriesStr()); 145 setText(8,mTodo->categoriesStr());
146 146
147#if 0 147#if 0
148 // Find sort id in description. It's the text behind the last '#' character 148 // Find sort id in description. It's the text behind the last '#' character
149 // found in the description. White spaces are removed from beginning and end 149 // found in the description. White spaces are removed from beginning and end
150 // of sort id. 150 // of sort id.
151 int pos = mTodo->description().findRev('#'); 151 int pos = mTodo->description().findRev('#');
152 if (pos < 0) { 152 if (pos < 0) {
153 setText(6,""); 153 setText(6,"");
154 } else { 154 } else {
155 QString str = mTodo->description().mid(pos+1); 155 QString str = mTodo->description().mid(pos+1);
156 str.stripWhiteSpace(); 156 str.stripWhiteSpace();
157 setText(6,str); 157 setText(6,str);
158 } 158 }
159#endif 159#endif
160 160
161 m_known = false; 161 m_known = false;
162 m_init = false; 162 m_init = false;
163 163
164 setMyPixmap(); 164 setMyPixmap();
165 165
166} 166}
167void KOTodoViewItem::setMyPixmap() 167void KOTodoViewItem::setMyPixmap()
168{ 168{
169 int size = 5; 169 int size = 5;
170 QPixmap pixi = QPixmap( 1, 1 ); 170 QPixmap pixi = QPixmap( 1, 1 );
171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 171 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
172// pixi = SmallIcon("redcross16"); 172// pixi = SmallIcon("redcross16");
173// } else { 173// } else {
174 QPainter p; 174 QPainter p;
175 175
176 int pixSize = 0; 176 int pixSize = 0;
177 QPixmap pPix = QPixmap( size, size ); 177 QPixmap pPix = QPixmap( size, size );
178 if ( mTodo->description().length() > 0 ) { 178 if ( mTodo->description().length() > 0 ) {
179 pixi.resize(size, pixSize+size); 179 pixi.resize(size, pixSize+size);
180 pPix.fill( Qt::darkGreen ); 180 pPix.fill( Qt::darkGreen );
181 p.begin( &pixi ); 181 p.begin( &pixi );
182 p. drawPixmap ( 0, pixSize, pPix); 182 p. drawPixmap ( 0, pixSize, pPix);
183 p.end(); 183 p.end();
184 pixSize += size; 184 pixSize += size;
185 } 185 }
186 if ( mTodo->isAlarmEnabled() ) { 186 if ( mTodo->isAlarmEnabled() ) {
187 pixi.resize(size, pixSize+size); 187 pixi.resize(size, pixSize+size);
188 pPix.fill( Qt::red ); 188 pPix.fill( Qt::red );
189 p.begin( &pixi ); 189 p.begin( &pixi );
190 p. drawPixmap ( 0, pixSize, pPix); 190 p. drawPixmap ( 0, pixSize, pPix);
191 p.end(); 191 p.end();
192 pixSize += size; 192 pixSize += size;
193 } 193 }
194 // } 194 // }
195 if ( pixi.width() > 1 ) { 195 if ( pixi.width() > 1 ) {
196 setPixmap ( 0,pixi ) ; 196 setPixmap ( 0,pixi ) ;
197 } else { 197 } else {
198 setPixmap ( 0,QPixmap() ) ; 198 setPixmap ( 0,QPixmap() ) ;
199 } 199 }
200} 200}
201void KOTodoViewItem::stateChange(bool state) 201void KOTodoViewItem::stateChange(bool state)
202{ 202{
203 // qDebug("KOTodoViewItem::stateChange "); 203 // qDebug("KOTodoViewItem::stateChange ");
204 // do not change setting on startup 204 // do not change setting on startup
205 if ( m_init ) return; 205 if ( m_init ) return;
206 qDebug("KOTodoViewItem::stateChange "); 206 if (isOn()!=state) {
207 setOn(state);
208 //qDebug("SETON ");
209 return;
210 }
207 QString keyd = "=="; 211 QString keyd = "==";
208 QString keyt = "=="; 212 QString keyt = "==";
209 213 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
210 mTodo->setCompleted(state); 214 mTodo->setCompleted(state);
211 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 215 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
212 if (isOn()!=state) {
213 setOn(state);
214 }
215 216
216 if (mTodo->hasDueDate()) { 217 if (mTodo->hasDueDate()) {
217 setText(3, mTodo->dtDueDateStr()); 218 setText(3, mTodo->dtDueDateStr());
218 QDate d = mTodo->dtDue().date(); 219 QDate d = mTodo->dtDue().date();
219 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 220 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
220 setSortKey(3,keyd); 221 setSortKey(3,keyd);
221 if (mTodo->doesFloat()) { 222 if (mTodo->doesFloat()) {
222 setText(4,""); 223 setText(4,"");
223 } 224 }
224 else { 225 else {
225 setText(4,mTodo->dtDueTimeStr()); 226 setText(4,mTodo->dtDueTimeStr());
226 QTime t = mTodo->dtDue().time(); 227 QTime t = mTodo->dtDue().time();
227 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 228 keyt.sprintf("%02d%02d",t.hour(),t.minute());
228 setSortKey(4,keyt); 229 setSortKey(4,keyt);
229 } 230 }
230 } 231 }
231 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 232 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
232 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 233 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
233 234
234 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 235 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
235 if (mTodo->percentComplete()<100) { 236 if (mTodo->percentComplete()<100) {
236 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 237 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
237 else setSortKey(2,QString::number(mTodo->percentComplete())); 238 else setSortKey(2,QString::number(mTodo->percentComplete()));
238 } 239 }
239 else { 240 else {
240 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 241 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
241 else setSortKey(2,QString::number(99)); 242 else setSortKey(2,QString::number(99));
242 } 243 }
243 QListViewItem * myChild = firstChild(); 244 if ( state ) {
244 KOTodoViewItem *item; 245 QListViewItem * myChild = firstChild();
245 while( myChild ) { 246 KOTodoViewItem *item;
246 item = static_cast<KOTodoViewItem*>(myChild); 247 while( myChild ) {
247 item->stateChange(state); 248 //qDebug("stateCH ");
248 myChild = myChild->nextSibling(); 249 item = static_cast<KOTodoViewItem*>(myChild);
250 item->stateChange(state);
251 myChild = myChild->nextSibling();
252 }
253 } else {
254 QListViewItem * myChild = parent();
255 if ( myChild )
256 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
249 } 257 }
250 mTodoView->modified(true); 258 mTodoView->modified(true);
251 setMyPixmap(); 259 setMyPixmap();
252 mTodoView->setTodoModified( mTodo ); 260 mTodoView->setTodoModified( mTodo );
253} 261}
254 262
255bool KOTodoViewItem::isAlternate() 263bool KOTodoViewItem::isAlternate()
256{ 264{
257#ifndef KORG_NOLVALTERNATION 265#ifndef KORG_NOLVALTERNATION
258 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 266 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
259 if (lv && lv->alternateBackground().isValid()) 267 if (lv && lv->alternateBackground().isValid())
260 { 268 {
261 KOTodoViewItem *above = 0; 269 KOTodoViewItem *above = 0;
262 above = dynamic_cast<KOTodoViewItem *>(itemAbove()); 270 above = dynamic_cast<KOTodoViewItem *>(itemAbove());
263 m_known = above ? above->m_known : true; 271 m_known = above ? above->m_known : true;
264 if (m_known) 272 if (m_known)
265 { 273 {
266 m_odd = above ? !above->m_odd : false; 274 m_odd = above ? !above->m_odd : false;
267 } 275 }
268 else 276 else
269 { 277 {
270 KOTodoViewItem *item; 278 KOTodoViewItem *item;
271 bool previous = true; 279 bool previous = true;
272 if (QListViewItem::parent()) 280 if (QListViewItem::parent())
273 { 281 {
274 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); 282 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent());
275 if (item) 283 if (item)
276 previous = item->m_odd; 284 previous = item->m_odd;
277 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 285 item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
278 } 286 }
279 else 287 else
280 { 288 {
281 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); 289 item = dynamic_cast<KOTodoViewItem *>(lv->firstChild());
282 } 290 }
283 291
284 while(item) 292 while(item)
285 { 293 {
286 item->m_odd = previous = !previous; 294 item->m_odd = previous = !previous;
287 item->m_known = true; 295 item->m_known = true;
288 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); 296 item = dynamic_cast<KOTodoViewItem *>(item->nextSibling());
289 } 297 }
290 } 298 }
291 return m_odd; 299 return m_odd;
292 } 300 }
293 return false; 301 return false;
294#else 302#else
295 return false; 303 return false;
296#endif 304#endif
297} 305}
298 306
299void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 307void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
300{ 308{
301 QColorGroup _cg = cg; 309 QColorGroup _cg = cg;
302 QColorGroup::ColorRole role; 310 QColorGroup::ColorRole role;
303 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) 311 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor )
304 role = QColorGroup::Text; 312 role = QColorGroup::Text;
305 else 313 else
306 role = QColorGroup::Base; 314 role = QColorGroup::Base;
307 //#ifndef KORG_NOLVALTERNATION 315 //#ifndef KORG_NOLVALTERNATION
308 // if (isAlternate()) 316 // if (isAlternate())
309 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 317 // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
310 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 318 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
311 QColor colorToSet; 319 QColor colorToSet;
312 if ( setColor ) { 320 if ( setColor ) {
313 QStringList categories = mTodo->categories(); 321 QStringList categories = mTodo->categories();
314 QString cat = categories.first(); 322 QString cat = categories.first();
315 if ( !cat.isEmpty()) { 323 if ( !cat.isEmpty()) {
316 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 324 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
317 } else 325 } else
318 setColor = false; 326 setColor = false;
319 } 327 }
320 if (mTodo->hasDueDate()) { 328 if (mTodo->hasDueDate()) {
321 if (mTodo->dtDue().date()==QDate::currentDate() && 329 if (mTodo->dtDue().date()==QDate::currentDate() &&
322 !mTodo->isCompleted()) { 330 !mTodo->isCompleted()) {
323 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); 331 //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor);
324 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 332 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
325 setColor = true; 333 setColor = true;
326 } 334 }
327 if (mTodo->dtDue().date() < QDate::currentDate() && 335 if (mTodo->dtDue().date() < QDate::currentDate() &&
328 !mTodo->isCompleted()) { 336 !mTodo->isCompleted()) {
329 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); 337 //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor);
330 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 338 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
331 setColor = true; 339 setColor = true;
332 } 340 }
333 } 341 }
334 342
335 if ( setColor ) { 343 if ( setColor ) {
336 _cg.setColor(role,colorToSet ); 344 _cg.setColor(role,colorToSet );
337 if ( role == QColorGroup::Base) { 345 if ( role == QColorGroup::Base) {
338 int rgb = colorToSet.red(); 346 int rgb = colorToSet.red();
339 rgb += colorToSet.blue()/2; 347 rgb += colorToSet.blue()/2;
340 rgb += colorToSet.green(); 348 rgb += colorToSet.green();
341 if ( rgb < 200 ) 349 if ( rgb < 200 )
342 _cg.setColor(QColorGroup::Text,Qt::white ); 350 _cg.setColor(QColorGroup::Text,Qt::white );
343 } 351 }
344 } 352 }