summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-05 05:29:02 (UTC)
committer zautrix <zautrix>2005-07-05 05:29:02 (UTC)
commit5992ea9025ebddde8be72322c90aac8edeaf4d1c (patch) (unidiff)
treef0d9385d80fe74af453aa23fd69715d66aeaee12
parent671d832454c8b68e0bb44e439f28fb1c768e033d (diff)
downloadkdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.zip
kdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.tar.gz
kdepimpi-5992ea9025ebddde8be72322c90aac8edeaf4d1c.tar.bz2
rf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp6
-rw-r--r--korganizer/koagendaitem.cpp11
-rw-r--r--korganizer/koagendaitem.h1
3 files changed, 15 insertions, 3 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 01cef35..0280c74 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1157,1026 +1157,1028 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1157 // Look for unused sub cell and insert item 1157 // Look for unused sub cell and insert item
1158 int i; 1158 int i;
1159 for(i=0;i<maxSubCells;++i) { 1159 for(i=0;i<maxSubCells;++i) {
1160 if (!subCellDict.find(i)) { 1160 if (!subCellDict.find(i)) {
1161 placeItem->setSubCell(i); 1161 placeItem->setSubCell(i);
1162 break; 1162 break;
1163 } 1163 }
1164 } 1164 }
1165 if (i == maxSubCells) { 1165 if (i == maxSubCells) {
1166 placeItem->setSubCell(maxSubCells); 1166 placeItem->setSubCell(maxSubCells);
1167 maxSubCells++; // add new item to number of sub cells 1167 maxSubCells++; // add new item to number of sub cells
1168 } 1168 }
1169 1169
1170 // Prepare for sub cell geometry adjustment 1170 // Prepare for sub cell geometry adjustment
1171 int newSubCellWidth; 1171 int newSubCellWidth;
1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1172 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1173 else newSubCellWidth = mGridSpacingX / maxSubCells; 1173 else newSubCellWidth = mGridSpacingX / maxSubCells;
1174 conflictItems.append(placeItem); 1174 conflictItems.append(placeItem);
1175 1175
1176 1176
1177 // Adjust sub cell geometry of all direct conflict items 1177 // Adjust sub cell geometry of all direct conflict items
1178 for ( item=conflictItems.first(); item != 0; 1178 for ( item=conflictItems.first(); item != 0;
1179 item=conflictItems.next() ) { 1179 item=conflictItems.next() ) {
1180 item->setSubCells(maxSubCells); 1180 item->setSubCells(maxSubCells);
1181 if (mAllDayMode) { 1181 if (mAllDayMode) {
1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1182 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1183 } else { 1183 } else {
1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1184 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1185 } 1185 }
1186 int x,y; 1186 int x,y;
1187 gridToContents(item->cellX(),item->cellYTop(),x,y); 1187 gridToContents(item->cellX(),item->cellYTop(),x,y);
1188 if (mAllDayMode) { 1188 if (mAllDayMode) {
1189 y += item->subCell() * newSubCellWidth; 1189 y += item->subCell() * newSubCellWidth;
1190 } else { 1190 } else {
1191 x += item->subCell() * newSubCellWidth; 1191 x += item->subCell() * newSubCellWidth;
1192 } 1192 }
1193 moveChild(item,x,y); 1193 moveChild(item,x,y);
1194 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1194 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1195 //item->updateItem(); 1195 //item->updateItem();
1196 } 1196 }
1197 // Adjust sub cell geometry of all conflict items of all conflict items 1197 // Adjust sub cell geometry of all conflict items of all conflict items
1198 for ( item=conflictItems.first(); item != 0; 1198 for ( item=conflictItems.first(); item != 0;
1199 item=conflictItems.next() ) { 1199 item=conflictItems.next() ) {
1200 if ( placeItem != item ) { 1200 if ( placeItem != item ) {
1201 KOAgendaItem *item2; 1201 KOAgendaItem *item2;
1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1203 for ( item2=conflictItems2.first(); item2 != 0; 1203 for ( item2=conflictItems2.first(); item2 != 0;
1204 item2=conflictItems2.next() ) { 1204 item2=conflictItems2.next() ) {
1205 if ( item2->subCells() != maxSubCells) { 1205 if ( item2->subCells() != maxSubCells) {
1206 item2->setSubCells(maxSubCells); 1206 item2->setSubCells(maxSubCells);
1207 if (mAllDayMode) { 1207 if (mAllDayMode) {
1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1209 } else { 1209 } else {
1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1211 } 1211 }
1212 int x,y; 1212 int x,y;
1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1214 if (mAllDayMode) { 1214 if (mAllDayMode) {
1215 y += item2->subCell() * newSubCellWidth; 1215 y += item2->subCell() * newSubCellWidth;
1216 } else { 1216 } else {
1217 x += item2->subCell() * newSubCellWidth; 1217 x += item2->subCell() * newSubCellWidth;
1218 } 1218 }
1219 moveChild(item2,x,y); 1219 moveChild(item2,x,y);
1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1221 } 1221 }
1222 } 1222 }
1223 } 1223 }
1224 } 1224 }
1225 } else { 1225 } else {
1226 placeItem->setSubCell(0); 1226 placeItem->setSubCell(0);
1227 placeItem->setSubCells(1); 1227 placeItem->setSubCells(1);
1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1229 else placeItem->resize(mGridSpacingX,placeItem->height()); 1229 else placeItem->resize(mGridSpacingX,placeItem->height());
1230 int x,y; 1230 int x,y;
1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1232 moveChild(placeItem,x,y); 1232 moveChild(placeItem,x,y);
1233 } 1233 }
1234 placeItem->setConflictItems(conflictItems); 1234 placeItem->setConflictItems(conflictItems);
1235 // for ( item=conflictItems.first(); item != 0; 1235 // for ( item=conflictItems.first(); item != 0;
1236// item=conflictItems.next() ) { 1236// item=conflictItems.next() ) {
1237// //item->updateItem(); 1237// //item->updateItem();
1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1239// } 1239// }
1240// placeItem->updateItem(); 1240// placeItem->updateItem();
1241} 1241}
1242 1242
1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1244{ 1244{
1245 if ( globalFlagBlockAgenda ) 1245 if ( globalFlagBlockAgenda )
1246 return; 1246 return;
1247 if ( ! mAllDayMode ) { 1247 if ( ! mAllDayMode ) {
1248 // currently not working for 1248 // currently not working for
1249 1249
1250 //qDebug("KOAgenda::drawContents "); 1250 //qDebug("KOAgenda::drawContents ");
1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1252 ;//drawContentsToPainter(); 1252 ;//drawContentsToPainter();
1253 1253
1254 QPaintDevice* pd = p->device(); 1254 QPaintDevice* pd = p->device();
1255 p->end(); 1255 p->end();
1256 int vx, vy; 1256 int vx, vy;
1257 int selectionX = KOGlobals::self()->reverseLayout() ? 1257 int selectionX = KOGlobals::self()->reverseLayout() ?
1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1259 mSelectionCellX * mGridSpacingX; 1259 mSelectionCellX * mGridSpacingX;
1260 contentsToViewport ( cx, cy, vx,vy); 1260 contentsToViewport ( cx, cy, vx,vy);
1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1262 1262
1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1266 1266
1267 int vxSel, vySel; 1267 int vxSel, vySel;
1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1269 int off = mSelectionHeight; 1269 int off = mSelectionHeight;
1270 if ( vySel < 0 ) 1270 if ( vySel < 0 )
1271 off += vySel; 1271 off += vySel;
1272 //qDebug("OFF %d %d %d", off,vySel, vy ); 1272 //qDebug("OFF %d %d %d", off,vySel, vy );
1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1274 } else { 1274 } else {
1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1276 } 1276 }
1277 } 1277 }
1278 if ( mSelectionHeight > 0 ) { 1278 if ( mSelectionHeight > 0 ) {
1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1283 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1283 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1284 int hei = mSelectionHeight; 1284 int hei = mSelectionHeight;
1285 int offset = 0; 1285 int offset = 0;
1286 while ( hei > 0 ) { 1286 while ( hei > 0 ) {
1287 int p_hei = 5; 1287 int p_hei = 5;
1288 if ( hei < 5 ) p_hei = hei; 1288 if ( hei < 5 ) p_hei = hei;
1289 hei -= 5; 1289 hei -= 5;
1290 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1290 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1291 offset += 5; 1291 offset += 5;
1292 } 1292 }
1293 } 1293 }
1294 } 1294 }
1295 p->begin( pd ); 1295 p->begin( pd );
1296 } else { 1296 } else {
1297 1297
1298 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1298 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1299 ;//drawContentsToPainter(); 1299 ;//drawContentsToPainter();
1300 1300
1301 QPaintDevice* pd = p->device(); 1301 QPaintDevice* pd = p->device();
1302 p->end(); 1302 p->end();
1303 int vx, vy; 1303 int vx, vy;
1304 int selectionX = KOGlobals::self()->reverseLayout() ? 1304 int selectionX = KOGlobals::self()->reverseLayout() ?
1305 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1305 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1306 mSelectionCellX * mGridSpacingX; 1306 mSelectionCellX * mGridSpacingX;
1307 contentsToViewport ( cx, cy, vx,vy); 1307 contentsToViewport ( cx, cy, vx,vy);
1308 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1308 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1309 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1309 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1310 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1310 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1311 1311
1312 if ( mSelectionHeight > 0 ) { 1312 if ( mSelectionHeight > 0 ) {
1313 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1313 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1314 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1314 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1315 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1315 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1316 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1316 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1317 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1317 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1318 int hei = mSelectionHeight; 1318 int hei = mSelectionHeight;
1319 int offset = 0; 1319 int offset = 0;
1320 while ( hei > 0 ) { 1320 while ( hei > 0 ) {
1321 int p_hei = 5; 1321 int p_hei = 5;
1322 if ( hei < 5 ) p_hei = hei; 1322 if ( hei < 5 ) p_hei = hei;
1323 hei -= 5; 1323 hei -= 5;
1324 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1324 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1325 offset += 5; 1325 offset += 5;
1326 } 1326 }
1327 } 1327 }
1328 } 1328 }
1329 p->begin( pd ); 1329 p->begin( pd );
1330 } 1330 }
1331 1331
1332} 1332}
1333 1333
1334void KOAgenda::finishUpdate() 1334void KOAgenda::finishUpdate()
1335{ 1335{
1336 1336
1337 KOAgendaItem *item; 1337 KOAgendaItem *item;
1338 globalFlagBlockAgendaItemPaint = 1; 1338 globalFlagBlockAgendaItemPaint = 1;
1339 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1339 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1340 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1340 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1341 if ( !item->checkLayout() ) { 1341 if ( !item->checkLayout() ) {
1342 //qDebug(" conflictitem found "); 1342 //qDebug(" conflictitem found ");
1343 int newSubCellWidth; 1343 int newSubCellWidth;
1344 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1344 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1345 else newSubCellWidth = mGridSpacingX / item->subCells(); 1345 else newSubCellWidth = mGridSpacingX / item->subCells();
1346 1346
1347 if (mAllDayMode) { 1347 if (mAllDayMode) {
1348 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1348 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1349 } else { 1349 } else {
1350 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1350 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1351 } 1351 }
1352 int x,y; 1352 int x,y;
1353 gridToContents(item->cellX(),item->cellYTop(),x,y); 1353 gridToContents(item->cellX(),item->cellYTop(),x,y);
1354 if (mAllDayMode) { 1354 if (mAllDayMode) {
1355 y += item->subCell() * newSubCellWidth; 1355 y += item->subCell() * newSubCellWidth;
1356 } else { 1356 } else {
1357 x += item->subCell() * newSubCellWidth; 1357 x += item->subCell() * newSubCellWidth;
1358 } 1358 }
1359 moveChild(item,x,y); 1359 moveChild(item,x,y);
1360 } 1360 }
1361 } 1361 }
1362 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1362 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1363 if ( !item->isVisible() ) 1363 if ( !item->isVisible() )
1364 item->show(); 1364 item->show();
1365 1365
1366 } 1366 }
1367 globalFlagBlockAgendaItemUpdate = 0; 1367 globalFlagBlockAgendaItemUpdate = 0;
1368 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1368 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1369 item->repaintMe( ); 1369 item->repaintMe( );
1370 } 1370 }
1371 globalFlagBlockAgendaItemUpdate = 1; 1371 globalFlagBlockAgendaItemUpdate = 1;
1372 qApp->processEvents(); 1372 qApp->processEvents();
1373 globalFlagBlockAgendaItemPaint = 0; 1373 globalFlagBlockAgendaItemPaint = 0;
1374 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1374 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1375 item->repaint( false ); 1375 item->repaint( false );
1376 } 1376 }
1377 1377
1378} 1378}
1379 1379
1380/* 1380/*
1381 Draw grid in the background of the agenda. 1381 Draw grid in the background of the agenda.
1382*/ 1382*/
1383void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1383void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1384{ 1384{
1385 1385
1386 1386
1387 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1387 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1388 return; 1388 return;
1389 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1389 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1390 return; 1390 return;
1391 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1391 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1392 if ( ch < 1 ) 1392 if ( ch < 1 )
1393 ch = 1; 1393 ch = 1;
1394 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1394 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1395 mPaintPixmap.resize( contentsWidth()+42, ch ); 1395 mPaintPixmap.resize( contentsWidth()+42, ch );
1396 } 1396 }
1397 mCurPixWid = contentsWidth(); 1397 mCurPixWid = contentsWidth();
1398 mCurPixHei = ch; 1398 mCurPixHei = ch;
1399 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1399 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1400 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1400 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1401 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1401 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1402 } 1402 }
1403 mPixPainter.begin( &mPaintPixmap) ; 1403 mPixPainter.begin( &mPaintPixmap) ;
1404 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1404 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1405 QPainter * p ; 1405 QPainter * p ;
1406 if (paint == 0) { 1406 if (paint == 0) {
1407 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1407 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1408 p = &mPixPainter; 1408 p = &mPixPainter;
1409 } 1409 }
1410 else 1410 else
1411 p = paint ; 1411 p = paint ;
1412 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1412 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1413 1413
1414 //--cx;++cw; 1414 //--cx;++cw;
1415 int lGridSpacingY = mGridSpacingY*2; 1415 int lGridSpacingY = mGridSpacingY*2;
1416 int selDay; 1416 int selDay;
1417 QDate curDate = QDate::currentDate(); 1417 QDate curDate = QDate::currentDate();
1418 if ( !backgroundOnly ) { 1418 if ( !backgroundOnly ) {
1419 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1419 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1420 { 1420 {
1421 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1421 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1422 int x1 = cx; 1422 int x1 = cx;
1423 int y1 = 0; 1423 int y1 = 0;
1424 if (y1 < cy) y1 = cy; 1424 if (y1 < cy) y1 = cy;
1425 int x2 = cx+cw-1; 1425 int x2 = cx+cw-1;
1426 int y2 = contentsHeight(); 1426 int y2 = contentsHeight();
1427 if (y2 > cy+ch-1) y2=cy+ch-1; 1427 if (y2 > cy+ch-1) y2=cy+ch-1;
1428 if (x2 >= x1 && y2 >= y1) { 1428 if (x2 >= x1 && y2 >= y1) {
1429 int gxStart = selDay; 1429 int gxStart = selDay;
1430 int gxEnd = gxStart ; 1430 int gxEnd = gxStart ;
1431 int xStart = KOGlobals::self()->reverseLayout() ? 1431 int xStart = KOGlobals::self()->reverseLayout() ?
1432 (mColumns - 1 - gxStart)*mGridSpacingX : 1432 (mColumns - 1 - gxStart)*mGridSpacingX :
1433 gxStart*mGridSpacingX; 1433 gxStart*mGridSpacingX;
1434 if (xStart < x1) xStart = x1; 1434 if (xStart < x1) xStart = x1;
1435 int xEnd = KOGlobals::self()->reverseLayout() ? 1435 int xEnd = KOGlobals::self()->reverseLayout() ?
1436 (mColumns - gxStart)*mGridSpacingX-1 : 1436 (mColumns - gxStart)*mGridSpacingX-1 :
1437 (gxStart+1)*mGridSpacingX-1; 1437 (gxStart+1)*mGridSpacingX-1;
1438 if (xEnd > x2) xEnd = x2; 1438 if (xEnd > x2) xEnd = x2;
1439 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1439 if ( KOPrefs::instance()->mUseHighlightLightColor )
1440 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1440 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1441 KOPrefs::instance()->mAgendaBgColor.light()); 1441 KOPrefs::instance()->mAgendaBgColor.light());
1442 else 1442 else
1443 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1443 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1444 KOPrefs::instance()->mAgendaBgColor.dark()); 1444 KOPrefs::instance()->mAgendaBgColor.dark());
1445 1445
1446 } 1446 }
1447 } 1447 }
1448 } 1448 }
1449 } 1449 }
1450 // Highlight working hours 1450 // Highlight working hours
1451 1451
1452 if ( !backgroundOnly ) 1452 if ( !backgroundOnly )
1453 if (mWorkingHoursEnable) { 1453 if (mWorkingHoursEnable) {
1454 int x1 = cx; 1454 int x1 = cx;
1455 int y1 = mWorkingHoursYTop; 1455 int y1 = mWorkingHoursYTop;
1456 if (y1 < cy) y1 = cy; 1456 if (y1 < cy) y1 = cy;
1457 int x2 = cx+cw-1; 1457 int x2 = cx+cw-1;
1458 // int x2 = mGridSpacingX * 5 - 1; 1458 // int x2 = mGridSpacingX * 5 - 1;
1459 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1459 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1460 int y2 = mWorkingHoursYBottom; 1460 int y2 = mWorkingHoursYBottom;
1461 if (y2 > cy+ch-1) y2=cy+ch-1; 1461 if (y2 > cy+ch-1) y2=cy+ch-1;
1462 1462
1463 if (x2 >= x1 && y2 >= y1) { 1463 if (x2 >= x1 && y2 >= y1) {
1464 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1464 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1465 int gxStart = x1/mGridSpacingX; 1465 int gxStart = x1/mGridSpacingX;
1466 int gxEnd = x2/mGridSpacingX; 1466 int gxEnd = x2/mGridSpacingX;
1467 while(gxStart <= gxEnd) { 1467 while(gxStart <= gxEnd) {
1468 if (gxStart < int(mHolidayMask->count()) && 1468 if (gxStart < int(mHolidayMask->count()) &&
1469 !mHolidayMask->at(gxStart)) { 1469 !mHolidayMask->at(gxStart)) {
1470 int xStart = KOGlobals::self()->reverseLayout() ? 1470 int xStart = KOGlobals::self()->reverseLayout() ?
1471 (mColumns - 1 - gxStart)*mGridSpacingX : 1471 (mColumns - 1 - gxStart)*mGridSpacingX :
1472 gxStart*mGridSpacingX; 1472 gxStart*mGridSpacingX;
1473 if (xStart < x1) xStart = x1; 1473 if (xStart < x1) xStart = x1;
1474 int xEnd = KOGlobals::self()->reverseLayout() ? 1474 int xEnd = KOGlobals::self()->reverseLayout() ?
1475 (mColumns - gxStart)*mGridSpacingX-1 : 1475 (mColumns - gxStart)*mGridSpacingX-1 :
1476 (gxStart+1)*mGridSpacingX-1; 1476 (gxStart+1)*mGridSpacingX-1;
1477 if (xEnd > x2) xEnd = x2; 1477 if (xEnd > x2) xEnd = x2;
1478 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { 1478 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
1479 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1479 if ( KOPrefs::instance()->mUseHighlightLightColor )
1480 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1480 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1481 KOPrefs::instance()->mWorkingHoursColor.light()); 1481 KOPrefs::instance()->mWorkingHoursColor.light());
1482 else 1482 else
1483 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1483 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1484 KOPrefs::instance()->mWorkingHoursColor.dark()); 1484 KOPrefs::instance()->mWorkingHoursColor.dark());
1485 } else { 1485 } else {
1486 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1486 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1487 KOPrefs::instance()->mWorkingHoursColor); 1487 KOPrefs::instance()->mWorkingHoursColor);
1488 } 1488 }
1489 } 1489 }
1490 ++gxStart; 1490 ++gxStart;
1491 } 1491 }
1492 } 1492 }
1493 } 1493 }
1494 /* 1494 /*
1495 int selectionX = KOGlobals::self()->reverseLayout() ? 1495 int selectionX = KOGlobals::self()->reverseLayout() ?
1496 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1496 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1497 mSelectionCellX * mGridSpacingX; 1497 mSelectionCellX * mGridSpacingX;
1498 1498
1499 // Draw selection 1499 // Draw selection
1500 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1500 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1501 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1501 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1502 // TODO: paint only part within cx,cy,cw,ch 1502 // TODO: paint only part within cx,cy,cw,ch
1503 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1503 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1504 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1504 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1505 } 1505 }
1506 */ 1506 */
1507 // Draw vertical lines of grid 1507 // Draw vertical lines of grid
1508 1508
1509 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1509 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1510 if ( mGridSpacingX > 0 ) { 1510 if ( mGridSpacingX > 0 ) {
1511 while (x < cx + cw) { 1511 while (x < cx + cw) {
1512 p->drawLine(x,cy,x,cy+ch); 1512 p->drawLine(x,cy,x,cy+ch);
1513 x+=mGridSpacingX; 1513 x+=mGridSpacingX;
1514 } 1514 }
1515 } 1515 }
1516 // Draw horizontal lines of grid 1516 // Draw horizontal lines of grid
1517 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1517 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1518 if ( lGridSpacingY > 0 ) { 1518 if ( lGridSpacingY > 0 ) {
1519 while (y < cy + ch) { 1519 while (y < cy + ch) {
1520 p->setPen( SolidLine ); 1520 p->setPen( SolidLine );
1521 p->drawLine(cx,y,cx+cw,y); 1521 p->drawLine(cx,y,cx+cw,y);
1522 y+=lGridSpacingY; 1522 y+=lGridSpacingY;
1523 p->setPen( DotLine ); 1523 p->setPen( DotLine );
1524 p->drawLine(cx,y,cx+cw,y); 1524 p->drawLine(cx,y,cx+cw,y);
1525 y+=lGridSpacingY; 1525 y+=lGridSpacingY;
1526 } 1526 }
1527 p->setPen( SolidLine ); 1527 p->setPen( SolidLine );
1528 } 1528 }
1529 mPixPainter.end() ; 1529 mPixPainter.end() ;
1530} 1530}
1531 1531
1532/* 1532/*
1533 Convert srcollview contents coordinates to agenda grid coordinates. 1533 Convert srcollview contents coordinates to agenda grid coordinates.
1534*/ 1534*/
1535void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1535void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1536{ 1536{
1537 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1537 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1538 x/mGridSpacingX; 1538 x/mGridSpacingX;
1539 gy = y/mGridSpacingY; 1539 gy = y/mGridSpacingY;
1540} 1540}
1541 1541
1542/* 1542/*
1543 Convert agenda grid coordinates to scrollview contents coordinates. 1543 Convert agenda grid coordinates to scrollview contents coordinates.
1544*/ 1544*/
1545void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1545void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1546{ 1546{
1547 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1547 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1548 gx*mGridSpacingX; 1548 gx*mGridSpacingX;
1549 y = gy*mGridSpacingY; 1549 y = gy*mGridSpacingY;
1550} 1550}
1551 1551
1552 1552
1553/* 1553/*
1554 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1554 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1555 the grid. 1555 the grid.
1556*/ 1556*/
1557int KOAgenda::timeToY(const QTime &time) 1557int KOAgenda::timeToY(const QTime &time)
1558{ 1558{
1559 int minutesPerCell = 24 * 60 / mRows; 1559 int minutesPerCell = 24 * 60 / mRows;
1560 int timeMinutes = time.hour() * 60 + time.minute(); 1560 int timeMinutes = time.hour() * 60 + time.minute();
1561 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1561 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1562 return Y; 1562 return Y;
1563} 1563}
1564 1564
1565 1565
1566/* 1566/*
1567 Return time corresponding to cell y coordinate. Coordinates are rounded to 1567 Return time corresponding to cell y coordinate. Coordinates are rounded to
1568 fit into the grid. 1568 fit into the grid.
1569*/ 1569*/
1570QTime KOAgenda::gyToTime(int gy) 1570QTime KOAgenda::gyToTime(int gy)
1571{ 1571{
1572 1572
1573 int secondsPerCell = 24 * 60 * 60/ mRows; 1573 int secondsPerCell = 24 * 60 * 60/ mRows;
1574 1574
1575 int timeSeconds = secondsPerCell * gy; 1575 int timeSeconds = secondsPerCell * gy;
1576 1576
1577 QTime time( 0, 0, 0 ); 1577 QTime time( 0, 0, 0 );
1578 if ( timeSeconds < 24 * 60 * 60 ) { 1578 if ( timeSeconds < 24 * 60 * 60 ) {
1579 time = time.addSecs(timeSeconds); 1579 time = time.addSecs(timeSeconds);
1580 } else { 1580 } else {
1581 time.setHMS( 23, 59, 59 ); 1581 time.setHMS( 23, 59, 59 );
1582 } 1582 }
1583 1583
1584 return time; 1584 return time;
1585} 1585}
1586 1586
1587void KOAgenda::setStartHour(int startHour) 1587void KOAgenda::setStartHour(int startHour)
1588{ 1588{
1589 int startCell = startHour * mRows / 24; 1589 int startCell = startHour * mRows / 24;
1590 setContentsPos(0,startCell * gridSpacingY()); 1590 setContentsPos(0,startCell * gridSpacingY());
1591} 1591}
1592void KOAgenda::hideUnused() 1592void KOAgenda::hideUnused()
1593{ 1593{
1594 // experimental only 1594 // experimental only
1595 // return; 1595 // return;
1596 KOAgendaItem *item; 1596 KOAgendaItem *item;
1597 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1597 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1598 item->hide(); 1598 item->hide();
1599 } 1599 }
1600} 1600}
1601 1601
1602 1602
1603KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1603KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1604{ 1604{
1605 1605
1606 KOAgendaItem *fi; 1606 KOAgendaItem *fi;
1607 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1607 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1608 if ( fi->incidence() == event ) { 1608 if ( fi->incidence() == event ) {
1609 mUnusedItems.remove(); 1609 mUnusedItems.remove();
1610 fi->init( event, qd ); 1610 fi->init( event, qd );
1611 return fi; 1611 return fi;
1612 } 1612 }
1613 } 1613 }
1614 fi=mUnusedItems.first(); 1614 fi=mUnusedItems.first();
1615 if ( fi ) { 1615 if ( fi ) {
1616 mUnusedItems.remove(); 1616 mUnusedItems.remove();
1617 fi->init( event, qd ); 1617 fi->init( event, qd );
1618 return fi; 1618 return fi;
1619 } 1619 }
1620 // qDebug("new KOAgendaItem "); 1620 // qDebug("new KOAgendaItem ");
1621 1621
1622 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1622 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1623 agendaItem->installEventFilter(this); 1623 agendaItem->installEventFilter(this);
1624 addChild(agendaItem,0,0); 1624 addChild(agendaItem,0,0);
1625 return agendaItem; 1625 return agendaItem;
1626} 1626}
1627KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1627KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1628{ 1628{
1629 KOAgendaItem *item; 1629 KOAgendaItem *item;
1630 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1630 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1631 if ( item->incidence() == todo ) { 1631 if ( item->incidence() == todo ) {
1632 mItems.remove(); 1632 mItems.remove();
1633 return item; 1633 return item;
1634 } 1634 }
1635 } 1635 }
1636 return 0; 1636 return 0;
1637} 1637}
1638 1638
1639 1639
1640void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1640void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1641{ 1641{
1642 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1642 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1643 KOAgendaItem *item; 1643 KOAgendaItem *item;
1644 item = getItemForTodo ( todo ); 1644 item = getItemForTodo ( todo );
1645 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1645 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1646 if ( item ) { 1646 if ( item ) {
1647 blockSignals( true ); 1647 blockSignals( true );
1648 //qDebug("item found "); 1648 //qDebug("item found ");
1649 item->hide(); 1649 item->hide();
1650 item->setCellX(-2, -1 ); 1650 item->setCellX(-2, -1 );
1651 item->select(false); 1651 item->select(false);
1652 mUnusedItems.append( item ); 1652 mUnusedItems.append( item );
1653 mItems.remove( item ); 1653 mItems.remove( item );
1654 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1654 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1655 KOAgendaItem *itemit; 1655 KOAgendaItem *itemit;
1656 //globalFlagBlockAgendaItemPaint = 1; 1656 //globalFlagBlockAgendaItemPaint = 1;
1657 for ( itemit=oldconflictItems.first(); itemit != 0; 1657 for ( itemit=oldconflictItems.first(); itemit != 0;
1658 itemit=oldconflictItems.next() ) { 1658 itemit=oldconflictItems.next() ) {
1659 if ( itemit != item ) 1659 if ( itemit != item )
1660 placeSubCells(itemit); 1660 placeSubCells(itemit);
1661 } 1661 }
1662 qApp->processEvents(); 1662 qApp->processEvents();
1663 //globalFlagBlockAgendaItemPaint = 0; 1663 //globalFlagBlockAgendaItemPaint = 0;
1664 for ( itemit=oldconflictItems.first(); itemit != 0; 1664 for ( itemit=oldconflictItems.first(); itemit != 0;
1665 itemit=oldconflictItems.next() ) { 1665 itemit=oldconflictItems.next() ) {
1666 globalFlagBlockAgendaItemUpdate = 0; 1666 globalFlagBlockAgendaItemUpdate = 0;
1667 if ( itemit != item ) 1667 if ( itemit != item )
1668 itemit->repaintMe(); 1668 itemit->repaintMe();
1669 globalFlagBlockAgendaItemUpdate = 1; 1669 globalFlagBlockAgendaItemUpdate = 1;
1670 itemit->repaint(); 1670 //qDebug("sigleshot ");
1671 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1672 //itemit->repaint( false ); repaintItem()
1671 } 1673 }
1672 blockSignals( false ); 1674 blockSignals( false );
1673 } 1675 }
1674 if ( remove ) { 1676 if ( remove ) {
1675 //qDebug("remove****************************************** "); 1677 //qDebug("remove****************************************** ");
1676 return; 1678 return;
1677 } 1679 }
1678 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1680 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1679 return; 1681 return;
1680 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1682 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1681 QDate currentDate = QDate::currentDate(); 1683 QDate currentDate = QDate::currentDate();
1682 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1684 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1683 QDateTime dt; 1685 QDateTime dt;
1684 if ( todo->hasCompletedDate() ) 1686 if ( todo->hasCompletedDate() )
1685 dt = todo->completed(); 1687 dt = todo->completed();
1686 else 1688 else
1687 dt = todo->dtDue(); 1689 dt = todo->dtDue();
1688 if ( overdue ) { 1690 if ( overdue ) {
1689 days += todo->dtDue().date().daysTo( currentDate ); 1691 days += todo->dtDue().date().daysTo( currentDate );
1690 } 1692 }
1691 else 1693 else
1692 currentDate = dt.date(); 1694 currentDate = dt.date();
1693 1695
1694 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1696 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1695 if ( ! mAllDayMode ) return; 1697 if ( ! mAllDayMode ) return;
1696 // aldayagenda 1698 // aldayagenda
1697 globalFlagBlockAgendaItemPaint = 1; 1699 globalFlagBlockAgendaItemPaint = 1;
1698 item = insertAllDayItem(todo, currentDate,days, days); 1700 item = insertAllDayItem(todo, currentDate,days, days);
1699 item->show(); 1701 item->show();
1700 1702
1701 } 1703 }
1702 else { 1704 else {
1703 if ( mAllDayMode ) return; 1705 if ( mAllDayMode ) return;
1704 // mAgenda 1706 // mAgenda
1705 globalFlagBlockAgendaItemPaint = 1; 1707 globalFlagBlockAgendaItemPaint = 1;
1706 int endY = timeToY(dt.time()) - 1; 1708 int endY = timeToY(dt.time()) - 1;
1707 int hi = 12/KOPrefs::instance()->mHourSize; 1709 int hi = 12/KOPrefs::instance()->mHourSize;
1708 int startY = endY - 1-hi; 1710 int startY = endY - 1-hi;
1709 item = insertItem(todo,currentDate,days,startY,endY); 1711 item = insertItem(todo,currentDate,days,startY,endY);
1710 item->show(); 1712 item->show();
1711 } 1713 }
1712 qApp->processEvents(); 1714 qApp->processEvents();
1713 globalFlagBlockAgendaItemPaint = 0; 1715 globalFlagBlockAgendaItemPaint = 0;
1714 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1716 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1715 KOAgendaItem *itemit; 1717 KOAgendaItem *itemit;
1716 for ( itemit=oldconflictItems.first(); itemit != 0; 1718 for ( itemit=oldconflictItems.first(); itemit != 0;
1717 itemit=oldconflictItems.next() ) { 1719 itemit=oldconflictItems.next() ) {
1718 globalFlagBlockAgendaItemUpdate = 0; 1720 globalFlagBlockAgendaItemUpdate = 0;
1719 itemit->repaintMe(); 1721 itemit->repaintMe();
1720 globalFlagBlockAgendaItemUpdate = 1; 1722 globalFlagBlockAgendaItemUpdate = 1;
1721 itemit->repaint(); 1723 itemit->repaint();
1722 } 1724 }
1723 globalFlagBlockAgendaItemUpdate = 0; 1725 globalFlagBlockAgendaItemUpdate = 0;
1724 item->repaintMe(); 1726 item->repaintMe();
1725 globalFlagBlockAgendaItemUpdate = 1; 1727 globalFlagBlockAgendaItemUpdate = 1;
1726 item->repaint(); 1728 item->repaint();
1727} 1729}
1728/* 1730/*
1729 Insert KOAgendaItem into agenda. 1731 Insert KOAgendaItem into agenda.
1730*/ 1732*/
1731KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1733KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1732{ 1734{
1733 if (mAllDayMode) { 1735 if (mAllDayMode) {
1734 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1736 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1735 return 0; 1737 return 0;
1736 } 1738 }
1737 1739
1738 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1740 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1739 //agendaItem->setFrameStyle(WinPanel|Raised); 1741 //agendaItem->setFrameStyle(WinPanel|Raised);
1740 1742
1741 int YSize = YBottom - YTop + 1; 1743 int YSize = YBottom - YTop + 1;
1742 if (YSize < 0) { 1744 if (YSize < 0) {
1743 YSize = 1; 1745 YSize = 1;
1744 } 1746 }
1745 int iheight = mGridSpacingY * YSize; 1747 int iheight = mGridSpacingY * YSize;
1746 1748
1747 agendaItem->resize(mGridSpacingX,iheight ); 1749 agendaItem->resize(mGridSpacingX,iheight );
1748 agendaItem->setCellXY(X,YTop,YBottom); 1750 agendaItem->setCellXY(X,YTop,YBottom);
1749 agendaItem->setCellXWidth(X); 1751 agendaItem->setCellXWidth(X);
1750 1752
1751 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1753 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1752 mItems.append(agendaItem); 1754 mItems.append(agendaItem);
1753 1755
1754 placeSubCells(agendaItem); 1756 placeSubCells(agendaItem);
1755 1757
1756 //agendaItem->show(); 1758 //agendaItem->show();
1757 1759
1758 marcus_bains(); 1760 marcus_bains();
1759 1761
1760 return agendaItem; 1762 return agendaItem;
1761} 1763}
1762 1764
1763 1765
1764/* 1766/*
1765 Insert all-day KOAgendaItem into agenda. 1767 Insert all-day KOAgendaItem into agenda.
1766*/ 1768*/
1767KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1769KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1768{ 1770{
1769 if (!mAllDayMode) { 1771 if (!mAllDayMode) {
1770 return 0; 1772 return 0;
1771 } 1773 }
1772 1774
1773 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1775 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1774 1776
1775 agendaItem->setCellXY(XBegin,0,0); 1777 agendaItem->setCellXY(XBegin,0,0);
1776 agendaItem->setCellXWidth(XEnd); 1778 agendaItem->setCellXWidth(XEnd);
1777 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1779 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1778 1780
1779 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1781 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1780 mItems.append(agendaItem); 1782 mItems.append(agendaItem);
1781 1783
1782 placeSubCells(agendaItem); 1784 placeSubCells(agendaItem);
1783 1785
1784 //agendaItem->show(); 1786 //agendaItem->show();
1785 1787
1786 return agendaItem; 1788 return agendaItem;
1787} 1789}
1788 1790
1789 1791
1790void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1792void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1791 int YTop,int YBottom) 1793 int YTop,int YBottom)
1792{ 1794{
1793 if (mAllDayMode) { 1795 if (mAllDayMode) {
1794 ; 1796 ;
1795 return; 1797 return;
1796 } 1798 }
1797 1799
1798 int cellX,cellYTop,cellYBottom; 1800 int cellX,cellYTop,cellYBottom;
1799 QString newtext; 1801 QString newtext;
1800 int width = XEnd - XBegin + 1; 1802 int width = XEnd - XBegin + 1;
1801 int count = 0; 1803 int count = 0;
1802 KOAgendaItem *current = 0; 1804 KOAgendaItem *current = 0;
1803 QPtrList<KOAgendaItem> multiItems; 1805 QPtrList<KOAgendaItem> multiItems;
1804 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1806 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1805 if (cellX == XBegin) cellYTop = YTop; 1807 if (cellX == XBegin) cellYTop = YTop;
1806 else cellYTop = 0; 1808 else cellYTop = 0;
1807 if (cellX == XEnd) cellYBottom = YBottom; 1809 if (cellX == XEnd) cellYBottom = YBottom;
1808 else cellYBottom = rows() - 1; 1810 else cellYBottom = rows() - 1;
1809 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1811 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1810 newtext.append(event->summary()); 1812 newtext.append(event->summary());
1811 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1813 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1812 current->setText(newtext); 1814 current->setText(newtext);
1813 multiItems.append(current); 1815 multiItems.append(current);
1814 } 1816 }
1815 1817
1816 KOAgendaItem *next = 0; 1818 KOAgendaItem *next = 0;
1817 KOAgendaItem *last = multiItems.last(); 1819 KOAgendaItem *last = multiItems.last();
1818 KOAgendaItem *first = multiItems.first(); 1820 KOAgendaItem *first = multiItems.first();
1819 KOAgendaItem *setFirst,*setLast; 1821 KOAgendaItem *setFirst,*setLast;
1820 current = first; 1822 current = first;
1821 while (current) { 1823 while (current) {
1822 next = multiItems.next(); 1824 next = multiItems.next();
1823 if (current == first) setFirst = 0; 1825 if (current == first) setFirst = 0;
1824 else setFirst = first; 1826 else setFirst = first;
1825 if (current == last) setLast = 0; 1827 if (current == last) setLast = 0;
1826 else setLast = last; 1828 else setLast = last;
1827 1829
1828 current->setMultiItem(setFirst,next,setLast); 1830 current->setMultiItem(setFirst,next,setLast);
1829 current = next; 1831 current = next;
1830 } 1832 }
1831 1833
1832 marcus_bains(); 1834 marcus_bains();
1833} 1835}
1834 1836
1835 1837
1836//QSizePolicy KOAgenda::sizePolicy() const 1838//QSizePolicy KOAgenda::sizePolicy() const
1837//{ 1839//{
1838 // Thought this would make the all-day event agenda minimum size and the 1840 // Thought this would make the all-day event agenda minimum size and the
1839 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1841 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1840 // don´t seem to think that an Expanding widget needs more space than a 1842 // don´t seem to think that an Expanding widget needs more space than a
1841 // Preferred one. 1843 // Preferred one.
1842 // But it doesn´t hurt, so it stays. 1844 // But it doesn´t hurt, so it stays.
1843// if (mAllDayMode) { 1845// if (mAllDayMode) {
1844// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1846// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1845// } else { 1847// } else {
1846// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1848// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1847// } 1849// }
1848//} 1850//}
1849void KOAgenda::finishResize ( ) 1851void KOAgenda::finishResize ( )
1850{ 1852{
1851 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1853 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1852 if ( globalFlagBlockAgenda == 0 ) { 1854 if ( globalFlagBlockAgenda == 0 ) {
1853 finishUpdate(); 1855 finishUpdate();
1854 //qDebug("finishUpdate() called "); 1856 //qDebug("finishUpdate() called ");
1855 } 1857 }
1856} 1858}
1857/* 1859/*
1858 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1860 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1859*/ 1861*/
1860void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1862void KOAgenda::resizeEvent ( QResizeEvent *ev )
1861{ 1863{
1862 mSelectionHeight = 0; 1864 mSelectionHeight = 0;
1863 mResizeTimer.start( 150 , true ); 1865 mResizeTimer.start( 150 , true );
1864 computeSizes(); 1866 computeSizes();
1865 return; 1867 return;
1866 1868
1867} 1869}
1868void KOAgenda::computeSizes() 1870void KOAgenda::computeSizes()
1869{ 1871{
1870 if ( globalFlagBlockStartup ) 1872 if ( globalFlagBlockStartup )
1871 return; 1873 return;
1872 int frameOffset = frameWidth() * 2 +1; 1874 int frameOffset = frameWidth() * 2 +1;
1873 if (mAllDayMode) { 1875 if (mAllDayMode) {
1874 mGridSpacingX = (width()-frameOffset) / mColumns; 1876 mGridSpacingX = (width()-frameOffset) / mColumns;
1875 mGridSpacingY = height() - 2 * frameWidth() - 1; 1877 mGridSpacingY = height() - 2 * frameWidth() - 1;
1876 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1878 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1877 // mGridSpacingY = height(); 1879 // mGridSpacingY = height();
1878 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1880 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1879 1881
1880 KOAgendaItem *item; 1882 KOAgendaItem *item;
1881 int subCellWidth; 1883 int subCellWidth;
1882 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1884 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1883 subCellWidth = mGridSpacingY / item->subCells(); 1885 subCellWidth = mGridSpacingY / item->subCells();
1884 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1886 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1885 moveChild(item,KOGlobals::self()->reverseLayout() ? 1887 moveChild(item,KOGlobals::self()->reverseLayout() ?
1886 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1888 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1887 item->cellX() * mGridSpacingX, 1889 item->cellX() * mGridSpacingX,
1888 item->subCell() * subCellWidth); 1890 item->subCell() * subCellWidth);
1889 } 1891 }
1890 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1892 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1891 } else { 1893 } else {
1892 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1894 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1893 if (height() > mGridSpacingY * mRows + 1 ) { 1895 if (height() > mGridSpacingY * mRows + 1 ) {
1894 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1896 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1895 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1897 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1896 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1898 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1897 emit resizedSignal(); 1899 emit resizedSignal();
1898 } else 1900 } else
1899 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1901 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1900 KOAgendaItem *item; 1902 KOAgendaItem *item;
1901 int subCellWidth; 1903 int subCellWidth;
1902 1904
1903 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1905 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1904 subCellWidth = mGridSpacingX / item->subCells(); 1906 subCellWidth = mGridSpacingX / item->subCells();
1905 item->resize(subCellWidth,item->height()); 1907 item->resize(subCellWidth,item->height());
1906 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1908 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1907 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1909 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1908 item->cellX() * mGridSpacingX) + 1910 item->cellX() * mGridSpacingX) +
1909 item->subCell() * subCellWidth,childY(item)); 1911 item->subCell() * subCellWidth,childY(item));
1910 } 1912 }
1911 } 1913 }
1912 int cw = contentsWidth(); 1914 int cw = contentsWidth();
1913 int ch = contentsHeight(); 1915 int ch = contentsHeight();
1914 if ( mAllDayMode ) { 1916 if ( mAllDayMode ) {
1915 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1917 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1916 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1918 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1917 //qDebug("paintPixAll->resize "); 1919 //qDebug("paintPixAll->resize ");
1918 paintPixAll->resize( cw, ch ); 1920 paintPixAll->resize( cw, ch );
1919 } 1921 }
1920 } else { 1922 } else {
1921 QPixmap* paintPix = KOAgendaItem::paintPix(); 1923 QPixmap* paintPix = KOAgendaItem::paintPix();
1922 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1924 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1923 //qDebug("paintPix->resize "); 1925 //qDebug("paintPix->resize ");
1924 paintPix->resize( cw , ch ); 1926 paintPix->resize( cw , ch );
1925 } 1927 }
1926 } 1928 }
1927 1929
1928 checkScrollBoundaries(); 1930 checkScrollBoundaries();
1929 marcus_bains(); 1931 marcus_bains();
1930 drawContentsToPainter(); 1932 drawContentsToPainter();
1931 viewport()->repaint(false); 1933 viewport()->repaint(false);
1932} 1934}
1933 1935
1934void KOAgenda::scrollUp() 1936void KOAgenda::scrollUp()
1935{ 1937{
1936 scrollBy(0,-mScrollOffset); 1938 scrollBy(0,-mScrollOffset);
1937} 1939}
1938 1940
1939 1941
1940void KOAgenda::scrollDown() 1942void KOAgenda::scrollDown()
1941{ 1943{
1942 scrollBy(0,mScrollOffset); 1944 scrollBy(0,mScrollOffset);
1943} 1945}
1944 1946
1945void KOAgenda::popupAlarm() 1947void KOAgenda::popupAlarm()
1946{ 1948{
1947 if (!mClickedItem) { 1949 if (!mClickedItem) {
1948 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1950 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1949 return; 1951 return;
1950 } 1952 }
1951 // TODO: deal correctly with multiple alarms 1953 // TODO: deal correctly with multiple alarms
1952 Alarm* alarm; 1954 Alarm* alarm;
1953 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1955 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1954 for(alarm=list.first();alarm;alarm=list.next()) { 1956 for(alarm=list.first();alarm;alarm=list.next()) {
1955 alarm->toggleAlarm(); 1957 alarm->toggleAlarm();
1956 } 1958 }
1957 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1959 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1958 mClickedItem->paintMe( true ); 1960 mClickedItem->paintMe( true );
1959 mClickedItem->repaint( false ); 1961 mClickedItem->repaint( false );
1960} 1962}
1961 1963
1962/* 1964/*
1963 Calculates the minimum width 1965 Calculates the minimum width
1964*/ 1966*/
1965int KOAgenda::minimumWidth() const 1967int KOAgenda::minimumWidth() const
1966{ 1968{
1967 // TODO:: develop a way to dynamically determine the minimum width 1969 // TODO:: develop a way to dynamically determine the minimum width
1968 int min = 100; 1970 int min = 100;
1969 1971
1970 return min; 1972 return min;
1971} 1973}
1972 1974
1973void KOAgenda::updateConfig() 1975void KOAgenda::updateConfig()
1974{ 1976{
1975 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1977 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1976 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1978 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1977 if ( mAllDayMode ) { 1979 if ( mAllDayMode ) {
1978 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1980 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1979 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1981 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1980 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1982 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1981 // setMaximumHeight( mGridSpacingY+1 ); 1983 // setMaximumHeight( mGridSpacingY+1 );
1982 viewport()->repaint( false ); 1984 viewport()->repaint( false );
1983 //setFixedHeight( mGridSpacingY+1 ); 1985 //setFixedHeight( mGridSpacingY+1 );
1984 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1986 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1985 } 1987 }
1986 else { 1988 else {
1987 mGridSpacingY = KOPrefs::instance()->mHourSize; 1989 mGridSpacingY = KOPrefs::instance()->mHourSize;
1988 calculateWorkingHours(); 1990 calculateWorkingHours();
1989 marcus_bains(); 1991 marcus_bains();
1990 } 1992 }
1991} 1993}
1992 1994
1993void KOAgenda::checkScrollBoundaries() 1995void KOAgenda::checkScrollBoundaries()
1994{ 1996{
1995 // Invalidate old values to force update 1997 // Invalidate old values to force update
1996 mOldLowerScrollValue = -1; 1998 mOldLowerScrollValue = -1;
1997 mOldUpperScrollValue = -1; 1999 mOldUpperScrollValue = -1;
1998 2000
1999 checkScrollBoundaries(verticalScrollBar()->value()); 2001 checkScrollBoundaries(verticalScrollBar()->value());
2000} 2002}
2001 2003
2002void KOAgenda::checkScrollBoundaries(int v) 2004void KOAgenda::checkScrollBoundaries(int v)
2003{ 2005{
2004 if ( mGridSpacingY == 0 ) 2006 if ( mGridSpacingY == 0 )
2005 return; 2007 return;
2006 int yMin = v/mGridSpacingY; 2008 int yMin = v/mGridSpacingY;
2007 int yMax = (v+visibleHeight())/mGridSpacingY; 2009 int yMax = (v+visibleHeight())/mGridSpacingY;
2008 2010
2009// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2011// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2010 2012
2011 if (yMin != mOldLowerScrollValue) { 2013 if (yMin != mOldLowerScrollValue) {
2012 mOldLowerScrollValue = yMin; 2014 mOldLowerScrollValue = yMin;
2013 emit lowerYChanged(yMin); 2015 emit lowerYChanged(yMin);
2014 } 2016 }
2015 if (yMax != mOldUpperScrollValue) { 2017 if (yMax != mOldUpperScrollValue) {
2016 mOldUpperScrollValue = yMax; 2018 mOldUpperScrollValue = yMax;
2017 emit upperYChanged(yMax); 2019 emit upperYChanged(yMax);
2018 } 2020 }
2019} 2021}
2020 2022
2021void KOAgenda::deselectItem() 2023void KOAgenda::deselectItem()
2022{ 2024{
2023 if (mSelectedItem.isNull()) return; 2025 if (mSelectedItem.isNull()) return;
2024 mSelectedItem->select(false); 2026 mSelectedItem->select(false);
2025 mSelectedItem = 0; 2027 mSelectedItem = 0;
2026} 2028}
2027 2029
2028void KOAgenda::selectItem(KOAgendaItem *item) 2030void KOAgenda::selectItem(KOAgendaItem *item)
2029{ 2031{
2030 if ((KOAgendaItem *)mSelectedItem == item) return; 2032 if ((KOAgendaItem *)mSelectedItem == item) return;
2031 deselectItem(); 2033 deselectItem();
2032 if (item == 0) { 2034 if (item == 0) {
2033 emit incidenceSelected( 0 ); 2035 emit incidenceSelected( 0 );
2034 return; 2036 return;
2035 } 2037 }
2036 mSelectedItem = item; 2038 mSelectedItem = item;
2037 mSelectedItem->select(); 2039 mSelectedItem->select();
2038 emit incidenceSelected( mSelectedItem->incidence() ); 2040 emit incidenceSelected( mSelectedItem->incidence() );
2039} 2041}
2040 2042
2041// This function seems never be called. 2043// This function seems never be called.
2042void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2044void KOAgenda::keyPressEvent( QKeyEvent *kev )
2043{ 2045{
2044 switch(kev->key()) { 2046 switch(kev->key()) {
2045 case Key_PageDown: 2047 case Key_PageDown:
2046 verticalScrollBar()->addPage(); 2048 verticalScrollBar()->addPage();
2047 break; 2049 break;
2048 case Key_PageUp: 2050 case Key_PageUp:
2049 verticalScrollBar()->subtractPage(); 2051 verticalScrollBar()->subtractPage();
2050 break; 2052 break;
2051 case Key_Down: 2053 case Key_Down:
2052 verticalScrollBar()->addLine(); 2054 verticalScrollBar()->addLine();
2053 break; 2055 break;
2054 case Key_Up: 2056 case Key_Up:
2055 verticalScrollBar()->subtractLine(); 2057 verticalScrollBar()->subtractLine();
2056 break; 2058 break;
2057 default: 2059 default:
2058 ; 2060 ;
2059 } 2061 }
2060} 2062}
2061 2063
2062void KOAgenda::calculateWorkingHours() 2064void KOAgenda::calculateWorkingHours()
2063{ 2065{
2064// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2066// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2065 mWorkingHoursEnable = !mAllDayMode; 2067 mWorkingHoursEnable = !mAllDayMode;
2066 2068
2067 mWorkingHoursYTop = mGridSpacingY * 2069 mWorkingHoursYTop = mGridSpacingY *
2068 KOPrefs::instance()->mWorkingHoursStart * 4; 2070 KOPrefs::instance()->mWorkingHoursStart * 4;
2069 mWorkingHoursYBottom = mGridSpacingY * 2071 mWorkingHoursYBottom = mGridSpacingY *
2070 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2072 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2071} 2073}
2072 2074
2073 2075
2074DateList KOAgenda::dateList() const 2076DateList KOAgenda::dateList() const
2075{ 2077{
2076 return mSelectedDates; 2078 return mSelectedDates;
2077} 2079}
2078 2080
2079void KOAgenda::setDateList(const DateList &selectedDates) 2081void KOAgenda::setDateList(const DateList &selectedDates)
2080{ 2082{
2081 mSelectedDates = selectedDates; 2083 mSelectedDates = selectedDates;
2082 marcus_bains(); 2084 marcus_bains();
2083} 2085}
2084 2086
2085void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2087void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2086{ 2088{
2087 mHolidayMask = mask; 2089 mHolidayMask = mask;
2088 2090
2089/* 2091/*
2090 kdDebug() << "HolidayMask: "; 2092 kdDebug() << "HolidayMask: ";
2091 for(uint i=0;i<mask->count();++i) { 2093 for(uint i=0;i<mask->count();++i) {
2092 kdDebug() << (mask->at(i) ? "*" : "o"); 2094 kdDebug() << (mask->at(i) ? "*" : "o");
2093 } 2095 }
2094 kdDebug() << endl; 2096 kdDebug() << endl;
2095*/ 2097*/
2096} 2098}
2097 2099
2098void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2100void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2099{ 2101{
2100 2102
2101 QScrollView::contentsMousePressEvent(event); 2103 QScrollView::contentsMousePressEvent(event);
2102} 2104}
2103 2105
2104void KOAgenda::storePosition() 2106void KOAgenda::storePosition()
2105{ 2107{
2106 //mContentPosition 2108 //mContentPosition
2107 int max = mGridSpacingY*4*24; 2109 int max = mGridSpacingY*4*24;
2108 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2110 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2109 mContentPosition = 0; 2111 mContentPosition = 0;
2110 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2112 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2111 mContentPosition = -1.0; 2113 mContentPosition = -1.0;
2112 else 2114 else
2113 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2115 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2114 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2116 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2115 2117
2116} 2118}
2117void KOAgenda::restorePosition() 2119void KOAgenda::restorePosition()
2118{ 2120{
2119 int posY; 2121 int posY;
2120 int max = mGridSpacingY*4*24; 2122 int max = mGridSpacingY*4*24;
2121 if ( mContentPosition < 0 ) 2123 if ( mContentPosition < 0 )
2122 posY = max-viewport()->height(); 2124 posY = max-viewport()->height();
2123 else 2125 else
2124 if ( mContentPosition == 0 ) 2126 if ( mContentPosition == 0 )
2125 posY = 0; 2127 posY = 0;
2126 else 2128 else
2127 posY = (max/mContentPosition)-(viewport()->height()/2); 2129 posY = (max/mContentPosition)-(viewport()->height()/2);
2128 setContentsPos (0, posY ); 2130 setContentsPos (0, posY );
2129 //qDebug("posY %d hei %d", posY, max); 2131 //qDebug("posY %d hei %d", posY, max);
2130 2132
2131} 2133}
2132void KOAgenda::moveChild( QWidget *w, int x , int y ) 2134void KOAgenda::moveChild( QWidget *w, int x , int y )
2133{ 2135{
2134 ++x; 2136 ++x;
2135 QScrollView::moveChild( w, x , y ); 2137 QScrollView::moveChild( w, x , y );
2136} 2138}
2137#include <qmessagebox.h> 2139#include <qmessagebox.h>
2138#ifdef DESKTOP_VERSION 2140#ifdef DESKTOP_VERSION
2139#include <qprinter.h> 2141#include <qprinter.h>
2140#include <qpainter.h> 2142#include <qpainter.h>
2141#include <qpaintdevicemetrics.h> 2143#include <qpaintdevicemetrics.h>
2142 2144
2143#endif 2145#endif
2144void KOAgenda::printSelection() 2146void KOAgenda::printSelection()
2145{ 2147{
2146#ifdef DESKTOP_VERSION 2148#ifdef DESKTOP_VERSION
2147 if ( mStartCellY == mCurrentCellY ) { 2149 if ( mStartCellY == mCurrentCellY ) {
2148 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2150 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2149 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2151 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2150 i18n("OK"), 0, 0, 2152 i18n("OK"), 0, 0,
2151 0, 1 ); 2153 0, 1 );
2152 return; 2154 return;
2153 } 2155 }
2154 2156
2155 float dx, dy; 2157 float dx, dy;
2156 int x,y,w,h; 2158 int x,y,w,h;
2157 x= 0; 2159 x= 0;
2158 w= contentsWidth()+2; 2160 w= contentsWidth()+2;
2159 // h= contentsHeight(); 2161 // h= contentsHeight();
2160 y = mGridSpacingY*mStartCellY; 2162 y = mGridSpacingY*mStartCellY;
2161 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2163 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2162 2164
2163 //return; 2165 //return;
2164 QPrinter* printer = new QPrinter(); 2166 QPrinter* printer = new QPrinter();
2165 if ( !printer->setup()) { 2167 if ( !printer->setup()) {
2166 delete printer; 2168 delete printer;
2167 return; 2169 return;
2168 } 2170 }
2169 QPainter p( printer ); 2171 QPainter p( printer );
2170 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2172 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2171 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2173 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2172 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2174 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2173 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2175 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2174 // p.drawText( 0, 0, date ); 2176 // p.drawText( 0, 0, date );
2175 int offset = m.width()/8; 2177 int offset = m.width()/8;
2176 // compute the scale 2178 // compute the scale
2177 dx = ((float) m.width()-offset) / (float)w; 2179 dx = ((float) m.width()-offset) / (float)w;
2178 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2180 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2179 float scale; 2181 float scale;
2180 // scale to fit the width or height of the paper 2182 // scale to fit the width or height of the paper
2181 if ( dx < dy ) 2183 if ( dx < dy )
2182 scale = dx; 2184 scale = dx;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index f855b03..8675ff6 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,844 +1,853 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100 100
101void KOAgendaItem::initColor () 101void KOAgendaItem::initColor ()
102{ 102{
103 if ( (mIncidence->typeID() == todoID ) && 103 if ( (mIncidence->typeID() == todoID ) &&
104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) && 104 ( !((static_cast<Todo*>(mIncidence))->isCompleted()) &&
105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) { 105 ((static_cast<Todo*>(mIncidence))->dtDue().date() <= QDate::currentDate()) ) ) {
106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date()) 106 if ( (static_cast<Todo*>(mIncidence))->dtDue() < QDateTime::currentDateTime().date())
107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 107 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
108 else 108 else
109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 109 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
110 } 110 }
111 else { 111 else {
112 QStringList categories = mIncidence->categories(); 112 QStringList categories = mIncidence->categories();
113 QString cat = categories.first(); 113 QString cat = categories.first();
114 if (cat.isEmpty()) { 114 if (cat.isEmpty()) {
115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) 115 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) )
116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 116 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
117 else 117 else
118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() ); 118 mBackgroundColor =KOPrefs::instance()->defaultColor( mIncidence->calID() );
119 } else { 119 } else {
120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 120 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) { 121 if ( (mIncidence->typeID() == todoID ) &&((static_cast<Todo*>(mIncidence))->isCompleted()) ) {
122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 122 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 123 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
124 } 124 }
125 } 125 }
126 126
127 } 127 }
128 128
129 QColor BackgroundColor ( mBackgroundColor ); 129 QColor BackgroundColor ( mBackgroundColor );
130 if ( mIncidence->calID() > 1 ) { 130 if ( mIncidence->calID() > 1 ) {
131 //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() ); 131 //BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
132 } 132 }
133 mColorGroup = QColorGroup( BackgroundColor.light(), 133 mColorGroup = QColorGroup( BackgroundColor.light(),
134 BackgroundColor.dark(),BackgroundColor.light(), 134 BackgroundColor.dark(),BackgroundColor.light(),
135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ; 135 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 136 setBackgroundColor( mBackgroundColor );
137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 137 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
138} 138}
139void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 139void KOAgendaItem::init ( Incidence *incidence, QDate qd )
140{ 140{
141 mIncidence = incidence; 141 mIncidence = incidence;
142 mDate = qd; 142 mDate = qd;
143 mFirstMultiItem = 0; 143 mFirstMultiItem = 0;
144 mNextMultiItem = 0; 144 mNextMultiItem = 0;
145 mLastMultiItem = 0; 145 mLastMultiItem = 0;
146 computeText(); 146 computeText();
147 initColor(); 147 initColor();
148 mConflictItems.clear(); 148 mConflictItems.clear();
149 setCellXY(0,0,1); 149 setCellXY(0,0,1);
150 setCellXWidth(0); 150 setCellXWidth(0);
151 setSubCell(0); 151 setSubCell(0);
152 setSubCells(1); 152 setSubCells(1);
153 setMultiItem(0,0,0); 153 setMultiItem(0,0,0);
154 startMove(); 154 startMove();
155 mSelected = true; 155 mSelected = true;
156 select(false); 156 select(false);
157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
158 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
159 hide(); 159 hide();
160 xPaintCoord = -1; 160 xPaintCoord = -1;
161 yPaintCoord = -1; 161 yPaintCoord = -1;
162} 162}
163 163
164 164
165KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
166{ 166{
167#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
168 168
169#else 169#else
170 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
171#endif 171#endif
172 172
173} 173}
174 174
175void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
176{ 176{
177#if 0 177#if 0
178 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
179 newInc->recreate(); 179 newInc->recreate();
180 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
181 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
182 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
184 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
185 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
187 } 187 }
188#endif 188#endif
189 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
190} 190}
191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
192{ 192{
193 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
194 194
195 int yOff = 0; 195 int yOff = 0;
196 int xOff = 0; 196 int xOff = 0;
197 int x = pos().x(); 197 int x = pos().x();
198 198
199 if ( x < 0 ) x = 0; 199 if ( x < 0 ) x = 0;
200 x += 3; 200 x += 3;
201 int y; 201 int y;
202 if ( mAllDay ) 202 if ( mAllDay )
203 y = pos().y()+3; 203 y = pos().y()+3;
204 else 204 else
205 y = mCellYTop * ( height() / cellHeight() ) +3; 205 y = mCellYTop * ( height() / cellHeight() ) +3;
206 206
207 207
208 if ( mIncidence->calID() > 1 ) { 208 if ( mIncidence->calID() > 1 ) {
209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); 210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 );
211 if ( horLayout ){ 211 if ( horLayout ){
212 ++xOff; 212 ++xOff;
213 ++x; 213 ++x;
214 } 214 }
215 else { 215 else {
216 ++yOff; 216 ++yOff;
217 ++y; 217 ++y;
218 } 218 }
219 } 219 }
220 if (mIncidence->cancelled() && height() < 20 ) { 220 if (mIncidence->cancelled() && height() < 20 ) {
221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
225 if ( horLayout ) 225 if ( horLayout )
226 ++xOff; 226 ++xOff;
227 else 227 else
228 ++yOff; 228 ++yOff;
229 } 229 }
230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } 236 }
237 if (mIncidence->recurrence()->doesRecur()) { 237 if (mIncidence->recurrence()->doesRecur()) {
238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
239 if ( horLayout ) 239 if ( horLayout )
240 ++xOff; 240 ++xOff;
241 else 241 else
242 ++yOff; 242 ++yOff;
243 } 243 }
244 if (mIncidence->description().length() > 0) { 244 if (mIncidence->description().length() > 0) {
245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
246 if ( horLayout ) 246 if ( horLayout )
247 ++xOff; 247 ++xOff;
248 else 248 else
249 ++yOff; 249 ++yOff;
250 } 250 }
251 if (mIncidence->isReadOnly()) { 251 if (mIncidence->isReadOnly()) {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
253 if ( horLayout ) 253 if ( horLayout )
254 ++xOff; 254 ++xOff;
255 else 255 else
256 ++yOff; 256 ++yOff;
257 } 257 }
258 258
259 if (mIncidence->attendeeCount()>0) { 259 if (mIncidence->attendeeCount()>0) {
260 260
261 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 261 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
263 if ( horLayout ) 263 if ( horLayout )
264 ++xOff; 264 ++xOff;
265 else 265 else
266 ++yOff; 266 ++yOff;
267 } else { 267 } else {
268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
269 if (me!=0) { 269 if (me!=0) {
270 270
271 271
272 } else { 272 } else {
273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
274 if ( horLayout ) 274 if ( horLayout )
275 ++xOff; 275 ++xOff;
276 else 276 else
277 ++yOff; 277 ++yOff;
278 278
279 } 279 }
280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
281 if ( horLayout ) 281 if ( horLayout )
282 ++xOff; 282 ++xOff;
283 else 283 else
284 ++yOff; 284 ++yOff;
285 285
286 } 286 }
287 287
288 } 288 }
289 return ( yOff || xOff ); 289 return ( yOff || xOff );
290} 290}
291 291
292 292
293void KOAgendaItem::select(bool selected) 293void KOAgendaItem::select(bool selected)
294{ 294{
295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
296 if (mSelected == selected) return; 296 if (mSelected == selected) return;
297 mSelected = selected; 297 mSelected = selected;
298 if ( ! isVisible() ) 298 if ( ! isVisible() )
299 return; 299 return;
300 if ( firstMultiItem() ) 300 if ( firstMultiItem() )
301 firstMultiItem()->select( selected ); 301 firstMultiItem()->select( selected );
302 if ( !firstMultiItem() && nextMultiItem() ) { 302 if ( !firstMultiItem() && nextMultiItem() ) {
303 KOAgendaItem * placeItem = nextMultiItem(); 303 KOAgendaItem * placeItem = nextMultiItem();
304 while ( placeItem ) { 304 while ( placeItem ) {
305 placeItem->select( selected ); 305 placeItem->select( selected );
306 placeItem = placeItem->nextMultiItem(); 306 placeItem = placeItem->nextMultiItem();
307 } 307 }
308 } 308 }
309 globalFlagBlockAgendaItemUpdate = 0; 309 globalFlagBlockAgendaItemUpdate = 0;
310 paintMe( selected ); 310 paintMe( selected );
311 globalFlagBlockAgendaItemUpdate = 1; 311 globalFlagBlockAgendaItemUpdate = 1;
312 repaint( false ); 312 repaint( false );
313} 313}
314 314
315 315
316/* 316/*
317 The eventFilter has to filter the mouse events of the agenda item childs. The 317 The eventFilter has to filter the mouse events of the agenda item childs. The
318 events are fed into the event handling method of KOAgendaItem. This allows the 318 events are fed into the event handling method of KOAgendaItem. This allows the
319 KOAgenda to handle the KOAgendaItems by using an eventFilter. 319 KOAgenda to handle the KOAgendaItems by using an eventFilter.
320*/ 320*/
321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
322{ 322{
323 if (e->type() == QEvent::MouseButtonPress || 323 if (e->type() == QEvent::MouseButtonPress ||
324 e->type() == QEvent::MouseButtonDblClick || 324 e->type() == QEvent::MouseButtonDblClick ||
325 e->type() == QEvent::MouseButtonRelease || 325 e->type() == QEvent::MouseButtonRelease ||
326 e->type() == QEvent::MouseMove) { 326 e->type() == QEvent::MouseMove) {
327 QMouseEvent *me = (QMouseEvent *)e; 327 QMouseEvent *me = (QMouseEvent *)e;
328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
329 mapToGlobal(me->pos())); 329 mapToGlobal(me->pos()));
330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
331 return event(&returnEvent); 331 return event(&returnEvent);
332 } else { 332 } else {
333 return false; 333 return false;
334 } 334 }
335} 335}
336void KOAgendaItem::repaintMe( ) 336void KOAgendaItem::repaintMe( )
337{ 337{
338 paintMe ( mSelected ); 338 paintMe ( mSelected );
339} 339}
340void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 340void KOAgendaItem::paintMe( bool selected, QPainter* paint )
341{ 341{
342 if ( globalFlagBlockAgendaItemUpdate && ! selected) 342 if ( globalFlagBlockAgendaItemUpdate && ! selected)
343 return; 343 return;
344 QPainter pa; 344 QPainter pa;
345 345
346 if ( mSelected ) { 346 if ( mSelected ) {
347 pa.begin( this ); 347 pa.begin( this );
348 } else { 348 } else {
349 if ( mAllDay ) 349 if ( mAllDay )
350 pa.begin( paintPixAllday() ); 350 pa.begin( paintPixAllday() );
351 else 351 else
352 pa.begin( paintPix() ); 352 pa.begin( paintPix() );
353 } 353 }
354 int x, yy, w, h; 354 int x, yy, w, h;
355 float nfh = 7.0; 355 float nfh = 7.0;
356 x = pos().x(); w = width(); h = height (); 356 x = pos().x(); w = width(); h = height ();
357 if ( mAllDay ) 357 if ( mAllDay )
358 yy = y(); 358 yy = y();
359 else 359 else
360 yy = mCellYTop * ( height() / cellHeight() ); 360 yy = mCellYTop * ( height() / cellHeight() );
361 if ( mSelected ) { 361 if ( mSelected ) {
362 pa.translate( -x, -yy ); 362 pa.translate( -x, -yy );
363 } 363 }
364 xPaintCoord= x; 364 xPaintCoord= x;
365 yPaintCoord = yy; 365 yPaintCoord = yy;
366 wPaintCoord = width(); 366 wPaintCoord = width();
367 hPaintCoord = height(); 367 hPaintCoord = height();
368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
369 if ( paint == 0 ) 369 if ( paint == 0 )
370 paint = &pa; 370 paint = &pa;
371 bool horLayout = ( w < h ); 371 bool horLayout = ( w < h );
372 int maxhei = mFontPixelSize+4; 372 int maxhei = mFontPixelSize+4;
373 if ( horLayout ) 373 if ( horLayout )
374 maxhei += AGENDA_ICON_SIZE -4; 374 maxhei += AGENDA_ICON_SIZE -4;
375 bool small = ( h < maxhei ); 375 bool small = ( h < maxhei );
376 if ( ! small ) 376 if ( ! small )
377 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 377 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
378 else { 378 else {
379 QFont f = KOPrefs::instance()->mAgendaViewFont; 379 QFont f = KOPrefs::instance()->mAgendaViewFont;
380 f.setBold( false ); 380 f.setBold( false );
381 int fh = f.pointSize(); 381 int fh = f.pointSize();
382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
383 if ( nfh < 6 ) 383 if ( nfh < 6 )
384 nfh = 6; 384 nfh = 6;
385 f.setPointSize( nfh ); 385 f.setPointSize( nfh );
386 paint->setFont(f); 386 paint->setFont(f);
387 } 387 }
388 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 388 paint->fillRect ( x, yy, w, h, mBackgroundColor );
389 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 389 static const QPixmap completedPxmp = SmallIcon("greenhook16");
390 static const QPixmap overduePxmp = SmallIcon("redcross16"); 390 static const QPixmap overduePxmp = SmallIcon("redcross16");
391 if ( mIncidence->typeID() == todoID ) { 391 if ( mIncidence->typeID() == todoID ) {
392 Todo* tempTodo = static_cast<Todo*>(mIncidence); 392 Todo* tempTodo = static_cast<Todo*>(mIncidence);
393 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 393 int xx = pos().x()+(width()-completedPxmp.width()-3 );
394 int yyy = yy+3; 394 int yyy = yy+3;
395 if ( tempTodo->isCompleted() ) 395 if ( tempTodo->isCompleted() )
396 paint->drawPixmap ( xx, yyy, completedPxmp ); 396 paint->drawPixmap ( xx, yyy, completedPxmp );
397 else { 397 else {
398 paint->drawPixmap ( xx, yyy, overduePxmp ); 398 paint->drawPixmap ( xx, yyy, overduePxmp );
399 399
400 } 400 }
401 } 401 }
402 bool addIcon = false; 402 bool addIcon = false;
403 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
404 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
405 405
406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
409 if ( ! small ) { 409 if ( ! small ) {
410 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
411 } else { 411 } else {
412 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
413 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
414 yy -= 2; 414 yy -= 2;
415 h += 4; 415 h += 4;
416 } 416 }
417 else 417 else
418 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
419 ++yy; 419 ++yy;
420 } 420 }
421 int align; 421 int align;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
424#else 424#else
425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
426#endif 426#endif
427 if ( addIcon ) { 427 if ( addIcon ) {
428 if ( ! horLayout ) { 428 if ( ! horLayout ) {
429 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
430 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
431 } 431 }
432 else { 432 else {
433 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
434 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
435 } 435 }
436 } 436 }
437 if ( mWhiteText ) 437 if ( mWhiteText )
438 paint->setPen ( white); 438 paint->setPen ( white);
439 if ( x < 0 ) { 439 if ( x < 0 ) {
440 w = w+x-3; 440 w = w+x-3;
441 x = 3; 441 x = 3;
442 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
443 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
444 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
445 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
446#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
447 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
448#else 448#else
449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
450#endif 450#endif
451 451
452 } 452 }
453 } 453 }
454 QRect dr; 454 QRect dr;
455 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
456 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
458 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
459 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
460 460
461 461
462 small = ( height() < 20 ); 462 small = ( height() < 20 );
463 463
464 if ( ! small ) { 464 if ( ! small ) {
465 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
467 } 467 }
468 468
469 } 469 }
470 pa.end(); 470 pa.end();
471 471
472} 472}
473 473
474QPixmap * KOAgendaItem::paintPix() 474QPixmap * KOAgendaItem::paintPix()
475{ 475{
476 static QPixmap* mPaintPix = 0; 476 static QPixmap* mPaintPix = 0;
477 if ( ! mPaintPix ) { 477 if ( ! mPaintPix ) {
478 int w = QApplication::desktop()->width(); 478 int w = QApplication::desktop()->width();
479 int h = QApplication::desktop()->height(); 479 int h = QApplication::desktop()->height();
480 mPaintPix = new QPixmap(w,h); 480 mPaintPix = new QPixmap(w,h);
481 } 481 }
482 return mPaintPix ; 482 return mPaintPix ;
483} 483}
484QPixmap * KOAgendaItem::paintPixAllday() 484QPixmap * KOAgendaItem::paintPixAllday()
485{ 485{
486 static QPixmap* mPaintPixA = 0; 486 static QPixmap* mPaintPixA = 0;
487 if ( ! mPaintPixA ) { 487 if ( ! mPaintPixA ) {
488 int w = QApplication::desktop()->width(); 488 int w = QApplication::desktop()->width();
489 int h = QApplication::desktop()->height()/5; 489 int h = QApplication::desktop()->height()/5;
490 mPaintPixA = new QPixmap(w,h); 490 mPaintPixA = new QPixmap(w,h);
491 } 491 }
492 return mPaintPixA ; 492 return mPaintPixA ;
493} 493}
494 494
495void KOAgendaItem::repaintItem()
496{
497 globalFlagBlockAgendaItemPaint = 0;
498 globalFlagBlockAgenda = 0;
499 //qDebug("AAA ");
500 repaint( false );
501 //qDebug("BBB ");
502}
495void KOAgendaItem::paintEvent ( QPaintEvent *e ) 503void KOAgendaItem::paintEvent ( QPaintEvent *e )
496{ 504{
497 505 qDebug("CCC ");
498 if ( globalFlagBlockAgendaItemPaint ) 506 if ( globalFlagBlockAgendaItemPaint )
499 return; 507 return;
500 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 508 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
501 return; 509 return;
510 qDebug("DDD ");
502 int yy; 511 int yy;
503 if ( mAllDay ) 512 if ( mAllDay )
504 yy = y(); 513 yy = y();
505 else 514 else
506 yy = mCellYTop * ( height() / cellHeight() ); 515 yy = mCellYTop * ( height() / cellHeight() );
507 int xx = x(); 516 int xx = x();
508 517
509 if ( xPaintCoord != xx || yPaintCoord != yy || 518 if ( xPaintCoord != xx || yPaintCoord != yy ||
510 wPaintCoord != width() || hPaintCoord != height()) { 519 wPaintCoord != width() || hPaintCoord != height()) {
511 xPaintCoord= xx; 520 xPaintCoord= xx;
512 yPaintCoord = yy; 521 yPaintCoord = yy;
513 wPaintCoord = width(); 522 wPaintCoord = width();
514 hPaintCoord = height(); 523 hPaintCoord = height();
515 globalFlagBlockAgendaItemUpdate = 0; 524 globalFlagBlockAgendaItemUpdate = 0;
516 paintMe( mSelected ); 525 paintMe( mSelected );
517 //qDebug("calling paintMe "); 526 //qDebug("calling paintMe ");
518 globalFlagBlockAgendaItemUpdate = 1; 527 globalFlagBlockAgendaItemUpdate = 1;
519 if ( mSelected ) 528 if ( mSelected )
520 return; 529 return;
521 } 530 }
522 int rx, ry, rw, rh; 531 int rx, ry, rw, rh;
523 rx = e->rect().x(); 532 rx = e->rect().x();
524 ry = e->rect().y(); 533 ry = e->rect().y();
525 rw = e->rect().width(); 534 rw = e->rect().width();
526 rh = e->rect().height(); 535 rh = e->rect().height();
527 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
528 537
529 QPixmap* paintFrom ; 538 QPixmap* paintFrom ;
530 if ( mSelected ) { 539 if ( mSelected ) {
531 paintMe( mSelected ); 540 paintMe( mSelected );
532 return; 541 return;
533 } else { 542 } else {
534 if ( mAllDay ) 543 if ( mAllDay )
535 paintFrom = paintPixAllday(); 544 paintFrom = paintPixAllday();
536 else 545 else
537 paintFrom = paintPix(); 546 paintFrom = paintPix();
538 } 547 }
539 xx += rx; 548 xx += rx;
540 549
541 if ( xx < 0 ) { 550 if ( xx < 0 ) {
542 rw = rw + xx; 551 rw = rw + xx;
543 rx -= xx; 552 rx -= xx;
544 xx = 0; 553 xx = 0;
545 if ( rw <= 1 ) { 554 if ( rw <= 1 ) {
546 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 555 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
547 return; 556 return;
548 } 557 }
549 } 558 }
550 if ( paintFrom->width() < xx+rw ) { 559 if ( paintFrom->width() < xx+rw ) {
551 rw = paintFrom->width() - xx; 560 rw = paintFrom->width() - xx;
552 if ( rw <= 1 ) { 561 if ( rw <= 1 ) {
553 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 562 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
554 return; 563 return;
555 } 564 }
556 } 565 }
557 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 566 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
558 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 567 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
559} 568}
560void KOAgendaItem::computeText() 569void KOAgendaItem::computeText()
561{ 570{
562 mDisplayedText = mIncidence->summary(); 571 mDisplayedText = mIncidence->summary();
563 if ( (mIncidence->typeID() == todoID ) ) { 572 if ( (mIncidence->typeID() == todoID ) ) {
564 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 573 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
565 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 574 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
566 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 575 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
567 else if ( !(mIncidence->doesFloat())) 576 else if ( !(mIncidence->doesFloat()))
568 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 577 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
569 } 578 }
570 } else { 579 } else {
571 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 580 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
572 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 581 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
573 582
574 if ( mAllDay ) { 583 if ( mAllDay ) {
575 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 584 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
576 if ( mIncidence->doesRecur() ) { 585 if ( mIncidence->doesRecur() ) {
577 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 586 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
578 } else { 587 } else {
579 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 588 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
580 } 589 }
581 } 590 }
582 } 591 }
583 } 592 }
584 593
585 if ( !mIncidence->location().isEmpty() ) { 594 if ( !mIncidence->location().isEmpty() ) {
586 if ( mAllDay ) 595 if ( mAllDay )
587 mDisplayedText += " ("; 596 mDisplayedText += " (";
588 else 597 else
589 mDisplayedText += "\n("; 598 mDisplayedText += "\n(";
590 mDisplayedText += mIncidence->location() +")"; 599 mDisplayedText += mIncidence->location() +")";
591 } 600 }
592#ifdef DESKTOP_VERSION 601#ifdef DESKTOP_VERSION
593 QString tipText = mIncidence->summary(); 602 QString tipText = mIncidence->summary();
594 if ( !mIncidence->doesFloat() ) { 603 if ( !mIncidence->doesFloat() ) {
595 if ( mIncidence->typeID() == eventID ) { 604 if ( mIncidence->typeID() == eventID ) {
596 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 605 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
597 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 606 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
598 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 607 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
599 } 608 }
600 else { 609 else {
601 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 610 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
602 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 611 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
603 } 612 }
604 } 613 }
605 else if ( mIncidence->typeID() == todoID ) { 614 else if ( mIncidence->typeID() == todoID ) {
606 if (mIncidence->hasStartDate()) 615 if (mIncidence->hasStartDate())
607 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 616 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
608 if (((Todo*)mIncidence)->hasDueDate()) 617 if (((Todo*)mIncidence)->hasDueDate())
609 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 618 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
610 } 619 }
611 } else if ( mIncidence->typeID() == todoID ) { 620 } else if ( mIncidence->typeID() == todoID ) {
612 if (mIncidence->hasStartDate()) 621 if (mIncidence->hasStartDate())
613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 622 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
614 if (((Todo*)mIncidence)->hasDueDate()) 623 if (((Todo*)mIncidence)->hasDueDate())
615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 624 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
616 } 625 }
617 626
618 if (!mIncidence->location().isEmpty()) { 627 if (!mIncidence->location().isEmpty()) {
619 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 628 tipText += "\n"+i18n("Location: ")+mIncidence->location();
620 } 629 }
621 QToolTip::add(this,tipText,toolTipGroup(),""); 630 QToolTip::add(this,tipText,toolTipGroup(),"");
622#endif 631#endif
623} 632}
624void KOAgendaItem::updateItem() 633void KOAgendaItem::updateItem()
625{ 634{
626 computeText(); 635 computeText();
627 636
628 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 637 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
629 paintMe( mSelected ); 638 paintMe( mSelected );
630 repaint( false); 639 repaint( false);
631} 640}
632 641
633void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 642void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
634{ 643{
635 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 644 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
636 paintMe( mSelected ); 645 paintMe( mSelected );
637 repaint( false ); 646 repaint( false );
638} 647}
639 648
640/* 649/*
641 Return height of item in units of agenda cells 650 Return height of item in units of agenda cells
642*/ 651*/
643int KOAgendaItem::cellHeight() 652int KOAgendaItem::cellHeight()
644{ 653{
645 int ret = mCellYBottom - mCellYTop + 1; 654 int ret = mCellYBottom - mCellYTop + 1;
646 if ( ret <= 0 ) { 655 if ( ret <= 0 ) {
647 ret = 1; 656 ret = 1;
648 mCellYBottom = 0; 657 mCellYBottom = 0;
649 mCellYTop = 0; 658 mCellYTop = 0;
650 } 659 }
651 return ret; 660 return ret;
652} 661}
653 662
654/* 663/*
655 Return height of item in units of agenda cells 664 Return height of item in units of agenda cells
656*/ 665*/
657int KOAgendaItem::cellWidth() 666int KOAgendaItem::cellWidth()
658{ 667{
659 return mCellXWidth - mCellX + 1; 668 return mCellXWidth - mCellX + 1;
660} 669}
661 670
662void KOAgendaItem::setItemDate(QDate qd) 671void KOAgendaItem::setItemDate(QDate qd)
663{ 672{
664 mDate = qd; 673 mDate = qd;
665} 674}
666 675
667void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 676void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
668{ 677{
669 mCellX = X; 678 mCellX = X;
670 mCellYTop = YTop; 679 mCellYTop = YTop;
671 mCellYBottom = YBottom; 680 mCellYBottom = YBottom;
672} 681}
673 682
674void KOAgendaItem::setCellXWidth(int xwidth) 683void KOAgendaItem::setCellXWidth(int xwidth)
675{ 684{
676 mCellXWidth = xwidth; 685 mCellXWidth = xwidth;
677} 686}
678 687
679void KOAgendaItem::setCellX(int XLeft, int XRight) 688void KOAgendaItem::setCellX(int XLeft, int XRight)
680{ 689{
681 mCellX = XLeft; 690 mCellX = XLeft;
682 mCellXWidth = XRight; 691 mCellXWidth = XRight;
683} 692}
684 693
685void KOAgendaItem::setCellY(int YTop, int YBottom) 694void KOAgendaItem::setCellY(int YTop, int YBottom)
686{ 695{
687 mCellYTop = YTop; 696 mCellYTop = YTop;
688 mCellYBottom = YBottom; 697 mCellYBottom = YBottom;
689} 698}
690 699
691void KOAgendaItem::setSubCell(int subCell) 700void KOAgendaItem::setSubCell(int subCell)
692{ 701{
693 mSubCell = subCell; 702 mSubCell = subCell;
694} 703}
695 704
696void KOAgendaItem::setSubCells(int subCells) 705void KOAgendaItem::setSubCells(int subCells)
697{ 706{
698 mSubCells = subCells; 707 mSubCells = subCells;
699} 708}
700 709
701void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 710void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
702 KOAgendaItem *last) 711 KOAgendaItem *last)
703{ 712{
704 mFirstMultiItem = first; 713 mFirstMultiItem = first;
705 mNextMultiItem = next; 714 mNextMultiItem = next;
706 mLastMultiItem = last; 715 mLastMultiItem = last;
707} 716}
708 717
709void KOAgendaItem::startMove() 718void KOAgendaItem::startMove()
710{ 719{
711 mStartCellX = mCellX; 720 mStartCellX = mCellX;
712 mStartCellXWidth = mCellXWidth; 721 mStartCellXWidth = mCellXWidth;
713 mStartCellYTop = mCellYTop; 722 mStartCellYTop = mCellYTop;
714 mStartCellYBottom = mCellYBottom; 723 mStartCellYBottom = mCellYBottom;
715} 724}
716 725
717void KOAgendaItem::resetMove() 726void KOAgendaItem::resetMove()
718{ 727{
719 mCellX = mStartCellX; 728 mCellX = mStartCellX;
720 mCellXWidth = mStartCellXWidth; 729 mCellXWidth = mStartCellXWidth;
721 mCellYTop = mStartCellYTop; 730 mCellYTop = mStartCellYTop;
722 mCellYBottom = mStartCellYBottom; 731 mCellYBottom = mStartCellYBottom;
723} 732}
724 733
725void KOAgendaItem::moveRelative(int dx, int dy) 734void KOAgendaItem::moveRelative(int dx, int dy)
726{ 735{
727 int newX = cellX() + dx; 736 int newX = cellX() + dx;
728 int newXWidth = cellXWidth() + dx; 737 int newXWidth = cellXWidth() + dx;
729 int newYTop = cellYTop() + dy; 738 int newYTop = cellYTop() + dy;
730 int newYBottom = cellYBottom() + dy; 739 int newYBottom = cellYBottom() + dy;
731 setCellXY(newX,newYTop,newYBottom); 740 setCellXY(newX,newYTop,newYBottom);
732 setCellXWidth(newXWidth); 741 setCellXWidth(newXWidth);
733} 742}
734 743
735void KOAgendaItem::expandTop(int dy) 744void KOAgendaItem::expandTop(int dy)
736{ 745{
737 int newYTop = cellYTop() + dy; 746 int newYTop = cellYTop() + dy;
738 int newYBottom = cellYBottom(); 747 int newYBottom = cellYBottom();
739 if (newYTop > newYBottom) newYTop = newYBottom; 748 if (newYTop > newYBottom) newYTop = newYBottom;
740 setCellY(newYTop, newYBottom); 749 setCellY(newYTop, newYBottom);
741} 750}
742 751
743void KOAgendaItem::expandBottom(int dy) 752void KOAgendaItem::expandBottom(int dy)
744{ 753{
745 int newYTop = cellYTop(); 754 int newYTop = cellYTop();
746 int newYBottom = cellYBottom() + dy; 755 int newYBottom = cellYBottom() + dy;
747 if (newYBottom < newYTop) newYBottom = newYTop; 756 if (newYBottom < newYTop) newYBottom = newYTop;
748 setCellY(newYTop, newYBottom); 757 setCellY(newYTop, newYBottom);
749} 758}
750 759
751void KOAgendaItem::expandLeft(int dx) 760void KOAgendaItem::expandLeft(int dx)
752{ 761{
753 int newX = cellX() + dx; 762 int newX = cellX() + dx;
754 int newXWidth = cellXWidth(); 763 int newXWidth = cellXWidth();
755 if (newX > newXWidth) newX = newXWidth; 764 if (newX > newXWidth) newX = newXWidth;
756 setCellX(newX,newXWidth); 765 setCellX(newX,newXWidth);
757} 766}
758 767
759void KOAgendaItem::expandRight(int dx) 768void KOAgendaItem::expandRight(int dx)
760{ 769{
761 int newX = cellX(); 770 int newX = cellX();
762 int newXWidth = cellXWidth() + dx; 771 int newXWidth = cellXWidth() + dx;
763 if (newXWidth < newX) newXWidth = newX; 772 if (newXWidth < newX) newXWidth = newX;
764 setCellX(newX,newXWidth); 773 setCellX(newX,newXWidth);
765} 774}
766 775
767QToolTipGroup *KOAgendaItem::toolTipGroup() 776QToolTipGroup *KOAgendaItem::toolTipGroup()
768{ 777{
769 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 778 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
770 return mToolTipGroup; 779 return mToolTipGroup;
771} 780}
772 781
773void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 782void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
774{ 783{
775#ifndef KORG_NODND 784#ifndef KORG_NODND
776 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 785 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
777 !QTextDrag::canDecode( e ) ) { 786 !QTextDrag::canDecode( e ) ) {
778 e->ignore(); 787 e->ignore();
779 return; 788 return;
780 } 789 }
781 e->accept(); 790 e->accept();
782#endif 791#endif
783} 792}
784 793
785void KOAgendaItem::dropEvent( QDropEvent *e ) 794void KOAgendaItem::dropEvent( QDropEvent *e )
786{ 795{
787#ifndef KORG_NODND 796#ifndef KORG_NODND
788 QString text; 797 QString text;
789 if(QTextDrag::decode(e,text)) 798 if(QTextDrag::decode(e,text))
790 { 799 {
791 kdDebug() << "Dropped : " << text << endl; 800 kdDebug() << "Dropped : " << text << endl;
792 QStringList emails = QStringList::split(",",text); 801 QStringList emails = QStringList::split(",",text);
793 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 802 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
794 kdDebug() << " Email: " << (*it) << endl; 803 kdDebug() << " Email: " << (*it) << endl;
795 int pos = (*it).find("<"); 804 int pos = (*it).find("<");
796 QString name = (*it).left(pos); 805 QString name = (*it).left(pos);
797 QString email = (*it).mid(pos); 806 QString email = (*it).mid(pos);
798 if (!email.isEmpty()) { 807 if (!email.isEmpty()) {
799 mIncidence->addAttendee(new Attendee(name,email)); 808 mIncidence->addAttendee(new Attendee(name,email));
800 } 809 }
801 } 810 }
802 } 811 }
803#endif 812#endif
804} 813}
805 814
806 815
807QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 816QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
808{ 817{
809 return mConflictItems; 818 return mConflictItems;
810} 819}
811 820
812void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 821void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
813{ 822{
814 mConflictItems = ci; 823 mConflictItems = ci;
815 KOAgendaItem *item; 824 KOAgendaItem *item;
816 for ( item=mConflictItems.first(); item != 0; 825 for ( item=mConflictItems.first(); item != 0;
817 item=mConflictItems.next() ) { 826 item=mConflictItems.next() ) {
818 item->addConflictItem(this); 827 item->addConflictItem(this);
819 } 828 }
820} 829}
821 830
822void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 831void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
823{ 832{
824 if (mConflictItems.find(ci)<0) 833 if (mConflictItems.find(ci)<0)
825 mConflictItems.append(ci); 834 mConflictItems.append(ci);
826} 835}
827 836
828bool KOAgendaItem::checkLayout() 837bool KOAgendaItem::checkLayout()
829{ 838{
830 if ( !mConflictItems.count() ) 839 if ( !mConflictItems.count() )
831 return true; 840 return true;
832 int max = 0; 841 int max = 0;
833 KOAgendaItem *item; 842 KOAgendaItem *item;
834 for ( item=mConflictItems.first(); item != 0; 843 for ( item=mConflictItems.first(); item != 0;
835 item=mConflictItems.next() ) { 844 item=mConflictItems.next() ) {
836 if ( item->subCells() > max ) 845 if ( item->subCells() > max )
837 max = item->subCells(); 846 max = item->subCells();
838 } 847 }
839 if ( max > subCells() ) { 848 if ( max > subCells() ) {
840 setSubCells( max ); 849 setSubCells( max );
841 return false; 850 return false;
842 } 851 }
843 return true; 852 return true;
844} 853}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 3ed68b0..99c564a 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,164 +1,165 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static QPixmap * paintPix(); 104 static QPixmap * paintPix();
105 static QPixmap * paintPixAllday(); 105 static QPixmap * paintPixAllday();
106 void updateItem(); 106 void updateItem();
107 void computeText(); 107 void computeText();
108 void recreateIncidence(); 108 void recreateIncidence();
109 bool checkLayout(); 109 bool checkLayout();
110 void initColor (); 110 void initColor ();
111 public slots: 111 public slots:
112 bool updateIcons( QPainter *, bool ); 112 bool updateIcons( QPainter *, bool );
113 void select(bool=true); 113 void select(bool=true);
114 void repaintItem();
114 115
115 protected: 116 protected:
116 void dragEnterEvent(QDragEnterEvent *e); 117 void dragEnterEvent(QDragEnterEvent *e);
117 void dropEvent(QDropEvent *e); 118 void dropEvent(QDropEvent *e);
118 void paintEvent ( QPaintEvent * ); 119 void paintEvent ( QPaintEvent * );
119 void resizeEvent ( QResizeEvent *ev ); 120 void resizeEvent ( QResizeEvent *ev );
120 121
121 private: 122 private:
122 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
123 bool mAllDay; 124 bool mAllDay;
124 bool mWhiteText; 125 bool mWhiteText;
125 int mCellX; 126 int mCellX;
126 int mCellXWidth; 127 int mCellXWidth;
127 int mCellYTop,mCellYBottom; 128 int mCellYTop,mCellYBottom;
128 int mSubCell; // subcell number of this item 129 int mSubCell; // subcell number of this item
129 int mSubCells; // Total number of subcells in cell of this item 130 int mSubCells; // Total number of subcells in cell of this item
130 int xPaintCoord; 131 int xPaintCoord;
131 int yPaintCoord; 132 int yPaintCoord;
132 int wPaintCoord; 133 int wPaintCoord;
133 int hPaintCoord; 134 int hPaintCoord;
134 // Variables to remember start position 135 // Variables to remember start position
135 int mStartCellX; 136 int mStartCellX;
136 int mStartCellXWidth; 137 int mStartCellXWidth;
137 int mStartCellYTop,mStartCellYBottom; 138 int mStartCellYTop,mStartCellYBottom;
138 int mLastMovePos; 139 int mLastMovePos;
139 140
140 // Multi item pointers 141 // Multi item pointers
141 KOAgendaItem *mFirstMultiItem; 142 KOAgendaItem *mFirstMultiItem;
142 KOAgendaItem *mNextMultiItem; 143 KOAgendaItem *mNextMultiItem;
143 KOAgendaItem *mLastMultiItem; 144 KOAgendaItem *mLastMultiItem;
144 145
145 int mFontPixelSize; 146 int mFontPixelSize;
146 Incidence *mIncidence; // corresponding event or todo 147 Incidence *mIncidence; // corresponding event or todo
147 QDate mDate; //date this events occurs (for recurrence) 148 QDate mDate; //date this events occurs (for recurrence)
148 //void showIcon( QLabel*, int ); 149 //void showIcon( QLabel*, int );
149 //QLabel *mTodoIconLabel; 150 //QLabel *mTodoIconLabel;
150 //QLabel *mItemLabel; 151 //QLabel *mItemLabel;
151 //QWidget *mIconBox; 152 //QWidget *mIconBox;
152 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
153 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
154 //QLabel *mIconMoreInfo; 155 //QLabel *mIconMoreInfo;
155 static QToolTipGroup *mToolTipGroup; 156 static QToolTipGroup *mToolTipGroup;
156 157
157 QColor mBackgroundColor; 158 QColor mBackgroundColor;
158 QColorGroup mColorGroup; 159 QColorGroup mColorGroup;
159 QString mDisplayedText; 160 QString mDisplayedText;
160 bool mSelected; 161 bool mSelected;
161 QPtrList<KOAgendaItem> mConflictItems; 162 QPtrList<KOAgendaItem> mConflictItems;
162}; 163};
163 164
164#endif // KOAGENDAITEM_H 165#endif // KOAGENDAITEM_H