summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp124
-rw-r--r--korganizer/koagendaitem.cpp11
-rw-r--r--korganizer/koagendaview.cpp30
3 files changed, 93 insertions, 72 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 148d914..18c506e 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1174,461 +1174,451 @@ void KOAgenda::endItemAction()
1174 1174
1175 oldconflictItems = modifiedItem->conflictItems(); 1175 oldconflictItems = modifiedItem->conflictItems();
1176 for ( item=oldconflictItems.first(); item != 0; 1176 for ( item=oldconflictItems.first(); item != 0;
1177 item=oldconflictItems.next() ) { 1177 item=oldconflictItems.next() ) {
1178 globalFlagBlockAgendaItemUpdate = 0; 1178 globalFlagBlockAgendaItemUpdate = 0;
1179 item->paintMe(false); 1179 item->paintMe(false);
1180 globalFlagBlockAgendaItemUpdate = 1; 1180 globalFlagBlockAgendaItemUpdate = 1;
1181 item->repaint(false); 1181 item->repaint(false);
1182 } 1182 }
1183 */ 1183 */
1184 1184
1185 1185
1186 } 1186 }
1187 1187
1188 } 1188 }
1189 1189
1190 mScrollUpTimer.stop(); 1190 mScrollUpTimer.stop();
1191 mScrollDownTimer.stop(); 1191 mScrollDownTimer.stop();
1192 setCursor( arrowCursor ); 1192 setCursor( arrowCursor );
1193 mActionItem = 0; 1193 mActionItem = 0;
1194 mActionType = NOP; 1194 mActionType = NOP;
1195 mItemMoved = 0; 1195 mItemMoved = 0;
1196 1196
1197} 1197}
1198 1198
1199void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1199void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1200{ 1200{
1201// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1201// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1202// QPoint point = viewport()->mapToGlobal(viewportPos); 1202// QPoint point = viewport()->mapToGlobal(viewportPos);
1203// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1203// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1204// point = clipper()->mapFromGlobal(point); 1204// point = clipper()->mapFromGlobal(point);
1205// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1205// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1206 1206
1207 int x,y; 1207 int x,y;
1208 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1208 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1209// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1209// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1210 int gx,gy; 1210 int gx,gy;
1211 contentsToGrid(x,y,gx,gy); 1211 contentsToGrid(x,y,gx,gy);
1212 1212
1213 // Change cursor to resize cursor if appropriate 1213 // Change cursor to resize cursor if appropriate
1214 if (mAllDayMode) { 1214 if (mAllDayMode) {
1215 int gridDistanceX = (x - gx * mGridSpacingX); 1215 int gridDistanceX = (x - gx * mGridSpacingX);
1216 if (gridDistanceX < mResizeBorderWidth && 1216 if (gridDistanceX < mResizeBorderWidth &&
1217 moveItem->cellX() == gx) { 1217 moveItem->cellX() == gx) {
1218 setCursor(sizeHorCursor); 1218 setCursor(sizeHorCursor);
1219 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1219 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1220 moveItem->cellXWidth() == gx) { 1220 moveItem->cellXWidth() == gx) {
1221 setCursor(sizeHorCursor); 1221 setCursor(sizeHorCursor);
1222 } else { 1222 } else {
1223 setCursor(arrowCursor); 1223 setCursor(arrowCursor);
1224 } 1224 }
1225 } else { 1225 } else {
1226 int gridDistanceY = (y - gy * mGridSpacingY); 1226 int gridDistanceY = (y - gy * mGridSpacingY);
1227 if (gridDistanceY < mResizeBorderWidth && 1227 if (gridDistanceY < mResizeBorderWidth &&
1228 moveItem->cellYTop() == gy && 1228 moveItem->cellYTop() == gy &&
1229 !moveItem->firstMultiItem()) { 1229 !moveItem->firstMultiItem()) {
1230 setCursor(sizeVerCursor); 1230 setCursor(sizeVerCursor);
1231 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1231 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1232 moveItem->cellYBottom() == gy && 1232 moveItem->cellYBottom() == gy &&
1233 !moveItem->lastMultiItem()) { 1233 !moveItem->lastMultiItem()) {
1234 setCursor(sizeVerCursor); 1234 setCursor(sizeVerCursor);
1235 } else { 1235 } else {
1236 setCursor(arrowCursor); 1236 setCursor(arrowCursor);
1237 } 1237 }
1238 } 1238 }
1239} 1239}
1240 1240
1241 1241
1242/* 1242/*
1243 Place item in cell and take care that multiple items using the same cell do 1243 Place item in cell and take care that multiple items using the same cell do
1244 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1244 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1245 it can get in all cases. 1245 it can get in all cases.
1246 At the moment the method has a bug: When an item is placed only the sub cell 1246 At the moment the method has a bug: When an item is placed only the sub cell
1247 widths of the items are changed, which are within the Y region the item to 1247 widths of the items are changed, which are within the Y region the item to
1248 place spans. When the sub cell width change of one of this items affects a 1248 place spans. When the sub cell width change of one of this items affects a
1249 cell, where other items are, which do not overlap in Y with the item to place, 1249 cell, where other items are, which do not overlap in Y with the item to place,
1250 the display gets corrupted, although the corruption looks quite nice. 1250 the display gets corrupted, although the corruption looks quite nice.
1251*/ 1251*/
1252void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1252void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1253{ 1253{
1254 1254
1255 QPtrList<KOAgendaItem> conflictItems; 1255 QPtrList<KOAgendaItem> conflictItems;
1256 int maxSubCells = 0; 1256 int maxSubCells = 0;
1257 QIntDict<KOAgendaItem> subCellDict(5); 1257 QIntDict<KOAgendaItem> subCellDict(5);
1258 1258
1259 KOAgendaItem *item; 1259 KOAgendaItem *item;
1260 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1260 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1261 if (item != placeItem) { 1261 if (item != placeItem) {
1262 if (placeItem->cellX() <= item->cellXWidth() && 1262 if (placeItem->cellX() <= item->cellXWidth() &&
1263 placeItem->cellXWidth() >= item->cellX()) { 1263 placeItem->cellXWidth() >= item->cellX()) {
1264 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1264 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1265 (placeItem->cellYBottom() >= item->cellYTop())) { 1265 (placeItem->cellYBottom() >= item->cellYTop())) {
1266 conflictItems.append(item); 1266 conflictItems.append(item);
1267 if (item->subCells() > maxSubCells) 1267 if (item->subCells() > maxSubCells)
1268 maxSubCells = item->subCells(); 1268 maxSubCells = item->subCells();
1269 subCellDict.insert(item->subCell(),item); 1269 subCellDict.insert(item->subCell(),item);
1270 } 1270 }
1271 } 1271 }
1272 } 1272 }
1273 } 1273 }
1274 1274
1275 if (conflictItems.count() > 0) { 1275 if (conflictItems.count() > 0) {
1276 // Look for unused sub cell and insert item 1276 // Look for unused sub cell and insert item
1277 int i; 1277 int i;
1278 for(i=0;i<maxSubCells;++i) { 1278 for(i=0;i<maxSubCells;++i) {
1279 if (!subCellDict.find(i)) { 1279 if (!subCellDict.find(i)) {
1280 placeItem->setSubCell(i); 1280 placeItem->setSubCell(i);
1281 break; 1281 break;
1282 } 1282 }
1283 } 1283 }
1284 if (i == maxSubCells) { 1284 if (i == maxSubCells) {
1285 placeItem->setSubCell(maxSubCells); 1285 placeItem->setSubCell(maxSubCells);
1286 maxSubCells++; // add new item to number of sub cells 1286 maxSubCells++; // add new item to number of sub cells
1287 } 1287 }
1288 1288
1289 // Prepare for sub cell geometry adjustment 1289 // Prepare for sub cell geometry adjustment
1290 int newSubCellWidth; 1290 int newSubCellWidth;
1291 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1291 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1292 else newSubCellWidth = mGridSpacingX / maxSubCells; 1292 else newSubCellWidth = mGridSpacingX / maxSubCells;
1293 conflictItems.append(placeItem); 1293 conflictItems.append(placeItem);
1294 1294
1295 1295
1296 // Adjust sub cell geometry of all direct conflict items 1296 // Adjust sub cell geometry of all direct conflict items
1297 for ( item=conflictItems.first(); item != 0; 1297 for ( item=conflictItems.first(); item != 0;
1298 item=conflictItems.next() ) { 1298 item=conflictItems.next() ) {
1299 item->setSubCells(maxSubCells); 1299 item->setSubCells(maxSubCells);
1300 if (mAllDayMode) { 1300 if (mAllDayMode) {
1301 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1301 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1302 } else { 1302 } else {
1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1304 } 1304 }
1305 int x,y; 1305 int x,y;
1306 gridToContents(item->cellX(),item->cellYTop(),x,y); 1306 gridToContents(item->cellX(),item->cellYTop(),x,y);
1307 if (mAllDayMode) { 1307 if (mAllDayMode) {
1308 y += item->subCell() * newSubCellWidth; 1308 y += item->subCell() * newSubCellWidth;
1309 } else { 1309 } else {
1310 x += item->subCell() * newSubCellWidth; 1310 x += item->subCell() * newSubCellWidth;
1311 } 1311 }
1312 moveChild(item,x,y); 1312 moveChild(item,x,y);
1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1314 //item->updateItem(); 1314 //item->updateItem();
1315 } 1315 }
1316 // Adjust sub cell geometry of all conflict items of all conflict items 1316 // Adjust sub cell geometry of all conflict items of all conflict items
1317 for ( item=conflictItems.first(); item != 0; 1317 for ( item=conflictItems.first(); item != 0;
1318 item=conflictItems.next() ) { 1318 item=conflictItems.next() ) {
1319 if ( placeItem != item ) { 1319 if ( placeItem != item ) {
1320 KOAgendaItem *item2; 1320 KOAgendaItem *item2;
1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1322 for ( item2=conflictItems2.first(); item2 != 0; 1322 for ( item2=conflictItems2.first(); item2 != 0;
1323 item2=conflictItems2.next() ) { 1323 item2=conflictItems2.next() ) {
1324 if ( item2->subCells() != maxSubCells) { 1324 if ( item2->subCells() != maxSubCells) {
1325 item2->setSubCells(maxSubCells); 1325 item2->setSubCells(maxSubCells);
1326 if (mAllDayMode) { 1326 if (mAllDayMode) {
1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1328 } else { 1328 } else {
1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1330 } 1330 }
1331 int x,y; 1331 int x,y;
1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1333 if (mAllDayMode) { 1333 if (mAllDayMode) {
1334 y += item2->subCell() * newSubCellWidth; 1334 y += item2->subCell() * newSubCellWidth;
1335 } else { 1335 } else {
1336 x += item2->subCell() * newSubCellWidth; 1336 x += item2->subCell() * newSubCellWidth;
1337 } 1337 }
1338 moveChild(item2,x,y); 1338 moveChild(item2,x,y);
1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1340 } 1340 }
1341 } 1341 }
1342 } 1342 }
1343 } 1343 }
1344 } else { 1344 } else {
1345 placeItem->setSubCell(0); 1345 placeItem->setSubCell(0);
1346 placeItem->setSubCells(1); 1346 placeItem->setSubCells(1);
1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1348 else placeItem->resize(mGridSpacingX,placeItem->height()); 1348 else placeItem->resize(mGridSpacingX,placeItem->height());
1349 int x,y; 1349 int x,y;
1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1351 moveChild(placeItem,x,y); 1351 moveChild(placeItem,x,y);
1352 } 1352 }
1353 placeItem->setConflictItems(conflictItems); 1353 placeItem->setConflictItems(conflictItems);
1354 // for ( item=conflictItems.first(); item != 0; 1354 // for ( item=conflictItems.first(); item != 0;
1355// item=conflictItems.next() ) { 1355// item=conflictItems.next() ) {
1356// //item->updateItem(); 1356// //item->updateItem();
1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1358// } 1358// }
1359// placeItem->updateItem(); 1359// placeItem->updateItem();
1360} 1360}
1361 1361
1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1363{ 1363{
1364 if ( globalFlagBlockAgenda ) 1364 if ( globalFlagBlockAgenda )
1365 return; 1365 return;
1366 //qDebug("KOAgenda::drawContents "); 1366 if ( ! mAllDayMode ) {
1367 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1367 // currently not working for
1368 ;//drawContentsToPainter();
1369 1368
1370 QPaintDevice* pd = p->device(); 1369 //qDebug("KOAgenda::drawContents ");
1371 p->end(); 1370 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1372 int vx, vy; 1371 ;//drawContentsToPainter();
1373 int selectionX = KOGlobals::self()->reverseLayout() ? 1372
1373 QPaintDevice* pd = p->device();
1374 p->end();
1375 int vx, vy;
1376 int selectionX = KOGlobals::self()->reverseLayout() ?
1374 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1377 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1375 mSelectionCellX * mGridSpacingX; 1378 mSelectionCellX * mGridSpacingX;
1376 contentsToViewport ( cx, cy, vx,vy); 1379 contentsToViewport ( cx, cy, vx,vy);
1377 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1380 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1378 1381
1379 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1382 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1380 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1383 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1381 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1384 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1382 1385
1383 int vxSel, vySel; 1386 int vxSel, vySel;
1384 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1387 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1385 int off = mSelectionHeight; 1388 int off = mSelectionHeight;
1386 if ( vySel < 0 ) 1389 if ( vySel < 0 )
1387 off += vySel; 1390 off += vySel;
1388 //qDebug("OFF %d %d %d", off,vySel, vy ); 1391 //qDebug("OFF %d %d %d", off,vySel, vy );
1389 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1392 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1390 } else { 1393 } else {
1391 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1394 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1395 }
1392 } 1396 }
1393 } 1397 if ( mSelectionHeight > 0 ) {
1394 if ( mSelectionHeight > 0 ) { 1398 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1395 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1399 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1396 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1400 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1397 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1401 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1398 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1402 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1399 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1403 }
1400 } 1404 }
1401 } 1405 p->begin( pd );
1402 //qDebug("btbl "); 1406 } else {
1403 p->begin( pd ); 1407
1404 //qDebug("end "); 1408 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1405#if 0 1409 ;//drawContentsToPainter();
1406
1407 if ( globalFlagBlockAgenda )
1408 return;
1409 //qDebug("KOAgenda::drawContents ");
1410 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1411 ;//drawContentsToPainter();
1412 1410
1413 QPaintDevice* pd = p->device(); 1411 QPaintDevice* pd = p->device();
1414 p->end(); 1412 p->end();
1415 int vx, vy; 1413 int vx, vy;
1416 int selectionX = KOGlobals::self()->reverseLayout() ? 1414 int selectionX = KOGlobals::self()->reverseLayout() ?
1417 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1415 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1418 mSelectionCellX * mGridSpacingX; 1416 mSelectionCellX * mGridSpacingX;
1419 contentsToViewport ( cx, cy, vx,vy); 1417 contentsToViewport ( cx, cy, vx,vy);
1420 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1418 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1421 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1419 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1422 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1420 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1423 1421
1424 if ( mSelectionHeight > 0 ) { 1422 if ( mSelectionHeight > 0 ) {
1425 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1423 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1426 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1424 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1427 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1425 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1428 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1426 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1429 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1427 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1430 } 1428 }
1431 } 1429 }
1432 //qDebug("btbl "); 1430 p->begin( pd );
1433 p->begin( pd ); 1431 }
1434 //qDebug("end ");
1435
1436
1437
1438
1439
1440
1441 1432
1442#endif
1443} 1433}
1444 1434
1445void KOAgenda::finishUpdate() 1435void KOAgenda::finishUpdate()
1446{ 1436{
1447 1437
1448 KOAgendaItem *item; 1438 KOAgendaItem *item;
1449 globalFlagBlockAgendaItemPaint = 1; 1439 globalFlagBlockAgendaItemPaint = 1;
1450 // 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 1440 // 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
1451 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1441 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1452 if ( !item->checkLayout() ) { 1442 if ( !item->checkLayout() ) {
1453 //qDebug(" conflictitem found "); 1443 //qDebug(" conflictitem found ");
1454 int newSubCellWidth; 1444 int newSubCellWidth;
1455 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1445 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1456 else newSubCellWidth = mGridSpacingX / item->subCells(); 1446 else newSubCellWidth = mGridSpacingX / item->subCells();
1457 1447
1458 if (mAllDayMode) { 1448 if (mAllDayMode) {
1459 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1449 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1460 } else { 1450 } else {
1461 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1451 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1462 } 1452 }
1463 int x,y; 1453 int x,y;
1464 gridToContents(item->cellX(),item->cellYTop(),x,y); 1454 gridToContents(item->cellX(),item->cellYTop(),x,y);
1465 if (mAllDayMode) { 1455 if (mAllDayMode) {
1466 y += item->subCell() * newSubCellWidth; 1456 y += item->subCell() * newSubCellWidth;
1467 } else { 1457 } else {
1468 x += item->subCell() * newSubCellWidth; 1458 x += item->subCell() * newSubCellWidth;
1469 } 1459 }
1470 moveChild(item,x,y); 1460 moveChild(item,x,y);
1471 } 1461 }
1472 } 1462 }
1473 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1463 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1474 if ( !item->isVisible() ) 1464 if ( !item->isVisible() )
1475 item->show(); 1465 item->show();
1476 1466
1477 } 1467 }
1478 globalFlagBlockAgendaItemUpdate = 0; 1468 globalFlagBlockAgendaItemUpdate = 0;
1479 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1469 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1480 item->repaintMe( ); 1470 item->repaintMe( );
1481 } 1471 }
1482 globalFlagBlockAgendaItemUpdate = 1; 1472 globalFlagBlockAgendaItemUpdate = 1;
1483 qApp->processEvents(); 1473 qApp->processEvents();
1484 globalFlagBlockAgendaItemPaint = 0; 1474 globalFlagBlockAgendaItemPaint = 0;
1485 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1475 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1486 item->repaint( false ); 1476 item->repaint( false );
1487 } 1477 }
1488 1478
1489} 1479}
1490 1480
1491/* 1481/*
1492 Draw grid in the background of the agenda. 1482 Draw grid in the background of the agenda.
1493*/ 1483*/
1494void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1484void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1495{ 1485{
1496 1486
1497 1487
1498 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1488 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1499 return; 1489 return;
1500 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1490 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1501 return; 1491 return;
1502 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1492 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1503 if ( ch < 1 ) 1493 if ( ch < 1 )
1504 ch = 1; 1494 ch = 1;
1505 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1495 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1506 mPaintPixmap.resize( contentsWidth()+42, ch ); 1496 mPaintPixmap.resize( contentsWidth()+42, ch );
1507 } 1497 }
1508 mCurPixWid = contentsWidth(); 1498 mCurPixWid = contentsWidth();
1509 mCurPixHei = ch; 1499 mCurPixHei = ch;
1510 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1500 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1511 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1501 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1512 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1502 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1513 } 1503 }
1514 mPixPainter.begin( &mPaintPixmap) ; 1504 mPixPainter.begin( &mPaintPixmap) ;
1515 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1505 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1516 QPainter * p ; 1506 QPainter * p ;
1517 if (paint == 0) { 1507 if (paint == 0) {
1518 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1508 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1519 p = &mPixPainter; 1509 p = &mPixPainter;
1520 } 1510 }
1521 else 1511 else
1522 p = paint ; 1512 p = paint ;
1523 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1513 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1524 1514
1525 //--cx;++cw; 1515 //--cx;++cw;
1526 int lGridSpacingY = mGridSpacingY*2; 1516 int lGridSpacingY = mGridSpacingY*2;
1527 int selDay; 1517 int selDay;
1528 if ( !backgroundOnly ) 1518 if ( !backgroundOnly )
1529 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1519 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1530 { 1520 {
1531 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1521 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1532 int x1 = cx; 1522 int x1 = cx;
1533 int y1 = 0; 1523 int y1 = 0;
1534 if (y1 < cy) y1 = cy; 1524 if (y1 < cy) y1 = cy;
1535 int x2 = cx+cw-1; 1525 int x2 = cx+cw-1;
1536 int y2 = contentsHeight(); 1526 int y2 = contentsHeight();
1537 if (y2 > cy+ch-1) y2=cy+ch-1; 1527 if (y2 > cy+ch-1) y2=cy+ch-1;
1538 if (x2 >= x1 && y2 >= y1) { 1528 if (x2 >= x1 && y2 >= y1) {
1539 int gxStart = selDay; 1529 int gxStart = selDay;
1540 int gxEnd = gxStart ; 1530 int gxEnd = gxStart ;
1541 int xStart = KOGlobals::self()->reverseLayout() ? 1531 int xStart = KOGlobals::self()->reverseLayout() ?
1542 (mColumns - 1 - gxStart)*mGridSpacingX : 1532 (mColumns - 1 - gxStart)*mGridSpacingX :
1543 gxStart*mGridSpacingX; 1533 gxStart*mGridSpacingX;
1544 if (xStart < x1) xStart = x1; 1534 if (xStart < x1) xStart = x1;
1545 int xEnd = KOGlobals::self()->reverseLayout() ? 1535 int xEnd = KOGlobals::self()->reverseLayout() ?
1546 (mColumns - gxStart)*mGridSpacingX-1 : 1536 (mColumns - gxStart)*mGridSpacingX-1 :
1547 (gxStart+1)*mGridSpacingX-1; 1537 (gxStart+1)*mGridSpacingX-1;
1548 if (xEnd > x2) xEnd = x2; 1538 if (xEnd > x2) xEnd = x2;
1549 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1539 if ( KOPrefs::instance()->mUseHighlightLightColor )
1550 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1540 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1551 KOPrefs::instance()->mAgendaBgColor.light()); 1541 KOPrefs::instance()->mAgendaBgColor.light());
1552 else 1542 else
1553 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1543 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1554 KOPrefs::instance()->mAgendaBgColor.dark()); 1544 KOPrefs::instance()->mAgendaBgColor.dark());
1555 1545
1556 } 1546 }
1557 } 1547 }
1558 } 1548 }
1559 // Highlight working hours 1549 // Highlight working hours
1560 1550
1561 if ( !backgroundOnly ) 1551 if ( !backgroundOnly )
1562 if (mWorkingHoursEnable) { 1552 if (mWorkingHoursEnable) {
1563 int x1 = cx; 1553 int x1 = cx;
1564 int y1 = mWorkingHoursYTop; 1554 int y1 = mWorkingHoursYTop;
1565 if (y1 < cy) y1 = cy; 1555 if (y1 < cy) y1 = cy;
1566 int x2 = cx+cw-1; 1556 int x2 = cx+cw-1;
1567 // int x2 = mGridSpacingX * 5 - 1; 1557 // int x2 = mGridSpacingX * 5 - 1;
1568 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1558 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1569 int y2 = mWorkingHoursYBottom; 1559 int y2 = mWorkingHoursYBottom;
1570 if (y2 > cy+ch-1) y2=cy+ch-1; 1560 if (y2 > cy+ch-1) y2=cy+ch-1;
1571 1561
1572 if (x2 >= x1 && y2 >= y1) { 1562 if (x2 >= x1 && y2 >= y1) {
1573 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1563 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1574 int gxStart = x1/mGridSpacingX; 1564 int gxStart = x1/mGridSpacingX;
1575 int gxEnd = x2/mGridSpacingX; 1565 int gxEnd = x2/mGridSpacingX;
1576 while(gxStart <= gxEnd) { 1566 while(gxStart <= gxEnd) {
1577 if (gxStart < int(mHolidayMask->count()) && 1567 if (gxStart < int(mHolidayMask->count()) &&
1578 !mHolidayMask->at(gxStart)) { 1568 !mHolidayMask->at(gxStart)) {
1579 int xStart = KOGlobals::self()->reverseLayout() ? 1569 int xStart = KOGlobals::self()->reverseLayout() ?
1580 (mColumns - 1 - gxStart)*mGridSpacingX : 1570 (mColumns - 1 - gxStart)*mGridSpacingX :
1581 gxStart*mGridSpacingX; 1571 gxStart*mGridSpacingX;
1582 if (xStart < x1) xStart = x1; 1572 if (xStart < x1) xStart = x1;
1583 int xEnd = KOGlobals::self()->reverseLayout() ? 1573 int xEnd = KOGlobals::self()->reverseLayout() ?
1584 (mColumns - gxStart)*mGridSpacingX-1 : 1574 (mColumns - gxStart)*mGridSpacingX-1 :
1585 (gxStart+1)*mGridSpacingX-1; 1575 (gxStart+1)*mGridSpacingX-1;
1586 if (xEnd > x2) xEnd = x2; 1576 if (xEnd > x2) xEnd = x2;
1587 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1577 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1588 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1578 if ( KOPrefs::instance()->mUseHighlightLightColor )
1589 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1579 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1590 KOPrefs::instance()->mWorkingHoursColor.light()); 1580 KOPrefs::instance()->mWorkingHoursColor.light());
1591 else 1581 else
1592 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1582 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1593 KOPrefs::instance()->mWorkingHoursColor.dark()); 1583 KOPrefs::instance()->mWorkingHoursColor.dark());
1594 } else { 1584 } else {
1595 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1585 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1596 KOPrefs::instance()->mWorkingHoursColor); 1586 KOPrefs::instance()->mWorkingHoursColor);
1597 } 1587 }
1598 } 1588 }
1599 ++gxStart; 1589 ++gxStart;
1600 } 1590 }
1601 } 1591 }
1602 } 1592 }
1603 /* 1593 /*
1604 int selectionX = KOGlobals::self()->reverseLayout() ? 1594 int selectionX = KOGlobals::self()->reverseLayout() ?
1605 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1595 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1606 mSelectionCellX * mGridSpacingX; 1596 mSelectionCellX * mGridSpacingX;
1607 1597
1608 // Draw selection 1598 // Draw selection
1609 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1599 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1610 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1600 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1611 // TODO: paint only part within cx,cy,cw,ch 1601 // TODO: paint only part within cx,cy,cw,ch
1612 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1602 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1613 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1603 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1614 } 1604 }
1615 */ 1605 */
1616 // Draw vertical lines of grid 1606 // Draw vertical lines of grid
1617 1607
1618 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1608 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1619 if ( mGridSpacingX > 0 ) { 1609 if ( mGridSpacingX > 0 ) {
1620 while (x < cx + cw) { 1610 while (x < cx + cw) {
1621 p->drawLine(x,cy,x,cy+ch); 1611 p->drawLine(x,cy,x,cy+ch);
1622 x+=mGridSpacingX; 1612 x+=mGridSpacingX;
1623 } 1613 }
1624 } 1614 }
1625 // Draw horizontal lines of grid 1615 // Draw horizontal lines of grid
1626 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1616 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1627 if ( lGridSpacingY > 0 ) { 1617 if ( lGridSpacingY > 0 ) {
1628 while (y < cy + ch) { 1618 while (y < cy + ch) {
1629 p->setPen( SolidLine ); 1619 p->setPen( SolidLine );
1630 p->drawLine(cx,y,cx+cw,y); 1620 p->drawLine(cx,y,cx+cw,y);
1631 y+=lGridSpacingY; 1621 y+=lGridSpacingY;
1632 p->setPen( DotLine ); 1622 p->setPen( DotLine );
1633 p->drawLine(cx,y,cx+cw,y); 1623 p->drawLine(cx,y,cx+cw,y);
1634 y+=lGridSpacingY; 1624 y+=lGridSpacingY;
@@ -1778,385 +1768,385 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1778 globalFlagBlockAgendaItemUpdate = 1; 1768 globalFlagBlockAgendaItemUpdate = 1;
1779 itemit->repaint(); 1769 itemit->repaint();
1780 } 1770 }
1781 blockSignals( false ); 1771 blockSignals( false );
1782 } 1772 }
1783 if ( remove ) { 1773 if ( remove ) {
1784 //qDebug("remove****************************************** "); 1774 //qDebug("remove****************************************** ");
1785 return; 1775 return;
1786 } 1776 }
1787 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1777 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1788 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1778 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1789 QDate currentDate; 1779 QDate currentDate;
1790 QDateTime dt; 1780 QDateTime dt;
1791 if ( todo->hasCompletedDate() ) 1781 if ( todo->hasCompletedDate() )
1792 dt = todo->completed(); 1782 dt = todo->completed();
1793 else 1783 else
1794 dt = todo->dtDue(); 1784 dt = todo->dtDue();
1795 if ( overdue ) { 1785 if ( overdue ) {
1796 currentDate = QDate::currentDate(); 1786 currentDate = QDate::currentDate();
1797 days += todo->dtDue().date().daysTo( currentDate ); 1787 days += todo->dtDue().date().daysTo( currentDate );
1798 } 1788 }
1799 else 1789 else
1800 currentDate = dt.date(); 1790 currentDate = dt.date();
1801 1791
1802 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1792 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1803 if ( ! mAllDayMode ) return; 1793 if ( ! mAllDayMode ) return;
1804 // aldayagenda 1794 // aldayagenda
1805 globalFlagBlockAgendaItemPaint = 1; 1795 globalFlagBlockAgendaItemPaint = 1;
1806 item = insertAllDayItem(todo, currentDate,days, days); 1796 item = insertAllDayItem(todo, currentDate,days, days);
1807 item->show(); 1797 item->show();
1808 1798
1809 } 1799 }
1810 else { 1800 else {
1811 if ( mAllDayMode ) return; 1801 if ( mAllDayMode ) return;
1812 // mAgenda 1802 // mAgenda
1813 globalFlagBlockAgendaItemPaint = 1; 1803 globalFlagBlockAgendaItemPaint = 1;
1814 int endY = timeToY(dt.time()) - 1; 1804 int endY = timeToY(dt.time()) - 1;
1815 int hi = 12/KOPrefs::instance()->mHourSize; 1805 int hi = 12/KOPrefs::instance()->mHourSize;
1816 int startY = endY - 1-hi; 1806 int startY = endY - 1-hi;
1817 item = insertItem(todo,currentDate,days,startY,endY); 1807 item = insertItem(todo,currentDate,days,startY,endY);
1818 item->show(); 1808 item->show();
1819 } 1809 }
1820 qApp->processEvents(); 1810 qApp->processEvents();
1821 globalFlagBlockAgendaItemPaint = 0; 1811 globalFlagBlockAgendaItemPaint = 0;
1822 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1812 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1823 KOAgendaItem *itemit; 1813 KOAgendaItem *itemit;
1824 for ( itemit=oldconflictItems.first(); itemit != 0; 1814 for ( itemit=oldconflictItems.first(); itemit != 0;
1825 itemit=oldconflictItems.next() ) { 1815 itemit=oldconflictItems.next() ) {
1826 globalFlagBlockAgendaItemUpdate = 0; 1816 globalFlagBlockAgendaItemUpdate = 0;
1827 itemit->repaintMe(); 1817 itemit->repaintMe();
1828 globalFlagBlockAgendaItemUpdate = 1; 1818 globalFlagBlockAgendaItemUpdate = 1;
1829 itemit->repaint(); 1819 itemit->repaint();
1830 } 1820 }
1831 globalFlagBlockAgendaItemUpdate = 0; 1821 globalFlagBlockAgendaItemUpdate = 0;
1832 item->repaintMe(); 1822 item->repaintMe();
1833 globalFlagBlockAgendaItemUpdate = 1; 1823 globalFlagBlockAgendaItemUpdate = 1;
1834 item->repaint(); 1824 item->repaint();
1835} 1825}
1836/* 1826/*
1837 Insert KOAgendaItem into agenda. 1827 Insert KOAgendaItem into agenda.
1838*/ 1828*/
1839KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1829KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1840{ 1830{
1841 if (mAllDayMode) { 1831 if (mAllDayMode) {
1842 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1832 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1843 return 0; 1833 return 0;
1844 } 1834 }
1845 1835
1846 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1836 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1847 //agendaItem->setFrameStyle(WinPanel|Raised); 1837 //agendaItem->setFrameStyle(WinPanel|Raised);
1848 1838
1849 int YSize = YBottom - YTop + 1; 1839 int YSize = YBottom - YTop + 1;
1850 if (YSize < 0) { 1840 if (YSize < 0) {
1851 YSize = 1; 1841 YSize = 1;
1852 } 1842 }
1853 int iheight = mGridSpacingY * YSize; 1843 int iheight = mGridSpacingY * YSize;
1854 1844
1855 agendaItem->resize(mGridSpacingX,iheight ); 1845 agendaItem->resize(mGridSpacingX,iheight );
1856 agendaItem->setCellXY(X,YTop,YBottom); 1846 agendaItem->setCellXY(X,YTop,YBottom);
1857 agendaItem->setCellXWidth(X); 1847 agendaItem->setCellXWidth(X);
1858 1848
1859 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1849 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1860 mItems.append(agendaItem); 1850 mItems.append(agendaItem);
1861 1851
1862 placeSubCells(agendaItem); 1852 placeSubCells(agendaItem);
1863 1853
1864 //agendaItem->show(); 1854 //agendaItem->show();
1865 1855
1866 marcus_bains(); 1856 marcus_bains();
1867 1857
1868 return agendaItem; 1858 return agendaItem;
1869} 1859}
1870 1860
1871 1861
1872/* 1862/*
1873 Insert all-day KOAgendaItem into agenda. 1863 Insert all-day KOAgendaItem into agenda.
1874*/ 1864*/
1875KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1865KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1876{ 1866{
1877 if (!mAllDayMode) { 1867 if (!mAllDayMode) {
1878 return 0; 1868 return 0;
1879 } 1869 }
1880 1870
1881 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1871 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1882 1872
1883 agendaItem->setCellXY(XBegin,0,0); 1873 agendaItem->setCellXY(XBegin,0,0);
1884 agendaItem->setCellXWidth(XEnd); 1874 agendaItem->setCellXWidth(XEnd);
1885 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1875 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1886 1876
1887 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1877 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1888 mItems.append(agendaItem); 1878 mItems.append(agendaItem);
1889 1879
1890 placeSubCells(agendaItem); 1880 placeSubCells(agendaItem);
1891 1881
1892 //agendaItem->show(); 1882 //agendaItem->show();
1893 1883
1894 return agendaItem; 1884 return agendaItem;
1895} 1885}
1896 1886
1897 1887
1898void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1888void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1899 int YTop,int YBottom) 1889 int YTop,int YBottom)
1900{ 1890{
1901 if (mAllDayMode) { 1891 if (mAllDayMode) {
1902 ; 1892 ;
1903 return; 1893 return;
1904 } 1894 }
1905 1895
1906 int cellX,cellYTop,cellYBottom; 1896 int cellX,cellYTop,cellYBottom;
1907 QString newtext; 1897 QString newtext;
1908 int width = XEnd - XBegin + 1; 1898 int width = XEnd - XBegin + 1;
1909 int count = 0; 1899 int count = 0;
1910 KOAgendaItem *current = 0; 1900 KOAgendaItem *current = 0;
1911 QPtrList<KOAgendaItem> multiItems; 1901 QPtrList<KOAgendaItem> multiItems;
1912 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1902 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1913 if (cellX == XBegin) cellYTop = YTop; 1903 if (cellX == XBegin) cellYTop = YTop;
1914 else cellYTop = 0; 1904 else cellYTop = 0;
1915 if (cellX == XEnd) cellYBottom = YBottom; 1905 if (cellX == XEnd) cellYBottom = YBottom;
1916 else cellYBottom = rows() - 1; 1906 else cellYBottom = rows() - 1;
1917 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1907 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1918 newtext.append(event->summary()); 1908 newtext.append(event->summary());
1919 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1909 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1920 current->setText(newtext); 1910 current->setText(newtext);
1921 multiItems.append(current); 1911 multiItems.append(current);
1922 } 1912 }
1923 1913
1924 KOAgendaItem *next = 0; 1914 KOAgendaItem *next = 0;
1925 KOAgendaItem *last = multiItems.last(); 1915 KOAgendaItem *last = multiItems.last();
1926 KOAgendaItem *first = multiItems.first(); 1916 KOAgendaItem *first = multiItems.first();
1927 KOAgendaItem *setFirst,*setLast; 1917 KOAgendaItem *setFirst,*setLast;
1928 current = first; 1918 current = first;
1929 while (current) { 1919 while (current) {
1930 next = multiItems.next(); 1920 next = multiItems.next();
1931 if (current == first) setFirst = 0; 1921 if (current == first) setFirst = 0;
1932 else setFirst = first; 1922 else setFirst = first;
1933 if (current == last) setLast = 0; 1923 if (current == last) setLast = 0;
1934 else setLast = last; 1924 else setLast = last;
1935 1925
1936 current->setMultiItem(setFirst,next,setLast); 1926 current->setMultiItem(setFirst,next,setLast);
1937 current = next; 1927 current = next;
1938 } 1928 }
1939 1929
1940 marcus_bains(); 1930 marcus_bains();
1941} 1931}
1942 1932
1943 1933
1944//QSizePolicy KOAgenda::sizePolicy() const 1934//QSizePolicy KOAgenda::sizePolicy() const
1945//{ 1935//{
1946 // Thought this would make the all-day event agenda minimum size and the 1936 // Thought this would make the all-day event agenda minimum size and the
1947 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1937 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1948 // don´t seem to think that an Expanding widget needs more space than a 1938 // don´t seem to think that an Expanding widget needs more space than a
1949 // Preferred one. 1939 // Preferred one.
1950 // But it doesn´t hurt, so it stays. 1940 // But it doesn´t hurt, so it stays.
1951// if (mAllDayMode) { 1941// if (mAllDayMode) {
1952// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1942// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1953// } else { 1943// } else {
1954// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1944// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1955// } 1945// }
1956//} 1946//}
1957void KOAgenda::finishResize ( ) 1947void KOAgenda::finishResize ( )
1958{ 1948{
1959 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1949 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1960 if ( globalFlagBlockAgenda == 0 ) { 1950 if ( globalFlagBlockAgenda == 0 ) {
1961 finishUpdate(); 1951 finishUpdate();
1962 //qDebug("finishUpdate() called "); 1952 //qDebug("finishUpdate() called ");
1963 } 1953 }
1964} 1954}
1965/* 1955/*
1966 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1956 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1967*/ 1957*/
1968void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1958void KOAgenda::resizeEvent ( QResizeEvent *ev )
1969{ 1959{
1970 1960 mSelectionHeight = 0;
1971 mResizeTimer.start( 150 , true ); 1961 mResizeTimer.start( 150 , true );
1972 computeSizes(); 1962 computeSizes();
1973 return; 1963 return;
1974 1964
1975} 1965}
1976void KOAgenda::computeSizes() 1966void KOAgenda::computeSizes()
1977{ 1967{
1978 if ( globalFlagBlockStartup ) 1968 if ( globalFlagBlockStartup )
1979 return; 1969 return;
1980 int frameOffset = frameWidth() * 2 +1; 1970 int frameOffset = frameWidth() * 2 +1;
1981 if (mAllDayMode) { 1971 if (mAllDayMode) {
1982 mGridSpacingX = (width()-frameOffset) / mColumns; 1972 mGridSpacingX = (width()-frameOffset) / mColumns;
1983 mGridSpacingY = height() - 2 * frameWidth() - 1; 1973 mGridSpacingY = height() - 2 * frameWidth() - 1;
1984 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1974 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1985 // mGridSpacingY = height(); 1975 // mGridSpacingY = height();
1986 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1976 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1987 1977
1988 KOAgendaItem *item; 1978 KOAgendaItem *item;
1989 int subCellWidth; 1979 int subCellWidth;
1990 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1980 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1991 subCellWidth = mGridSpacingY / item->subCells(); 1981 subCellWidth = mGridSpacingY / item->subCells();
1992 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1982 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1993 moveChild(item,KOGlobals::self()->reverseLayout() ? 1983 moveChild(item,KOGlobals::self()->reverseLayout() ?
1994 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1984 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1995 item->cellX() * mGridSpacingX, 1985 item->cellX() * mGridSpacingX,
1996 item->subCell() * subCellWidth); 1986 item->subCell() * subCellWidth);
1997 } 1987 }
1998 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1988 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1999 } else { 1989 } else {
2000 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1990 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
2001 if (height() > mGridSpacingY * mRows + 1 ) { 1991 if (height() > mGridSpacingY * mRows + 1 ) {
2002 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1992 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
2003 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1993 mGridSpacingY = KOPrefs::instance()->mHourSize ;
2004 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1994 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
2005 emit resizedSignal(); 1995 emit resizedSignal();
2006 } else 1996 } else
2007 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1997 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
2008 KOAgendaItem *item; 1998 KOAgendaItem *item;
2009 int subCellWidth; 1999 int subCellWidth;
2010 2000
2011 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2001 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2012 subCellWidth = mGridSpacingX / item->subCells(); 2002 subCellWidth = mGridSpacingX / item->subCells();
2013 item->resize(subCellWidth,item->height()); 2003 item->resize(subCellWidth,item->height());
2014 moveChild(item,(KOGlobals::self()->reverseLayout() ? 2004 moveChild(item,(KOGlobals::self()->reverseLayout() ?
2015 (mColumns - 1 - item->cellX()) * mGridSpacingX : 2005 (mColumns - 1 - item->cellX()) * mGridSpacingX :
2016 item->cellX() * mGridSpacingX) + 2006 item->cellX() * mGridSpacingX) +
2017 item->subCell() * subCellWidth,childY(item)); 2007 item->subCell() * subCellWidth,childY(item));
2018 } 2008 }
2019 } 2009 }
2020 int cw = contentsWidth(); 2010 int cw = contentsWidth();
2021 int ch = contentsHeight(); 2011 int ch = contentsHeight();
2022 if ( mAllDayMode ) { 2012 if ( mAllDayMode ) {
2023 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 2013 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
2024 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 2014 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
2025 paintPixAll->resize( cw, ch ); 2015 paintPixAll->resize( cw, ch );
2026 } else { 2016 } else {
2027 QPixmap* paintPix = KOAgendaItem::paintPix(); 2017 QPixmap* paintPix = KOAgendaItem::paintPix();
2028 if ( paintPix->width() < cw || paintPix->height() < ch ) 2018 if ( paintPix->width() < cw || paintPix->height() < ch )
2029 KOAgendaItem::resizePixmap( cw , ch ); 2019 KOAgendaItem::resizePixmap( cw , ch );
2030 } 2020 }
2031 2021
2032 checkScrollBoundaries(); 2022 checkScrollBoundaries();
2033 marcus_bains(); 2023 marcus_bains();
2034 drawContentsToPainter(); 2024 drawContentsToPainter();
2035 viewport()->repaint(false); 2025 viewport()->repaint(false);
2036} 2026}
2037 2027
2038void KOAgenda::scrollUp() 2028void KOAgenda::scrollUp()
2039{ 2029{
2040 scrollBy(0,-mScrollOffset); 2030 scrollBy(0,-mScrollOffset);
2041} 2031}
2042 2032
2043 2033
2044void KOAgenda::scrollDown() 2034void KOAgenda::scrollDown()
2045{ 2035{
2046 scrollBy(0,mScrollOffset); 2036 scrollBy(0,mScrollOffset);
2047} 2037}
2048 2038
2049void KOAgenda::popupAlarm() 2039void KOAgenda::popupAlarm()
2050{ 2040{
2051 if (!mClickedItem) { 2041 if (!mClickedItem) {
2052 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 2042 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
2053 return; 2043 return;
2054 } 2044 }
2055 // TODO: deal correctly with multiple alarms 2045 // TODO: deal correctly with multiple alarms
2056 Alarm* alarm; 2046 Alarm* alarm;
2057 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 2047 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
2058 for(alarm=list.first();alarm;alarm=list.next()) { 2048 for(alarm=list.first();alarm;alarm=list.next()) {
2059 alarm->toggleAlarm(); 2049 alarm->toggleAlarm();
2060 } 2050 }
2061 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2051 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2062 mClickedItem->paintMe( true ); 2052 mClickedItem->paintMe( true );
2063 mClickedItem->repaint( false ); 2053 mClickedItem->repaint( false );
2064} 2054}
2065 2055
2066/* 2056/*
2067 Calculates the minimum width 2057 Calculates the minimum width
2068*/ 2058*/
2069int KOAgenda::minimumWidth() const 2059int KOAgenda::minimumWidth() const
2070{ 2060{
2071 // TODO:: develop a way to dynamically determine the minimum width 2061 // TODO:: develop a way to dynamically determine the minimum width
2072 int min = 100; 2062 int min = 100;
2073 2063
2074 return min; 2064 return min;
2075} 2065}
2076 2066
2077void KOAgenda::updateConfig() 2067void KOAgenda::updateConfig()
2078{ 2068{
2079 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2069 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
2080 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2070 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
2081 if ( mAllDayMode ) { 2071 if ( mAllDayMode ) {
2082 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 2072 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
2083 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 2073 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
2084 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 2074 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
2085 // setMaximumHeight( mGridSpacingY+1 ); 2075 // setMaximumHeight( mGridSpacingY+1 );
2086 viewport()->repaint( false ); 2076 viewport()->repaint( false );
2087 //setFixedHeight( mGridSpacingY+1 ); 2077 //setFixedHeight( mGridSpacingY+1 );
2088 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 2078 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
2089 } 2079 }
2090 else { 2080 else {
2091 mGridSpacingY = KOPrefs::instance()->mHourSize; 2081 mGridSpacingY = KOPrefs::instance()->mHourSize;
2092 calculateWorkingHours(); 2082 calculateWorkingHours();
2093 marcus_bains(); 2083 marcus_bains();
2094 } 2084 }
2095} 2085}
2096 2086
2097void KOAgenda::checkScrollBoundaries() 2087void KOAgenda::checkScrollBoundaries()
2098{ 2088{
2099 // Invalidate old values to force update 2089 // Invalidate old values to force update
2100 mOldLowerScrollValue = -1; 2090 mOldLowerScrollValue = -1;
2101 mOldUpperScrollValue = -1; 2091 mOldUpperScrollValue = -1;
2102 2092
2103 checkScrollBoundaries(verticalScrollBar()->value()); 2093 checkScrollBoundaries(verticalScrollBar()->value());
2104} 2094}
2105 2095
2106void KOAgenda::checkScrollBoundaries(int v) 2096void KOAgenda::checkScrollBoundaries(int v)
2107{ 2097{
2108 if ( mGridSpacingY == 0 ) 2098 if ( mGridSpacingY == 0 )
2109 return; 2099 return;
2110 int yMin = v/mGridSpacingY; 2100 int yMin = v/mGridSpacingY;
2111 int yMax = (v+visibleHeight())/mGridSpacingY; 2101 int yMax = (v+visibleHeight())/mGridSpacingY;
2112 2102
2113// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2103// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2114 2104
2115 if (yMin != mOldLowerScrollValue) { 2105 if (yMin != mOldLowerScrollValue) {
2116 mOldLowerScrollValue = yMin; 2106 mOldLowerScrollValue = yMin;
2117 emit lowerYChanged(yMin); 2107 emit lowerYChanged(yMin);
2118 } 2108 }
2119 if (yMax != mOldUpperScrollValue) { 2109 if (yMax != mOldUpperScrollValue) {
2120 mOldUpperScrollValue = yMax; 2110 mOldUpperScrollValue = yMax;
2121 emit upperYChanged(yMax); 2111 emit upperYChanged(yMax);
2122 } 2112 }
2123} 2113}
2124 2114
2125void KOAgenda::deselectItem() 2115void KOAgenda::deselectItem()
2126{ 2116{
2127 if (mSelectedItem.isNull()) return; 2117 if (mSelectedItem.isNull()) return;
2128 mSelectedItem->select(false); 2118 mSelectedItem->select(false);
2129 mSelectedItem = 0; 2119 mSelectedItem = 0;
2130} 2120}
2131 2121
2132void KOAgenda::selectItem(KOAgendaItem *item) 2122void KOAgenda::selectItem(KOAgendaItem *item)
2133{ 2123{
2134 if ((KOAgendaItem *)mSelectedItem == item) return; 2124 if ((KOAgendaItem *)mSelectedItem == item) return;
2135 deselectItem(); 2125 deselectItem();
2136 if (item == 0) { 2126 if (item == 0) {
2137 emit incidenceSelected( 0 ); 2127 emit incidenceSelected( 0 );
2138 return; 2128 return;
2139 } 2129 }
2140 mSelectedItem = item; 2130 mSelectedItem = item;
2141 mSelectedItem->select(); 2131 mSelectedItem->select();
2142 emit incidenceSelected( mSelectedItem->incidence() ); 2132 emit incidenceSelected( mSelectedItem->incidence() );
2143} 2133}
2144 2134
2145// This function seems never be called. 2135// This function seems never be called.
2146void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2136void KOAgenda::keyPressEvent( QKeyEvent *kev )
2147{ 2137{
2148 switch(kev->key()) { 2138 switch(kev->key()) {
2149 case Key_PageDown: 2139 case Key_PageDown:
2150 verticalScrollBar()->addPage(); 2140 verticalScrollBar()->addPage();
2151 break; 2141 break;
2152 case Key_PageUp: 2142 case Key_PageUp:
2153 verticalScrollBar()->subtractPage(); 2143 verticalScrollBar()->subtractPage();
2154 break; 2144 break;
2155 case Key_Down: 2145 case Key_Down:
2156 verticalScrollBar()->addLine(); 2146 verticalScrollBar()->addLine();
2157 break; 2147 break;
2158 case Key_Up: 2148 case Key_Up:
2159 verticalScrollBar()->subtractLine(); 2149 verticalScrollBar()->subtractLine();
2160 break; 2150 break;
2161 default: 2151 default:
2162 ; 2152 ;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index c9e307f..1801d7e 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -359,389 +359,392 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
359 Todo* tempTodo = static_cast<Todo*>(mIncidence); 359 Todo* tempTodo = static_cast<Todo*>(mIncidence);
360 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 360 int xx = pos().x()+(width()-completedPxmp.width()-3 );
361 int yyy = yy+3; 361 int yyy = yy+3;
362 if ( tempTodo->isCompleted() ) 362 if ( tempTodo->isCompleted() )
363 paint->drawPixmap ( xx, yyy, completedPxmp ); 363 paint->drawPixmap ( xx, yyy, completedPxmp );
364 else { 364 else {
365 paint->drawPixmap ( xx, yyy, overduePxmp ); 365 paint->drawPixmap ( xx, yyy, overduePxmp );
366 366
367 } 367 }
368 } 368 }
369 bool addIcon = false; 369 bool addIcon = false;
370 if ( ! small || w > 3 * h || h > 3* w ) 370 if ( ! small || w > 3 * h || h > 3* w )
371 addIcon = updateIcons( paint, horLayout ); 371 addIcon = updateIcons( paint, horLayout );
372 372
373 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 373 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
374 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 374 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
375 if ( ! small ) { 375 if ( ! small ) {
376 x += 3; yy += 3;w -= 6; h-= 5; 376 x += 3; yy += 3;w -= 6; h-= 5;
377 } else { 377 } else {
378 x += 2; yy += 1;w -= 4; h-= 4; 378 x += 2; yy += 1;w -= 4; h-= 4;
379 if ( nfh < 6.01 ) { 379 if ( nfh < 6.01 ) {
380 yy -= 2; 380 yy -= 2;
381 h += 4; 381 h += 4;
382 } 382 }
383 else 383 else
384 if ( nfh < h -2 ) 384 if ( nfh < h -2 )
385 ++yy; 385 ++yy;
386 } 386 }
387 int align; 387 int align;
388#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
389 align = ( AlignLeft|WordBreak|AlignTop); 389 align = ( AlignLeft|WordBreak|AlignTop);
390#else 390#else
391 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 391 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
392#endif 392#endif
393 if ( addIcon ) { 393 if ( addIcon ) {
394 if ( ! horLayout ) { 394 if ( ! horLayout ) {
395 x += AGENDA_ICON_SIZE+3; 395 x += AGENDA_ICON_SIZE+3;
396 w -= (AGENDA_ICON_SIZE+3); 396 w -= (AGENDA_ICON_SIZE+3);
397 } 397 }
398 else { 398 else {
399 yy+= AGENDA_ICON_SIZE+2; 399 yy+= AGENDA_ICON_SIZE+2;
400 h -=(AGENDA_ICON_SIZE+3); 400 h -=(AGENDA_ICON_SIZE+3);
401 } 401 }
402 } 402 }
403 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 403 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
404 if ( colsum < 250 ) 404 if ( colsum < 250 )
405 paint->setPen ( white); 405 paint->setPen ( white);
406 if ( x < 0 ) { 406 if ( x < 0 ) {
407 w = w+x-3; 407 w = w+x-3;
408 x = 3; 408 x = 3;
409 if ( w > parentWidget()->width() ){ 409 if ( w > parentWidget()->width() ){
410 w = parentWidget()->width() - 6; 410 w = parentWidget()->width() - 6;
411#ifndef DESKTOP_VERSION 411#ifndef DESKTOP_VERSION
412 align = ( AlignHCenter|WordBreak|AlignTop); 412 align = ( AlignHCenter|WordBreak|AlignTop);
413#else 413#else
414 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 414 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
415#endif 415#endif
416 416
417 } 417 }
418 } 418 }
419 QRect dr; 419 QRect dr;
420 if ( w + x > parentWidget()->width() ) 420 if ( w + x > parentWidget()->width() )
421 w = parentWidget()->width()-x; 421 w = parentWidget()->width()-x;
422 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 422 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
423 //qDebug("%d %d %d %d ", x, yy, w, h ); 423 //qDebug("%d %d %d %d ", x, yy, w, h );
424 if ( mIncidence->cancelled() ){ 424 if ( mIncidence->cancelled() ){
425 425
426 426
427 small = ( height() < 20 ); 427 small = ( height() < 20 );
428 428
429 if ( ! small ) { 429 if ( ! small ) {
430 QFontMetrics fm ( paint->font() ); 430 QFontMetrics fm ( paint->font() );
431 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 431 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
432 } 432 }
433 433
434 } 434 }
435 pa.end(); 435 pa.end();
436 436
437} 437}
438void KOAgendaItem::resizePixmap( int w , int h ) 438void KOAgendaItem::resizePixmap( int w , int h )
439{ 439{
440 paintPix()->resize( w, h ); 440 paintPix()->resize( w, h );
441 paintPixSel()->resize( w, h ); 441 paintPixSel()->resize( w, h );
442 442
443} 443}
444QPixmap * KOAgendaItem::paintPix() 444QPixmap * KOAgendaItem::paintPix()
445{ 445{
446 static QPixmap* mPaintPix = 0; 446 static QPixmap* mPaintPix = 0;
447 if ( ! mPaintPix ) { 447 if ( ! mPaintPix ) {
448 int w = QApplication::desktop()->width(); 448 int w = QApplication::desktop()->width();
449 int h = QApplication::desktop()->height(); 449 int h = QApplication::desktop()->height();
450 mPaintPix = new QPixmap(w,h); 450 mPaintPix = new QPixmap(w,h);
451 } 451 }
452 return mPaintPix ; 452 return mPaintPix ;
453} 453}
454QPixmap * KOAgendaItem::paintPixAllday() 454QPixmap * KOAgendaItem::paintPixAllday()
455{ 455{
456 static QPixmap* mPaintPixA = 0; 456 static QPixmap* mPaintPixA = 0;
457 if ( ! mPaintPixA ) { 457 if ( ! mPaintPixA ) {
458 int w = QApplication::desktop()->width(); 458 int w = QApplication::desktop()->width();
459 int h = QApplication::desktop()->height()/3; 459 int h = QApplication::desktop()->height()/3;
460 mPaintPixA = new QPixmap(w,h); 460 mPaintPixA = new QPixmap(w,h);
461 } 461 }
462 return mPaintPixA ; 462 return mPaintPixA ;
463} 463}
464QPixmap * KOAgendaItem::paintPixSel() 464QPixmap * KOAgendaItem::paintPixSel()
465{ 465{
466 static QPixmap* mPaintPixSel = 0; 466 static QPixmap* mPaintPixSel = 0;
467 if ( ! mPaintPixSel ) { 467 if ( ! mPaintPixSel ) {
468 int w = QApplication::desktop()->width(); 468 int w = QApplication::desktop()->width();
469 int h = QApplication::desktop()->height(); 469 int h = QApplication::desktop()->height();
470 mPaintPixSel = new QPixmap(w,h); 470 mPaintPixSel = new QPixmap(w,h);
471 } 471 }
472 return mPaintPixSel ; 472 return mPaintPixSel ;
473} 473}
474void KOAgendaItem::paintEvent ( QPaintEvent *e ) 474void KOAgendaItem::paintEvent ( QPaintEvent *e )
475{ 475{
476 476
477 if ( globalFlagBlockAgendaItemPaint ) 477 if ( globalFlagBlockAgendaItemPaint )
478 return; 478 return;
479 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 479 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
480 return; 480 return;
481 int yy; 481 int yy;
482 if ( mAllDay ) 482 if ( mAllDay )
483 yy = y(); 483 yy = y();
484 else 484 else
485 yy = mCellYTop * ( height() / cellHeight() ); 485 yy = mCellYTop * ( height() / cellHeight() );
486 int xx = x(); 486 int xx = x();
487 487
488 if ( xPaintCoord != xx || yPaintCoord != yy || 488 if ( xPaintCoord != xx || yPaintCoord != yy ||
489 wPaintCoord != width() || hPaintCoord != height()) { 489 wPaintCoord != width() || hPaintCoord != height()) {
490 xPaintCoord= xx; 490 xPaintCoord= xx;
491 yPaintCoord = yy; 491 yPaintCoord = yy;
492 wPaintCoord = width(); 492 wPaintCoord = width();
493 hPaintCoord = height(); 493 hPaintCoord = height();
494 globalFlagBlockAgendaItemUpdate = 0; 494 globalFlagBlockAgendaItemUpdate = 0;
495 paintMe( mSelected ); 495 paintMe( mSelected );
496 //qDebug("calling paintMe "); 496 //qDebug("calling paintMe ");
497 globalFlagBlockAgendaItemUpdate = 1; 497 globalFlagBlockAgendaItemUpdate = 1;
498 } 498 }
499 int rx, ry, rw, rh; 499 int rx, ry, rw, rh;
500 rx = e->rect().x(); 500 rx = e->rect().x();
501 ry = e->rect().y(); 501 ry = e->rect().y();
502 rw = e->rect().width(); 502 rw = e->rect().width();
503 rh = e->rect().height(); 503 rh = e->rect().height();
504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
505 505
506 QPixmap* paintFrom ; 506 QPixmap* paintFrom ;
507 if ( mSelected ) { 507 if ( mSelected ) {
508 paintFrom = paintPixSel(); 508 paintFrom = paintPixSel();
509 } else { 509 } else {
510 if ( mAllDay ) 510 if ( mAllDay )
511 paintFrom = paintPixAllday(); 511 paintFrom = paintPixAllday();
512 else 512 else
513 paintFrom = paintPix(); 513 paintFrom = paintPix();
514 } 514 }
515 xx += rx; 515 xx += rx;
516 516
517 if ( xx < 0 ) { 517 if ( xx < 0 ) {
518 rw = rw + xx; 518 rw = rw + xx;
519 rx -= xx; 519 rx -= xx;
520 xx = 0; 520 xx = 0;
521 if ( rw <= 1 ) { 521 if ( rw <= 1 ) {
522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
523 return; 523 return;
524 } 524 }
525 } 525 }
526 if ( paintFrom->width() < xx+rw ) { 526 if ( paintFrom->width() < xx+rw ) {
527 rw = paintFrom->width() - xx; 527 rw = paintFrom->width() - xx;
528 if ( rw <= 1 ) { 528 if ( rw <= 1 ) {
529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
530 return; 530 return;
531 } 531 }
532 } 532 }
533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
535} 535}
536void KOAgendaItem::computeText() 536void KOAgendaItem::computeText()
537{ 537{
538 mDisplayedText = mIncidence->summary(); 538 mDisplayedText = mIncidence->summary();
539 if ( (mIncidence->type() == "Todo") ) { 539 if ( (mIncidence->type() == "Todo") ) {
540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
543 else if ( !(mIncidence->doesFloat())) 543 else if ( !(mIncidence->doesFloat()))
544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
545 } 545 }
546 } else { 546 } else {
547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
549 549
550 if ( mAllDay ) { 550 if ( mAllDay ) {
551 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 551 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
552 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 552 if ( mIncidence->doesRecur() ) {
553 } 553 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
554 } else {
555 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
556 }
557 }
554 } 558 }
555
556 } 559 }
557 560
558 if ( !mIncidence->location().isEmpty() ) { 561 if ( !mIncidence->location().isEmpty() ) {
559 if ( mAllDay ) 562 if ( mAllDay )
560 mDisplayedText += " ("; 563 mDisplayedText += " (";
561 else 564 else
562 mDisplayedText += "\n("; 565 mDisplayedText += "\n(";
563 mDisplayedText += mIncidence->location() +")"; 566 mDisplayedText += mIncidence->location() +")";
564 } 567 }
565#ifdef DESKTOP_VERSION 568#ifdef DESKTOP_VERSION
566 QString tipText = mIncidence->summary(); 569 QString tipText = mIncidence->summary();
567 if ( !mIncidence->doesFloat() ) { 570 if ( !mIncidence->doesFloat() ) {
568 if ( mIncidence->type() == "Event" ) { 571 if ( mIncidence->type() == "Event" ) {
569 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 572 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
570 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 573 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
571 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 574 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
572 } 575 }
573 else { 576 else {
574 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 577 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
575 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 578 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
576 } 579 }
577 } 580 }
578 else if ( mIncidence->type() == "Todo" ) { 581 else if ( mIncidence->type() == "Todo" ) {
579 if (mIncidence->hasStartDate()) 582 if (mIncidence->hasStartDate())
580 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 583 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
581 if (((Todo*)mIncidence)->hasDueDate()) 584 if (((Todo*)mIncidence)->hasDueDate())
582 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 585 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
583 } 586 }
584 } else if ( mIncidence->type() == "Todo" ) { 587 } else if ( mIncidence->type() == "Todo" ) {
585 if (mIncidence->hasStartDate()) 588 if (mIncidence->hasStartDate())
586 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 589 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
587 if (((Todo*)mIncidence)->hasDueDate()) 590 if (((Todo*)mIncidence)->hasDueDate())
588 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 591 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
589 } 592 }
590 593
591 if (!mIncidence->location().isEmpty()) { 594 if (!mIncidence->location().isEmpty()) {
592 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 595 tipText += "\n"+i18n("Location: ")+mIncidence->location();
593 } 596 }
594 QToolTip::add(this,tipText,toolTipGroup(),""); 597 QToolTip::add(this,tipText,toolTipGroup(),"");
595#endif 598#endif
596} 599}
597void KOAgendaItem::updateItem() 600void KOAgendaItem::updateItem()
598{ 601{
599 computeText(); 602 computeText();
600 603
601 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 604 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
602 paintMe( mSelected ); 605 paintMe( mSelected );
603 repaint( false); 606 repaint( false);
604} 607}
605 608
606void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 609void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
607{ 610{
608 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 611 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
609 paintMe( mSelected ); 612 paintMe( mSelected );
610 repaint( false ); 613 repaint( false );
611} 614}
612 615
613/* 616/*
614 Return height of item in units of agenda cells 617 Return height of item in units of agenda cells
615*/ 618*/
616int KOAgendaItem::cellHeight() 619int KOAgendaItem::cellHeight()
617{ 620{
618 int ret = mCellYBottom - mCellYTop + 1; 621 int ret = mCellYBottom - mCellYTop + 1;
619 if ( ret <= 0 ) { 622 if ( ret <= 0 ) {
620 ret = 1; 623 ret = 1;
621 mCellYBottom = 0; 624 mCellYBottom = 0;
622 mCellYTop = 0; 625 mCellYTop = 0;
623 } 626 }
624 return ret; 627 return ret;
625} 628}
626 629
627/* 630/*
628 Return height of item in units of agenda cells 631 Return height of item in units of agenda cells
629*/ 632*/
630int KOAgendaItem::cellWidth() 633int KOAgendaItem::cellWidth()
631{ 634{
632 return mCellXWidth - mCellX + 1; 635 return mCellXWidth - mCellX + 1;
633} 636}
634 637
635void KOAgendaItem::setItemDate(QDate qd) 638void KOAgendaItem::setItemDate(QDate qd)
636{ 639{
637 mDate = qd; 640 mDate = qd;
638} 641}
639 642
640void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 643void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
641{ 644{
642 mCellX = X; 645 mCellX = X;
643 mCellYTop = YTop; 646 mCellYTop = YTop;
644 mCellYBottom = YBottom; 647 mCellYBottom = YBottom;
645} 648}
646 649
647void KOAgendaItem::setCellXWidth(int xwidth) 650void KOAgendaItem::setCellXWidth(int xwidth)
648{ 651{
649 mCellXWidth = xwidth; 652 mCellXWidth = xwidth;
650} 653}
651 654
652void KOAgendaItem::setCellX(int XLeft, int XRight) 655void KOAgendaItem::setCellX(int XLeft, int XRight)
653{ 656{
654 mCellX = XLeft; 657 mCellX = XLeft;
655 mCellXWidth = XRight; 658 mCellXWidth = XRight;
656} 659}
657 660
658void KOAgendaItem::setCellY(int YTop, int YBottom) 661void KOAgendaItem::setCellY(int YTop, int YBottom)
659{ 662{
660 mCellYTop = YTop; 663 mCellYTop = YTop;
661 mCellYBottom = YBottom; 664 mCellYBottom = YBottom;
662} 665}
663 666
664void KOAgendaItem::setSubCell(int subCell) 667void KOAgendaItem::setSubCell(int subCell)
665{ 668{
666 mSubCell = subCell; 669 mSubCell = subCell;
667} 670}
668 671
669void KOAgendaItem::setSubCells(int subCells) 672void KOAgendaItem::setSubCells(int subCells)
670{ 673{
671 mSubCells = subCells; 674 mSubCells = subCells;
672} 675}
673 676
674void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 677void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
675 KOAgendaItem *last) 678 KOAgendaItem *last)
676{ 679{
677 mFirstMultiItem = first; 680 mFirstMultiItem = first;
678 mNextMultiItem = next; 681 mNextMultiItem = next;
679 mLastMultiItem = last; 682 mLastMultiItem = last;
680} 683}
681 684
682void KOAgendaItem::startMove() 685void KOAgendaItem::startMove()
683{ 686{
684 mStartCellX = mCellX; 687 mStartCellX = mCellX;
685 mStartCellXWidth = mCellXWidth; 688 mStartCellXWidth = mCellXWidth;
686 mStartCellYTop = mCellYTop; 689 mStartCellYTop = mCellYTop;
687 mStartCellYBottom = mCellYBottom; 690 mStartCellYBottom = mCellYBottom;
688} 691}
689 692
690void KOAgendaItem::resetMove() 693void KOAgendaItem::resetMove()
691{ 694{
692 mCellX = mStartCellX; 695 mCellX = mStartCellX;
693 mCellXWidth = mStartCellXWidth; 696 mCellXWidth = mStartCellXWidth;
694 mCellYTop = mStartCellYTop; 697 mCellYTop = mStartCellYTop;
695 mCellYBottom = mStartCellYBottom; 698 mCellYBottom = mStartCellYBottom;
696} 699}
697 700
698void KOAgendaItem::moveRelative(int dx, int dy) 701void KOAgendaItem::moveRelative(int dx, int dy)
699{ 702{
700 int newX = cellX() + dx; 703 int newX = cellX() + dx;
701 int newXWidth = cellXWidth() + dx; 704 int newXWidth = cellXWidth() + dx;
702 int newYTop = cellYTop() + dy; 705 int newYTop = cellYTop() + dy;
703 int newYBottom = cellYBottom() + dy; 706 int newYBottom = cellYBottom() + dy;
704 setCellXY(newX,newYTop,newYBottom); 707 setCellXY(newX,newYTop,newYBottom);
705 setCellXWidth(newXWidth); 708 setCellXWidth(newXWidth);
706} 709}
707 710
708void KOAgendaItem::expandTop(int dy) 711void KOAgendaItem::expandTop(int dy)
709{ 712{
710 int newYTop = cellYTop() + dy; 713 int newYTop = cellYTop() + dy;
711 int newYBottom = cellYBottom(); 714 int newYBottom = cellYBottom();
712 if (newYTop > newYBottom) newYTop = newYBottom; 715 if (newYTop > newYBottom) newYTop = newYBottom;
713 setCellY(newYTop, newYBottom); 716 setCellY(newYTop, newYBottom);
714} 717}
715 718
716void KOAgendaItem::expandBottom(int dy) 719void KOAgendaItem::expandBottom(int dy)
717{ 720{
718 int newYTop = cellYTop(); 721 int newYTop = cellYTop();
719 int newYBottom = cellYBottom() + dy; 722 int newYBottom = cellYBottom() + dy;
720 if (newYBottom < newYTop) newYBottom = newYTop; 723 if (newYBottom < newYTop) newYBottom = newYTop;
721 setCellY(newYTop, newYBottom); 724 setCellY(newYTop, newYBottom);
722} 725}
723 726
724void KOAgendaItem::expandLeft(int dx) 727void KOAgendaItem::expandLeft(int dx)
725{ 728{
726 int newX = cellX() + dx; 729 int newX = cellX() + dx;
727 int newXWidth = cellXWidth(); 730 int newXWidth = cellXWidth();
728 if (newX > newXWidth) newX = newXWidth; 731 if (newX > newXWidth) newX = newXWidth;
729 setCellX(newX,newXWidth); 732 setCellX(newX,newXWidth);
730} 733}
731 734
732void KOAgendaItem::expandRight(int dx) 735void KOAgendaItem::expandRight(int dx)
733{ 736{
734 int newX = cellX(); 737 int newX = cellX();
735 int newXWidth = cellXWidth() + dx; 738 int newXWidth = cellXWidth() + dx;
736 if (newXWidth < newX) newXWidth = newX; 739 if (newXWidth < newX) newXWidth = newX;
737 setCellX(newX,newXWidth); 740 setCellX(newX,newXWidth);
738} 741}
739 742
740QToolTipGroup *KOAgendaItem::toolTipGroup() 743QToolTipGroup *KOAgendaItem::toolTipGroup()
741{ 744{
742 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 745 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
743 return mToolTipGroup; 746 return mToolTipGroup;
744} 747}
745 748
746void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 749void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
747{ 750{
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 76d5c4b..f53e5d5 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -971,385 +971,413 @@ void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
971 // if ( type == KOAgenda::MOVE ) 971 // if ( type == KOAgenda::MOVE )
972 // qDebug("MOVE "); 972 // qDebug("MOVE ");
973 if ( item->incidence()->type() == "Event" ) { 973 if ( item->incidence()->type() == "Event" ) {
974 startDt =item->incidence()->dtStart(); 974 startDt =item->incidence()->dtStart();
975 endDt = item->incidence()->dtEnd(); 975 endDt = item->incidence()->dtEnd();
976 lenInSecs = startDt.secsTo( endDt ); 976 lenInSecs = startDt.secsTo( endDt );
977 } 977 }
978 978
979 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 979 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
980 980
981 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 981 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
982 startDate = mSelectedDates[item->mLastMoveXPos]; 982 startDate = mSelectedDates[item->mLastMoveXPos];
983 } else { 983 } else {
984 if (item->cellX() < 0) { 984 if (item->cellX() < 0) {
985 startDate = (mSelectedDates.first()).addDays(item->cellX()); 985 startDate = (mSelectedDates.first()).addDays(item->cellX());
986 } else { 986 } else {
987 startDate = mSelectedDates[item->cellX()]; 987 startDate = mSelectedDates[item->cellX()];
988 } 988 }
989 } 989 }
990 startDt.setDate(startDate); 990 startDt.setDate(startDate);
991 991
992 if (item->incidence()->doesFloat()) { 992 if (item->incidence()->doesFloat()) {
993 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 993 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
994 } else { 994 } else {
995 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 995 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
996 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 996 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
997 if ( item->incidence()->type() == "Event" ) { 997 if ( item->incidence()->type() == "Event" ) {
998 if ( type == KOAgenda::MOVE ) { 998 if ( type == KOAgenda::MOVE ) {
999 endDt = startDt.addSecs(lenInSecs); 999 endDt = startDt.addSecs(lenInSecs);
1000 1000
1001 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1001 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1002 if (item->lastMultiItem()) { 1002 if (item->lastMultiItem()) {
1003 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1003 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1004 endDt.setDate(startDate. 1004 endDt.setDate(startDate.
1005 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1005 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1006 } else { 1006 } else {
1007 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1007 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1008 endDt.setDate(startDate); 1008 endDt.setDate(startDate);
1009 } 1009 }
1010 } 1010 }
1011 } else { 1011 } else {
1012 // todo 1012 // todo
1013 if (item->lastMultiItem()) { 1013 if (item->lastMultiItem()) {
1014 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1014 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1015 endDt.setDate(startDate. 1015 endDt.setDate(startDate.
1016 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1016 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1017 } else { 1017 } else {
1018 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1018 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1019 if ( item->cellYBottom() > 0 ) 1019 if ( item->cellYBottom() > 0 )
1020 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1020 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1021 else 1021 else
1022 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1022 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1023 endDt.setDate(startDate); 1023 endDt.setDate(startDate);
1024 } 1024 }
1025 } 1025 }
1026 } 1026 }
1027 if ( item->incidence()->type() == "Event" ) { 1027 if ( item->incidence()->type() == "Event" ) {
1028 item->incidence()->setDtStart(startDt); 1028 item->incidence()->setDtStart(startDt);
1029 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1029 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1030 } else if ( item->incidence()->type() == "Todo" ) { 1030 } else if ( item->incidence()->type() == "Todo" ) {
1031 Todo* to = static_cast<Todo*>(item->incidence()); 1031 Todo* to = static_cast<Todo*>(item->incidence());
1032 1032
1033 to->setDtDue(endDt); 1033 to->setDtDue(endDt);
1034 if ( to->hasStartDate() ) { 1034 if ( to->hasStartDate() ) {
1035 if (to->dtStart() >= to->dtDue() ) 1035 if (to->dtStart() >= to->dtDue() )
1036 to->setDtStart(to->dtDue().addDays( -2 )); 1036 to->setDtStart(to->dtDue().addDays( -2 ));
1037 } 1037 }
1038 1038
1039 } 1039 }
1040 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1040 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1041 item->incidence()->setRevision(item->incidence()->revision()+1); 1041 item->incidence()->setRevision(item->incidence()->revision()+1);
1042 item->setItemDate(startDt.date()); 1042 item->setItemDate(startDt.date());
1043 //item->updateItem(); 1043 //item->updateItem();
1044 if ( item->incidence()->type() == "Todo" ) { 1044 if ( item->incidence()->type() == "Todo" ) {
1045 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1045 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1046 1046
1047 } 1047 }
1048 else 1048 else
1049 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1049 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1050 item->updateItem(); 1050 item->updateItem();
1051} 1051}
1052 1052
1053void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1053void KOAgendaView::showDates( const QDate &start, const QDate &end )
1054{ 1054{
1055 // kdDebug() << "KOAgendaView::selectDates" << endl; 1055 // kdDebug() << "KOAgendaView::selectDates" << endl;
1056 1056
1057 mSelectedDates.clear(); 1057 mSelectedDates.clear();
1058 // qDebug("KOAgendaView::showDates "); 1058 // qDebug("KOAgendaView::showDates ");
1059 QDate d = start; 1059 QDate d = start;
1060 while (d <= end) { 1060 while (d <= end) {
1061 mSelectedDates.append(d); 1061 mSelectedDates.append(d);
1062 d = d.addDays( 1 ); 1062 d = d.addDays( 1 );
1063 } 1063 }
1064 1064
1065 // and update the view 1065 // and update the view
1066 fillAgenda(); 1066 fillAgenda();
1067} 1067}
1068 1068
1069 1069
1070void KOAgendaView::showEvents(QPtrList<Event>) 1070void KOAgendaView::showEvents(QPtrList<Event>)
1071{ 1071{
1072 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1072 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1073} 1073}
1074 1074
1075void KOAgendaView::changeEventDisplay(Event *, int) 1075void KOAgendaView::changeEventDisplay(Event *, int)
1076{ 1076{
1077 // qDebug("KOAgendaView::changeEventDisplay "); 1077 // qDebug("KOAgendaView::changeEventDisplay ");
1078 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1078 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1079 // this should be re-written to be MUCH smarter. Right now we 1079 // this should be re-written to be MUCH smarter. Right now we
1080 // are just playing dumb. 1080 // are just playing dumb.
1081 fillAgenda(); 1081 fillAgenda();
1082} 1082}
1083 1083
1084void KOAgendaView::fillAgenda(const QDate &) 1084void KOAgendaView::fillAgenda(const QDate &)
1085{ 1085{
1086 // qDebug("KOAgendaView::fillAgenda "); 1086 // qDebug("KOAgendaView::fillAgenda ");
1087 fillAgenda(); 1087 fillAgenda();
1088} 1088}
1089 1089
1090void KOAgendaView::fillAgenda() 1090void KOAgendaView::fillAgenda()
1091{ 1091{
1092 if ( globalFlagBlockStartup ) 1092 if ( globalFlagBlockStartup )
1093 return; 1093 return;
1094 if ( globalFlagBlockAgenda == 1 ) 1094 if ( globalFlagBlockAgenda == 1 )
1095 return; 1095 return;
1096 static bool onlyOne = false; 1096 static bool onlyOne = false;
1097 if ( onlyOne ) 1097 if ( onlyOne )
1098 return; 1098 return;
1099 onlyOne = true; 1099 onlyOne = true;
1100 //if ( globalFlagBlockAgenda == 2 ) 1100 //if ( globalFlagBlockAgenda == 2 )
1101 //globalFlagBlockAgenda = 0; 1101 //globalFlagBlockAgenda = 0;
1102 // globalFlagBlockPainting = false; 1102 // globalFlagBlockPainting = false;
1103 if ( globalFlagBlockAgenda == 0 ) 1103 if ( globalFlagBlockAgenda == 0 )
1104 globalFlagBlockAgenda = 1; 1104 globalFlagBlockAgenda = 1;
1105 // clearView(); 1105 // clearView();
1106 //qDebug("fillAgenda()++++ "); 1106 //qDebug("fillAgenda()++++ ");
1107 globalFlagBlockAgendaItemPaint = 1; 1107 globalFlagBlockAgendaItemPaint = 1;
1108 1108
1109 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1109 mAllDayAgenda->changeColumns(mSelectedDates.count());
1110 mAgenda->changeColumns(mSelectedDates.count()); 1110 mAgenda->changeColumns(mSelectedDates.count());
1111 qApp->processEvents(); 1111 qApp->processEvents();
1112 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1112 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1114 setHolidayMasks(); 1114 setHolidayMasks();
1115 1115
1116 //mAgenda->hideUnused(); 1116 //mAgenda->hideUnused();
1117 //mAllDayAgenda->hideUnused(); 1117 //mAllDayAgenda->hideUnused();
1118 1118
1119 // mAgenda->blockNextRepaint( false ); 1119 // mAgenda->blockNextRepaint( false );
1120 // mAgenda->viewport()->repaint(); 1120 // mAgenda->viewport()->repaint();
1121 // mAgenda->blockNextRepaint( true ); 1121 // mAgenda->blockNextRepaint( true );
1122 mMinY.resize(mSelectedDates.count()); 1122 mMinY.resize(mSelectedDates.count());
1123 mMaxY.resize(mSelectedDates.count()); 1123 mMaxY.resize(mSelectedDates.count());
1124 1124
1125 QPtrList<Event> dayEvents; 1125 QPtrList<Event> dayEvents;
1126 1126
1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1128 // Therefore, gtodoset all of them. 1128 // Therefore, gtodoset all of them.
1129 QPtrList<Todo> todos = calendar()->todos(); 1129 QPtrList<Todo> todos = calendar()->todos();
1130 1130
1131 mAgenda->setDateList(mSelectedDates); 1131 mAgenda->setDateList(mSelectedDates);
1132 1132
1133 QDate today = QDate::currentDate(); 1133 QDate today = QDate::currentDate();
1134 1134
1135 DateList::ConstIterator dit; 1135 DateList::ConstIterator dit;
1136 int curCol = 0; 1136 int curCol = 0;
1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1138 QDate currentDate = *dit; 1138 QDate currentDate = *dit;
1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1140 // << endl; 1140 // << endl;
1141 1141
1142 dayEvents = calendar()->events(currentDate,true); 1142 dayEvents = calendar()->events(currentDate,true);
1143 1143
1144 // Default values, which can never be reached 1144 // Default values, which can never be reached
1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1147 1147
1148 unsigned int numEvent; 1148 unsigned int numEvent;
1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1150 Event *event = dayEvents.at(numEvent); 1150 Event *event = dayEvents.at(numEvent);
1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1152 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1152 if ( event->uid().left(15) == QString("last-syncEvent-") )
1153 continue; 1153 continue;
1154 // kdDebug() << " Event: " << event->summary() << endl; 1154 // kdDebug() << " Event: " << event->summary() << endl;
1155 1155
1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1158 1158
1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1160 1160
1161 if (event->doesFloat()) { 1161 if (event->doesFloat()) {
1162 if (event->recurrence()->doesRecur()) { 1162 if (event->recurrence()->doesRecur()) {
1163 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1163 if (event->isMultiDay() ) {
1164 endX = endX - beginX;// endX is now number of days
1165 if ( event->recursOn( currentDate ) ) {
1166 endX += curCol;
1167 beginX = curCol;
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } else {
1170 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1171 QDate dateit = currentDate.addDays( -endX );
1172 if ( event->recursOn( dateit ) ) {
1173 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1174 if ( curCol-endX < 0 ) {
1175 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1176 }
1177 }
1178 }
1179 } else {
1180 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1181 }
1182#if 0
1183 if (beginX <= 0 && curCol == 0) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } else if (beginX == curCol) {
1186 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1187 } else {
1188 qDebug("skipped %d %d %d ",beginX , endX, curCol);
1189 }
1190#endif
1191 //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1164 } else { 1192 } else {
1165 if (beginX <= 0 && curCol == 0) { 1193 if (beginX <= 0 && curCol == 0) {
1166 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1194 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1167 } else if (beginX == curCol) { 1195 } else if (beginX == curCol) {
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1196 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } 1197 }
1170 } 1198 }
1171 } else if (event->isMultiDay()) { 1199 } else if (event->isMultiDay()) {
1172 if ( event->doesRecur () ) { 1200 if ( event->doesRecur () ) {
1173 QDate dateit = currentDate; 1201 QDate dateit = currentDate;
1174 int count = 0; 1202 int count = 0;
1175 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1203 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1176 while (! event->recursOn( dateit ) && count <= max ) { 1204 while (! event->recursOn( dateit ) && count <= max ) {
1177 ++count; 1205 ++count;
1178 dateit = dateit.addDays( -1 ); 1206 dateit = dateit.addDays( -1 );
1179 } 1207 }
1180 bool ok; 1208 bool ok;
1181 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1209 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1182 if ( ok ) 1210 if ( ok )
1183 { 1211 {
1184 int secs = event->dtStart().secsTo( event->dtEnd() ); 1212 int secs = event->dtStart().secsTo( event->dtEnd() );
1185 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1213 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1186 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1214 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1187 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1215 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1188 1216
1189 } 1217 }
1190 } 1218 }
1191 int startY = mAgenda->timeToY(event->dtStart().time()); 1219 int startY = mAgenda->timeToY(event->dtStart().time());
1192 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1220 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1193 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1221 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1194 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1222 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1195 //qDebug("insert!!! "); 1223 //qDebug("insert!!! ");
1196 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1224 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1197 } 1225 }
1198 if (beginX == curCol) { 1226 if (beginX == curCol) {
1199 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1200 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1228 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1201 } else if (endX == curCol) { 1229 } else if (endX == curCol) {
1202 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1230 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1203 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1204 } else { 1232 } else {
1205 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1233 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1206 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1234 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1207 } 1235 }
1208 } else { 1236 } else {
1209 int startY = mAgenda->timeToY(event->dtStart().time()); 1237 int startY = mAgenda->timeToY(event->dtStart().time());
1210 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1238 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1211 if (endY < startY) endY = startY; 1239 if (endY < startY) endY = startY;
1212 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1240 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1213 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1241 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1214 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1242 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1215 } 1243 }
1216 } 1244 }
1217 // ---------- [display Todos -------------- 1245 // ---------- [display Todos --------------
1218 unsigned int numTodo; 1246 unsigned int numTodo;
1219 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1247 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1220 Todo *todo = todos.at(numTodo); 1248 Todo *todo = todos.at(numTodo);
1221 1249
1222 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1250 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1223 1251
1224 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1252 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1225 // Already completed items can be displayed on their original due date 1253 // Already completed items can be displayed on their original due date
1226 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1254 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1227 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1255 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1228 bool fillIn = false; 1256 bool fillIn = false;
1229 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1257 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1230 fillIn = true; 1258 fillIn = true;
1231 if ( ! fillIn && !todo->hasCompletedDate() ) 1259 if ( ! fillIn && !todo->hasCompletedDate() )
1232 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1260 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1233 if ( fillIn ) { 1261 if ( fillIn ) {
1234 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1262 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1235 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1263 if ( KOPrefs::instance()->mShowTodoInAgenda )
1236 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1264 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1237 } 1265 }
1238 else { 1266 else {
1239 QDateTime dt; 1267 QDateTime dt;
1240 if ( todo->hasCompletedDate() ) 1268 if ( todo->hasCompletedDate() )
1241 dt = todo->completed(); 1269 dt = todo->completed();
1242 else 1270 else
1243 dt = todo->dtDue();; 1271 dt = todo->dtDue();;
1244 1272
1245 1273
1246 int endY = mAgenda->timeToY(dt.time()) - 1; 1274 int endY = mAgenda->timeToY(dt.time()) - 1;
1247 int hi = (18/KOPrefs::instance()->mHourSize); 1275 int hi = (18/KOPrefs::instance()->mHourSize);
1248 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1276 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1249 int startY = endY -hi; 1277 int startY = endY -hi;
1250 1278
1251 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1279 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1252 1280
1253 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1281 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1254 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1282 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1255 } 1283 }
1256 } 1284 }
1257 } 1285 }
1258 // ---------- display Todos] -------------- 1286 // ---------- display Todos] --------------
1259 1287
1260 ++curCol; 1288 ++curCol;
1261 } 1289 }
1262 mAgenda->hideUnused(); 1290 mAgenda->hideUnused();
1263 mAllDayAgenda->hideUnused(); 1291 mAllDayAgenda->hideUnused();
1264 mAgenda->checkScrollBoundaries(); 1292 mAgenda->checkScrollBoundaries();
1265 1293
1266 deleteSelectedDateTime(); 1294 deleteSelectedDateTime();
1267 1295
1268 createDayLabels(); 1296 createDayLabels();
1269 emit incidenceSelected( 0 ); 1297 emit incidenceSelected( 0 );
1270 1298
1271 if ( globalFlagBlockAgenda == 2 ) { 1299 if ( globalFlagBlockAgenda == 2 ) {
1272 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1300 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1273 setStartHour( KOPrefs::instance()->mDayBegins ); 1301 setStartHour( KOPrefs::instance()->mDayBegins );
1274 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1302 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1275 setStartHour( QTime::currentTime ().hour() ); 1303 setStartHour( QTime::currentTime ().hour() );
1276 // qApp->processEvents(); 1304 // qApp->processEvents();
1277 } 1305 }
1278 qApp->processEvents(); 1306 qApp->processEvents();
1279 //qDebug("qApp->processEvents(); END "); 1307 //qDebug("qApp->processEvents(); END ");
1280 globalFlagBlockAgenda = 0; 1308 globalFlagBlockAgenda = 0;
1281 1309
1282 // mAgenda->hideUnused(); 1310 // mAgenda->hideUnused();
1283 //mAllDayAgenda->hideUnused(); 1311 //mAllDayAgenda->hideUnused();
1284 mAllDayAgenda->drawContentsToPainter(); 1312 mAllDayAgenda->drawContentsToPainter();
1285 mAgenda->drawContentsToPainter(); 1313 mAgenda->drawContentsToPainter();
1286 repaintAgenda(); 1314 repaintAgenda();
1287 onlyOne = false; 1315 onlyOne = false;
1288 // mAgenda->finishUpdate(); 1316 // mAgenda->finishUpdate();
1289 //mAllDayAgenda->finishUpdate(); 1317 //mAllDayAgenda->finishUpdate();
1290 1318
1291 // repaintAgenda(); 1319 // repaintAgenda();
1292 //qApp->processEvents(); 1320 //qApp->processEvents();
1293 // globalFlagBlockAgenda = 0; 1321 // globalFlagBlockAgenda = 0;
1294} 1322}
1295void KOAgendaView::repaintAgenda() 1323void KOAgendaView::repaintAgenda()
1296{ 1324{
1297 // mAllDayAgenda->drawContentsToPainter(); 1325 // mAllDayAgenda->drawContentsToPainter();
1298// mAllDayAgenda->viewport()->repaint( false ); 1326// mAllDayAgenda->viewport()->repaint( false );
1299// mAgenda->drawContentsToPainter(); 1327// mAgenda->drawContentsToPainter();
1300// mAgenda->viewport()->repaint( false ); 1328// mAgenda->viewport()->repaint( false );
1301// qApp->processEvents(); 1329// qApp->processEvents();
1302 1330
1303 //qDebug("KOAgendaView::repaintAgenda() "); 1331 //qDebug("KOAgendaView::repaintAgenda() ");
1304 //qApp->processEvents(); 1332 //qApp->processEvents();
1305 mAgenda->viewport()->repaint( false ); 1333 mAgenda->viewport()->repaint( false );
1306 mAllDayAgenda->viewport()->repaint( false ); 1334 mAllDayAgenda->viewport()->repaint( false );
1307 mAgenda->finishUpdate(); 1335 mAgenda->finishUpdate();
1308 mAllDayAgenda->finishUpdate(); 1336 mAllDayAgenda->finishUpdate();
1309} 1337}
1310 1338
1311 1339
1312void KOAgendaView::clearView() 1340void KOAgendaView::clearView()
1313{ 1341{
1314 // kdDebug() << "ClearView" << endl; 1342 // kdDebug() << "ClearView" << endl;
1315 mAllDayAgenda->clear(); 1343 mAllDayAgenda->clear();
1316 mAgenda->clear(); 1344 mAgenda->clear();
1317} 1345}
1318 1346
1319void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1347void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1320 const QDate &td) 1348 const QDate &td)
1321{ 1349{
1322#ifndef KORG_NOPRINTER 1350#ifndef KORG_NOPRINTER
1323 if (fd == td) 1351 if (fd == td)
1324 calPrinter->preview(CalPrinter::Day, fd, td); 1352 calPrinter->preview(CalPrinter::Day, fd, td);
1325 else 1353 else
1326 calPrinter->preview(CalPrinter::Week, fd, td); 1354 calPrinter->preview(CalPrinter::Week, fd, td);
1327#endif 1355#endif
1328} 1356}
1329 1357
1330// void KOAgendaView::updateMovedTodo() 1358// void KOAgendaView::updateMovedTodo()
1331// { 1359// {
1332// // updateConfig(); 1360// // updateConfig();
1333// // emit updateTodoViews(); 1361// // emit updateTodoViews();
1334// } 1362// }
1335 1363
1336void KOAgendaView::slotShowDateView( int mode , int d ) 1364void KOAgendaView::slotShowDateView( int mode , int d )
1337{ 1365{
1338 if ( d >= mSelectedDates.count() ) { 1366 if ( d >= mSelectedDates.count() ) {
1339 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1367 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1340 1368
1341 } else { 1369 } else {
1342 QDate day = mSelectedDates[d]; 1370 QDate day = mSelectedDates[d];
1343 emit showDateView(mode , day ); 1371 emit showDateView(mode , day );
1344 } 1372 }
1345 1373
1346} 1374}
1347void KOAgendaView::newEvent(int gx, int gy) 1375void KOAgendaView::newEvent(int gx, int gy)
1348{ 1376{
1349 if (!mSelectedDates.count()) return; 1377 if (!mSelectedDates.count()) return;
1350 1378
1351 QDate day = mSelectedDates[gx]; 1379 QDate day = mSelectedDates[gx];
1352 1380
1353 QTime time = mAgenda->gyToTime(gy); 1381 QTime time = mAgenda->gyToTime(gy);
1354 QDateTime dt(day,time); 1382 QDateTime dt(day,time);
1355 // if ( dt < QDateTime::currentDateTime () ) 1383 // if ( dt < QDateTime::currentDateTime () )