-rw-r--r-- | korganizer/koagenda.cpp | 225 |
1 files changed, 113 insertions, 112 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 63fdecd..9b817bc 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1319,465 +1319,466 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | |||
1319 | int offset = 0; | 1319 | int offset = 0; |
1320 | while ( hei > 0 ) { | 1320 | while ( hei > 0 ) { |
1321 | int p_hei = 5; | 1321 | int p_hei = 5; |
1322 | if ( hei < 5 ) p_hei = hei; | 1322 | if ( hei < 5 ) p_hei = hei; |
1323 | hei -= 5; | 1323 | hei -= 5; |
1324 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1324 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1325 | offset += 5; | 1325 | offset += 5; |
1326 | } | 1326 | } |
1327 | } | 1327 | } |
1328 | } | 1328 | } |
1329 | p->begin( pd ); | 1329 | p->begin( pd ); |
1330 | } | 1330 | } |
1331 | 1331 | ||
1332 | } | 1332 | } |
1333 | 1333 | ||
1334 | void KOAgenda::finishUpdate() | 1334 | void KOAgenda::finishUpdate() |
1335 | { | 1335 | { |
1336 | 1336 | ||
1337 | KOAgendaItem *item; | 1337 | KOAgendaItem *item; |
1338 | globalFlagBlockAgendaItemPaint = 1; | 1338 | globalFlagBlockAgendaItemPaint = 1; |
1339 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | 1339 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems |
1340 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1340 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1341 | if ( !item->checkLayout() ) { | 1341 | if ( !item->checkLayout() ) { |
1342 | //qDebug(" conflictitem found "); | 1342 | //qDebug(" conflictitem found "); |
1343 | int newSubCellWidth; | 1343 | int newSubCellWidth; |
1344 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1344 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1345 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1345 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1346 | 1346 | ||
1347 | if (mAllDayMode) { | 1347 | if (mAllDayMode) { |
1348 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1348 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1349 | } else { | 1349 | } else { |
1350 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1350 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1351 | } | 1351 | } |
1352 | int x,y; | 1352 | int x,y; |
1353 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1353 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1354 | if (mAllDayMode) { | 1354 | if (mAllDayMode) { |
1355 | y += item->subCell() * newSubCellWidth; | 1355 | y += item->subCell() * newSubCellWidth; |
1356 | } else { | 1356 | } else { |
1357 | x += item->subCell() * newSubCellWidth; | 1357 | x += item->subCell() * newSubCellWidth; |
1358 | } | 1358 | } |
1359 | moveChild(item,x,y); | 1359 | moveChild(item,x,y); |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1362 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1363 | if ( !item->isVisible() ) | 1363 | if ( !item->isVisible() ) |
1364 | item->show(); | 1364 | item->show(); |
1365 | 1365 | ||
1366 | } | 1366 | } |
1367 | globalFlagBlockAgendaItemUpdate = 0; | 1367 | globalFlagBlockAgendaItemUpdate = 0; |
1368 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1368 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1369 | item->repaintMe( ); | 1369 | item->repaintMe( ); |
1370 | } | 1370 | } |
1371 | globalFlagBlockAgendaItemUpdate = 1; | 1371 | globalFlagBlockAgendaItemUpdate = 1; |
1372 | qApp->processEvents(); | 1372 | qApp->processEvents(); |
1373 | globalFlagBlockAgendaItemPaint = 0; | 1373 | globalFlagBlockAgendaItemPaint = 0; |
1374 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1374 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1375 | item->repaint( false ); | 1375 | item->repaint( false ); |
1376 | } | 1376 | } |
1377 | 1377 | ||
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | /* | 1380 | /* |
1381 | Draw grid in the background of the agenda. | 1381 | Draw grid in the background of the agenda. |
1382 | */ | 1382 | */ |
1383 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1383 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1384 | { | 1384 | { |
1385 | 1385 | ||
1386 | 1386 | ||
1387 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1387 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1388 | return; | 1388 | return; |
1389 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1389 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1390 | return; | 1390 | return; |
1391 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1391 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1392 | if ( ch < 1 ) | 1392 | if ( ch < 1 ) |
1393 | ch = 1; | 1393 | ch = 1; |
1394 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1394 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1395 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1395 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1396 | } | 1396 | } |
1397 | mCurPixWid = contentsWidth(); | 1397 | mCurPixWid = contentsWidth(); |
1398 | mCurPixHei = ch; | 1398 | mCurPixHei = ch; |
1399 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1399 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1400 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1400 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1401 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1401 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1402 | } | 1402 | } |
1403 | mPixPainter.begin( &mPaintPixmap) ; | 1403 | mPixPainter.begin( &mPaintPixmap) ; |
1404 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1404 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1405 | QPainter * p ; | 1405 | QPainter * p ; |
1406 | if (paint == 0) { | 1406 | if (paint == 0) { |
1407 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1407 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1408 | p = &mPixPainter; | 1408 | p = &mPixPainter; |
1409 | } | 1409 | } |
1410 | else | 1410 | else |
1411 | p = paint ; | 1411 | p = paint ; |
1412 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1412 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1413 | 1413 | ||
1414 | //--cx;++cw; | 1414 | //--cx;++cw; |
1415 | int lGridSpacingY = mGridSpacingY*2; | 1415 | int lGridSpacingY = mGridSpacingY*2; |
1416 | int selDay; | 1416 | int selDay; |
1417 | if ( !backgroundOnly ) | 1417 | QDate curDate = QDate::currentDate(); |
1418 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1418 | if ( !backgroundOnly ) { |
1419 | { | 1419 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1420 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1420 | { |
1421 | int x1 = cx; | 1421 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1422 | int y1 = 0; | 1422 | int x1 = cx; |
1423 | if (y1 < cy) y1 = cy; | 1423 | int y1 = 0; |
1424 | int x2 = cx+cw-1; | 1424 | if (y1 < cy) y1 = cy; |
1425 | int y2 = contentsHeight(); | 1425 | int x2 = cx+cw-1; |
1426 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1426 | int y2 = contentsHeight(); |
1427 | if (x2 >= x1 && y2 >= y1) { | 1427 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1428 | int gxStart = selDay; | 1428 | if (x2 >= x1 && y2 >= y1) { |
1429 | int gxEnd = gxStart ; | 1429 | int gxStart = selDay; |
1430 | int xStart = KOGlobals::self()->reverseLayout() ? | 1430 | int gxEnd = gxStart ; |
1431 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1431 | int xStart = KOGlobals::self()->reverseLayout() ? |
1432 | gxStart*mGridSpacingX; | 1432 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1433 | if (xStart < x1) xStart = x1; | 1433 | gxStart*mGridSpacingX; |
1434 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1434 | if (xStart < x1) xStart = x1; |
1435 | (mColumns - gxStart)*mGridSpacingX-1 : | 1435 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1436 | (gxStart+1)*mGridSpacingX-1; | 1436 | (mColumns - gxStart)*mGridSpacingX-1 : |
1437 | if (xEnd > x2) xEnd = x2; | 1437 | (gxStart+1)*mGridSpacingX-1; |
1438 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1438 | if (xEnd > x2) xEnd = x2; |
1439 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1439 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1440 | KOPrefs::instance()->mAgendaBgColor.light()); | 1440 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1441 | else | 1441 | KOPrefs::instance()->mAgendaBgColor.light()); |
1442 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1442 | else |
1443 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1443 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1444 | KOPrefs::instance()->mAgendaBgColor.dark()); | ||
1444 | 1445 | ||
1445 | } | 1446 | } |
1446 | } | 1447 | } |
1447 | } | 1448 | } |
1448 | // Highlight working hours | 1449 | } |
1449 | 1450 | // Highlight working hours | |
1450 | if ( !backgroundOnly ) | 1451 | |
1451 | if (mWorkingHoursEnable) { | 1452 | if ( !backgroundOnly ) |
1452 | int x1 = cx; | 1453 | if (mWorkingHoursEnable) { |
1453 | int y1 = mWorkingHoursYTop; | 1454 | int x1 = cx; |
1454 | if (y1 < cy) y1 = cy; | 1455 | int y1 = mWorkingHoursYTop; |
1455 | int x2 = cx+cw-1; | 1456 | if (y1 < cy) y1 = cy; |
1456 | // int x2 = mGridSpacingX * 5 - 1; | 1457 | int x2 = cx+cw-1; |
1457 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1458 | // int x2 = mGridSpacingX * 5 - 1; |
1458 | int y2 = mWorkingHoursYBottom; | 1459 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1459 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1460 | int y2 = mWorkingHoursYBottom; |
1460 | 1461 | if (y2 > cy+ch-1) y2=cy+ch-1; | |
1461 | if (x2 >= x1 && y2 >= y1) { | 1462 | |
1462 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1463 | if (x2 >= x1 && y2 >= y1) { |
1463 | int gxStart = x1/mGridSpacingX; | 1464 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1464 | int gxEnd = x2/mGridSpacingX; | 1465 | int gxStart = x1/mGridSpacingX; |
1465 | while(gxStart <= gxEnd) { | 1466 | int gxEnd = x2/mGridSpacingX; |
1466 | if (gxStart < int(mHolidayMask->count()) && | 1467 | while(gxStart <= gxEnd) { |
1467 | !mHolidayMask->at(gxStart)) { | 1468 | if (gxStart < int(mHolidayMask->count()) && |
1468 | int xStart = KOGlobals::self()->reverseLayout() ? | 1469 | !mHolidayMask->at(gxStart)) { |
1469 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1470 | int xStart = KOGlobals::self()->reverseLayout() ? |
1470 | gxStart*mGridSpacingX; | 1471 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1471 | if (xStart < x1) xStart = x1; | 1472 | gxStart*mGridSpacingX; |
1472 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1473 | if (xStart < x1) xStart = x1; |
1473 | (mColumns - gxStart)*mGridSpacingX-1 : | 1474 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1474 | (gxStart+1)*mGridSpacingX-1; | 1475 | (mColumns - gxStart)*mGridSpacingX-1 : |
1475 | if (xEnd > x2) xEnd = x2; | 1476 | (gxStart+1)*mGridSpacingX-1; |
1476 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1477 | if (xEnd > x2) xEnd = x2; |
1477 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1478 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1478 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1479 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1479 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1480 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1480 | else | 1481 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1481 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1482 | else |
1482 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1483 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1483 | } else { | 1484 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1484 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1485 | } else { |
1485 | KOPrefs::instance()->mWorkingHoursColor); | 1486 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1486 | } | 1487 | KOPrefs::instance()->mWorkingHoursColor); |
1488 | } | ||
1489 | } | ||
1490 | ++gxStart; | ||
1491 | } | ||
1492 | } | ||
1487 | } | 1493 | } |
1488 | ++gxStart; | 1494 | /* |
1495 | int selectionX = KOGlobals::self()->reverseLayout() ? | ||
1496 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | ||
1497 | mSelectionCellX * mGridSpacingX; | ||
1498 | |||
1499 | // Draw selection | ||
1500 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | ||
1501 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | ||
1502 | // TODO: paint only part within cx,cy,cw,ch | ||
1503 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | ||
1504 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | ||
1489 | } | 1505 | } |
1490 | } | 1506 | */ |
1491 | } | 1507 | // Draw vertical lines of grid |
1492 | /* | ||
1493 | int selectionX = KOGlobals::self()->reverseLayout() ? | ||
1494 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | ||
1495 | mSelectionCellX * mGridSpacingX; | ||
1496 | |||
1497 | // Draw selection | ||
1498 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | ||
1499 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | ||
1500 | // TODO: paint only part within cx,cy,cw,ch | ||
1501 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | ||
1502 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | ||
1503 | } | ||
1504 | */ | ||
1505 | // Draw vertical lines of grid | ||
1506 | 1508 | ||
1507 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1509 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1508 | if ( mGridSpacingX > 0 ) { | 1510 | if ( mGridSpacingX > 0 ) { |
1509 | while (x < cx + cw) { | 1511 | while (x < cx + cw) { |
1510 | p->drawLine(x,cy,x,cy+ch); | 1512 | p->drawLine(x,cy,x,cy+ch); |
1511 | x+=mGridSpacingX; | 1513 | x+=mGridSpacingX; |
1512 | } | 1514 | } |
1513 | } | 1515 | } |
1514 | // Draw horizontal lines of grid | 1516 | // Draw horizontal lines of grid |
1515 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1517 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1516 | if ( lGridSpacingY > 0 ) { | 1518 | if ( lGridSpacingY > 0 ) { |
1517 | while (y < cy + ch) { | 1519 | while (y < cy + ch) { |
1518 | p->setPen( SolidLine ); | 1520 | p->setPen( SolidLine ); |
1519 | p->drawLine(cx,y,cx+cw,y); | 1521 | p->drawLine(cx,y,cx+cw,y); |
1520 | y+=lGridSpacingY; | 1522 | y+=lGridSpacingY; |
1521 | p->setPen( DotLine ); | 1523 | p->setPen( DotLine ); |
1522 | p->drawLine(cx,y,cx+cw,y); | 1524 | p->drawLine(cx,y,cx+cw,y); |
1523 | y+=lGridSpacingY; | 1525 | y+=lGridSpacingY; |
1524 | } | 1526 | } |
1525 | p->setPen( SolidLine ); | 1527 | p->setPen( SolidLine ); |
1526 | } | 1528 | } |
1527 | mPixPainter.end() ; | 1529 | mPixPainter.end() ; |
1528 | } | 1530 | } |
1529 | 1531 | ||
1530 | /* | 1532 | /* |
1531 | Convert srcollview contents coordinates to agenda grid coordinates. | 1533 | Convert srcollview contents coordinates to agenda grid coordinates. |
1532 | */ | 1534 | */ |
1533 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1535 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1534 | { | 1536 | { |
1535 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1537 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1536 | x/mGridSpacingX; | 1538 | x/mGridSpacingX; |
1537 | gy = y/mGridSpacingY; | 1539 | gy = y/mGridSpacingY; |
1538 | } | 1540 | } |
1539 | 1541 | ||
1540 | /* | 1542 | /* |
1541 | Convert agenda grid coordinates to scrollview contents coordinates. | 1543 | Convert agenda grid coordinates to scrollview contents coordinates. |
1542 | */ | 1544 | */ |
1543 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1545 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1544 | { | 1546 | { |
1545 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1547 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1546 | gx*mGridSpacingX; | 1548 | gx*mGridSpacingX; |
1547 | y = gy*mGridSpacingY; | 1549 | y = gy*mGridSpacingY; |
1548 | } | 1550 | } |
1549 | 1551 | ||
1550 | 1552 | ||
1551 | /* | 1553 | /* |
1552 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1554 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1553 | the grid. | 1555 | the grid. |
1554 | */ | 1556 | */ |
1555 | int KOAgenda::timeToY(const QTime &time) | 1557 | int KOAgenda::timeToY(const QTime &time) |
1556 | { | 1558 | { |
1557 | int minutesPerCell = 24 * 60 / mRows; | 1559 | int minutesPerCell = 24 * 60 / mRows; |
1558 | int timeMinutes = time.hour() * 60 + time.minute(); | 1560 | int timeMinutes = time.hour() * 60 + time.minute(); |
1559 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1561 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1560 | return Y; | 1562 | return Y; |
1561 | } | 1563 | } |
1562 | 1564 | ||
1563 | 1565 | ||
1564 | /* | 1566 | /* |
1565 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1567 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1566 | fit into the grid. | 1568 | fit into the grid. |
1567 | */ | 1569 | */ |
1568 | QTime KOAgenda::gyToTime(int gy) | 1570 | QTime KOAgenda::gyToTime(int gy) |
1569 | { | 1571 | { |
1570 | 1572 | ||
1571 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1573 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1572 | 1574 | ||
1573 | int timeSeconds = secondsPerCell * gy; | 1575 | int timeSeconds = secondsPerCell * gy; |
1574 | 1576 | ||
1575 | QTime time( 0, 0, 0 ); | 1577 | QTime time( 0, 0, 0 ); |
1576 | if ( timeSeconds < 24 * 60 * 60 ) { | 1578 | if ( timeSeconds < 24 * 60 * 60 ) { |
1577 | time = time.addSecs(timeSeconds); | 1579 | time = time.addSecs(timeSeconds); |
1578 | } else { | 1580 | } else { |
1579 | time.setHMS( 23, 59, 59 ); | 1581 | time.setHMS( 23, 59, 59 ); |
1580 | } | 1582 | } |
1581 | 1583 | ||
1582 | return time; | 1584 | return time; |
1583 | } | 1585 | } |
1584 | 1586 | ||
1585 | void KOAgenda::setStartHour(int startHour) | 1587 | void KOAgenda::setStartHour(int startHour) |
1586 | { | 1588 | { |
1587 | int startCell = startHour * mRows / 24; | 1589 | int startCell = startHour * mRows / 24; |
1588 | setContentsPos(0,startCell * gridSpacingY()); | 1590 | setContentsPos(0,startCell * gridSpacingY()); |
1589 | } | 1591 | } |
1590 | void KOAgenda::hideUnused() | 1592 | void KOAgenda::hideUnused() |
1591 | { | 1593 | { |
1592 | // experimental only | 1594 | // experimental only |
1593 | // return; | 1595 | // return; |
1594 | KOAgendaItem *item; | 1596 | KOAgendaItem *item; |
1595 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1597 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1596 | item->hide(); | 1598 | item->hide(); |
1597 | } | 1599 | } |
1598 | } | 1600 | } |
1599 | 1601 | ||
1600 | 1602 | ||
1601 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1603 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1602 | { | 1604 | { |
1603 | 1605 | ||
1604 | KOAgendaItem *fi; | 1606 | KOAgendaItem *fi; |
1605 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1607 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1606 | if ( fi->incidence() == event ) { | 1608 | if ( fi->incidence() == event ) { |
1607 | mUnusedItems.remove(); | 1609 | mUnusedItems.remove(); |
1608 | fi->init( event, qd ); | 1610 | fi->init( event, qd ); |
1609 | return fi; | 1611 | return fi; |
1610 | } | 1612 | } |
1611 | } | 1613 | } |
1612 | fi=mUnusedItems.first(); | 1614 | fi=mUnusedItems.first(); |
1613 | if ( fi ) { | 1615 | if ( fi ) { |
1614 | mUnusedItems.remove(); | 1616 | mUnusedItems.remove(); |
1615 | fi->init( event, qd ); | 1617 | fi->init( event, qd ); |
1616 | return fi; | 1618 | return fi; |
1617 | } | 1619 | } |
1618 | // qDebug("new KOAgendaItem "); | 1620 | // qDebug("new KOAgendaItem "); |
1619 | 1621 | ||
1620 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1622 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1621 | agendaItem->installEventFilter(this); | 1623 | agendaItem->installEventFilter(this); |
1622 | addChild(agendaItem,0,0); | 1624 | addChild(agendaItem,0,0); |
1623 | return agendaItem; | 1625 | return agendaItem; |
1624 | } | 1626 | } |
1625 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1627 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1626 | { | 1628 | { |
1627 | KOAgendaItem *item; | 1629 | KOAgendaItem *item; |
1628 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1630 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1629 | if ( item->incidence() == todo ) { | 1631 | if ( item->incidence() == todo ) { |
1630 | mItems.remove(); | 1632 | mItems.remove(); |
1631 | return item; | 1633 | return item; |
1632 | } | 1634 | } |
1633 | } | 1635 | } |
1634 | return 0; | 1636 | return 0; |
1635 | } | 1637 | } |
1636 | 1638 | ||
1637 | 1639 | ||
1638 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1640 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1639 | { | 1641 | { |
1640 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1642 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1641 | KOAgendaItem *item; | 1643 | KOAgendaItem *item; |
1642 | item = getItemForTodo ( todo ); | 1644 | item = getItemForTodo ( todo ); |
1643 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1645 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1644 | if ( item ) { | 1646 | if ( item ) { |
1645 | blockSignals( true ); | 1647 | blockSignals( true ); |
1646 | //qDebug("item found "); | 1648 | //qDebug("item found "); |
1647 | item->hide(); | 1649 | item->hide(); |
1648 | item->setCellX(-2, -1 ); | 1650 | item->setCellX(-2, -1 ); |
1649 | item->select(false); | 1651 | item->select(false); |
1650 | mUnusedItems.append( item ); | 1652 | mUnusedItems.append( item ); |
1651 | mItems.remove( item ); | 1653 | mItems.remove( item ); |
1652 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1654 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1653 | KOAgendaItem *itemit; | 1655 | KOAgendaItem *itemit; |
1654 | //globalFlagBlockAgendaItemPaint = 1; | 1656 | //globalFlagBlockAgendaItemPaint = 1; |
1655 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1657 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1656 | itemit=oldconflictItems.next() ) { | 1658 | itemit=oldconflictItems.next() ) { |
1657 | if ( itemit != item ) | 1659 | if ( itemit != item ) |
1658 | placeSubCells(itemit); | 1660 | placeSubCells(itemit); |
1659 | } | 1661 | } |
1660 | qApp->processEvents(); | 1662 | qApp->processEvents(); |
1661 | //globalFlagBlockAgendaItemPaint = 0; | 1663 | //globalFlagBlockAgendaItemPaint = 0; |
1662 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1664 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1663 | itemit=oldconflictItems.next() ) { | 1665 | itemit=oldconflictItems.next() ) { |
1664 | globalFlagBlockAgendaItemUpdate = 0; | 1666 | globalFlagBlockAgendaItemUpdate = 0; |
1665 | if ( itemit != item ) | 1667 | if ( itemit != item ) |
1666 | itemit->repaintMe(); | 1668 | itemit->repaintMe(); |
1667 | globalFlagBlockAgendaItemUpdate = 1; | 1669 | globalFlagBlockAgendaItemUpdate = 1; |
1668 | itemit->repaint(); | 1670 | itemit->repaint(); |
1669 | } | 1671 | } |
1670 | blockSignals( false ); | 1672 | blockSignals( false ); |
1671 | } | 1673 | } |
1672 | if ( remove ) { | 1674 | if ( remove ) { |
1673 | //qDebug("remove****************************************** "); | 1675 | //qDebug("remove****************************************** "); |
1674 | return; | 1676 | return; |
1675 | } | 1677 | } |
1676 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) | 1678 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) |
1677 | return; | 1679 | return; |
1678 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1680 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1679 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1681 | QDate currentDate = QDate::currentDate(); |
1680 | QDate currentDate; | 1682 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1681 | QDateTime dt; | 1683 | QDateTime dt; |
1682 | if ( todo->hasCompletedDate() ) | 1684 | if ( todo->hasCompletedDate() ) |
1683 | dt = todo->completed(); | 1685 | dt = todo->completed(); |
1684 | else | 1686 | else |
1685 | dt = todo->dtDue(); | 1687 | dt = todo->dtDue(); |
1686 | if ( overdue ) { | 1688 | if ( overdue ) { |
1687 | currentDate = QDate::currentDate(); | ||
1688 | days += todo->dtDue().date().daysTo( currentDate ); | 1689 | days += todo->dtDue().date().daysTo( currentDate ); |
1689 | } | 1690 | } |
1690 | else | 1691 | else |
1691 | currentDate = dt.date(); | 1692 | currentDate = dt.date(); |
1692 | 1693 | ||
1693 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1694 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1694 | if ( ! mAllDayMode ) return; | 1695 | if ( ! mAllDayMode ) return; |
1695 | // aldayagenda | 1696 | // aldayagenda |
1696 | globalFlagBlockAgendaItemPaint = 1; | 1697 | globalFlagBlockAgendaItemPaint = 1; |
1697 | item = insertAllDayItem(todo, currentDate,days, days); | 1698 | item = insertAllDayItem(todo, currentDate,days, days); |
1698 | item->show(); | 1699 | item->show(); |
1699 | 1700 | ||
1700 | } | 1701 | } |
1701 | else { | 1702 | else { |
1702 | if ( mAllDayMode ) return; | 1703 | if ( mAllDayMode ) return; |
1703 | // mAgenda | 1704 | // mAgenda |
1704 | globalFlagBlockAgendaItemPaint = 1; | 1705 | globalFlagBlockAgendaItemPaint = 1; |
1705 | int endY = timeToY(dt.time()) - 1; | 1706 | int endY = timeToY(dt.time()) - 1; |
1706 | int hi = 12/KOPrefs::instance()->mHourSize; | 1707 | int hi = 12/KOPrefs::instance()->mHourSize; |
1707 | int startY = endY - 1-hi; | 1708 | int startY = endY - 1-hi; |
1708 | item = insertItem(todo,currentDate,days,startY,endY); | 1709 | item = insertItem(todo,currentDate,days,startY,endY); |
1709 | item->show(); | 1710 | item->show(); |
1710 | } | 1711 | } |
1711 | qApp->processEvents(); | 1712 | qApp->processEvents(); |
1712 | globalFlagBlockAgendaItemPaint = 0; | 1713 | globalFlagBlockAgendaItemPaint = 0; |
1713 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1714 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1714 | KOAgendaItem *itemit; | 1715 | KOAgendaItem *itemit; |
1715 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1716 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1716 | itemit=oldconflictItems.next() ) { | 1717 | itemit=oldconflictItems.next() ) { |
1717 | globalFlagBlockAgendaItemUpdate = 0; | 1718 | globalFlagBlockAgendaItemUpdate = 0; |
1718 | itemit->repaintMe(); | 1719 | itemit->repaintMe(); |
1719 | globalFlagBlockAgendaItemUpdate = 1; | 1720 | globalFlagBlockAgendaItemUpdate = 1; |
1720 | itemit->repaint(); | 1721 | itemit->repaint(); |
1721 | } | 1722 | } |
1722 | globalFlagBlockAgendaItemUpdate = 0; | 1723 | globalFlagBlockAgendaItemUpdate = 0; |
1723 | item->repaintMe(); | 1724 | item->repaintMe(); |
1724 | globalFlagBlockAgendaItemUpdate = 1; | 1725 | globalFlagBlockAgendaItemUpdate = 1; |
1725 | item->repaint(); | 1726 | item->repaint(); |
1726 | } | 1727 | } |
1727 | /* | 1728 | /* |
1728 | Insert KOAgendaItem into agenda. | 1729 | Insert KOAgendaItem into agenda. |
1729 | */ | 1730 | */ |
1730 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1731 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1731 | { | 1732 | { |
1732 | if (mAllDayMode) { | 1733 | if (mAllDayMode) { |
1733 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1734 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1734 | return 0; | 1735 | return 0; |
1735 | } | 1736 | } |
1736 | 1737 | ||
1737 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1738 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1738 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1739 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1739 | 1740 | ||
1740 | int YSize = YBottom - YTop + 1; | 1741 | int YSize = YBottom - YTop + 1; |
1741 | if (YSize < 0) { | 1742 | if (YSize < 0) { |
1742 | YSize = 1; | 1743 | YSize = 1; |
1743 | } | 1744 | } |
1744 | int iheight = mGridSpacingY * YSize; | 1745 | int iheight = mGridSpacingY * YSize; |
1745 | 1746 | ||
1746 | agendaItem->resize(mGridSpacingX,iheight ); | 1747 | agendaItem->resize(mGridSpacingX,iheight ); |
1747 | agendaItem->setCellXY(X,YTop,YBottom); | 1748 | agendaItem->setCellXY(X,YTop,YBottom); |
1748 | agendaItem->setCellXWidth(X); | 1749 | agendaItem->setCellXWidth(X); |
1749 | 1750 | ||
1750 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1751 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1751 | mItems.append(agendaItem); | 1752 | mItems.append(agendaItem); |
1752 | 1753 | ||
1753 | placeSubCells(agendaItem); | 1754 | placeSubCells(agendaItem); |
1754 | 1755 | ||
1755 | //agendaItem->show(); | 1756 | //agendaItem->show(); |
1756 | 1757 | ||
1757 | marcus_bains(); | 1758 | marcus_bains(); |
1758 | 1759 | ||
1759 | return agendaItem; | 1760 | return agendaItem; |
1760 | } | 1761 | } |
1761 | 1762 | ||
1762 | 1763 | ||
1763 | /* | 1764 | /* |
1764 | Insert all-day KOAgendaItem into agenda. | 1765 | Insert all-day KOAgendaItem into agenda. |
1765 | */ | 1766 | */ |
1766 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1767 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1767 | { | 1768 | { |
1768 | if (!mAllDayMode) { | 1769 | if (!mAllDayMode) { |
1769 | return 0; | 1770 | return 0; |
1770 | } | 1771 | } |
1771 | 1772 | ||
1772 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1773 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1773 | 1774 | ||
1774 | agendaItem->setCellXY(XBegin,0,0); | 1775 | agendaItem->setCellXY(XBegin,0,0); |
1775 | agendaItem->setCellXWidth(XEnd); | 1776 | agendaItem->setCellXWidth(XEnd); |
1776 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1777 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1777 | 1778 | ||
1778 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1779 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1779 | mItems.append(agendaItem); | 1780 | mItems.append(agendaItem); |
1780 | 1781 | ||
1781 | placeSubCells(agendaItem); | 1782 | placeSubCells(agendaItem); |
1782 | 1783 | ||
1783 | //agendaItem->show(); | 1784 | //agendaItem->show(); |