summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-30 16:38:38 (UTC)
committer zautrix <zautrix>2005-01-30 16:38:38 (UTC)
commit23d345c877ae9de6a077af3705026d15bb04d1e3 (patch) (unidiff)
tree1c90eaf14b5fe5daf97645bebed2eabbe66b8a89 /korganizer
parenta34c528fdd8d2cdec14bae9ccb0eee54c8e4e374 (diff)
downloadkdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.zip
kdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.tar.gz
kdepimpi-23d345c877ae9de6a077af3705026d15bb04d1e3.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp2
-rw-r--r--korganizer/koagendaview.cpp3
-rw-r--r--korganizer/koeditorgeneraltodo.h1
-rw-r--r--korganizer/kotodoeditor.cpp12
4 files changed, 13 insertions, 5 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 7c41cab..0aef929 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1088,769 +1088,769 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1088 } else { 1088 } else {
1089 placeItem->setSubCell(0); 1089 placeItem->setSubCell(0);
1090 placeItem->setSubCells(1); 1090 placeItem->setSubCells(1);
1091 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1091 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1092 else placeItem->resize(mGridSpacingX,placeItem->height()); 1092 else placeItem->resize(mGridSpacingX,placeItem->height());
1093 int x,y; 1093 int x,y;
1094 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1094 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1095 moveChild(placeItem,x,y); 1095 moveChild(placeItem,x,y);
1096 } 1096 }
1097 placeItem->setConflictItems(conflictItems); 1097 placeItem->setConflictItems(conflictItems);
1098 // for ( item=conflictItems.first(); item != 0; 1098 // for ( item=conflictItems.first(); item != 0;
1099// item=conflictItems.next() ) { 1099// item=conflictItems.next() ) {
1100// //item->updateItem(); 1100// //item->updateItem();
1101// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1101// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1102// } 1102// }
1103// placeItem->updateItem(); 1103// placeItem->updateItem();
1104} 1104}
1105 1105
1106void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1106void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1107{ 1107{
1108 if ( globalFlagBlockAgenda ) 1108 if ( globalFlagBlockAgenda )
1109 return; 1109 return;
1110 //qDebug("KOAgenda::drawContents "); 1110 //qDebug("KOAgenda::drawContents ");
1111 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1111 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1112 ;//drawContentsToPainter(); 1112 ;//drawContentsToPainter();
1113 1113
1114 QPaintDevice* pd = p->device(); 1114 QPaintDevice* pd = p->device();
1115 p->end(); 1115 p->end();
1116 int vx, vy; 1116 int vx, vy;
1117 int selectionX = KOGlobals::self()->reverseLayout() ? 1117 int selectionX = KOGlobals::self()->reverseLayout() ?
1118 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1118 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1119 mSelectionCellX * mGridSpacingX; 1119 mSelectionCellX * mGridSpacingX;
1120 contentsToViewport ( cx, cy, vx,vy); 1120 contentsToViewport ( cx, cy, vx,vy);
1121 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1121 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1122 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1122 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1123 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1123 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1124 1124
1125 if ( mSelectionHeight > 0 ) { 1125 if ( mSelectionHeight > 0 ) {
1126 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1126 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1127 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1127 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1128 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1128 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1129 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1129 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1130 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1130 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1131 } 1131 }
1132 } 1132 }
1133 //qDebug("btbl "); 1133 //qDebug("btbl ");
1134 p->begin( pd ); 1134 p->begin( pd );
1135 //qDebug("end "); 1135 //qDebug("end ");
1136} 1136}
1137 1137
1138void KOAgenda::finishUpdate() 1138void KOAgenda::finishUpdate()
1139{ 1139{
1140 1140
1141 KOAgendaItem *item; 1141 KOAgendaItem *item;
1142 globalFlagBlockAgendaItemPaint = 1; 1142 globalFlagBlockAgendaItemPaint = 1;
1143 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1143 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1144 if ( !item->isVisible() ) 1144 if ( !item->isVisible() )
1145 item->show(); 1145 item->show();
1146 1146
1147 } 1147 }
1148 globalFlagBlockAgendaItemUpdate = 0; 1148 globalFlagBlockAgendaItemUpdate = 0;
1149 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1149 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1150 item->repaintMe( ); 1150 item->repaintMe( );
1151 } 1151 }
1152 globalFlagBlockAgendaItemUpdate = 1; 1152 globalFlagBlockAgendaItemUpdate = 1;
1153 qApp->processEvents(); 1153 qApp->processEvents();
1154 globalFlagBlockAgendaItemPaint = 0; 1154 globalFlagBlockAgendaItemPaint = 0;
1155 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1155 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1156 item->repaint( false ); 1156 item->repaint( false );
1157 } 1157 }
1158 1158
1159} 1159}
1160 1160
1161/* 1161/*
1162 Draw grid in the background of the agenda. 1162 Draw grid in the background of the agenda.
1163*/ 1163*/
1164void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1164void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1165{ 1165{
1166 1166
1167 1167
1168 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1168 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1169 return; 1169 return;
1170 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1170 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1171 return; 1171 return;
1172 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1172 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1173 if ( ch < 1 ) 1173 if ( ch < 1 )
1174 ch = 1; 1174 ch = 1;
1175 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1175 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1176 mPaintPixmap.resize( contentsWidth()+42, ch ); 1176 mPaintPixmap.resize( contentsWidth()+42, ch );
1177 } 1177 }
1178 mCurPixWid = contentsWidth(); 1178 mCurPixWid = contentsWidth();
1179 mCurPixHei = ch; 1179 mCurPixHei = ch;
1180 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1180 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1181 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1181 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1182 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1182 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1183 } 1183 }
1184 mPixPainter.begin( &mPaintPixmap) ; 1184 mPixPainter.begin( &mPaintPixmap) ;
1185 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1185 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1186 QPainter * p ; 1186 QPainter * p ;
1187 if (paint == 0) { 1187 if (paint == 0) {
1188 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1188 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1189 p = &mPixPainter; 1189 p = &mPixPainter;
1190 } 1190 }
1191 else 1191 else
1192 p = paint ; 1192 p = paint ;
1193 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1193 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1194 1194
1195 //--cx;++cw; 1195 //--cx;++cw;
1196 int lGridSpacingY = mGridSpacingY*2; 1196 int lGridSpacingY = mGridSpacingY*2;
1197 int selDay; 1197 int selDay;
1198 if ( !backgroundOnly ) 1198 if ( !backgroundOnly )
1199 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1199 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1200 { 1200 {
1201 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1201 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1202 int x1 = cx; 1202 int x1 = cx;
1203 int y1 = 0; 1203 int y1 = 0;
1204 if (y1 < cy) y1 = cy; 1204 if (y1 < cy) y1 = cy;
1205 int x2 = cx+cw-1; 1205 int x2 = cx+cw-1;
1206 int y2 = contentsHeight(); 1206 int y2 = contentsHeight();
1207 if (y2 > cy+ch-1) y2=cy+ch-1; 1207 if (y2 > cy+ch-1) y2=cy+ch-1;
1208 if (x2 >= x1 && y2 >= y1) { 1208 if (x2 >= x1 && y2 >= y1) {
1209 int gxStart = selDay; 1209 int gxStart = selDay;
1210 int gxEnd = gxStart ; 1210 int gxEnd = gxStart ;
1211 int xStart = KOGlobals::self()->reverseLayout() ? 1211 int xStart = KOGlobals::self()->reverseLayout() ?
1212 (mColumns - 1 - gxStart)*mGridSpacingX : 1212 (mColumns - 1 - gxStart)*mGridSpacingX :
1213 gxStart*mGridSpacingX; 1213 gxStart*mGridSpacingX;
1214 if (xStart < x1) xStart = x1; 1214 if (xStart < x1) xStart = x1;
1215 int xEnd = KOGlobals::self()->reverseLayout() ? 1215 int xEnd = KOGlobals::self()->reverseLayout() ?
1216 (mColumns - gxStart)*mGridSpacingX-1 : 1216 (mColumns - gxStart)*mGridSpacingX-1 :
1217 (gxStart+1)*mGridSpacingX-1; 1217 (gxStart+1)*mGridSpacingX-1;
1218 if (xEnd > x2) xEnd = x2; 1218 if (xEnd > x2) xEnd = x2;
1219 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1219 if ( KOPrefs::instance()->mUseHighlightLightColor )
1220 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1220 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1221 KOPrefs::instance()->mAgendaBgColor.light()); 1221 KOPrefs::instance()->mAgendaBgColor.light());
1222 else 1222 else
1223 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1223 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1224 KOPrefs::instance()->mAgendaBgColor.dark()); 1224 KOPrefs::instance()->mAgendaBgColor.dark());
1225 1225
1226 } 1226 }
1227 } 1227 }
1228 } 1228 }
1229 // Highlight working hours 1229 // Highlight working hours
1230 1230
1231 if ( !backgroundOnly ) 1231 if ( !backgroundOnly )
1232 if (mWorkingHoursEnable) { 1232 if (mWorkingHoursEnable) {
1233 int x1 = cx; 1233 int x1 = cx;
1234 int y1 = mWorkingHoursYTop; 1234 int y1 = mWorkingHoursYTop;
1235 if (y1 < cy) y1 = cy; 1235 if (y1 < cy) y1 = cy;
1236 int x2 = cx+cw-1; 1236 int x2 = cx+cw-1;
1237 // int x2 = mGridSpacingX * 5 - 1; 1237 // int x2 = mGridSpacingX * 5 - 1;
1238 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1238 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1239 int y2 = mWorkingHoursYBottom; 1239 int y2 = mWorkingHoursYBottom;
1240 if (y2 > cy+ch-1) y2=cy+ch-1; 1240 if (y2 > cy+ch-1) y2=cy+ch-1;
1241 1241
1242 if (x2 >= x1 && y2 >= y1) { 1242 if (x2 >= x1 && y2 >= y1) {
1243 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1243 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1244 int gxStart = x1/mGridSpacingX; 1244 int gxStart = x1/mGridSpacingX;
1245 int gxEnd = x2/mGridSpacingX; 1245 int gxEnd = x2/mGridSpacingX;
1246 while(gxStart <= gxEnd) { 1246 while(gxStart <= gxEnd) {
1247 if (gxStart < int(mHolidayMask->count()) && 1247 if (gxStart < int(mHolidayMask->count()) &&
1248 !mHolidayMask->at(gxStart)) { 1248 !mHolidayMask->at(gxStart)) {
1249 int xStart = KOGlobals::self()->reverseLayout() ? 1249 int xStart = KOGlobals::self()->reverseLayout() ?
1250 (mColumns - 1 - gxStart)*mGridSpacingX : 1250 (mColumns - 1 - gxStart)*mGridSpacingX :
1251 gxStart*mGridSpacingX; 1251 gxStart*mGridSpacingX;
1252 if (xStart < x1) xStart = x1; 1252 if (xStart < x1) xStart = x1;
1253 int xEnd = KOGlobals::self()->reverseLayout() ? 1253 int xEnd = KOGlobals::self()->reverseLayout() ?
1254 (mColumns - gxStart)*mGridSpacingX-1 : 1254 (mColumns - gxStart)*mGridSpacingX-1 :
1255 (gxStart+1)*mGridSpacingX-1; 1255 (gxStart+1)*mGridSpacingX-1;
1256 if (xEnd > x2) xEnd = x2; 1256 if (xEnd > x2) xEnd = x2;
1257 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1257 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1258 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1258 if ( KOPrefs::instance()->mUseHighlightLightColor )
1259 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1259 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1260 KOPrefs::instance()->mWorkingHoursColor.light()); 1260 KOPrefs::instance()->mWorkingHoursColor.light());
1261 else 1261 else
1262 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1262 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1263 KOPrefs::instance()->mWorkingHoursColor.dark()); 1263 KOPrefs::instance()->mWorkingHoursColor.dark());
1264 } else { 1264 } else {
1265 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1265 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1266 KOPrefs::instance()->mWorkingHoursColor); 1266 KOPrefs::instance()->mWorkingHoursColor);
1267 } 1267 }
1268 } 1268 }
1269 ++gxStart; 1269 ++gxStart;
1270 } 1270 }
1271 } 1271 }
1272 } 1272 }
1273 /* 1273 /*
1274 int selectionX = KOGlobals::self()->reverseLayout() ? 1274 int selectionX = KOGlobals::self()->reverseLayout() ?
1275 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1275 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1276 mSelectionCellX * mGridSpacingX; 1276 mSelectionCellX * mGridSpacingX;
1277 1277
1278 // Draw selection 1278 // Draw selection
1279 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1279 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1280 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1280 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1281 // TODO: paint only part within cx,cy,cw,ch 1281 // TODO: paint only part within cx,cy,cw,ch
1282 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1282 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1283 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1283 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1284 } 1284 }
1285 */ 1285 */
1286 // Draw vertical lines of grid 1286 // Draw vertical lines of grid
1287 1287
1288 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1288 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1289 if ( mGridSpacingX > 0 ) { 1289 if ( mGridSpacingX > 0 ) {
1290 while (x < cx + cw) { 1290 while (x < cx + cw) {
1291 p->drawLine(x,cy,x,cy+ch); 1291 p->drawLine(x,cy,x,cy+ch);
1292 x+=mGridSpacingX; 1292 x+=mGridSpacingX;
1293 } 1293 }
1294 } 1294 }
1295 // Draw horizontal lines of grid 1295 // Draw horizontal lines of grid
1296 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1296 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1297 if ( lGridSpacingY > 0 ) { 1297 if ( lGridSpacingY > 0 ) {
1298 while (y < cy + ch) { 1298 while (y < cy + ch) {
1299 p->setPen( SolidLine ); 1299 p->setPen( SolidLine );
1300 p->drawLine(cx,y,cx+cw,y); 1300 p->drawLine(cx,y,cx+cw,y);
1301 y+=lGridSpacingY; 1301 y+=lGridSpacingY;
1302 p->setPen( DotLine ); 1302 p->setPen( DotLine );
1303 p->drawLine(cx,y,cx+cw,y); 1303 p->drawLine(cx,y,cx+cw,y);
1304 y+=lGridSpacingY; 1304 y+=lGridSpacingY;
1305 } 1305 }
1306 p->setPen( SolidLine ); 1306 p->setPen( SolidLine );
1307 } 1307 }
1308 mPixPainter.end() ; 1308 mPixPainter.end() ;
1309} 1309}
1310 1310
1311/* 1311/*
1312 Convert srcollview contents coordinates to agenda grid coordinates. 1312 Convert srcollview contents coordinates to agenda grid coordinates.
1313*/ 1313*/
1314void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1314void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1315{ 1315{
1316 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1316 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1317 x/mGridSpacingX; 1317 x/mGridSpacingX;
1318 gy = y/mGridSpacingY; 1318 gy = y/mGridSpacingY;
1319} 1319}
1320 1320
1321/* 1321/*
1322 Convert agenda grid coordinates to scrollview contents coordinates. 1322 Convert agenda grid coordinates to scrollview contents coordinates.
1323*/ 1323*/
1324void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1324void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1325{ 1325{
1326 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1326 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1327 gx*mGridSpacingX; 1327 gx*mGridSpacingX;
1328 y = gy*mGridSpacingY; 1328 y = gy*mGridSpacingY;
1329} 1329}
1330 1330
1331 1331
1332/* 1332/*
1333 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1333 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1334 the grid. 1334 the grid.
1335*/ 1335*/
1336int KOAgenda::timeToY(const QTime &time) 1336int KOAgenda::timeToY(const QTime &time)
1337{ 1337{
1338 int minutesPerCell = 24 * 60 / mRows; 1338 int minutesPerCell = 24 * 60 / mRows;
1339 int timeMinutes = time.hour() * 60 + time.minute(); 1339 int timeMinutes = time.hour() * 60 + time.minute();
1340 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1340 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1341 return Y; 1341 return Y;
1342} 1342}
1343 1343
1344 1344
1345/* 1345/*
1346 Return time corresponding to cell y coordinate. Coordinates are rounded to 1346 Return time corresponding to cell y coordinate. Coordinates are rounded to
1347 fit into the grid. 1347 fit into the grid.
1348*/ 1348*/
1349QTime KOAgenda::gyToTime(int gy) 1349QTime KOAgenda::gyToTime(int gy)
1350{ 1350{
1351 1351
1352 int secondsPerCell = 24 * 60 * 60/ mRows; 1352 int secondsPerCell = 24 * 60 * 60/ mRows;
1353 1353
1354 int timeSeconds = secondsPerCell * gy; 1354 int timeSeconds = secondsPerCell * gy;
1355 1355
1356 QTime time( 0, 0, 0 ); 1356 QTime time( 0, 0, 0 );
1357 if ( timeSeconds < 24 * 60 * 60 ) { 1357 if ( timeSeconds < 24 * 60 * 60 ) {
1358 time = time.addSecs(timeSeconds); 1358 time = time.addSecs(timeSeconds);
1359 } else { 1359 } else {
1360 time.setHMS( 23, 59, 59 ); 1360 time.setHMS( 23, 59, 59 );
1361 } 1361 }
1362 1362
1363 return time; 1363 return time;
1364} 1364}
1365 1365
1366void KOAgenda::setStartHour(int startHour) 1366void KOAgenda::setStartHour(int startHour)
1367{ 1367{
1368 int startCell = startHour * mRows / 24; 1368 int startCell = startHour * mRows / 24;
1369 setContentsPos(0,startCell * gridSpacingY()); 1369 setContentsPos(0,startCell * gridSpacingY());
1370} 1370}
1371void KOAgenda::hideUnused() 1371void KOAgenda::hideUnused()
1372{ 1372{
1373 // experimental only 1373 // experimental only
1374 // return; 1374 // return;
1375 KOAgendaItem *item; 1375 KOAgendaItem *item;
1376 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1376 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1377 item->hide(); 1377 item->hide();
1378 } 1378 }
1379} 1379}
1380 1380
1381 1381
1382KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1382KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1383{ 1383{
1384 1384
1385 KOAgendaItem *fi; 1385 KOAgendaItem *fi;
1386 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1386 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1387 if ( fi->incidence() == event ) { 1387 if ( fi->incidence() == event ) {
1388 mUnusedItems.remove(); 1388 mUnusedItems.remove();
1389 fi->init( event, qd ); 1389 fi->init( event, qd );
1390 return fi; 1390 return fi;
1391 } 1391 }
1392 } 1392 }
1393 fi=mUnusedItems.first(); 1393 fi=mUnusedItems.first();
1394 if ( fi ) { 1394 if ( fi ) {
1395 mUnusedItems.remove(); 1395 mUnusedItems.remove();
1396 fi->init( event, qd ); 1396 fi->init( event, qd );
1397 return fi; 1397 return fi;
1398 } 1398 }
1399 // qDebug("new KOAgendaItem "); 1399 // qDebug("new KOAgendaItem ");
1400 1400
1401 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1401 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1402 agendaItem->installEventFilter(this); 1402 agendaItem->installEventFilter(this);
1403 addChild(agendaItem,0,0); 1403 addChild(agendaItem,0,0);
1404 return agendaItem; 1404 return agendaItem;
1405} 1405}
1406KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1406KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1407{ 1407{
1408 KOAgendaItem *item; 1408 KOAgendaItem *item;
1409 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1409 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1410 if ( item->incidence() == todo ) { 1410 if ( item->incidence() == todo ) {
1411 mItems.remove(); 1411 mItems.remove();
1412 return item; 1412 return item;
1413 } 1413 }
1414 } 1414 }
1415 return 0; 1415 return 0;
1416} 1416}
1417 1417
1418 1418
1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1419void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1420{ 1420{
1421 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1421 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1422 KOAgendaItem *item; 1422 KOAgendaItem *item;
1423 item = getItemForTodo ( todo ); 1423 item = getItemForTodo ( todo );
1424 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1424 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1425 if ( item ) { 1425 if ( item ) {
1426 blockSignals( true ); 1426 blockSignals( true );
1427 //qDebug("item found "); 1427 //qDebug("item found ");
1428 item->hide(); 1428 item->hide();
1429 item->setCellX(-2, -1 ); 1429 item->setCellX(-2, -1 );
1430 item->select(false); 1430 item->select(false);
1431 mUnusedItems.append( item ); 1431 mUnusedItems.append( item );
1432 mItems.remove( item ); 1432 mItems.remove( item );
1433 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1433 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1434 KOAgendaItem *itemit; 1434 KOAgendaItem *itemit;
1435 //globalFlagBlockAgendaItemPaint = 1; 1435 //globalFlagBlockAgendaItemPaint = 1;
1436 for ( itemit=oldconflictItems.first(); itemit != 0; 1436 for ( itemit=oldconflictItems.first(); itemit != 0;
1437 itemit=oldconflictItems.next() ) { 1437 itemit=oldconflictItems.next() ) {
1438 if ( itemit != item ) 1438 if ( itemit != item )
1439 placeSubCells(itemit); 1439 placeSubCells(itemit);
1440 } 1440 }
1441 qApp->processEvents(); 1441 qApp->processEvents();
1442 //globalFlagBlockAgendaItemPaint = 0; 1442 //globalFlagBlockAgendaItemPaint = 0;
1443 for ( itemit=oldconflictItems.first(); itemit != 0; 1443 for ( itemit=oldconflictItems.first(); itemit != 0;
1444 itemit=oldconflictItems.next() ) { 1444 itemit=oldconflictItems.next() ) {
1445 globalFlagBlockAgendaItemUpdate = 0; 1445 globalFlagBlockAgendaItemUpdate = 0;
1446 if ( itemit != item ) 1446 if ( itemit != item )
1447 itemit->repaintMe(); 1447 itemit->repaintMe();
1448 globalFlagBlockAgendaItemUpdate = 1; 1448 globalFlagBlockAgendaItemUpdate = 1;
1449 itemit->repaint(); 1449 itemit->repaint();
1450 } 1450 }
1451 blockSignals( false ); 1451 blockSignals( false );
1452 } 1452 }
1453 if ( remove ) { 1453 if ( remove ) {
1454 //qDebug("remove****************************************** "); 1454 //qDebug("remove****************************************** ");
1455 return; 1455 return;
1456 } 1456 }
1457 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1457 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1458 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1458 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1459 QDate currentDate; 1459 QDate currentDate;
1460 QDateTime dt; 1460 QDateTime dt;
1461 if ( todo->hasCompletedDate() ) 1461 if ( todo->hasCompletedDate() )
1462 dt = todo->completed(); 1462 dt = todo->completed();
1463 else 1463 else
1464 dt = todo->dtDue(); 1464 dt = todo->dtDue();
1465 if ( overdue ) { 1465 if ( overdue ) {
1466 currentDate = QDate::currentDate(); 1466 currentDate = QDate::currentDate();
1467 days += todo->dtDue().date().daysTo( currentDate ); 1467 days += todo->dtDue().date().daysTo( currentDate );
1468 } 1468 }
1469 else 1469 else
1470 currentDate = dt.date(); 1470 currentDate = dt.date();
1471 1471
1472 if ( todo->doesFloat() || overdue ) { 1472 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1473 if ( ! mAllDayMode ) return; 1473 if ( ! mAllDayMode ) return;
1474 // aldayagenda 1474 // aldayagenda
1475 globalFlagBlockAgendaItemPaint = 1; 1475 globalFlagBlockAgendaItemPaint = 1;
1476 item = insertAllDayItem(todo, currentDate,days, days); 1476 item = insertAllDayItem(todo, currentDate,days, days);
1477 item->show(); 1477 item->show();
1478 1478
1479 } 1479 }
1480 else { 1480 else {
1481 if ( mAllDayMode ) return; 1481 if ( mAllDayMode ) return;
1482 // mAgenda 1482 // mAgenda
1483 globalFlagBlockAgendaItemPaint = 1; 1483 globalFlagBlockAgendaItemPaint = 1;
1484 int endY = timeToY(dt.time()) - 1; 1484 int endY = timeToY(dt.time()) - 1;
1485 int hi = 12/KOPrefs::instance()->mHourSize; 1485 int hi = 12/KOPrefs::instance()->mHourSize;
1486 int startY = endY - 1-hi; 1486 int startY = endY - 1-hi;
1487 item = insertItem(todo,currentDate,days,startY,endY); 1487 item = insertItem(todo,currentDate,days,startY,endY);
1488 item->show(); 1488 item->show();
1489 } 1489 }
1490 qApp->processEvents(); 1490 qApp->processEvents();
1491 globalFlagBlockAgendaItemPaint = 0; 1491 globalFlagBlockAgendaItemPaint = 0;
1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1492 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1493 KOAgendaItem *itemit; 1493 KOAgendaItem *itemit;
1494 for ( itemit=oldconflictItems.first(); itemit != 0; 1494 for ( itemit=oldconflictItems.first(); itemit != 0;
1495 itemit=oldconflictItems.next() ) { 1495 itemit=oldconflictItems.next() ) {
1496 globalFlagBlockAgendaItemUpdate = 0; 1496 globalFlagBlockAgendaItemUpdate = 0;
1497 itemit->repaintMe(); 1497 itemit->repaintMe();
1498 globalFlagBlockAgendaItemUpdate = 1; 1498 globalFlagBlockAgendaItemUpdate = 1;
1499 itemit->repaint(); 1499 itemit->repaint();
1500 } 1500 }
1501 globalFlagBlockAgendaItemUpdate = 0; 1501 globalFlagBlockAgendaItemUpdate = 0;
1502 item->repaintMe(); 1502 item->repaintMe();
1503 globalFlagBlockAgendaItemUpdate = 1; 1503 globalFlagBlockAgendaItemUpdate = 1;
1504 item->repaint(); 1504 item->repaint();
1505} 1505}
1506/* 1506/*
1507 Insert KOAgendaItem into agenda. 1507 Insert KOAgendaItem into agenda.
1508*/ 1508*/
1509KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1509KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1510{ 1510{
1511 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; 1511 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1512 1512
1513 if (mAllDayMode) { 1513 if (mAllDayMode) {
1514 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1514 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1515 return 0; 1515 return 0;
1516 } 1516 }
1517 1517
1518 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1518 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1519 //agendaItem->setFrameStyle(WinPanel|Raised); 1519 //agendaItem->setFrameStyle(WinPanel|Raised);
1520 1520
1521 int YSize = YBottom - YTop + 1; 1521 int YSize = YBottom - YTop + 1;
1522 if (YSize < 0) { 1522 if (YSize < 0) {
1523 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1523 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1524 YSize = 1; 1524 YSize = 1;
1525 } 1525 }
1526 int iheight = mGridSpacingY * YSize; 1526 int iheight = mGridSpacingY * YSize;
1527 1527
1528 agendaItem->resize(mGridSpacingX,iheight ); 1528 agendaItem->resize(mGridSpacingX,iheight );
1529 agendaItem->setCellXY(X,YTop,YBottom); 1529 agendaItem->setCellXY(X,YTop,YBottom);
1530 agendaItem->setCellXWidth(X); 1530 agendaItem->setCellXWidth(X);
1531 1531
1532 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1532 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1533 mItems.append(agendaItem); 1533 mItems.append(agendaItem);
1534 1534
1535 placeSubCells(agendaItem); 1535 placeSubCells(agendaItem);
1536 1536
1537 //agendaItem->show(); 1537 //agendaItem->show();
1538 1538
1539 marcus_bains(); 1539 marcus_bains();
1540 1540
1541 return agendaItem; 1541 return agendaItem;
1542} 1542}
1543 1543
1544 1544
1545/* 1545/*
1546 Insert all-day KOAgendaItem into agenda. 1546 Insert all-day KOAgendaItem into agenda.
1547*/ 1547*/
1548KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1548KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1549{ 1549{
1550 if (!mAllDayMode) { 1550 if (!mAllDayMode) {
1551 return 0; 1551 return 0;
1552 } 1552 }
1553 1553
1554 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1554 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1555 1555
1556 agendaItem->setCellXY(XBegin,0,0); 1556 agendaItem->setCellXY(XBegin,0,0);
1557 agendaItem->setCellXWidth(XEnd); 1557 agendaItem->setCellXWidth(XEnd);
1558 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1558 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1559 1559
1560 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1560 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1561 mItems.append(agendaItem); 1561 mItems.append(agendaItem);
1562 1562
1563 placeSubCells(agendaItem); 1563 placeSubCells(agendaItem);
1564 1564
1565 //agendaItem->show(); 1565 //agendaItem->show();
1566 1566
1567 return agendaItem; 1567 return agendaItem;
1568} 1568}
1569 1569
1570 1570
1571void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1571void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1572 int YTop,int YBottom) 1572 int YTop,int YBottom)
1573{ 1573{
1574 if (mAllDayMode) { 1574 if (mAllDayMode) {
1575 ; 1575 ;
1576 return; 1576 return;
1577 } 1577 }
1578 1578
1579 int cellX,cellYTop,cellYBottom; 1579 int cellX,cellYTop,cellYBottom;
1580 QString newtext; 1580 QString newtext;
1581 int width = XEnd - XBegin + 1; 1581 int width = XEnd - XBegin + 1;
1582 int count = 0; 1582 int count = 0;
1583 KOAgendaItem *current = 0; 1583 KOAgendaItem *current = 0;
1584 QPtrList<KOAgendaItem> multiItems; 1584 QPtrList<KOAgendaItem> multiItems;
1585 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1585 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1586 if (cellX == XBegin) cellYTop = YTop; 1586 if (cellX == XBegin) cellYTop = YTop;
1587 else cellYTop = 0; 1587 else cellYTop = 0;
1588 if (cellX == XEnd) cellYBottom = YBottom; 1588 if (cellX == XEnd) cellYBottom = YBottom;
1589 else cellYBottom = rows() - 1; 1589 else cellYBottom = rows() - 1;
1590 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1590 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1591 newtext.append(event->summary()); 1591 newtext.append(event->summary());
1592 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1592 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1593 current->setText(newtext); 1593 current->setText(newtext);
1594 multiItems.append(current); 1594 multiItems.append(current);
1595 } 1595 }
1596 1596
1597 KOAgendaItem *next = 0; 1597 KOAgendaItem *next = 0;
1598 KOAgendaItem *last = multiItems.last(); 1598 KOAgendaItem *last = multiItems.last();
1599 KOAgendaItem *first = multiItems.first(); 1599 KOAgendaItem *first = multiItems.first();
1600 KOAgendaItem *setFirst,*setLast; 1600 KOAgendaItem *setFirst,*setLast;
1601 current = first; 1601 current = first;
1602 while (current) { 1602 while (current) {
1603 next = multiItems.next(); 1603 next = multiItems.next();
1604 if (current == first) setFirst = 0; 1604 if (current == first) setFirst = 0;
1605 else setFirst = first; 1605 else setFirst = first;
1606 if (current == last) setLast = 0; 1606 if (current == last) setLast = 0;
1607 else setLast = last; 1607 else setLast = last;
1608 1608
1609 current->setMultiItem(setFirst,next,setLast); 1609 current->setMultiItem(setFirst,next,setLast);
1610 current = next; 1610 current = next;
1611 } 1611 }
1612 1612
1613 marcus_bains(); 1613 marcus_bains();
1614} 1614}
1615 1615
1616 1616
1617//QSizePolicy KOAgenda::sizePolicy() const 1617//QSizePolicy KOAgenda::sizePolicy() const
1618//{ 1618//{
1619 // Thought this would make the all-day event agenda minimum size and the 1619 // Thought this would make the all-day event agenda minimum size and the
1620 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1620 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1621 // don´t seem to think that an Expanding widget needs more space than a 1621 // don´t seem to think that an Expanding widget needs more space than a
1622 // Preferred one. 1622 // Preferred one.
1623 // But it doesn´t hurt, so it stays. 1623 // But it doesn´t hurt, so it stays.
1624// if (mAllDayMode) { 1624// if (mAllDayMode) {
1625// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1625// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1626// } else { 1626// } else {
1627// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1627// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1628// } 1628// }
1629//} 1629//}
1630void KOAgenda::finishResize ( ) 1630void KOAgenda::finishResize ( )
1631{ 1631{
1632 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1632 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1633 if ( globalFlagBlockAgenda == 0 ) { 1633 if ( globalFlagBlockAgenda == 0 ) {
1634 finishUpdate(); 1634 finishUpdate();
1635 //qDebug("finishUpdate() called "); 1635 //qDebug("finishUpdate() called ");
1636 } 1636 }
1637} 1637}
1638/* 1638/*
1639 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1639 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1640*/ 1640*/
1641void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1641void KOAgenda::resizeEvent ( QResizeEvent *ev )
1642{ 1642{
1643 1643
1644 mResizeTimer.start( 150 , true ); 1644 mResizeTimer.start( 150 , true );
1645 computeSizes(); 1645 computeSizes();
1646 return; 1646 return;
1647 1647
1648} 1648}
1649void KOAgenda::computeSizes() 1649void KOAgenda::computeSizes()
1650{ 1650{
1651 if ( globalFlagBlockStartup ) 1651 if ( globalFlagBlockStartup )
1652 return; 1652 return;
1653 1653
1654 if (mAllDayMode) { 1654 if (mAllDayMode) {
1655 mGridSpacingX = (width()-3) / mColumns; 1655 mGridSpacingX = (width()-3) / mColumns;
1656 mGridSpacingY = height() - 2 * frameWidth() - 1; 1656 mGridSpacingY = height() - 2 * frameWidth() - 1;
1657 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1657 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1658// mGridSpacingY = height(); 1658// mGridSpacingY = height();
1659// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1659// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1660 1660
1661 KOAgendaItem *item; 1661 KOAgendaItem *item;
1662 int subCellWidth; 1662 int subCellWidth;
1663 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1663 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1664 subCellWidth = mGridSpacingY / item->subCells(); 1664 subCellWidth = mGridSpacingY / item->subCells();
1665 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1665 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1666 moveChild(item,KOGlobals::self()->reverseLayout() ? 1666 moveChild(item,KOGlobals::self()->reverseLayout() ?
1667 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1667 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1668 item->cellX() * mGridSpacingX, 1668 item->cellX() * mGridSpacingX,
1669 item->subCell() * subCellWidth); 1669 item->subCell() * subCellWidth);
1670 } 1670 }
1671 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1671 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1672 } else { 1672 } else {
1673 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1673 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1674 if (height() > mGridSpacingY * mRows + 1 ) { 1674 if (height() > mGridSpacingY * mRows + 1 ) {
1675 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1675 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1676 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1676 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1677 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1677 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1678 emit resizedSignal(); 1678 emit resizedSignal();
1679 } else 1679 } else
1680 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1680 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1681 KOAgendaItem *item; 1681 KOAgendaItem *item;
1682 int subCellWidth; 1682 int subCellWidth;
1683 1683
1684 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1684 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1685 subCellWidth = mGridSpacingX / item->subCells(); 1685 subCellWidth = mGridSpacingX / item->subCells();
1686 item->resize(subCellWidth,item->height()); 1686 item->resize(subCellWidth,item->height());
1687 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1687 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1688 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1688 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1689 item->cellX() * mGridSpacingX) + 1689 item->cellX() * mGridSpacingX) +
1690 item->subCell() * subCellWidth,childY(item)); 1690 item->subCell() * subCellWidth,childY(item));
1691 } 1691 }
1692 } 1692 }
1693 int cw = contentsWidth(); 1693 int cw = contentsWidth();
1694 int ch = contentsHeight(); 1694 int ch = contentsHeight();
1695 if ( mAllDayMode ) { 1695 if ( mAllDayMode ) {
1696 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1696 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1697 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 1697 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1698 paintPixAll->resize( cw, ch ); 1698 paintPixAll->resize( cw, ch );
1699 } else { 1699 } else {
1700 QPixmap* paintPix = KOAgendaItem::paintPix(); 1700 QPixmap* paintPix = KOAgendaItem::paintPix();
1701 if ( paintPix->width() < cw || paintPix->height() < ch ) 1701 if ( paintPix->width() < cw || paintPix->height() < ch )
1702 KOAgendaItem::resizePixmap( cw , ch ); 1702 KOAgendaItem::resizePixmap( cw , ch );
1703 } 1703 }
1704 1704
1705 checkScrollBoundaries(); 1705 checkScrollBoundaries();
1706 marcus_bains(); 1706 marcus_bains();
1707 drawContentsToPainter(); 1707 drawContentsToPainter();
1708 viewport()->repaint(false); 1708 viewport()->repaint(false);
1709} 1709}
1710 1710
1711void KOAgenda::scrollUp() 1711void KOAgenda::scrollUp()
1712{ 1712{
1713 scrollBy(0,-mScrollOffset); 1713 scrollBy(0,-mScrollOffset);
1714} 1714}
1715 1715
1716 1716
1717void KOAgenda::scrollDown() 1717void KOAgenda::scrollDown()
1718{ 1718{
1719 scrollBy(0,mScrollOffset); 1719 scrollBy(0,mScrollOffset);
1720} 1720}
1721 1721
1722void KOAgenda::popupAlarm() 1722void KOAgenda::popupAlarm()
1723{ 1723{
1724 if (!mClickedItem) { 1724 if (!mClickedItem) {
1725 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1725 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1726 return; 1726 return;
1727 } 1727 }
1728// TODO: deal correctly with multiple alarms 1728// TODO: deal correctly with multiple alarms
1729 Alarm* alarm; 1729 Alarm* alarm;
1730 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1730 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1731 for(alarm=list.first();alarm;alarm=list.next()) { 1731 for(alarm=list.first();alarm;alarm=list.next()) {
1732 alarm->toggleAlarm(); 1732 alarm->toggleAlarm();
1733 } 1733 }
1734 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1734 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1735 mClickedItem->paintMe( true ); 1735 mClickedItem->paintMe( true );
1736 mClickedItem->repaint( false ); 1736 mClickedItem->repaint( false );
1737} 1737}
1738 1738
1739/* 1739/*
1740 Calculates the minimum width 1740 Calculates the minimum width
1741*/ 1741*/
1742int KOAgenda::minimumWidth() const 1742int KOAgenda::minimumWidth() const
1743{ 1743{
1744 // TODO:: develop a way to dynamically determine the minimum width 1744 // TODO:: develop a way to dynamically determine the minimum width
1745 int min = 100; 1745 int min = 100;
1746 1746
1747 return min; 1747 return min;
1748} 1748}
1749 1749
1750void KOAgenda::updateConfig() 1750void KOAgenda::updateConfig()
1751{ 1751{
1752 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1752 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1753 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1753 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1754 if ( mAllDayMode ) { 1754 if ( mAllDayMode ) {
1755 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1755 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1756 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1756 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1757 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1757 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1758 // setMaximumHeight( mGridSpacingY+1 ); 1758 // setMaximumHeight( mGridSpacingY+1 );
1759 viewport()->repaint( false ); 1759 viewport()->repaint( false );
1760 //setFixedHeight( mGridSpacingY+1 ); 1760 //setFixedHeight( mGridSpacingY+1 );
1761 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1761 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1762 } 1762 }
1763 else { 1763 else {
1764 mGridSpacingY = KOPrefs::instance()->mHourSize; 1764 mGridSpacingY = KOPrefs::instance()->mHourSize;
1765 calculateWorkingHours(); 1765 calculateWorkingHours();
1766 marcus_bains(); 1766 marcus_bains();
1767 } 1767 }
1768} 1768}
1769 1769
1770void KOAgenda::checkScrollBoundaries() 1770void KOAgenda::checkScrollBoundaries()
1771{ 1771{
1772 // Invalidate old values to force update 1772 // Invalidate old values to force update
1773 mOldLowerScrollValue = -1; 1773 mOldLowerScrollValue = -1;
1774 mOldUpperScrollValue = -1; 1774 mOldUpperScrollValue = -1;
1775 1775
1776 checkScrollBoundaries(verticalScrollBar()->value()); 1776 checkScrollBoundaries(verticalScrollBar()->value());
1777} 1777}
1778 1778
1779void KOAgenda::checkScrollBoundaries(int v) 1779void KOAgenda::checkScrollBoundaries(int v)
1780{ 1780{
1781 if ( mGridSpacingY == 0 ) 1781 if ( mGridSpacingY == 0 )
1782 return; 1782 return;
1783 int yMin = v/mGridSpacingY; 1783 int yMin = v/mGridSpacingY;
1784 int yMax = (v+visibleHeight())/mGridSpacingY; 1784 int yMax = (v+visibleHeight())/mGridSpacingY;
1785 1785
1786// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1786// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1787 1787
1788 if (yMin != mOldLowerScrollValue) { 1788 if (yMin != mOldLowerScrollValue) {
1789 mOldLowerScrollValue = yMin; 1789 mOldLowerScrollValue = yMin;
1790 emit lowerYChanged(yMin); 1790 emit lowerYChanged(yMin);
1791 } 1791 }
1792 if (yMax != mOldUpperScrollValue) { 1792 if (yMax != mOldUpperScrollValue) {
1793 mOldUpperScrollValue = yMax; 1793 mOldUpperScrollValue = yMax;
1794 emit upperYChanged(yMax); 1794 emit upperYChanged(yMax);
1795 } 1795 }
1796} 1796}
1797 1797
1798void KOAgenda::deselectItem() 1798void KOAgenda::deselectItem()
1799{ 1799{
1800 if (mSelectedItem.isNull()) return; 1800 if (mSelectedItem.isNull()) return;
1801 mSelectedItem->select(false); 1801 mSelectedItem->select(false);
1802 mSelectedItem = 0; 1802 mSelectedItem = 0;
1803} 1803}
1804 1804
1805void KOAgenda::selectItem(KOAgendaItem *item) 1805void KOAgenda::selectItem(KOAgendaItem *item)
1806{ 1806{
1807 if ((KOAgendaItem *)mSelectedItem == item) return; 1807 if ((KOAgendaItem *)mSelectedItem == item) return;
1808 deselectItem(); 1808 deselectItem();
1809 if (item == 0) { 1809 if (item == 0) {
1810 emit incidenceSelected( 0 ); 1810 emit incidenceSelected( 0 );
1811 return; 1811 return;
1812 } 1812 }
1813 mSelectedItem = item; 1813 mSelectedItem = item;
1814 mSelectedItem->select(); 1814 mSelectedItem->select();
1815 emit incidenceSelected( mSelectedItem->incidence() ); 1815 emit incidenceSelected( mSelectedItem->incidence() );
1816} 1816}
1817 1817
1818// This function seems never be called. 1818// This function seems never be called.
1819void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1819void KOAgenda::keyPressEvent( QKeyEvent *kev )
1820{ 1820{
1821 switch(kev->key()) { 1821 switch(kev->key()) {
1822 case Key_PageDown: 1822 case Key_PageDown:
1823 verticalScrollBar()->addPage(); 1823 verticalScrollBar()->addPage();
1824 break; 1824 break;
1825 case Key_PageUp: 1825 case Key_PageUp:
1826 verticalScrollBar()->subtractPage(); 1826 verticalScrollBar()->subtractPage();
1827 break; 1827 break;
1828 case Key_Down: 1828 case Key_Down:
1829 verticalScrollBar()->addLine(); 1829 verticalScrollBar()->addLine();
1830 break; 1830 break;
1831 case Key_Up: 1831 case Key_Up:
1832 verticalScrollBar()->subtractLine(); 1832 verticalScrollBar()->subtractLine();
1833 break; 1833 break;
1834 default: 1834 default:
1835 ; 1835 ;
1836 } 1836 }
1837} 1837}
1838 1838
1839void KOAgenda::calculateWorkingHours() 1839void KOAgenda::calculateWorkingHours()
1840{ 1840{
1841// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1841// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1842 mWorkingHoursEnable = !mAllDayMode; 1842 mWorkingHoursEnable = !mAllDayMode;
1843 1843
1844 mWorkingHoursYTop = mGridSpacingY * 1844 mWorkingHoursYTop = mGridSpacingY *
1845 KOPrefs::instance()->mWorkingHoursStart * 4; 1845 KOPrefs::instance()->mWorkingHoursStart * 4;
1846 mWorkingHoursYBottom = mGridSpacingY * 1846 mWorkingHoursYBottom = mGridSpacingY *
1847 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1847 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1848} 1848}
1849 1849
1850 1850
1851DateList KOAgenda::dateList() const 1851DateList KOAgenda::dateList() const
1852{ 1852{
1853 return mSelectedDates; 1853 return mSelectedDates;
1854} 1854}
1855 1855
1856void KOAgenda::setDateList(const DateList &selectedDates) 1856void KOAgenda::setDateList(const DateList &selectedDates)
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 42a6f7c..8b79788 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1126,424 +1126,423 @@ void KOAgendaView::fillAgenda()
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 if ( fillIn ) { 1164 if ( fillIn ) {
1165 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
1166 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1166 if ( KOPrefs::instance()->mShowTodoInAgenda )
1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1168 } 1168 }
1169 else { 1169 else {
1170 QDateTime dt; 1170 QDateTime dt;
1171 if ( todo->hasCompletedDate() ) 1171 if ( todo->hasCompletedDate() )
1172 dt = todo->completed(); 1172 dt = todo->completed();
1173 else 1173 else
1174 dt = todo->dtDue();; 1174 dt = todo->dtDue();;
1175 1175
1176 1176
1177 int endY = mAgenda->timeToY(dt.time()) - 1; 1177 int endY = mAgenda->timeToY(dt.time()) - 1;
1178 int hi = (18/KOPrefs::instance()->mHourSize); 1178 int hi = (18/KOPrefs::instance()->mHourSize);
1179 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1179 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1180 int startY = endY -hi; 1180 int startY = endY -hi;
1181 1181
1182 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1182 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1183 1183
1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 // ---------- display Todos] -------------- 1189 // ---------- display Todos] --------------
1190 1190
1191 ++curCol; 1191 ++curCol;
1192 } 1192 }
1193 mAgenda->hideUnused(); 1193 mAgenda->hideUnused();
1194 mAllDayAgenda->hideUnused(); 1194 mAllDayAgenda->hideUnused();
1195 mAgenda->checkScrollBoundaries(); 1195 mAgenda->checkScrollBoundaries();
1196 1196
1197 deleteSelectedDateTime(); 1197 deleteSelectedDateTime();
1198 1198
1199 createDayLabels(); 1199 createDayLabels();
1200 emit incidenceSelected( 0 ); 1200 emit incidenceSelected( 0 );
1201 1201
1202 if ( globalFlagBlockAgenda == 2 ) { 1202 if ( globalFlagBlockAgenda == 2 ) {
1203 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1203 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1204 setStartHour( KOPrefs::instance()->mDayBegins ); 1204 setStartHour( KOPrefs::instance()->mDayBegins );
1205 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1205 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1206 setStartHour( QTime::currentTime ().hour() ); 1206 setStartHour( QTime::currentTime ().hour() );
1207 // qApp->processEvents(); 1207 // qApp->processEvents();
1208 } 1208 }
1209 qApp->processEvents(); 1209 qApp->processEvents();
1210 //qDebug("qApp->processEvents(); END "); 1210 //qDebug("qApp->processEvents(); END ");
1211 globalFlagBlockAgenda = 0; 1211 globalFlagBlockAgenda = 0;
1212 1212
1213 // mAgenda->hideUnused(); 1213 // mAgenda->hideUnused();
1214 //mAllDayAgenda->hideUnused(); 1214 //mAllDayAgenda->hideUnused();
1215 mAllDayAgenda->drawContentsToPainter(); 1215 mAllDayAgenda->drawContentsToPainter();
1216 mAgenda->drawContentsToPainter(); 1216 mAgenda->drawContentsToPainter();
1217 repaintAgenda(); 1217 repaintAgenda();
1218 // mAgenda->finishUpdate(); 1218 // mAgenda->finishUpdate();
1219 //mAllDayAgenda->finishUpdate(); 1219 //mAllDayAgenda->finishUpdate();
1220 1220
1221 // repaintAgenda(); 1221 // repaintAgenda();
1222 //qApp->processEvents(); 1222 //qApp->processEvents();
1223 // globalFlagBlockAgenda = 0; 1223 // globalFlagBlockAgenda = 0;
1224} 1224}
1225void KOAgendaView::repaintAgenda() 1225void KOAgendaView::repaintAgenda()
1226{ 1226{
1227 // mAllDayAgenda->drawContentsToPainter(); 1227 // mAllDayAgenda->drawContentsToPainter();
1228// mAllDayAgenda->viewport()->repaint( false ); 1228// mAllDayAgenda->viewport()->repaint( false );
1229// mAgenda->drawContentsToPainter(); 1229// mAgenda->drawContentsToPainter();
1230// mAgenda->viewport()->repaint( false ); 1230// mAgenda->viewport()->repaint( false );
1231// qApp->processEvents(); 1231// qApp->processEvents();
1232 1232
1233 //qDebug("KOAgendaView::repaintAgenda() "); 1233 //qDebug("KOAgendaView::repaintAgenda() ");
1234 //qApp->processEvents(); 1234 //qApp->processEvents();
1235 mAgenda->viewport()->repaint( false ); 1235 mAgenda->viewport()->repaint( false );
1236 mAllDayAgenda->viewport()->repaint( false ); 1236 mAllDayAgenda->viewport()->repaint( false );
1237 mAgenda->finishUpdate(); 1237 mAgenda->finishUpdate();
1238 mAllDayAgenda->finishUpdate(); 1238 mAllDayAgenda->finishUpdate();
1239} 1239}
1240 1240
1241 1241
1242void KOAgendaView::clearView() 1242void KOAgendaView::clearView()
1243{ 1243{
1244 // kdDebug() << "ClearView" << endl; 1244 // kdDebug() << "ClearView" << endl;
1245 mAllDayAgenda->clear(); 1245 mAllDayAgenda->clear();
1246 mAgenda->clear(); 1246 mAgenda->clear();
1247} 1247}
1248 1248
1249void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1249void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1250 const QDate &td) 1250 const QDate &td)
1251{ 1251{
1252#ifndef KORG_NOPRINTER 1252#ifndef KORG_NOPRINTER
1253 if (fd == td) 1253 if (fd == td)
1254 calPrinter->preview(CalPrinter::Day, fd, td); 1254 calPrinter->preview(CalPrinter::Day, fd, td);
1255 else 1255 else
1256 calPrinter->preview(CalPrinter::Week, fd, td); 1256 calPrinter->preview(CalPrinter::Week, fd, td);
1257#endif 1257#endif
1258} 1258}
1259 1259
1260// void KOAgendaView::updateMovedTodo() 1260// void KOAgendaView::updateMovedTodo()
1261// { 1261// {
1262// // updateConfig(); 1262// // updateConfig();
1263// // emit updateTodoViews(); 1263// // emit updateTodoViews();
1264// } 1264// }
1265 1265
1266void KOAgendaView::newEvent(int gx, int gy) 1266void KOAgendaView::newEvent(int gx, int gy)
1267{ 1267{
1268 if (!mSelectedDates.count()) return; 1268 if (!mSelectedDates.count()) return;
1269 1269
1270 QDate day = mSelectedDates[gx]; 1270 QDate day = mSelectedDates[gx];
1271 1271
1272 QTime time = mAgenda->gyToTime(gy); 1272 QTime time = mAgenda->gyToTime(gy);
1273 QDateTime dt(day,time); 1273 QDateTime dt(day,time);
1274 // if ( dt < QDateTime::currentDateTime () ) 1274 // if ( dt < QDateTime::currentDateTime () )
1275 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1275 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1276 emit newEventSignal(dt); 1276 emit newEventSignal(dt);
1277} 1277}
1278 1278
1279void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1279void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1280{ 1280{
1281 if (!mSelectedDates.count()) return; 1281 if (!mSelectedDates.count()) return;
1282 1282
1283 QDate dayStart = mSelectedDates[gxStart]; 1283 QDate dayStart = mSelectedDates[gxStart];
1284 QDate dayEnd = mSelectedDates[gxEnd]; 1284 QDate dayEnd = mSelectedDates[gxEnd];
1285 1285
1286 QTime timeStart = mAgenda->gyToTime(gyStart); 1286 QTime timeStart = mAgenda->gyToTime(gyStart);
1287 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1287 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1288 1288
1289 QDateTime dtStart(dayStart,timeStart); 1289 QDateTime dtStart(dayStart,timeStart);
1290 QDateTime dtEnd(dayEnd,timeEnd); 1290 QDateTime dtEnd(dayEnd,timeEnd);
1291 1291
1292 emit newEventSignal(dtStart,dtEnd); 1292 emit newEventSignal(dtStart,dtEnd);
1293} 1293}
1294 1294
1295void KOAgendaView::newEventAllDay(int gx, int ) 1295void KOAgendaView::newEventAllDay(int gx, int )
1296{ 1296{
1297 if (!mSelectedDates.count()) return; 1297 if (!mSelectedDates.count()) return;
1298 1298
1299 QDate day = mSelectedDates[gx]; 1299 QDate day = mSelectedDates[gx];
1300 1300
1301 emit newEventSignal(day); 1301 emit newEventSignal(day);
1302} 1302}
1303void KOAgendaView::newTodoAllDay(int gx, int ) 1303void KOAgendaView::newTodoAllDay(int gx, int )
1304{ 1304{
1305 if (!mSelectedDates.count()) return; 1305 if (!mSelectedDates.count()) return;
1306 1306
1307 QDateTime day (mSelectedDates[gx] ); 1307 QDateTime day (mSelectedDates[gx] );
1308 emit newTodoSignal(day, true); 1308 emit newTodoSignal(day, true);
1309} 1309}
1310void KOAgendaView::newTodo(int gx, int gy ) 1310void KOAgendaView::newTodo(int gx, int gy )
1311{ 1311{
1312 if (!mSelectedDates.count()) return; 1312 if (!mSelectedDates.count()) return;
1313 QDate dayStart = mSelectedDates[gx]; 1313 QDate dayStart = mSelectedDates[gx];
1314 QTime timeStart = mAgenda->gyToTime(gy); 1314 QTime timeStart = mAgenda->gyToTime(gy);
1315 QDateTime dt (dayStart,timeStart); 1315 QDateTime dt (dayStart,timeStart);
1316 emit newTodoSignal( dt, false ); 1316 emit newTodoSignal( dt, false );
1317} 1317}
1318 1318
1319void KOAgendaView::updateEventIndicatorTop(int newY) 1319void KOAgendaView::updateEventIndicatorTop(int newY)
1320{ 1320{
1321 uint i; 1321 uint i;
1322 for(i=0;i<mMinY.size();++i) { 1322 for(i=0;i<mMinY.size();++i) {
1323 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1323 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1324 else mEventIndicatorTop->enableColumn(i,false); 1324 else mEventIndicatorTop->enableColumn(i,false);
1325 } 1325 }
1326 1326
1327 mEventIndicatorTop->update(); 1327 mEventIndicatorTop->update();
1328} 1328}
1329 1329
1330void KOAgendaView::updateEventIndicatorBottom(int newY) 1330void KOAgendaView::updateEventIndicatorBottom(int newY)
1331{ 1331{
1332 uint i; 1332 uint i;
1333 for(i=0;i<mMaxY.size();++i) { 1333 for(i=0;i<mMaxY.size();++i) {
1334 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1334 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1335 else mEventIndicatorBottom->enableColumn(i,false); 1335 else mEventIndicatorBottom->enableColumn(i,false);
1336 } 1336 }
1337 1337
1338 mEventIndicatorBottom->update(); 1338 mEventIndicatorBottom->update();
1339} 1339}
1340 1340
1341void KOAgendaView::startDrag(Event *event) 1341void KOAgendaView::startDrag(Event *event)
1342{ 1342{
1343#ifndef KORG_NODND 1343#ifndef KORG_NODND
1344 DndFactory factory( calendar() ); 1344 DndFactory factory( calendar() );
1345 ICalDrag *vd = factory.createDrag(event,this); 1345 ICalDrag *vd = factory.createDrag(event,this);
1346 if (vd->drag()) { 1346 if (vd->drag()) {
1347 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1347 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1348 } 1348 }
1349#endif 1349#endif
1350} 1350}
1351 1351
1352void KOAgendaView::readSettings() 1352void KOAgendaView::readSettings()
1353{ 1353{
1354 readSettings(KOGlobals::config()); 1354 readSettings(KOGlobals::config());
1355} 1355}
1356 1356
1357void KOAgendaView::readSettings(KConfig *config) 1357void KOAgendaView::readSettings(KConfig *config)
1358{ 1358{
1359 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1359 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1360 1360
1361 config->setGroup("Views"); 1361 config->setGroup("Views");
1362 1362
1363 //#ifndef KORG_NOSPLITTER 1363 //#ifndef KORG_NOSPLITTER
1364 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1364 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1365 if (sizes.count() == 2) { 1365 if (sizes.count() == 2) {
1366 if ( sizes[0] < 20 ) { 1366 if ( sizes[0] < 20 ) {
1367 sizes[1] = sizes[1] +20 - sizes[0]; 1367 sizes[1] = sizes[1] +20 - sizes[0];
1368 sizes[0] = 20; 1368 sizes[0] = 20;
1369 } 1369 }
1370 mSplitterAgenda->setSizes(sizes); 1370 mSplitterAgenda->setSizes(sizes);
1371 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1371 // qDebug("read %d %d ",sizes[0],sizes[1] );
1372 } 1372 }
1373 //#endif 1373 //#endif
1374 1374
1375 // updateConfig(); 1375 // updateConfig();
1376} 1376}
1377 1377
1378void KOAgendaView::writeSettings(KConfig *config) 1378void KOAgendaView::writeSettings(KConfig *config)
1379{ 1379{
1380 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1380 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1381 1381
1382 config->setGroup("Views"); 1382 config->setGroup("Views");
1383 1383
1384 //#ifndef KORG_NOSPLITTER 1384 //#ifndef KORG_NOSPLITTER
1385 QValueList<int> list = mSplitterAgenda->sizes(); 1385 QValueList<int> list = mSplitterAgenda->sizes();
1386 config->writeEntry("Separator AgendaView",list); 1386 config->writeEntry("Separator AgendaView",list);
1387 //qDebug("write %d %d ", list[0],list[1] ); 1387 //qDebug("write %d %d ", list[0],list[1] );
1388 //#endif 1388 //#endif
1389} 1389}
1390 1390
1391void KOAgendaView::setHolidayMasks() 1391void KOAgendaView::setHolidayMasks()
1392{ 1392{
1393 mHolidayMask.resize(mSelectedDates.count()); 1393 mHolidayMask.resize(mSelectedDates.count());
1394 1394
1395 uint i; 1395 uint i;
1396 for(i=0;i<mSelectedDates.count();++i) { 1396 for(i=0;i<mSelectedDates.count();++i) {
1397 QDate date = mSelectedDates[i]; 1397 QDate date = mSelectedDates[i];
1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1400 bool showHoliday = false; 1400 bool showHoliday = false;
1401 if ( KOPrefs::instance()->mExcludeHolidays ) { 1401 if ( KOPrefs::instance()->mExcludeHolidays ) {
1402 QPtrList<Event> events = calendar()->events( date, true ); 1402 QPtrList<Event> events = calendar()->events( date, true );
1403 Event *event; 1403 Event *event;
1404 for( event = events.first(); event; event = events.next() ) { 1404 for( event = events.first(); event; event = events.next() ) {
1405 if ( event->categories().contains("Holiday") || 1405 if ( event->categories().contains("Holiday") ||
1406 event->categories().contains(i18n("Holiday"))) { 1406 event->categories().contains(i18n("Holiday"))) {
1407 showHoliday = true; 1407 showHoliday = true;
1408 break; 1408 break;
1409 } 1409 }
1410 } 1410 }
1411 1411
1412 } 1412 }
1413 1413
1414#ifndef KORG_NOPLUGINS 1414#ifndef KORG_NOPLUGINS
1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1416 !KOCore::self()->holiday(date).isEmpty(); 1416 !KOCore::self()->holiday(date).isEmpty();
1417#endif 1417#endif
1418 bool showDay = showSaturday || showSunday || showHoliday; 1418 bool showDay = showSaturday || showSunday || showHoliday;
1419 1419
1420 if (showDay) { 1420 if (showDay) {
1421 mHolidayMask.at(i) = true; 1421 mHolidayMask.at(i) = true;
1422 } else { 1422 } else {
1423 mHolidayMask.at(i) = false; 1423 mHolidayMask.at(i) = false;
1424 } 1424 }
1425 } 1425 }
1426 1426
1427 mAgenda->setHolidayMask(&mHolidayMask); 1427 mAgenda->setHolidayMask(&mHolidayMask);
1428 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1428 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1429} 1429}
1430 1430
1431void KOAgendaView::setContentsPos(int y) 1431void KOAgendaView::setContentsPos(int y)
1432{ 1432{
1433 mAgenda->setContentsPos(0,y); 1433 mAgenda->setContentsPos(0,y);
1434} 1434}
1435 1435
1436void KOAgendaView::setExpandedButton( bool expanded ) 1436void KOAgendaView::setExpandedButton( bool expanded )
1437{ 1437{
1438 if ( expanded ) { 1438 if ( expanded ) {
1439 mExpandButton->setPixmap( mExpandedPixmap ); 1439 mExpandButton->setPixmap( mExpandedPixmap );
1440 } else { 1440 } else {
1441 mExpandButton->setPixmap( mNotExpandedPixmap ); 1441 mExpandButton->setPixmap( mNotExpandedPixmap );
1442 } 1442 }
1443} 1443}
1444 1444
1445void KOAgendaView::clearSelection() 1445void KOAgendaView::clearSelection()
1446{ 1446{
1447 mAgenda->deselectItem(); 1447 mAgenda->deselectItem();
1448 mAllDayAgenda->deselectItem(); 1448 mAllDayAgenda->deselectItem();
1449} 1449}
1450 1450
1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1452 int gxEnd, int gyEnd) 1452 int gxEnd, int gyEnd)
1453{ 1453{
1454 mTimeSpanInAllDay = true; 1454 mTimeSpanInAllDay = true;
1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1456} 1456}
1457 1457
1458 1458
1459 1459
1460 1460
1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1462 int gxEnd, int gyEnd) 1462 int gxEnd, int gyEnd)
1463{ 1463{
1464 if (!mSelectedDates.count()) return; 1464 if (!mSelectedDates.count()) return;
1465 1465
1466 QDate dayStart = mSelectedDates[gxStart]; 1466 QDate dayStart = mSelectedDates[gxStart];
1467 QDate dayEnd = mSelectedDates[gxEnd]; 1467 QDate dayEnd = mSelectedDates[gxEnd];
1468 1468
1469 QTime timeStart = mAgenda->gyToTime(gyStart); 1469 QTime timeStart = mAgenda->gyToTime(gyStart);
1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1471 1471
1472 QDateTime dtStart(dayStart,timeStart); 1472 QDateTime dtStart(dayStart,timeStart);
1473 QDateTime dtEnd(dayEnd,timeEnd); 1473 QDateTime dtEnd(dayEnd,timeEnd);
1474 1474
1475 mTimeSpanBegin = dtStart; 1475 mTimeSpanBegin = dtStart;
1476 mTimeSpanEnd = dtEnd; 1476 mTimeSpanEnd = dtEnd;
1477 1477
1478} 1478}
1479 1479
1480void KOAgendaView::deleteSelectedDateTime() 1480void KOAgendaView::deleteSelectedDateTime()
1481{ 1481{
1482 mTimeSpanBegin.setDate(QDate()); 1482 mTimeSpanBegin.setDate(QDate());
1483 mTimeSpanEnd.setDate(QDate()); 1483 mTimeSpanEnd.setDate(QDate());
1484 mTimeSpanInAllDay = false; 1484 mTimeSpanInAllDay = false;
1485} 1485}
1486 1486
1487void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1487void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1488{ 1488{
1489 e->ignore(); 1489 e->ignore();
1490} 1490}
1491 1491
1492void KOAgendaView::scrollOneHourUp() 1492void KOAgendaView::scrollOneHourUp()
1493{ 1493{
1494 1494
1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1496} 1496}
1497void KOAgendaView::scrollOneHourDown() 1497void KOAgendaView::scrollOneHourDown()
1498{ 1498{
1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1500} 1500}
1501 1501
1502void KOAgendaView::setStartHour( int h ) 1502void KOAgendaView::setStartHour( int h )
1503{ 1503{
1504 mAgenda->setStartHour( h ); 1504 mAgenda->setStartHour( h );
1505 1505
1506} 1506}
1507 1507
1508void KOAgendaView::updateTodo( Todo * t, int ) 1508void KOAgendaView::updateTodo( Todo * t, int )
1509{ 1509{
1510
1511 bool remove = false; 1510 bool remove = false;
1512 bool removeAD = false; 1511 bool removeAD = false;
1513 QDate da; 1512 QDate da;
1514 if ( t->hasCompletedDate() ) 1513 if ( t->hasCompletedDate() )
1515 da = t->completed().date(); 1514 da = t->completed().date();
1516 else 1515 else
1517 da = t->dtDue().date(); 1516 da = t->dtDue().date();
1518 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1517 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1519 remove = true; 1518 remove = true;
1520 removeAD = true; 1519 removeAD = true;
1521 } 1520 }
1522 else { 1521 else {
1523 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1522 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1524 if ( overdue && 1523 if ( overdue &&
1525 QDate::currentDate() >= mSelectedDates.first() && 1524 QDate::currentDate() >= mSelectedDates.first() &&
1526 QDate::currentDate() <= mSelectedDates.last()) { 1525 QDate::currentDate() <= mSelectedDates.last()) {
1527 removeAD = false; 1526 removeAD = false;
1528 remove = true; 1527 remove = true;
1529 } 1528 }
1530 else { 1529 else {
1531 1530
1532 if ( da < mSelectedDates.first() || 1531 if ( da < mSelectedDates.first() ||
1533 da > mSelectedDates.last() ) { 1532 da > mSelectedDates.last() ) {
1534 remove = true; 1533 remove = true;
1535 removeAD = true; 1534 removeAD = true;
1536 } else { 1535 } else {
1537 remove = t->doesFloat() && !t->hasCompletedDate(); 1536 remove = t->doesFloat() && !t->hasCompletedDate();
1538 removeAD = !remove; 1537 removeAD = !remove;
1539 } 1538 }
1540 } 1539 }
1541 } 1540 }
1542 int days = mSelectedDates.first().daysTo( da ); 1541 int days = mSelectedDates.first().daysTo( da );
1543 // qDebug("daysto %d ", days ); 1542 //qDebug("daysto %d %d %d", days, remove,removeAD );
1544 mAgenda->updateTodo( t , days, remove); 1543 mAgenda->updateTodo( t , days, remove);
1545 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1544 if ( KOPrefs::instance()->mShowTodoInAgenda )
1546 mAllDayAgenda->updateTodo( t , days, removeAD); 1545 mAllDayAgenda->updateTodo( t , days, removeAD);
1547 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1546 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1548 1547
1549} 1548}
diff --git a/korganizer/koeditorgeneraltodo.h b/korganizer/koeditorgeneraltodo.h
index f6c30f8..5f1c3cc 100644
--- a/korganizer/koeditorgeneraltodo.h
+++ b/korganizer/koeditorgeneraltodo.h
@@ -1,105 +1,106 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KOEDITORGENERALTODO_H 23#ifndef _KOEDITORGENERALTODO_H
24#define _KOEDITORGENERALTODO_H 24#define _KOEDITORGENERALTODO_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qgroupbox.h> 30#include <qgroupbox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34#include <qlistview.h> 34#include <qlistview.h>
35#include <qradiobutton.h> 35#include <qradiobutton.h>
36 36
37#include "koeditorgeneral.h" 37#include "koeditorgeneral.h"
38#include "koglobals.h" 38#include "koglobals.h"
39 39
40class KRestrictedLine; 40class KRestrictedLine;
41 41
42class KDateEdit; 42class KDateEdit;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class KOEditorGeneralTodo : public KOEditorGeneral 46class KOEditorGeneralTodo : public KOEditorGeneral
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 public: 49 public:
50 KOEditorGeneralTodo (QObject* parent=0,const char* name=0); 50 KOEditorGeneralTodo (QObject* parent=0,const char* name=0);
51 virtual ~KOEditorGeneralTodo(); 51 virtual ~KOEditorGeneralTodo();
52 52
53 void initTime(QWidget *, QBoxLayout *); 53 void initTime(QWidget *, QBoxLayout *);
54 void initStatus(QWidget *, QBoxLayout *); 54 void initStatus(QWidget *, QBoxLayout *);
55 void initCompletion(QWidget *, QBoxLayout *); 55 void initCompletion(QWidget *, QBoxLayout *);
56 void initPriority(QWidget *, QBoxLayout *); 56 void initPriority(QWidget *, QBoxLayout *);
57 57
58 void finishSetup(); 58 void finishSetup();
59 59
60 /** Set widgets to default values */ 60 /** Set widgets to default values */
61 void setDefaults(QDateTime due,bool allDay); 61 void setDefaults(QDateTime due,bool allDay);
62 /** Read todo object and setup widgets accordingly */ 62 /** Read todo object and setup widgets accordingly */
63 void readTodo(Todo *); 63 void readTodo(Todo *);
64 /** Write todo settings to event object */ 64 /** Write todo settings to event object */
65 void writeTodo(Todo *); 65 void writeTodo(Todo *);
66 66
67 /** Check if the input is valid. */ 67 /** Check if the input is valid. */
68 bool validateInput(); 68 bool validateInput();
69 69
70 /** The todo has been modified externally */ 70 /** The todo has been modified externally */
71 void modified (Todo*, int); 71 void modified (Todo*, int);
72 72
73 signals: 73 signals:
74 void openCategoryDialog(); 74 void openCategoryDialog();
75 75
76 protected slots: 76 protected slots:
77 void completedChanged(int); 77 void completedChanged(int);
78 78
79 void enableDueEdit( bool enable ); 79 void enableDueEdit( bool enable );
80 void enableStartEdit( bool enable ); 80 void enableStartEdit( bool enable );
81 void enableTimeEdits( bool enable ); 81 void enableTimeEdits( bool enable );
82 void showAlarm(); 82 void showAlarm();
83 83
84 protected: 84 protected:
85 void setCompletedDate(); 85 void setCompletedDate();
86 86
87 private: 87 private:
88 friend class KOTodoEditor;
88 KDateEdit *mStartDateEdit; 89 KDateEdit *mStartDateEdit;
89 KOTimeEdit *mStartTimeEdit; 90 KOTimeEdit *mStartTimeEdit;
90 QCheckBox *mTimeButton; 91 QCheckBox *mTimeButton;
91 QCheckBox *mDueCheck; 92 QCheckBox *mDueCheck;
92 KDateEdit *mDueDateEdit; 93 KDateEdit *mDueDateEdit;
93 KOTimeEdit *mDueTimeEdit; 94 KOTimeEdit *mDueTimeEdit;
94 QComboBox *mCompletedCombo; 95 QComboBox *mCompletedCombo;
95 QLabel *mCompletedLabel; 96 QLabel *mCompletedLabel;
96 QLabel *mPriorityLabel; 97 QLabel *mPriorityLabel;
97 QComboBox *mPriorityCombo; 98 QComboBox *mPriorityCombo;
98 99
99 QCheckBox *mStartCheck; 100 QCheckBox *mStartCheck;
100 101
101 QDateTime mCompleted; 102 QDateTime mCompleted;
102}; 103};
103 104
104 105
105#endif 106#endif
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 16c19a4..ec5c2d1 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,375 +1,383 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown 3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qframe.h> 26#include <qframe.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qdir.h> 30#include <qdir.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39 39
40#include <libkdepim/categoryselectdialog.h> 40#include <libkdepim/categoryselectdialog.h>
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/calendarresources.h> 42#include <libkcal/calendarresources.h>
43#include <libkcal/resourcecalendar.h> 43#include <libkcal/resourcecalendar.h>
44#include <libkcal/icalformat.h> 44#include <libkcal/icalformat.h>
45#include <kresources/resourceselectdialog.h> 45#include <kresources/resourceselectdialog.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "kolocationbox.h"
48 49
49#include "kotodoeditor.h" 50#include "kotodoeditor.h"
50extern int globalFlagBlockAgenda; 51extern int globalFlagBlockAgenda;
51 52
52KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 53KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
53 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 54 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
54{ 55{
55 mTodo = 0; 56 mTodo = 0;
56 mRelatedTodo = 0; 57 mRelatedTodo = 0;
57 findButton(User1)->hide(); 58 findButton(User1)->hide();
58 init(); 59 init();
59} 60}
60 61
61KOTodoEditor::~KOTodoEditor() 62KOTodoEditor::~KOTodoEditor()
62{ 63{
63 emit dialogClose( mTodo ); 64 emit dialogClose( mTodo );
64} 65}
65 66
66void KOTodoEditor::init() 67void KOTodoEditor::init()
67{ 68{
68 setupGeneral(); 69 setupGeneral();
69 setupAttendeesTab(); 70 setupAttendeesTab();
70} 71}
71void KOTodoEditor::setCategories( QString s ) 72void KOTodoEditor::setCategories( QString s )
72{ 73{
73 mGeneral->setCategories(s); 74 mGeneral->setCategories(s);
74} 75}
75void KOTodoEditor::setSecrecy( int sec ) 76void KOTodoEditor::setSecrecy( int sec )
76{ 77{
77 mGeneral->setSecrecy( sec ); 78 mGeneral->setSecrecy( sec );
78} 79}
79void KOTodoEditor::reload() 80void KOTodoEditor::reload()
80{ 81{
81 if ( mTodo ) readTodo( mTodo ); 82 if ( mTodo ) readTodo( mTodo );
82} 83}
83 84
84void KOTodoEditor::setupGeneral() 85void KOTodoEditor::setupGeneral()
85{ 86{
86 mGeneral = new KOEditorGeneralTodo(this); 87 mGeneral = new KOEditorGeneralTodo(this);
87 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 88 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
88 89
89 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 90 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
90 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 91 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
91 // mGeneral,SLOT(setCategories(const QString &))); 92 // mGeneral,SLOT(setCategories(const QString &)));
92 93
93 if (KOPrefs::instance()->mCompactDialogs) { 94 if (KOPrefs::instance()->mCompactDialogs) {
94 QFrame *topFrame = addPage(i18n("General")); 95 QFrame *topFrame = addPage(i18n("General"));
95 96
96 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 97 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
97 if ( QApplication::desktop()->width() < 480 ) { 98 if ( QApplication::desktop()->width() < 480 ) {
98 topLayout->setMargin(1); 99 topLayout->setMargin(1);
99 topLayout->setSpacing(1); 100 topLayout->setSpacing(1);
100 } else { 101 } else {
101 topLayout->setMargin(marginHint()-1); 102 topLayout->setMargin(marginHint()-1);
102 topLayout->setSpacing(spacingHint()-1); 103 topLayout->setSpacing(spacingHint()-1);
103 } 104 }
104 mGeneral->initHeader(topFrame,topLayout); 105 mGeneral->initHeader(topFrame,topLayout);
105 mGeneral->initTime(topFrame,topLayout); 106 mGeneral->initTime(topFrame,topLayout);
106 mGeneral->initAlarm(topFrame,topLayout); 107 mGeneral->initAlarm(topFrame,topLayout);
107 mGeneral->enableAlarm( false ); 108 mGeneral->enableAlarm( false );
108 109
109 110
110 QBoxLayout *priorityLayout; 111 QBoxLayout *priorityLayout;
111 if ( QApplication::desktop()->width() < 500 ) 112 if ( QApplication::desktop()->width() < 500 )
112 priorityLayout = new QVBoxLayout( topLayout ); 113 priorityLayout = new QVBoxLayout( topLayout );
113 else 114 else
114 priorityLayout = new QHBoxLayout( topLayout ); 115 priorityLayout = new QHBoxLayout( topLayout );
115 QWidget* prioWidget = new QWidget (topFrame); 116 QWidget* prioWidget = new QWidget (topFrame);
116 priorityLayout->addWidget( prioWidget ); 117 priorityLayout->addWidget( prioWidget );
117 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 118 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
118 119
119 120
120 QIconSet icon; 121 QIconSet icon;
121 if ( QApplication::desktop()->width() < 321 ) 122 if ( QApplication::desktop()->width() < 321 )
122 icon = SmallIcon("fileexport16"); 123 icon = SmallIcon("fileexport16");
123 else 124 else
124 icon = SmallIcon("fileexport"); 125 icon = SmallIcon("fileexport");
125 QPushButton * saveTemplate = new QPushButton( prioWidget); 126 QPushButton * saveTemplate = new QPushButton( prioWidget);
126 saveTemplate->setIconSet (icon ) ; 127 saveTemplate->setIconSet (icon ) ;
127 int size = saveTemplate->sizeHint().height(); 128 int size = saveTemplate->sizeHint().height();
128 saveTemplate->setFixedSize( size, size ); 129 saveTemplate->setFixedSize( size, size );
129 if ( QApplication::desktop()->width() < 321 ) 130 if ( QApplication::desktop()->width() < 321 )
130 icon = SmallIcon("fileimport16"); 131 icon = SmallIcon("fileimport16");
131 else 132 else
132 icon = SmallIcon("fileimport"); 133 icon = SmallIcon("fileimport");
133 QPushButton * loadTemplate = new QPushButton( prioWidget); 134 QPushButton * loadTemplate = new QPushButton( prioWidget);
134 loadTemplate->setIconSet (icon ) ; 135 loadTemplate->setIconSet (icon ) ;
135 loadTemplate->setFixedSize( size, size ); 136 loadTemplate->setFixedSize( size, size );
136 137
137 priorityLayout2->addWidget(loadTemplate); 138 priorityLayout2->addWidget(loadTemplate);
138 priorityLayout2->addWidget(saveTemplate); 139 priorityLayout2->addWidget(saveTemplate);
139 mGeneral->initPriority(prioWidget,priorityLayout2); 140 mGeneral->initPriority(prioWidget,priorityLayout2);
140 mGeneral->initCategories( topFrame, priorityLayout ); 141 mGeneral->initCategories( topFrame, priorityLayout );
141 topLayout->addStretch(1); 142 topLayout->addStretch(1);
142 143
143 QFrame *topFrame2 = addPage(i18n("Details")); 144 QFrame *topFrame2 = addPage(i18n("Details"));
144 145
145 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
146 topLayout2->setMargin(marginHint()); 147 topLayout2->setMargin(marginHint());
147 topLayout2->setSpacing(spacingHint()); 148 topLayout2->setSpacing(spacingHint());
148 149
149 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 150 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
150 mGeneral->initCompletion(topFrame2,completionLayout); 151 mGeneral->initCompletion(topFrame2,completionLayout);
151 152
152 153
153 mGeneral->initSecrecy( topFrame2, topLayout2 ); 154 mGeneral->initSecrecy( topFrame2, topLayout2 );
154 mGeneral->initDescription(topFrame2,topLayout2); 155 mGeneral->initDescription(topFrame2,topLayout2);
155 156
156 // QHBox * hb = new QHBox ( topFrame2 ); 157 // QHBox * hb = new QHBox ( topFrame2 );
157 // topLayout2->addWidget(hb); 158 // topLayout2->addWidget(hb);
158 // hb->setSpacing( 3 ); 159 // hb->setSpacing( 3 );
159 160
160 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 161 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
161 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 162 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
162 163
163 } else { 164 } else {
164 QFrame *topFrame = addPage(i18n("General")); 165 QFrame *topFrame = addPage(i18n("General"));
165 166
166 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 167 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
167 topLayout->setSpacing(spacingHint()); 168 topLayout->setSpacing(spacingHint());
168 169
169 mGeneral->initHeader(topFrame,topLayout); 170 mGeneral->initHeader(topFrame,topLayout);
170 mGeneral->initTime(topFrame,topLayout); 171 mGeneral->initTime(topFrame,topLayout);
171 mGeneral->initStatus(topFrame,topLayout); 172 mGeneral->initStatus(topFrame,topLayout);
172 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
173 mGeneral->initAlarm(topFrame,alarmLineLayout); 174 mGeneral->initAlarm(topFrame,alarmLineLayout);
174 mGeneral->initDescription(topFrame,topLayout); 175 mGeneral->initDescription(topFrame,topLayout);
175 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 176 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
176 mGeneral->initCategories( topFrame, detailsLayout ); 177 mGeneral->initCategories( topFrame, detailsLayout );
177 mGeneral->initSecrecy( topFrame, detailsLayout ); 178 mGeneral->initSecrecy( topFrame, detailsLayout );
178 } 179 }
179 mGeneral->finishSetup(); 180 mGeneral->finishSetup();
180 181
181} 182}
182 183
183void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 184void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
184{ 185{
185 //init(); 186 //init();
186 187
187 mTodo = todo; 188 mTodo = todo;
188 readTodo(mTodo); 189 readTodo(mTodo);
189 if ( editDescription ) { 190 if ( editDescription ) {
190 showPage( 1 ); 191 showPage( 1 );
191 mGeneral->setFocusOn( 1 ); 192 mGeneral->setFocusOn( 1 );
192 } else { 193 } else {
193 showPage( 0 ); 194 showPage( 0 );
194 mGeneral->setFocusOn( 2 ); 195 mGeneral->setFocusOn( 2 );
195 } 196 }
196} 197}
197 198
198void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 199void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
199{ 200{
200 //init(); 201 //init();
201 202
202 mTodo = 0; 203 mTodo = 0;
203 setDefaults(due,relatedTodo,allDay); 204 setDefaults(due,relatedTodo,allDay);
204} 205}
205 206
206void KOTodoEditor::loadDefaults() 207void KOTodoEditor::loadDefaults()
207{ 208{
208 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
209} 210}
210 211
211bool KOTodoEditor::processInput( bool emitTime ) 212bool KOTodoEditor::processInput( bool emitTime )
212{ 213{
213 if (!validateInput()) return false; 214 if (!validateInput()) return false;
214 215
215 Todo *todo = 0; 216 Todo *todo = 0;
216 217
217 if (mTodo) todo = mTodo; 218 if (mTodo) todo = mTodo;
218 else { 219 else {
219 todo = new Todo; 220 todo = new Todo;
220 todo->setOrganizer(KOPrefs::instance()->email()); 221 todo->setOrganizer(KOPrefs::instance()->email());
221 } 222 }
222 223
223 writeTodo(todo); 224 writeTodo(todo);
224 if ( emitTime ) { 225 if ( emitTime ) {
225 globalFlagBlockAgenda = 1; 226 globalFlagBlockAgenda = 1;
226 emit showAgendaView( false ); 227 emit showAgendaView( false );
227 if ( todo->hasDueDate() ) 228 if ( todo->hasDueDate() )
228 emit jumpToTime( todo->dtDue().date() ); 229 emit jumpToTime( todo->dtDue().date() );
229 globalFlagBlockAgenda = 2; 230 globalFlagBlockAgenda = 2;
230 } 231 }
231 if (mTodo) { 232 if (mTodo) {
232 todo->setRevision(todo->revision()+1); 233 todo->setRevision(todo->revision()+1);
233 emit todoChanged(todo); 234 emit todoChanged(todo);
234 } else { 235 } else {
235 mCalendar->addTodo(todo); 236 mCalendar->addTodo(todo);
236 mTodo = todo; 237 mTodo = todo;
237 emit todoAdded(todo); 238 emit todoAdded(todo);
238 } 239 }
239 240
240 return true; 241 return true;
241} 242}
242 243
243void KOTodoEditor::deleteTodo() 244void KOTodoEditor::deleteTodo()
244{ 245{
245 if (mTodo) { 246 if (mTodo) {
246 if (KOPrefs::instance()->mConfirm) { 247 if (KOPrefs::instance()->mConfirm) {
247 switch (msgItemDelete()) { 248 switch (msgItemDelete()) {
248 case KMessageBox::Continue: // OK 249 case KMessageBox::Continue: // OK
249 emit todoToBeDeleted(mTodo); 250 emit todoToBeDeleted(mTodo);
250 emit dialogClose(mTodo); 251 emit dialogClose(mTodo);
251 mCalendar->deleteTodo(mTodo); 252 mCalendar->deleteTodo(mTodo);
252 emit todoDeleted(); 253 emit todoDeleted();
253 reject(); 254 reject();
254 break; 255 break;
255 } 256 }
256 } 257 }
257 else { 258 else {
258 emit todoToBeDeleted(mTodo); 259 emit todoToBeDeleted(mTodo);
259 emit dialogClose(mTodo); 260 emit dialogClose(mTodo);
260 mCalendar->deleteTodo(mTodo); 261 mCalendar->deleteTodo(mTodo);
261 emit todoDeleted(); 262 emit todoDeleted();
262 reject(); 263 reject();
263 } 264 }
264 } else { 265 } else {
265 reject(); 266 reject();
266 } 267 }
267} 268}
268 269
269void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 270void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
270{ 271{
271 mRelatedTodo = relatedEvent; 272 mRelatedTodo = relatedEvent;
272 273
273 mGeneral->setDefaults(due,allDay); 274 mGeneral->setDefaults(due,allDay);
274 mDetails->setDefaults(); 275 mDetails->setDefaults();
275 showPage( 0 ); 276 showPage( 0 );
276 if ( mRelatedTodo ) { 277 if ( mRelatedTodo ) {
277 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 278 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
278 mGeneral->setSecrecy (mRelatedTodo->secrecy ()); 279 mGeneral->setSecrecy (mRelatedTodo->secrecy ());
280 if ( mRelatedTodo->priority() < 3 )
281 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
282 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
283 int len = mRelatedTodo->summary().length();
284 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
285 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
286 mGeneral->mSummaryEdit->lineEdit()->setFocus();
279 287
280 } 288 } else
281 mGeneral->setFocusOn( 2 ); 289 mGeneral->setFocusOn( 2 );
282} 290}
283 291
284void KOTodoEditor::readTodo(Todo *todo) 292void KOTodoEditor::readTodo(Todo *todo)
285{ 293{
286 mGeneral->readTodo(todo); 294 mGeneral->readTodo(todo);
287 mDetails->readEvent(todo); 295 mDetails->readEvent(todo);
288 mRelatedTodo = 0;//todo->relatedTo(); 296 mRelatedTodo = 0;//todo->relatedTo();
289 // categories 297 // categories
290 // mCategoryDialog->setSelected(todo->categories()); 298 // mCategoryDialog->setSelected(todo->categories());
291 299
292 // We should handle read-only events here. 300 // We should handle read-only events here.
293} 301}
294 302
295void KOTodoEditor::writeTodo(Todo *event) 303void KOTodoEditor::writeTodo(Todo *event)
296{ 304{
297 mGeneral->writeTodo(event); 305 mGeneral->writeTodo(event);
298 mDetails->writeEvent(event); 306 mDetails->writeEvent(event);
299 307
300 // set related event, i.e. parent to-do in this case. 308 // set related event, i.e. parent to-do in this case.
301 if (mRelatedTodo) { 309 if (mRelatedTodo) {
302 event->setRelatedTo(mRelatedTodo); 310 event->setRelatedTo(mRelatedTodo);
303 } 311 }
304} 312}
305 313
306bool KOTodoEditor::validateInput() 314bool KOTodoEditor::validateInput()
307{ 315{
308 if (!mGeneral->validateInput()) return false; 316 if (!mGeneral->validateInput()) return false;
309 if (!mDetails->validateInput()) return false; 317 if (!mDetails->validateInput()) return false;
310 return true; 318 return true;
311} 319}
312 320
313int KOTodoEditor::msgItemDelete() 321int KOTodoEditor::msgItemDelete()
314{ 322{
315 return KMessageBox::warningContinueCancel(this, 323 return KMessageBox::warningContinueCancel(this,
316 i18n("This item will be permanently deleted."), 324 i18n("This item will be permanently deleted."),
317 i18n("KOrganizer Confirmation"),i18n("Delete")); 325 i18n("KOrganizer Confirmation"),i18n("Delete"));
318} 326}
319 327
320void KOTodoEditor::modified (int modification) 328void KOTodoEditor::modified (int modification)
321{ 329{
322 if (modification == KOGlobals::CATEGORY_MODIFIED || 330 if (modification == KOGlobals::CATEGORY_MODIFIED ||
323 KOGlobals::UNKNOWN_MODIFIED == modification ) 331 KOGlobals::UNKNOWN_MODIFIED == modification )
324 // mCategoryDialog->setSelected (mTodo->categories ()); 332 // mCategoryDialog->setSelected (mTodo->categories ());
325 mGeneral->modified (mTodo, modification); 333 mGeneral->modified (mTodo, modification);
326 334
327} 335}
328 336
329void KOTodoEditor::slotLoadTemplate() 337void KOTodoEditor::slotLoadTemplate()
330{ 338{
331 339
332 QString fileName =locateLocal( "templates", "todos" ); 340 QString fileName =locateLocal( "templates", "todos" );
333 QDir t_dir; 341 QDir t_dir;
334 if ( !t_dir.exists(fileName) ) 342 if ( !t_dir.exists(fileName) )
335 t_dir.mkdir ( fileName ); 343 t_dir.mkdir ( fileName );
336 fileName += "/todo"; 344 fileName += "/todo";
337 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 345 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
338 if ( fileName.length() == 0 ) 346 if ( fileName.length() == 0 )
339 return; 347 return;
340 CalendarLocal cal; 348 CalendarLocal cal;
341 ICalFormat format; 349 ICalFormat format;
342 if ( !format.load( &cal, fileName ) ) { 350 if ( !format.load( &cal, fileName ) ) {
343 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 351 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
344 .arg( fileName ) ); 352 .arg( fileName ) );
345 return ; 353 return ;
346 } 354 }
347 QPtrList<Todo> todos = cal.todos(); 355 QPtrList<Todo> todos = cal.todos();
348 Todo * todo = todos.first(); 356 Todo * todo = todos.first();
349 if ( !todo ) { 357 if ( !todo ) {
350 KMessageBox::error( this, 358 KMessageBox::error( this,
351 i18n("Template does not\ncontain a valid Todo.")); 359 i18n("Template does not\ncontain a valid Todo."));
352 } else { 360 } else {
353 readTodo( todo ); 361 readTodo( todo );
354 } 362 }
355 363
356} 364}
357 365
358void KOTodoEditor::slotSaveTemplate() 366void KOTodoEditor::slotSaveTemplate()
359{ 367{
360 QString fileName =locateLocal( "templates", "todos" ); 368 QString fileName =locateLocal( "templates", "todos" );
361 QDir t_dir; 369 QDir t_dir;
362 if ( !t_dir.exists(fileName) ) 370 if ( !t_dir.exists(fileName) )
363 t_dir.mkdir ( fileName ); 371 t_dir.mkdir ( fileName );
364 fileName += "/todo"; 372 fileName += "/todo";
365 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 373 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
366 if ( fileName.length() > 0 ) 374 if ( fileName.length() > 0 )
367 saveTemplate( fileName ); 375 saveTemplate( fileName );
368} 376}
369 377
370void KOTodoEditor::saveTemplate( const QString &templateName ) 378void KOTodoEditor::saveTemplate( const QString &templateName )
371{ 379{
372 Todo *todo = new Todo; 380 Todo *todo = new Todo;
373 writeTodo( todo ); 381 writeTodo( todo );
374 saveAsTemplate( todo, templateName ); 382 saveAsTemplate( todo, templateName );
375} 383}