author | zautrix <zautrix> | 2005-08-17 12:04:19 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 12:04:19 (UTC) |
commit | 31393a99cd2b190e62a7a09a7739a14af83936d1 (patch) (unidiff) | |
tree | 1e000be050be3119f7b7eb8a248401c39cabf597 | |
parent | 5f33ec89f5110ea646a32856eb6685c61cf24079 (diff) | |
download | kdepimpi-31393a99cd2b190e62a7a09a7739a14af83936d1.zip kdepimpi-31393a99cd2b190e62a7a09a7739a14af83936d1.tar.gz kdepimpi-31393a99cd2b190e62a7a09a7739a14af83936d1.tar.bz2 |
fixed warnings
-rw-r--r-- | korganizer/koagenda.cpp | 21 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 11 |
3 files changed, 18 insertions, 15 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 7d9d674..88f5d99 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1342,271 +1342,271 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | |||
1342 | offset += 5; | 1342 | offset += 5; |
1343 | } | 1343 | } |
1344 | } | 1344 | } |
1345 | } | 1345 | } |
1346 | p->begin( pd ); | 1346 | p->begin( pd ); |
1347 | } else { | 1347 | } else { |
1348 | #if 0 | 1348 | #if 0 |
1349 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); | 1349 | qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); |
1350 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { | 1350 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { |
1351 | qDebug("WAUWAU "); | 1351 | qDebug("WAUWAU "); |
1352 | drawContentsToPainter(); | 1352 | drawContentsToPainter(); |
1353 | } | 1353 | } |
1354 | #endif | 1354 | #endif |
1355 | QPaintDevice* pd = p->device(); | 1355 | QPaintDevice* pd = p->device(); |
1356 | p->end(); | 1356 | p->end(); |
1357 | int vx, vy; | 1357 | int vx, vy; |
1358 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1358 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1359 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1359 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1360 | mSelectionCellX * mGridSpacingX; | 1360 | mSelectionCellX * mGridSpacingX; |
1361 | contentsToViewport ( cx, cy, vx,vy); | 1361 | contentsToViewport ( cx, cy, vx,vy); |
1362 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1362 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1363 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1363 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1364 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1364 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1365 | 1365 | ||
1366 | if ( mSelectionHeight > 0 ) { | 1366 | if ( mSelectionHeight > 0 ) { |
1367 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1367 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1368 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1368 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1369 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1369 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1370 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1370 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1371 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1371 | //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1372 | int hei = mSelectionHeight; | 1372 | int hei = mSelectionHeight; |
1373 | int offset = 0; | 1373 | int offset = 0; |
1374 | while ( hei > 0 ) { | 1374 | while ( hei > 0 ) { |
1375 | int p_hei = 5; | 1375 | int p_hei = 5; |
1376 | if ( hei < 5 ) p_hei = hei; | 1376 | if ( hei < 5 ) p_hei = hei; |
1377 | hei -= 5; | 1377 | hei -= 5; |
1378 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); | 1378 | bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); |
1379 | offset += 5; | 1379 | offset += 5; |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | p->begin( pd ); | 1383 | p->begin( pd ); |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | void KOAgenda::finishUpdate() | 1388 | void KOAgenda::finishUpdate() |
1389 | { | 1389 | { |
1390 | 1390 | ||
1391 | KOAgendaItem *item; | 1391 | KOAgendaItem *item; |
1392 | globalFlagBlockAgendaItemPaint = 1; | 1392 | globalFlagBlockAgendaItemPaint = 1; |
1393 | // 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 | 1393 | // 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 |
1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1394 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1395 | if ( !item->checkLayout() ) { | 1395 | if ( !item->checkLayout() ) { |
1396 | //qDebug(" conflictitem found "); | 1396 | //qDebug(" conflictitem found "); |
1397 | int newSubCellWidth; | 1397 | int newSubCellWidth; |
1398 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | 1398 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); |
1399 | else newSubCellWidth = mGridSpacingX / item->subCells(); | 1399 | else newSubCellWidth = mGridSpacingX / item->subCells(); |
1400 | 1400 | ||
1401 | if (mAllDayMode) { | 1401 | if (mAllDayMode) { |
1402 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1402 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1403 | } else { | 1403 | } else { |
1404 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1404 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1405 | } | 1405 | } |
1406 | int x,y; | 1406 | int x,y; |
1407 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1407 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1408 | if (mAllDayMode) { | 1408 | if (mAllDayMode) { |
1409 | y += item->subCell() * newSubCellWidth; | 1409 | y += item->subCell() * newSubCellWidth; |
1410 | } else { | 1410 | } else { |
1411 | x += item->subCell() * newSubCellWidth; | 1411 | x += item->subCell() * newSubCellWidth; |
1412 | } | 1412 | } |
1413 | moveChild(item,x,y); | 1413 | moveChild(item,x,y); |
1414 | } | 1414 | } |
1415 | } | 1415 | } |
1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1416 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1417 | if ( !item->isVisible() ) | 1417 | if ( !item->isVisible() ) |
1418 | item->show(); | 1418 | item->show(); |
1419 | 1419 | ||
1420 | } | 1420 | } |
1421 | globalFlagBlockAgendaItemUpdate = 0; | 1421 | globalFlagBlockAgendaItemUpdate = 0; |
1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1422 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1423 | item->repaintMe( ); | 1423 | item->repaintMe( ); |
1424 | } | 1424 | } |
1425 | globalFlagBlockAgendaItemUpdate = 1; | 1425 | globalFlagBlockAgendaItemUpdate = 1; |
1426 | qApp->processEvents(); | 1426 | qApp->processEvents(); |
1427 | globalFlagBlockAgendaItemPaint = 0; | 1427 | globalFlagBlockAgendaItemPaint = 0; |
1428 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1428 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1429 | item->repaint( false ); | 1429 | item->repaint( false ); |
1430 | } | 1430 | } |
1431 | marcus_bains(); | 1431 | marcus_bains(); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | /* | 1434 | /* |
1435 | Draw grid in the background of the agenda. | 1435 | Draw grid in the background of the agenda. |
1436 | */ | 1436 | */ |
1437 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1437 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1438 | { | 1438 | { |
1439 | 1439 | ||
1440 | 1440 | ||
1441 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1441 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1442 | return; | 1442 | return; |
1443 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1443 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1444 | return; | 1444 | return; |
1445 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1445 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1446 | if ( ch < 1 ) | 1446 | if ( ch < 1 ) |
1447 | ch = 1; | 1447 | ch = 1; |
1448 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1448 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1449 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1449 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1450 | } | 1450 | } |
1451 | mCurPixWid = contentsWidth(); | 1451 | mCurPixWid = contentsWidth(); |
1452 | mCurPixHei = ch; | 1452 | mCurPixHei = ch; |
1453 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { | 1453 | if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { |
1454 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); | 1454 | mHighlightPixmap.resize( mGridSpacingX-1, 5 ); |
1455 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1455 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1456 | } | 1456 | } |
1457 | mPixPainter.begin( &mPaintPixmap) ; | 1457 | mPixPainter.begin( &mPaintPixmap) ; |
1458 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1458 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1459 | QPainter * p ; | 1459 | QPainter * p ; |
1460 | if (paint == 0) { | 1460 | if (paint == 0) { |
1461 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1461 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1462 | p = &mPixPainter; | 1462 | p = &mPixPainter; |
1463 | } | 1463 | } |
1464 | else | 1464 | else |
1465 | p = paint ; | 1465 | p = paint ; |
1466 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1466 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1467 | 1467 | ||
1468 | //--cx;++cw; | 1468 | //--cx;++cw; |
1469 | int lGridSpacingY = mGridSpacingY*2; | 1469 | int lGridSpacingY = mGridSpacingY*2; |
1470 | int selDay; | 1470 | uint selDay; |
1471 | QDate curDate = QDate::currentDate(); | 1471 | QDate curDate = QDate::currentDate(); |
1472 | if ( !backgroundOnly ) { | 1472 | if ( !backgroundOnly ) { |
1473 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1473 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1474 | { | 1474 | { |
1475 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { | 1475 | if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { |
1476 | int x1 = cx; | 1476 | int x1 = cx; |
1477 | int y1 = 0; | 1477 | int y1 = 0; |
1478 | if (y1 < cy) y1 = cy; | 1478 | if (y1 < cy) y1 = cy; |
1479 | int x2 = cx+cw-1; | 1479 | int x2 = cx+cw-1; |
1480 | int y2 = contentsHeight(); | 1480 | int y2 = contentsHeight(); |
1481 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1481 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1482 | if (x2 >= x1 && y2 >= y1) { | 1482 | if (x2 >= x1 && y2 >= y1) { |
1483 | int gxStart = selDay; | 1483 | int gxStart = selDay; |
1484 | int gxEnd = gxStart ; | 1484 | //int gxEnd = gxStart ; |
1485 | int xStart = KOGlobals::self()->reverseLayout() ? | 1485 | int xStart = KOGlobals::self()->reverseLayout() ? |
1486 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1486 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1487 | gxStart*mGridSpacingX; | 1487 | gxStart*mGridSpacingX; |
1488 | if (xStart < x1) xStart = x1; | 1488 | if (xStart < x1) xStart = x1; |
1489 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1489 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1490 | (mColumns - gxStart)*mGridSpacingX-1 : | 1490 | (mColumns - gxStart)*mGridSpacingX-1 : |
1491 | (gxStart+1)*mGridSpacingX-1; | 1491 | (gxStart+1)*mGridSpacingX-1; |
1492 | if (xEnd > x2) xEnd = x2; | 1492 | if (xEnd > x2) xEnd = x2; |
1493 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1493 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1494 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1494 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1495 | KOPrefs::instance()->mAgendaBgColor.light()); | 1495 | KOPrefs::instance()->mAgendaBgColor.light()); |
1496 | else | 1496 | else |
1497 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1497 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1498 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1498 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1499 | 1499 | ||
1500 | } | 1500 | } |
1501 | } | 1501 | } |
1502 | } | 1502 | } |
1503 | } | 1503 | } |
1504 | // Highlight working hours | 1504 | // Highlight working hours |
1505 | 1505 | ||
1506 | if ( !backgroundOnly ) | 1506 | if ( !backgroundOnly ) |
1507 | if (mWorkingHoursEnable) { | 1507 | if (mWorkingHoursEnable) { |
1508 | int x1 = cx; | 1508 | int x1 = cx; |
1509 | int y1 = mWorkingHoursYTop; | 1509 | int y1 = mWorkingHoursYTop; |
1510 | if (y1 < cy) y1 = cy; | 1510 | if (y1 < cy) y1 = cy; |
1511 | int x2 = cx+cw-1; | 1511 | int x2 = cx+cw-1; |
1512 | // int x2 = mGridSpacingX * 5 - 1; | 1512 | // int x2 = mGridSpacingX * 5 - 1; |
1513 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1513 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1514 | int y2 = mWorkingHoursYBottom; | 1514 | int y2 = mWorkingHoursYBottom; |
1515 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1515 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1516 | 1516 | ||
1517 | if (x2 >= x1 && y2 >= y1) { | 1517 | if (x2 >= x1 && y2 >= y1) { |
1518 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1518 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1519 | int gxStart = x1/mGridSpacingX; | 1519 | int gxStart = x1/mGridSpacingX; |
1520 | int gxEnd = x2/mGridSpacingX; | 1520 | int gxEnd = x2/mGridSpacingX; |
1521 | while(gxStart <= gxEnd) { | 1521 | while(gxStart <= gxEnd) { |
1522 | if (gxStart < int(mHolidayMask->count()) && | 1522 | if (gxStart < int(mHolidayMask->count()) && |
1523 | !mHolidayMask->at(gxStart)) { | 1523 | !mHolidayMask->at(gxStart)) { |
1524 | int xStart = KOGlobals::self()->reverseLayout() ? | 1524 | int xStart = KOGlobals::self()->reverseLayout() ? |
1525 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1525 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1526 | gxStart*mGridSpacingX; | 1526 | gxStart*mGridSpacingX; |
1527 | if (xStart < x1) xStart = x1; | 1527 | if (xStart < x1) xStart = x1; |
1528 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1528 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1529 | (mColumns - gxStart)*mGridSpacingX-1 : | 1529 | (mColumns - gxStart)*mGridSpacingX-1 : |
1530 | (gxStart+1)*mGridSpacingX-1; | 1530 | (gxStart+1)*mGridSpacingX-1; |
1531 | if (xEnd > x2) xEnd = x2; | 1531 | if (xEnd > x2) xEnd = x2; |
1532 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { | 1532 | if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { |
1533 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1533 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1534 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1534 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1535 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1535 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1536 | else | 1536 | else |
1537 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1537 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1538 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1538 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1539 | } else { | 1539 | } else { |
1540 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1540 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1541 | KOPrefs::instance()->mWorkingHoursColor); | 1541 | KOPrefs::instance()->mWorkingHoursColor); |
1542 | } | 1542 | } |
1543 | } | 1543 | } |
1544 | ++gxStart; | 1544 | ++gxStart; |
1545 | } | 1545 | } |
1546 | } | 1546 | } |
1547 | } | 1547 | } |
1548 | /* | 1548 | /* |
1549 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1549 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1550 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1550 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1551 | mSelectionCellX * mGridSpacingX; | 1551 | mSelectionCellX * mGridSpacingX; |
1552 | 1552 | ||
1553 | // Draw selection | 1553 | // Draw selection |
1554 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1554 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1555 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1555 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1556 | // TODO: paint only part within cx,cy,cw,ch | 1556 | // TODO: paint only part within cx,cy,cw,ch |
1557 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1557 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1558 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1558 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1559 | } | 1559 | } |
1560 | */ | 1560 | */ |
1561 | // Draw vertical lines of grid | 1561 | // Draw vertical lines of grid |
1562 | 1562 | ||
1563 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1563 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1564 | if ( mGridSpacingX > 0 ) { | 1564 | if ( mGridSpacingX > 0 ) { |
1565 | while (x < cx + cw) { | 1565 | while (x < cx + cw) { |
1566 | p->drawLine(x,cy,x,cy+ch); | 1566 | p->drawLine(x,cy,x,cy+ch); |
1567 | x+=mGridSpacingX; | 1567 | x+=mGridSpacingX; |
1568 | } | 1568 | } |
1569 | } | 1569 | } |
1570 | // Draw horizontal lines of grid | 1570 | // Draw horizontal lines of grid |
1571 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1571 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1572 | if ( lGridSpacingY > 0 ) { | 1572 | if ( lGridSpacingY > 0 ) { |
1573 | while (y < cy + ch) { | 1573 | while (y < cy + ch) { |
1574 | p->setPen( SolidLine ); | 1574 | p->setPen( SolidLine ); |
1575 | p->drawLine(cx,y,cx+cw,y); | 1575 | p->drawLine(cx,y,cx+cw,y); |
1576 | y+=lGridSpacingY; | 1576 | y+=lGridSpacingY; |
1577 | p->setPen( DotLine ); | 1577 | p->setPen( DotLine ); |
1578 | p->drawLine(cx,y,cx+cw,y); | 1578 | p->drawLine(cx,y,cx+cw,y); |
1579 | y+=lGridSpacingY; | 1579 | y+=lGridSpacingY; |
1580 | } | 1580 | } |
1581 | p->setPen( SolidLine ); | 1581 | p->setPen( SolidLine ); |
1582 | } | 1582 | } |
1583 | mPixPainter.end() ; | 1583 | mPixPainter.end() ; |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | /* | 1586 | /* |
1587 | Convert srcollview contents coordinates to agenda grid coordinates. | 1587 | Convert srcollview contents coordinates to agenda grid coordinates. |
1588 | */ | 1588 | */ |
1589 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1589 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1590 | { | 1590 | { |
1591 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1591 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1592 | x/mGridSpacingX; | 1592 | x/mGridSpacingX; |
1593 | gy = y/mGridSpacingY; | 1593 | gy = y/mGridSpacingY; |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | /* | 1596 | /* |
1597 | Convert agenda grid coordinates to scrollview contents coordinates. | 1597 | Convert agenda grid coordinates to scrollview contents coordinates. |
1598 | */ | 1598 | */ |
1599 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1599 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1600 | { | 1600 | { |
1601 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1601 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1602 | gx*mGridSpacingX; | 1602 | gx*mGridSpacingX; |
1603 | y = gy*mGridSpacingY; | 1603 | y = gy*mGridSpacingY; |
1604 | } | 1604 | } |
1605 | 1605 | ||
1606 | 1606 | ||
1607 | /* | 1607 | /* |
1608 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1608 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1609 | the grid. | 1609 | the grid. |
1610 | */ | 1610 | */ |
1611 | int KOAgenda::timeToY(const QTime &time) | 1611 | int KOAgenda::timeToY(const QTime &time) |
1612 | { | 1612 | { |
@@ -1797,256 +1797,257 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int | |||
1797 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); | 1797 | qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); |
1798 | return 0; | 1798 | return 0; |
1799 | } | 1799 | } |
1800 | 1800 | ||
1801 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1801 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1802 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1802 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1803 | 1803 | ||
1804 | int YSize = YBottom - YTop + 1; | 1804 | int YSize = YBottom - YTop + 1; |
1805 | if (YSize < 0) { | 1805 | if (YSize < 0) { |
1806 | YSize = 1; | 1806 | YSize = 1; |
1807 | } | 1807 | } |
1808 | int iheight = mGridSpacingY * YSize; | 1808 | int iheight = mGridSpacingY * YSize; |
1809 | 1809 | ||
1810 | agendaItem->resize(mGridSpacingX,iheight ); | 1810 | agendaItem->resize(mGridSpacingX,iheight ); |
1811 | agendaItem->setCellXY(X,YTop,YBottom); | 1811 | agendaItem->setCellXY(X,YTop,YBottom); |
1812 | agendaItem->setCellXWidth(X); | 1812 | agendaItem->setCellXWidth(X); |
1813 | 1813 | ||
1814 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1814 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1815 | mItems.append(agendaItem); | 1815 | mItems.append(agendaItem); |
1816 | 1816 | ||
1817 | placeSubCells(agendaItem); | 1817 | placeSubCells(agendaItem); |
1818 | 1818 | ||
1819 | //agendaItem->show(); | 1819 | //agendaItem->show(); |
1820 | 1820 | ||
1821 | 1821 | ||
1822 | return agendaItem; | 1822 | return agendaItem; |
1823 | } | 1823 | } |
1824 | 1824 | ||
1825 | 1825 | ||
1826 | /* | 1826 | /* |
1827 | Insert all-day KOAgendaItem into agenda. | 1827 | Insert all-day KOAgendaItem into agenda. |
1828 | */ | 1828 | */ |
1829 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1829 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1830 | { | 1830 | { |
1831 | if (!mAllDayMode) { | 1831 | if (!mAllDayMode) { |
1832 | return 0; | 1832 | return 0; |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1835 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1836 | 1836 | ||
1837 | agendaItem->setCellXY(XBegin,0,0); | 1837 | agendaItem->setCellXY(XBegin,0,0); |
1838 | agendaItem->setCellXWidth(XEnd); | 1838 | agendaItem->setCellXWidth(XEnd); |
1839 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1839 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1840 | 1840 | ||
1841 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1841 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1842 | mItems.append(agendaItem); | 1842 | mItems.append(agendaItem); |
1843 | 1843 | ||
1844 | placeSubCells(agendaItem); | 1844 | placeSubCells(agendaItem); |
1845 | 1845 | ||
1846 | //agendaItem->show(); | 1846 | //agendaItem->show(); |
1847 | 1847 | ||
1848 | return agendaItem; | 1848 | return agendaItem; |
1849 | } | 1849 | } |
1850 | 1850 | ||
1851 | 1851 | ||
1852 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1852 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1853 | int YTop,int YBottom) | 1853 | int YTop,int YBottom) |
1854 | { | 1854 | { |
1855 | if (mAllDayMode) { | 1855 | if (mAllDayMode) { |
1856 | ; | 1856 | ; |
1857 | return; | 1857 | return; |
1858 | } | 1858 | } |
1859 | 1859 | ||
1860 | int cellX,cellYTop,cellYBottom; | 1860 | int cellX,cellYTop,cellYBottom; |
1861 | QString newtext; | 1861 | QString newtext; |
1862 | int width = XEnd - XBegin + 1; | 1862 | int width = XEnd - XBegin + 1; |
1863 | int count = 0; | 1863 | int count = 0; |
1864 | KOAgendaItem *current = 0; | 1864 | KOAgendaItem *current = 0; |
1865 | QPtrList<KOAgendaItem> multiItems; | 1865 | QPtrList<KOAgendaItem> multiItems; |
1866 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1866 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1867 | if (cellX == XBegin) cellYTop = YTop; | 1867 | if (cellX == XBegin) cellYTop = YTop; |
1868 | else cellYTop = 0; | 1868 | else cellYTop = 0; |
1869 | if (cellX == XEnd) cellYBottom = YBottom; | 1869 | if (cellX == XEnd) cellYBottom = YBottom; |
1870 | else cellYBottom = rows() - 1; | 1870 | else cellYBottom = rows() - 1; |
1871 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1871 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1872 | newtext.append(event->summary()); | 1872 | newtext.append(event->summary()); |
1873 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1873 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1874 | current->setText(newtext); | 1874 | current->setText(newtext); |
1875 | multiItems.append(current); | 1875 | multiItems.append(current); |
1876 | } | 1876 | } |
1877 | 1877 | ||
1878 | KOAgendaItem *next = 0; | 1878 | KOAgendaItem *next = 0; |
1879 | KOAgendaItem *last = multiItems.last(); | 1879 | KOAgendaItem *last = multiItems.last(); |
1880 | KOAgendaItem *first = multiItems.first(); | 1880 | KOAgendaItem *first = multiItems.first(); |
1881 | KOAgendaItem *setFirst,*setLast; | 1881 | KOAgendaItem *setFirst,*setLast; |
1882 | current = first; | 1882 | current = first; |
1883 | while (current) { | 1883 | while (current) { |
1884 | next = multiItems.next(); | 1884 | next = multiItems.next(); |
1885 | if (current == first) setFirst = 0; | 1885 | if (current == first) setFirst = 0; |
1886 | else setFirst = first; | 1886 | else setFirst = first; |
1887 | if (current == last) setLast = 0; | 1887 | if (current == last) setLast = 0; |
1888 | else setLast = last; | 1888 | else setLast = last; |
1889 | 1889 | ||
1890 | current->setMultiItem(setFirst,next,setLast); | 1890 | current->setMultiItem(setFirst,next,setLast); |
1891 | current = next; | 1891 | current = next; |
1892 | } | 1892 | } |
1893 | } | 1893 | } |
1894 | 1894 | ||
1895 | 1895 | ||
1896 | //QSizePolicy KOAgenda::sizePolicy() const | 1896 | //QSizePolicy KOAgenda::sizePolicy() const |
1897 | //{ | 1897 | //{ |
1898 | // Thought this would make the all-day event agenda minimum size and the | 1898 | // Thought this would make the all-day event agenda minimum size and the |
1899 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1899 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1900 | // don´t seem to think that an Expanding widget needs more space than a | 1900 | // don´t seem to think that an Expanding widget needs more space than a |
1901 | // Preferred one. | 1901 | // Preferred one. |
1902 | // But it doesn´t hurt, so it stays. | 1902 | // But it doesn´t hurt, so it stays. |
1903 | // if (mAllDayMode) { | 1903 | // if (mAllDayMode) { |
1904 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1904 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1905 | // } else { | 1905 | // } else { |
1906 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1906 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1907 | // } | 1907 | // } |
1908 | //} | 1908 | //} |
1909 | void KOAgenda::finishResize ( ) | 1909 | void KOAgenda::finishResize ( ) |
1910 | { | 1910 | { |
1911 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1911 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1912 | if ( globalFlagBlockAgenda == 0 ) { | 1912 | if ( globalFlagBlockAgenda == 0 ) { |
1913 | finishUpdate(); | 1913 | finishUpdate(); |
1914 | //qDebug("finishUpdate() called "); | 1914 | //qDebug("finishUpdate() called "); |
1915 | } | 1915 | } |
1916 | } | 1916 | } |
1917 | /* | 1917 | /* |
1918 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1918 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1919 | */ | 1919 | */ |
1920 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1920 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1921 | { | 1921 | { |
1922 | mSelectionHeight = 0; | 1922 | mSelectionHeight = 0; |
1923 | mResizeTimer.start( 150 , true ); | 1923 | mResizeTimer.start( 150 , true ); |
1924 | computeSizes(); | 1924 | computeSizes(); |
1925 | QScrollView::resizeEvent( ev ); | ||
1925 | return; | 1926 | return; |
1926 | 1927 | ||
1927 | } | 1928 | } |
1928 | void KOAgenda::computeSizes() | 1929 | void KOAgenda::computeSizes() |
1929 | { | 1930 | { |
1930 | if ( globalFlagBlockStartup ) | 1931 | if ( globalFlagBlockStartup ) |
1931 | return; | 1932 | return; |
1932 | int frameOffset = frameWidth() * 2 +1; | 1933 | int frameOffset = frameWidth() * 2 +1; |
1933 | if (mAllDayMode) { | 1934 | if (mAllDayMode) { |
1934 | mGridSpacingX = (width()-frameOffset) / mColumns; | 1935 | mGridSpacingX = (width()-frameOffset) / mColumns; |
1935 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1936 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1936 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1937 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1937 | // mGridSpacingY = height(); | 1938 | // mGridSpacingY = height(); |
1938 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1939 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1939 | 1940 | ||
1940 | KOAgendaItem *item; | 1941 | KOAgendaItem *item; |
1941 | int subCellWidth; | 1942 | int subCellWidth; |
1942 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1943 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1943 | subCellWidth = mGridSpacingY / item->subCells(); | 1944 | subCellWidth = mGridSpacingY / item->subCells(); |
1944 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1945 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1945 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1946 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1946 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1947 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1947 | item->cellX() * mGridSpacingX, | 1948 | item->cellX() * mGridSpacingX, |
1948 | item->subCell() * subCellWidth); | 1949 | item->subCell() * subCellWidth); |
1949 | } | 1950 | } |
1950 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1951 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1951 | } else { | 1952 | } else { |
1952 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; | 1953 | mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; |
1953 | if (height() > mGridSpacingY * mRows + 1 ) { | 1954 | if (height() > mGridSpacingY * mRows + 1 ) { |
1954 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1955 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1955 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1956 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1956 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1957 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1957 | emit resizedSignal(); | 1958 | emit resizedSignal(); |
1958 | } else | 1959 | } else |
1959 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1960 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1960 | KOAgendaItem *item; | 1961 | KOAgendaItem *item; |
1961 | int subCellWidth; | 1962 | int subCellWidth; |
1962 | 1963 | ||
1963 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1964 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1964 | subCellWidth = mGridSpacingX / item->subCells(); | 1965 | subCellWidth = mGridSpacingX / item->subCells(); |
1965 | item->resize(subCellWidth,item->height()); | 1966 | item->resize(subCellWidth,item->height()); |
1966 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1967 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1967 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1968 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1968 | item->cellX() * mGridSpacingX) + | 1969 | item->cellX() * mGridSpacingX) + |
1969 | item->subCell() * subCellWidth,childY(item)); | 1970 | item->subCell() * subCellWidth,childY(item)); |
1970 | } | 1971 | } |
1971 | } | 1972 | } |
1972 | int cw = contentsWidth(); | 1973 | int cw = contentsWidth(); |
1973 | int ch = contentsHeight(); | 1974 | int ch = contentsHeight(); |
1974 | if ( mAllDayMode ) { | 1975 | if ( mAllDayMode ) { |
1975 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1976 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1976 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { | 1977 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { |
1977 | //qDebug("paintPixAll->resize "); | 1978 | //qDebug("paintPixAll->resize "); |
1978 | paintPixAll->resize( cw, ch ); | 1979 | paintPixAll->resize( cw, ch ); |
1979 | } | 1980 | } |
1980 | } else { | 1981 | } else { |
1981 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1982 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1982 | if ( paintPix->width() < cw || paintPix->height() < ch ) { | 1983 | if ( paintPix->width() < cw || paintPix->height() < ch ) { |
1983 | //qDebug("paintPix->resize "); | 1984 | //qDebug("paintPix->resize "); |
1984 | paintPix->resize( cw , ch ); | 1985 | paintPix->resize( cw , ch ); |
1985 | } | 1986 | } |
1986 | } | 1987 | } |
1987 | 1988 | ||
1988 | checkScrollBoundaries(); | 1989 | checkScrollBoundaries(); |
1989 | drawContentsToPainter(); | 1990 | drawContentsToPainter(); |
1990 | viewport()->repaint(false); | 1991 | viewport()->repaint(false); |
1991 | } | 1992 | } |
1992 | 1993 | ||
1993 | void KOAgenda::scrollUp() | 1994 | void KOAgenda::scrollUp() |
1994 | { | 1995 | { |
1995 | scrollBy(0,-mScrollOffset); | 1996 | scrollBy(0,-mScrollOffset); |
1996 | } | 1997 | } |
1997 | 1998 | ||
1998 | 1999 | ||
1999 | void KOAgenda::scrollDown() | 2000 | void KOAgenda::scrollDown() |
2000 | { | 2001 | { |
2001 | scrollBy(0,mScrollOffset); | 2002 | scrollBy(0,mScrollOffset); |
2002 | } | 2003 | } |
2003 | 2004 | ||
2004 | void KOAgenda::popupAlarm() | 2005 | void KOAgenda::popupAlarm() |
2005 | { | 2006 | { |
2006 | if (!mClickedItem) { | 2007 | if (!mClickedItem) { |
2007 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 2008 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
2008 | return; | 2009 | return; |
2009 | } | 2010 | } |
2010 | // TODO: deal correctly with multiple alarms | 2011 | // TODO: deal correctly with multiple alarms |
2011 | Alarm* alarm; | 2012 | Alarm* alarm; |
2012 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 2013 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
2013 | for(alarm=list.first();alarm;alarm=list.next()) { | 2014 | for(alarm=list.first();alarm;alarm=list.next()) { |
2014 | alarm->toggleAlarm(); | 2015 | alarm->toggleAlarm(); |
2015 | } | 2016 | } |
2016 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 2017 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
2017 | mClickedItem->paintMe( true ); | 2018 | mClickedItem->paintMe( true ); |
2018 | mClickedItem->repaint( false ); | 2019 | mClickedItem->repaint( false ); |
2019 | } | 2020 | } |
2020 | 2021 | ||
2021 | /* | 2022 | /* |
2022 | Calculates the minimum width | 2023 | Calculates the minimum width |
2023 | */ | 2024 | */ |
2024 | int KOAgenda::minimumWidth() const | 2025 | int KOAgenda::minimumWidth() const |
2025 | { | 2026 | { |
2026 | // TODO:: develop a way to dynamically determine the minimum width | 2027 | // TODO:: develop a way to dynamically determine the minimum width |
2027 | int min = 100; | 2028 | int min = 100; |
2028 | 2029 | ||
2029 | return min; | 2030 | return min; |
2030 | } | 2031 | } |
2031 | 2032 | ||
2032 | void KOAgenda::updateConfig() | 2033 | void KOAgenda::updateConfig() |
2033 | { | 2034 | { |
2034 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 2035 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
2035 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 2036 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
2036 | if ( mAllDayMode ) { | 2037 | if ( mAllDayMode ) { |
2037 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 2038 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
2038 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 2039 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
2039 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 2040 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
2040 | // setMaximumHeight( mGridSpacingY+1 ); | 2041 | // setMaximumHeight( mGridSpacingY+1 ); |
2041 | viewport()->repaint( false ); | 2042 | viewport()->repaint( false ); |
2042 | //setFixedHeight( mGridSpacingY+1 ); | 2043 | //setFixedHeight( mGridSpacingY+1 ); |
2043 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 2044 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
2044 | } | 2045 | } |
2045 | else { | 2046 | else { |
2046 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 2047 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
2047 | calculateWorkingHours(); | 2048 | calculateWorkingHours(); |
2048 | } | 2049 | } |
2049 | } | 2050 | } |
2050 | 2051 | ||
2051 | void KOAgenda::checkScrollBoundaries() | 2052 | void KOAgenda::checkScrollBoundaries() |
2052 | { | 2053 | { |
@@ -2056,223 +2057,223 @@ void KOAgenda::checkScrollBoundaries() | |||
2056 | 2057 | ||
2057 | checkScrollBoundaries(verticalScrollBar()->value()); | 2058 | checkScrollBoundaries(verticalScrollBar()->value()); |
2058 | } | 2059 | } |
2059 | 2060 | ||
2060 | void KOAgenda::checkScrollBoundaries(int v) | 2061 | void KOAgenda::checkScrollBoundaries(int v) |
2061 | { | 2062 | { |
2062 | if ( mGridSpacingY == 0 ) | 2063 | if ( mGridSpacingY == 0 ) |
2063 | return; | 2064 | return; |
2064 | int yMin = v/mGridSpacingY; | 2065 | int yMin = v/mGridSpacingY; |
2065 | int yMax = (v+visibleHeight())/mGridSpacingY; | 2066 | int yMax = (v+visibleHeight())/mGridSpacingY; |
2066 | 2067 | ||
2067 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 2068 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
2068 | 2069 | ||
2069 | if (yMin != mOldLowerScrollValue) { | 2070 | if (yMin != mOldLowerScrollValue) { |
2070 | mOldLowerScrollValue = yMin; | 2071 | mOldLowerScrollValue = yMin; |
2071 | emit lowerYChanged(yMin); | 2072 | emit lowerYChanged(yMin); |
2072 | } | 2073 | } |
2073 | if (yMax != mOldUpperScrollValue) { | 2074 | if (yMax != mOldUpperScrollValue) { |
2074 | mOldUpperScrollValue = yMax; | 2075 | mOldUpperScrollValue = yMax; |
2075 | emit upperYChanged(yMax); | 2076 | emit upperYChanged(yMax); |
2076 | } | 2077 | } |
2077 | } | 2078 | } |
2078 | 2079 | ||
2079 | void KOAgenda::deselectItem() | 2080 | void KOAgenda::deselectItem() |
2080 | { | 2081 | { |
2081 | if (mSelectedItem.isNull()) return; | 2082 | if (mSelectedItem.isNull()) return; |
2082 | mSelectedItem->select(false); | 2083 | mSelectedItem->select(false); |
2083 | mSelectedItem = 0; | 2084 | mSelectedItem = 0; |
2084 | } | 2085 | } |
2085 | 2086 | ||
2086 | void KOAgenda::selectItem(KOAgendaItem *item) | 2087 | void KOAgenda::selectItem(KOAgendaItem *item) |
2087 | { | 2088 | { |
2088 | if ((KOAgendaItem *)mSelectedItem == item) return; | 2089 | if ((KOAgendaItem *)mSelectedItem == item) return; |
2089 | deselectItem(); | 2090 | deselectItem(); |
2090 | if (item == 0) { | 2091 | if (item == 0) { |
2091 | emit incidenceSelected( 0 ); | 2092 | emit incidenceSelected( 0 ); |
2092 | return; | 2093 | return; |
2093 | } | 2094 | } |
2094 | mSelectedItem = item; | 2095 | mSelectedItem = item; |
2095 | mSelectedItem->select(); | 2096 | mSelectedItem->select(); |
2096 | emit incidenceSelected( mSelectedItem->incidence() ); | 2097 | emit incidenceSelected( mSelectedItem->incidence() ); |
2097 | } | 2098 | } |
2098 | 2099 | ||
2099 | // This function seems never be called. | 2100 | // This function seems never be called. |
2100 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 2101 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
2101 | { | 2102 | { |
2102 | switch(kev->key()) { | 2103 | switch(kev->key()) { |
2103 | case Key_PageDown: | 2104 | case Key_PageDown: |
2104 | verticalScrollBar()->addPage(); | 2105 | verticalScrollBar()->addPage(); |
2105 | break; | 2106 | break; |
2106 | case Key_PageUp: | 2107 | case Key_PageUp: |
2107 | verticalScrollBar()->subtractPage(); | 2108 | verticalScrollBar()->subtractPage(); |
2108 | break; | 2109 | break; |
2109 | case Key_Down: | 2110 | case Key_Down: |
2110 | verticalScrollBar()->addLine(); | 2111 | verticalScrollBar()->addLine(); |
2111 | break; | 2112 | break; |
2112 | case Key_Up: | 2113 | case Key_Up: |
2113 | verticalScrollBar()->subtractLine(); | 2114 | verticalScrollBar()->subtractLine(); |
2114 | break; | 2115 | break; |
2115 | default: | 2116 | default: |
2116 | ; | 2117 | ; |
2117 | } | 2118 | } |
2118 | } | 2119 | } |
2119 | 2120 | ||
2120 | void KOAgenda::calculateWorkingHours() | 2121 | void KOAgenda::calculateWorkingHours() |
2121 | { | 2122 | { |
2122 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 2123 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
2123 | mWorkingHoursEnable = !mAllDayMode; | 2124 | mWorkingHoursEnable = !mAllDayMode; |
2124 | 2125 | ||
2125 | mWorkingHoursYTop = mGridSpacingY * | 2126 | mWorkingHoursYTop = mGridSpacingY * |
2126 | KOPrefs::instance()->mWorkingHoursStart * 4; | 2127 | KOPrefs::instance()->mWorkingHoursStart * 4; |
2127 | mWorkingHoursYBottom = mGridSpacingY * | 2128 | mWorkingHoursYBottom = mGridSpacingY * |
2128 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 2129 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
2129 | } | 2130 | } |
2130 | 2131 | ||
2131 | 2132 | ||
2132 | DateList KOAgenda::dateList() const | 2133 | DateList KOAgenda::dateList() const |
2133 | { | 2134 | { |
2134 | return mSelectedDates; | 2135 | return mSelectedDates; |
2135 | } | 2136 | } |
2136 | 2137 | ||
2137 | void KOAgenda::setDateList(const DateList &selectedDates) | 2138 | void KOAgenda::setDateList(const DateList &selectedDates) |
2138 | { | 2139 | { |
2139 | mSelectedDates = selectedDates; | 2140 | mSelectedDates = selectedDates; |
2140 | } | 2141 | } |
2141 | 2142 | ||
2142 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 2143 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
2143 | { | 2144 | { |
2144 | mHolidayMask = mask; | 2145 | mHolidayMask = mask; |
2145 | 2146 | ||
2146 | /* | 2147 | /* |
2147 | kdDebug() << "HolidayMask: "; | 2148 | kdDebug() << "HolidayMask: "; |
2148 | for(uint i=0;i<mask->count();++i) { | 2149 | for(uint i=0;i<mask->count();++i) { |
2149 | kdDebug() << (mask->at(i) ? "*" : "o"); | 2150 | kdDebug() << (mask->at(i) ? "*" : "o"); |
2150 | } | 2151 | } |
2151 | kdDebug() << endl; | 2152 | kdDebug() << endl; |
2152 | */ | 2153 | */ |
2153 | } | 2154 | } |
2154 | 2155 | ||
2155 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 2156 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
2156 | { | 2157 | { |
2157 | 2158 | ||
2158 | QScrollView::contentsMousePressEvent(event); | 2159 | QScrollView::contentsMousePressEvent(event); |
2159 | } | 2160 | } |
2160 | 2161 | ||
2161 | void KOAgenda::storePosition() | 2162 | void KOAgenda::storePosition() |
2162 | { | 2163 | { |
2163 | //mContentPosition | 2164 | //mContentPosition |
2164 | int max = mGridSpacingY*4*24; | 2165 | int max = mGridSpacingY*4*24; |
2165 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 2166 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
2166 | mContentPosition = 0; | 2167 | mContentPosition = 0; |
2167 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 2168 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
2168 | mContentPosition = -1.0; | 2169 | mContentPosition = -1.0; |
2169 | else | 2170 | else |
2170 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 2171 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
2171 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 2172 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
2172 | 2173 | ||
2173 | } | 2174 | } |
2174 | void KOAgenda::restorePosition() | 2175 | void KOAgenda::restorePosition() |
2175 | { | 2176 | { |
2176 | int posY; | 2177 | int posY; |
2177 | int max = mGridSpacingY*4*24; | 2178 | int max = mGridSpacingY*4*24; |
2178 | if ( mContentPosition < 0 ) | 2179 | if ( mContentPosition < 0 ) |
2179 | posY = max-viewport()->height(); | 2180 | posY = max-viewport()->height(); |
2180 | else | 2181 | else |
2181 | if ( mContentPosition == 0 ) | 2182 | if ( mContentPosition == 0 ) |
2182 | posY = 0; | 2183 | posY = 0; |
2183 | else | 2184 | else |
2184 | posY = (max/mContentPosition)-(viewport()->height()/2); | 2185 | posY = (int) ((max/mContentPosition)-(viewport()->height()/2)); |
2185 | setContentsPos (0, posY ); | 2186 | setContentsPos (0, posY ); |
2186 | //qDebug("posY %d hei %d", posY, max); | 2187 | //qDebug("posY %d hei %d", posY, max); |
2187 | 2188 | ||
2188 | } | 2189 | } |
2189 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 2190 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
2190 | { | 2191 | { |
2191 | ++x; | 2192 | ++x; |
2192 | QScrollView::moveChild( w, x , y ); | 2193 | QScrollView::moveChild( w, x , y ); |
2193 | } | 2194 | } |
2194 | #include <qmessagebox.h> | 2195 | #include <qmessagebox.h> |
2195 | #ifdef DESKTOP_VERSION | 2196 | #ifdef DESKTOP_VERSION |
2196 | #include <qprinter.h> | 2197 | #include <qprinter.h> |
2197 | #include <qpainter.h> | 2198 | #include <qpainter.h> |
2198 | #include <qpaintdevicemetrics.h> | 2199 | #include <qpaintdevicemetrics.h> |
2199 | 2200 | ||
2200 | #endif | 2201 | #endif |
2201 | void KOAgenda::printSelection() | 2202 | void KOAgenda::printSelection() |
2202 | { | 2203 | { |
2203 | #ifdef DESKTOP_VERSION | 2204 | #ifdef DESKTOP_VERSION |
2204 | if ( mStartCellY == mCurrentCellY ) { | 2205 | if ( mStartCellY == mCurrentCellY ) { |
2205 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2206 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2206 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 2207 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
2207 | i18n("OK"), 0, 0, | 2208 | i18n("OK"), 0, 0, |
2208 | 0, 1 ); | 2209 | 0, 1 ); |
2209 | return; | 2210 | return; |
2210 | } | 2211 | } |
2211 | 2212 | ||
2212 | float dx, dy; | 2213 | float dx, dy; |
2213 | int x,y,w,h; | 2214 | int x,y,w,h; |
2214 | x= 0; | 2215 | x= 0; |
2215 | w= contentsWidth()+2; | 2216 | w= contentsWidth()+2; |
2216 | // h= contentsHeight(); | 2217 | // h= contentsHeight(); |
2217 | y = mGridSpacingY*mStartCellY; | 2218 | y = mGridSpacingY*mStartCellY; |
2218 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2219 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
2219 | 2220 | ||
2220 | //return; | 2221 | //return; |
2221 | QPrinter* printer = new QPrinter(); | 2222 | QPrinter* printer = new QPrinter(); |
2222 | if ( !printer->setup()) { | 2223 | if ( !printer->setup()) { |
2223 | delete printer; | 2224 | delete printer; |
2224 | return; | 2225 | return; |
2225 | } | 2226 | } |
2226 | QPainter p( printer ); | 2227 | QPainter p( printer ); |
2227 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2228 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2228 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2229 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2229 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2230 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2230 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2231 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2231 | // p.drawText( 0, 0, date ); | 2232 | // p.drawText( 0, 0, date ); |
2232 | int offset = m.width()/8; | 2233 | int offset = m.width()/8; |
2233 | // compute the scale | 2234 | // compute the scale |
2234 | dx = ((float) m.width()-offset) / (float)w; | 2235 | dx = ((float) m.width()-offset) / (float)w; |
2235 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2236 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2236 | float scale; | 2237 | float scale; |
2237 | // scale to fit the width or height of the paper | 2238 | // scale to fit the width or height of the paper |
2238 | if ( dx < dy ) | 2239 | if ( dx < dy ) |
2239 | scale = dx; | 2240 | scale = dx; |
2240 | else | 2241 | else |
2241 | scale = dy; | 2242 | scale = dy; |
2242 | // set the scale | 2243 | // set the scale |
2243 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2244 | p.drawText( (int) (offset* scale), (int) (offset* scale*3/4), date ); |
2244 | 2245 | ||
2245 | int selDay; | 2246 | uint selDay; |
2246 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2247 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2247 | float startX = 1; | 2248 | float startX = 1; |
2248 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2249 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2249 | { | 2250 | { |
2250 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2251 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2251 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2252 | p.setClipRect((int) (offset* scale+startX) , 0, (int) (widOffset-4), (int) (offset* scale+(2*hei* scale)) ); |
2252 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2253 | p.drawText( (int) (offset* scale+startX), (int) ((offset+hei)* scale), text ); |
2253 | startX += widOffset; | 2254 | startX += widOffset; |
2254 | 2255 | ||
2255 | } | 2256 | } |
2256 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2257 | p.translate( (int) (offset* scale),(int) (offset* scale+ (-y * scale)+(2*hei* scale))); |
2257 | p.scale( scale, scale ); | 2258 | p.scale( scale, scale ); |
2258 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2259 | p.setClipRect( (int) (offset* scale), (int) (offset* scale+(2*hei* scale)), (int) (w*scale), (int) (h*scale) ); |
2259 | // now printing with y offset: 2 hei | 2260 | // now printing with y offset: 2 hei |
2260 | // p.translate( 0, -y*scale); | 2261 | // p.translate( 0, -y*scale); |
2261 | 2262 | ||
2262 | drawContentsToPainter(&p, true ); | 2263 | drawContentsToPainter(&p, true ); |
2263 | globalFlagBlockAgendaItemUpdate = false; | 2264 | globalFlagBlockAgendaItemUpdate = false; |
2264 | KOAgendaItem *item; | 2265 | KOAgendaItem *item; |
2265 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2266 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2266 | item->select(false); | 2267 | item->select(false); |
2267 | item->paintMe( false, &p ); | 2268 | item->paintMe( false, &p ); |
2268 | } | 2269 | } |
2269 | globalFlagBlockAgendaItemUpdate = true; | 2270 | globalFlagBlockAgendaItemUpdate = true; |
2270 | p.end(); | 2271 | p.end(); |
2271 | delete printer; | 2272 | delete printer; |
2272 | #else | 2273 | #else |
2273 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2274 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2274 | i18n("Not supported \non PDA!\n"), | 2275 | i18n("Not supported \non PDA!\n"), |
2275 | i18n("OK"), 0, 0, | 2276 | i18n("OK"), 0, 0, |
2276 | 0, 1 ); | 2277 | 0, 1 ); |
2277 | #endif | 2278 | #endif |
2278 | } | 2279 | } |
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 99c564a..2b26e95 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,165 +1,166 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOAGENDAITEM_H | 19 | #ifndef KOAGENDAITEM_H |
20 | #define KOAGENDAITEM_H | 20 | #define KOAGENDAITEM_H |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpalette.h> | 26 | #include <qpalette.h> |
27 | 27 | ||
28 | #include <libkcal/incidence.h> | 28 | #include <libkcal/incidence.h> |
29 | 29 | ||
30 | class KOAgendaItemWhatsThis; | 30 | class KOAgendaItemWhatsThis; |
31 | class QToolTipGroup; | 31 | class QToolTipGroup; |
32 | class QDragEnterEvent; | 32 | class QDragEnterEvent; |
33 | class QDropEvent; | 33 | class QDropEvent; |
34 | 34 | ||
35 | using namespace KCal; | 35 | using namespace KCal; |
36 | 36 | ||
37 | /* | 37 | /* |
38 | The KOAgendaItem has to make sure that it receives all mouse events, which are | 38 | The KOAgendaItem has to make sure that it receives all mouse events, which are |
39 | to be used for dragging and resizing. That means it has to be installed as | 39 | to be used for dragging and resizing. That means it has to be installed as |
40 | eventfiler for its children, if it has children, and it has to pass mouse | 40 | eventfiler for its children, if it has children, and it has to pass mouse |
41 | events from the cildren to itself. See eventFilter(). | 41 | events from the cildren to itself. See eventFilter(). |
42 | */ | 42 | */ |
43 | class KOAgendaItem : public QWidget | 43 | class KOAgendaItem : public QWidget |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | public: | 46 | public: |
47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, | 47 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, |
48 | WFlags f=0 ); | 48 | WFlags f=0 ); |
49 | ~KOAgendaItem(); | 49 | ~KOAgendaItem(); |
50 | QString getWhatsThisText(); | 50 | QString getWhatsThisText(); |
51 | void init ( Incidence *incidence, QDate qd ); | 51 | void init ( Incidence *incidence, QDate qd ); |
52 | int cellX() { return mCellX; } | 52 | int cellX() { return mCellX; } |
53 | int cellXWidth() { return mCellXWidth; } | 53 | int cellXWidth() { return mCellXWidth; } |
54 | int cellYTop() { return mCellYTop; } | 54 | int cellYTop() { return mCellYTop; } |
55 | int cellYBottom() { return mCellYBottom; } | 55 | int cellYBottom() { return mCellYBottom; } |
56 | int cellHeight(); | 56 | int cellHeight(); |
57 | int cellWidth(); | 57 | int cellWidth(); |
58 | int subCell() { return mSubCell; } | 58 | int subCell() { return mSubCell; } |
59 | int subCells() { return mSubCells; } | 59 | int subCells() { return mSubCells; } |
60 | 60 | ||
61 | void setCellXY(int X, int YTop, int YBottom); | 61 | void setCellXY(int X, int YTop, int YBottom); |
62 | void setCellY(int YTop, int YBottom); | 62 | void setCellY(int YTop, int YBottom); |
63 | void setCellX(int XLeft, int XRight); | 63 | void setCellX(int XLeft, int XRight); |
64 | void setCellXWidth(int xwidth); | 64 | void setCellXWidth(int xwidth); |
65 | void setSubCell(int subCell); | 65 | void setSubCell(int subCell); |
66 | void setSubCells(int subCells); | 66 | void setSubCells(int subCells); |
67 | 67 | ||
68 | /** Start movement */ | 68 | /** Start movement */ |
69 | void startMove(); | 69 | void startMove(); |
70 | /** Reset to original values */ | 70 | /** Reset to original values */ |
71 | void resetMove(); | 71 | void resetMove(); |
72 | 72 | ||
73 | void moveRelative(int dx,int dy); | 73 | void moveRelative(int dx,int dy); |
74 | void expandTop(int dy); | 74 | void expandTop(int dy); |
75 | void expandBottom(int dy); | 75 | void expandBottom(int dy); |
76 | void expandLeft(int dx); | 76 | void expandLeft(int dx); |
77 | void expandRight(int dx); | 77 | void expandRight(int dx); |
78 | int mLastMoveXPos; | 78 | int mLastMoveXPos; |
79 | 79 | ||
80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 80 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
81 | KOAgendaItem *last); | 81 | KOAgendaItem *last); |
82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } | 82 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } |
83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } | 83 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } |
84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } | 84 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } |
85 | 85 | ||
86 | Incidence *incidence() const { return mIncidence; } | 86 | Incidence *incidence() const { return mIncidence; } |
87 | QDate itemDate() { return mDate; } | 87 | QDate itemDate() { return mDate; } |
88 | 88 | ||
89 | /** Update the date of this item's occurence (not in the event) */ | 89 | /** Update the date of this item's occurence (not in the event) */ |
90 | void setItemDate(QDate qd); | 90 | void setItemDate(QDate qd); |
91 | 91 | ||
92 | void setText ( const QString & text ) { mDisplayedText = text; } | 92 | void setText ( const QString & text ) { mDisplayedText = text; } |
93 | QString text () { return mDisplayedText; } | 93 | QString text () { return mDisplayedText; } |
94 | 94 | ||
95 | virtual bool eventFilter ( QObject *, QEvent * ); | 95 | virtual bool eventFilter ( QObject *, QEvent * ); |
96 | 96 | ||
97 | static QToolTipGroup *toolTipGroup(); | 97 | static QToolTipGroup *toolTipGroup(); |
98 | 98 | ||
99 | QPtrList<KOAgendaItem> conflictItems(); | 99 | QPtrList<KOAgendaItem> conflictItems(); |
100 | void setConflictItems(QPtrList<KOAgendaItem>); | 100 | void setConflictItems(QPtrList<KOAgendaItem>); |
101 | void addConflictItem(KOAgendaItem *ci); | 101 | void addConflictItem(KOAgendaItem *ci); |
102 | void paintMe( bool, QPainter* painter = 0 ); | 102 | void paintMe( bool, QPainter* painter = 0 ); |
103 | void repaintMe(); | 103 | void repaintMe(); |
104 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
105 | static QPixmap * paintPixAllday(); | 105 | static QPixmap * paintPixAllday(); |
106 | void updateItem(); | 106 | void updateItem(); |
107 | void computeText(); | 107 | void computeText(); |
108 | void recreateIncidence(); | 108 | void recreateIncidence(); |
109 | bool checkLayout(); | 109 | bool checkLayout(); |
110 | void initColor (); | 110 | void initColor (); |
111 | bool isAllDay() { return mAllDay; } | ||
111 | public slots: | 112 | public slots: |
112 | bool updateIcons( QPainter *, bool ); | 113 | bool updateIcons( QPainter *, bool ); |
113 | void select(bool=true); | 114 | void select(bool=true); |
114 | void repaintItem(); | 115 | void repaintItem(); |
115 | 116 | ||
116 | protected: | 117 | protected: |
117 | void dragEnterEvent(QDragEnterEvent *e); | 118 | void dragEnterEvent(QDragEnterEvent *e); |
118 | void dropEvent(QDropEvent *e); | 119 | void dropEvent(QDropEvent *e); |
119 | void paintEvent ( QPaintEvent * ); | 120 | void paintEvent ( QPaintEvent * ); |
120 | void resizeEvent ( QResizeEvent *ev ); | 121 | void resizeEvent ( QResizeEvent *ev ); |
121 | 122 | ||
122 | private: | 123 | private: |
123 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; | 124 | KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; |
124 | bool mAllDay; | 125 | bool mAllDay; |
125 | bool mWhiteText; | 126 | bool mWhiteText; |
126 | int mCellX; | 127 | int mCellX; |
127 | int mCellXWidth; | 128 | int mCellXWidth; |
128 | int mCellYTop,mCellYBottom; | 129 | int mCellYTop,mCellYBottom; |
129 | int mSubCell; // subcell number of this item | 130 | int mSubCell; // subcell number of this item |
130 | int mSubCells; // Total number of subcells in cell of this item | 131 | int mSubCells; // Total number of subcells in cell of this item |
131 | int xPaintCoord; | 132 | int xPaintCoord; |
132 | int yPaintCoord; | 133 | int yPaintCoord; |
133 | int wPaintCoord; | 134 | int wPaintCoord; |
134 | int hPaintCoord; | 135 | int hPaintCoord; |
135 | // Variables to remember start position | 136 | // Variables to remember start position |
136 | int mStartCellX; | 137 | int mStartCellX; |
137 | int mStartCellXWidth; | 138 | int mStartCellXWidth; |
138 | int mStartCellYTop,mStartCellYBottom; | 139 | int mStartCellYTop,mStartCellYBottom; |
139 | int mLastMovePos; | 140 | int mLastMovePos; |
140 | 141 | ||
141 | // Multi item pointers | 142 | // Multi item pointers |
142 | KOAgendaItem *mFirstMultiItem; | 143 | KOAgendaItem *mFirstMultiItem; |
143 | KOAgendaItem *mNextMultiItem; | 144 | KOAgendaItem *mNextMultiItem; |
144 | KOAgendaItem *mLastMultiItem; | 145 | KOAgendaItem *mLastMultiItem; |
145 | 146 | ||
146 | int mFontPixelSize; | 147 | int mFontPixelSize; |
147 | Incidence *mIncidence; // corresponding event or todo | 148 | Incidence *mIncidence; // corresponding event or todo |
148 | QDate mDate; //date this events occurs (for recurrence) | 149 | QDate mDate; //date this events occurs (for recurrence) |
149 | //void showIcon( QLabel*, int ); | 150 | //void showIcon( QLabel*, int ); |
150 | //QLabel *mTodoIconLabel; | 151 | //QLabel *mTodoIconLabel; |
151 | //QLabel *mItemLabel; | 152 | //QLabel *mItemLabel; |
152 | //QWidget *mIconBox; | 153 | //QWidget *mIconBox; |
153 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 154 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
154 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 155 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
155 | //QLabel *mIconMoreInfo; | 156 | //QLabel *mIconMoreInfo; |
156 | static QToolTipGroup *mToolTipGroup; | 157 | static QToolTipGroup *mToolTipGroup; |
157 | 158 | ||
158 | QColor mBackgroundColor; | 159 | QColor mBackgroundColor; |
159 | QColorGroup mColorGroup; | 160 | QColorGroup mColorGroup; |
160 | QString mDisplayedText; | 161 | QString mDisplayedText; |
161 | bool mSelected; | 162 | bool mSelected; |
162 | QPtrList<KOAgendaItem> mConflictItems; | 163 | QPtrList<KOAgendaItem> mConflictItems; |
163 | }; | 164 | }; |
164 | 165 | ||
165 | #endif // KOAGENDAITEM_H | 166 | #endif // KOAGENDAITEM_H |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index f5a3a4b..1cf03a0 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -877,261 +877,262 @@ void KOAgendaView::createDayLabels() | |||
877 | if ( ! appendLabels ) { | 877 | if ( ! appendLabels ) { |
878 | dayLabel = mDayLabelsList.next(); | 878 | dayLabel = mDayLabelsList.next(); |
879 | if ( !dayLabel ) | 879 | if ( !dayLabel ) |
880 | appendLabels = true; | 880 | appendLabels = true; |
881 | } | 881 | } |
882 | if ( appendLabels ) { | 882 | if ( appendLabels ) { |
883 | dayLabel = getNewDaylabel(); | 883 | dayLabel = getNewDaylabel(); |
884 | } | 884 | } |
885 | //dayLabel->hide();//test only | 885 | //dayLabel->hide();//test only |
886 | 886 | ||
887 | dayLabel->setText(">"); | 887 | dayLabel->setText(">"); |
888 | dayLabel->setFont( dlf ); | 888 | dayLabel->setFont( dlf ); |
889 | dayLabel->setAutoRepeat( true ); | 889 | dayLabel->setAutoRepeat( true ); |
890 | dayLabel->show(); | 890 | dayLabel->show(); |
891 | dayLabel->setNum( -2 ); | 891 | dayLabel->setNum( -2 ); |
892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 892 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
893 | 893 | ||
894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 894 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
895 | if ( !appendLabels ) { | 895 | if ( !appendLabels ) { |
896 | dayLabel = mDayLabelsList.next(); | 896 | dayLabel = mDayLabelsList.next(); |
897 | while ( dayLabel ) { | 897 | while ( dayLabel ) { |
898 | //qDebug("!dayLabel %d",dayLabel ); | 898 | //qDebug("!dayLabel %d",dayLabel ); |
899 | dayLabel->hide(); | 899 | dayLabel->hide(); |
900 | dayLabel = mDayLabelsList.next(); | 900 | dayLabel = mDayLabelsList.next(); |
901 | } | 901 | } |
902 | } | 902 | } |
903 | 903 | ||
904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 904 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
905 | } | 905 | } |
906 | 906 | ||
907 | int KOAgendaView::maxDatesHint() | 907 | int KOAgendaView::maxDatesHint() |
908 | { | 908 | { |
909 | // Not sure about the max number of events, so return 0 for now. | 909 | // Not sure about the max number of events, so return 0 for now. |
910 | return 0; | 910 | return 0; |
911 | } | 911 | } |
912 | 912 | ||
913 | int KOAgendaView::currentDateCount() | 913 | int KOAgendaView::currentDateCount() |
914 | { | 914 | { |
915 | return mSelectedDates.count(); | 915 | return mSelectedDates.count(); |
916 | } | 916 | } |
917 | 917 | ||
918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 918 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
919 | { | 919 | { |
920 | QPtrList<Incidence> selected; | 920 | QPtrList<Incidence> selected; |
921 | Incidence *incidence; | 921 | Incidence *incidence; |
922 | 922 | ||
923 | incidence = mAgenda->selectedIncidence(); | 923 | incidence = mAgenda->selectedIncidence(); |
924 | if (incidence) selected.append(incidence); | 924 | if (incidence) selected.append(incidence); |
925 | 925 | ||
926 | incidence = mAllDayAgenda->selectedIncidence(); | 926 | incidence = mAllDayAgenda->selectedIncidence(); |
927 | if (incidence) selected.append(incidence); | 927 | if (incidence) selected.append(incidence); |
928 | 928 | ||
929 | return selected; | 929 | return selected; |
930 | } | 930 | } |
931 | 931 | ||
932 | DateList KOAgendaView::selectedDates() | 932 | DateList KOAgendaView::selectedDates() |
933 | { | 933 | { |
934 | DateList selected; | 934 | DateList selected; |
935 | QDate qd; | 935 | QDate qd; |
936 | 936 | ||
937 | qd = mAgenda->selectedIncidenceDate(); | 937 | qd = mAgenda->selectedIncidenceDate(); |
938 | if (qd.isValid()) selected.append(qd); | 938 | if (qd.isValid()) selected.append(qd); |
939 | 939 | ||
940 | qd = mAllDayAgenda->selectedIncidenceDate(); | 940 | qd = mAllDayAgenda->selectedIncidenceDate(); |
941 | if (qd.isValid()) selected.append(qd); | 941 | if (qd.isValid()) selected.append(qd); |
942 | 942 | ||
943 | return selected; | 943 | return selected; |
944 | } | 944 | } |
945 | 945 | ||
946 | 946 | ||
947 | void KOAgendaView::updateView() | 947 | void KOAgendaView::updateView() |
948 | { | 948 | { |
949 | if ( mBlockUpdating ) | 949 | if ( mBlockUpdating ) |
950 | return; | 950 | return; |
951 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 951 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
952 | fillAgenda(); | 952 | fillAgenda(); |
953 | 953 | ||
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | /* | 957 | /* |
958 | Update configuration settings for the agenda view. This method is not | 958 | Update configuration settings for the agenda view. This method is not |
959 | complete. | 959 | complete. |
960 | */ | 960 | */ |
961 | void KOAgendaView::updateConfig() | 961 | void KOAgendaView::updateConfig() |
962 | { | 962 | { |
963 | if ( mBlockUpdating ) | 963 | if ( mBlockUpdating ) |
964 | return; | 964 | return; |
965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 965 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
966 | int old = KOPrefs::instance()->mHourSize; | 966 | int old = KOPrefs::instance()->mHourSize; |
967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 967 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 968 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
969 | } | 969 | } |
970 | 970 | ||
971 | 971 | ||
972 | // update config for children | 972 | // update config for children |
973 | mTimeLabels->updateConfig(); | 973 | mTimeLabels->updateConfig(); |
974 | mAgenda->storePosition(); | 974 | mAgenda->storePosition(); |
975 | mAgenda->updateConfig(); | 975 | mAgenda->updateConfig(); |
976 | mAllDayAgenda->updateConfig(); | 976 | mAllDayAgenda->updateConfig(); |
977 | // widget synchronization | 977 | // widget synchronization |
978 | //TODO: find a better way, maybe signal/slot | 978 | //TODO: find a better way, maybe signal/slot |
979 | mTimeLabels->positionChanged(); | 979 | mTimeLabels->positionChanged(); |
980 | 980 | ||
981 | // for some reason, this needs to be called explicitly | 981 | // for some reason, this needs to be called explicitly |
982 | mTimeLabels->repaint(); | 982 | mTimeLabels->repaint(); |
983 | 983 | ||
984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 984 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
985 | 985 | ||
986 | // ToolTips displaying summary of events | 986 | // ToolTips displaying summary of events |
987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 987 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
988 | ->mEnableToolTips); | 988 | ->mEnableToolTips); |
989 | 989 | ||
990 | //setHolidayMasks(); | 990 | //setHolidayMasks(); |
991 | 991 | ||
992 | //createDayLabels(); called by via updateView(); | 992 | //createDayLabels(); called by via updateView(); |
993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 993 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
994 | updateView(); | 994 | updateView(); |
995 | mAgenda->restorePosition(); | 995 | mAgenda->restorePosition(); |
996 | } | 996 | } |
997 | 997 | ||
998 | 998 | ||
999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 999 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
1000 | { | 1000 | { |
1001 | 1001 | ||
1002 | 1002 | ||
1003 | int xxx = item->cellX(); | 1003 | int xxx = item->cellX(); |
1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 1004 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
1005 | if ( mMinY.at(xxx) > item->cellYTop() ) | 1005 | if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) { |
1006 | mMinY.at(xxx) = item->cellYTop(); | 1006 | if ( mMinY.at(xxx) > item->cellYTop() ) |
1007 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 1007 | mMinY.at(xxx) = item->cellYTop(); |
1008 | mMaxY.at(xxx) = item->cellYBottom(); | 1008 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
1009 | 1009 | mMaxY.at(xxx) = item->cellYBottom(); | |
1010 | } | ||
1010 | QDateTime startDt,endDt; | 1011 | QDateTime startDt,endDt; |
1011 | QDate startDate; | 1012 | QDate startDate; |
1012 | int lenInSecs; | 1013 | int lenInSecs; |
1013 | // if ( type == KOAgenda::RESIZETOP ) | 1014 | // if ( type == KOAgenda::RESIZETOP ) |
1014 | // qDebug("RESIZETOP "); | 1015 | // qDebug("RESIZETOP "); |
1015 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 1016 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
1016 | // qDebug("RESIZEBOTTOM "); | 1017 | // qDebug("RESIZEBOTTOM "); |
1017 | // if ( type == KOAgenda::MOVE ) | 1018 | // if ( type == KOAgenda::MOVE ) |
1018 | // qDebug("MOVE "); | 1019 | // qDebug("MOVE "); |
1019 | if ( item->incidence()->typeID() == eventID ) { | 1020 | if ( item->incidence()->typeID() == eventID ) { |
1020 | startDt =item->incidence()->dtStart(); | 1021 | startDt =item->incidence()->dtStart(); |
1021 | endDt = item->incidence()->dtEnd(); | 1022 | endDt = item->incidence()->dtEnd(); |
1022 | lenInSecs = startDt.secsTo( endDt ); | 1023 | lenInSecs = startDt.secsTo( endDt ); |
1023 | } | 1024 | } |
1024 | 1025 | ||
1025 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 1026 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
1026 | 1027 | ||
1027 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { | 1028 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
1028 | startDate = mSelectedDates[item->mLastMoveXPos]; | 1029 | startDate = mSelectedDates[item->mLastMoveXPos]; |
1029 | } else { | 1030 | } else { |
1030 | if (item->cellX() < 0) { | 1031 | if (item->cellX() < 0) { |
1031 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 1032 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
1032 | } else { | 1033 | } else { |
1033 | startDate = mSelectedDates[item->cellX()]; | 1034 | startDate = mSelectedDates[item->cellX()]; |
1034 | } | 1035 | } |
1035 | } | 1036 | } |
1036 | startDt.setDate(startDate); | 1037 | startDt.setDate(startDate); |
1037 | 1038 | ||
1038 | if (item->incidence()->doesFloat()) { | 1039 | if (item->incidence()->doesFloat()) { |
1039 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 1040 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
1040 | } else { | 1041 | } else { |
1041 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 1042 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
1042 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 1043 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
1043 | if ( item->incidence()->typeID() == eventID ) { | 1044 | if ( item->incidence()->typeID() == eventID ) { |
1044 | if ( type == KOAgenda::MOVE ) { | 1045 | if ( type == KOAgenda::MOVE ) { |
1045 | endDt = startDt.addSecs(lenInSecs); | 1046 | endDt = startDt.addSecs(lenInSecs); |
1046 | 1047 | ||
1047 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 1048 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
1048 | if (item->lastMultiItem()) { | 1049 | if (item->lastMultiItem()) { |
1049 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1050 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1050 | endDt.setDate(startDate. | 1051 | endDt.setDate(startDate. |
1051 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1052 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1052 | } else { | 1053 | } else { |
1053 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1054 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1054 | endDt.setDate(startDate); | 1055 | endDt.setDate(startDate); |
1055 | } | 1056 | } |
1056 | } | 1057 | } |
1057 | } else { | 1058 | } else { |
1058 | // todo | 1059 | // todo |
1059 | if (item->lastMultiItem()) { | 1060 | if (item->lastMultiItem()) { |
1060 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1061 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1061 | endDt.setDate(startDate. | 1062 | endDt.setDate(startDate. |
1062 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1063 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1063 | } else { | 1064 | } else { |
1064 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1065 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1065 | if ( item->cellYBottom() > 0 ) | 1066 | if ( item->cellYBottom() > 0 ) |
1066 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1067 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1067 | else | 1068 | else |
1068 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1069 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1069 | endDt.setDate(startDate); | 1070 | endDt.setDate(startDate); |
1070 | } | 1071 | } |
1071 | } | 1072 | } |
1072 | } | 1073 | } |
1073 | if ( item->incidence()->typeID() == eventID ) { | 1074 | if ( item->incidence()->typeID() == eventID ) { |
1074 | item->incidence()->setDtStart(startDt); | 1075 | item->incidence()->setDtStart(startDt); |
1075 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1076 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1076 | } else if ( item->incidence()->typeID() == todoID ) { | 1077 | } else if ( item->incidence()->typeID() == todoID ) { |
1077 | Todo* to = static_cast<Todo*>(item->incidence()); | 1078 | Todo* to = static_cast<Todo*>(item->incidence()); |
1078 | 1079 | ||
1079 | to->setDtDue(endDt); | 1080 | to->setDtDue(endDt); |
1080 | if ( to->hasStartDate() ) { | 1081 | if ( to->hasStartDate() ) { |
1081 | if (to->dtStart() >= to->dtDue() ) | 1082 | if (to->dtStart() >= to->dtDue() ) |
1082 | to->setDtStart(to->dtDue().addDays( -2 )); | 1083 | to->setDtStart(to->dtDue().addDays( -2 )); |
1083 | } | 1084 | } |
1084 | 1085 | ||
1085 | } | 1086 | } |
1086 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1087 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1087 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1088 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1088 | item->setItemDate(startDt.date()); | 1089 | item->setItemDate(startDt.date()); |
1089 | //item->updateItem(); | 1090 | //item->updateItem(); |
1090 | if ( item->incidence()->typeID() == todoID ) { | 1091 | if ( item->incidence()->typeID() == todoID ) { |
1091 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1092 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1092 | 1093 | ||
1093 | } | 1094 | } |
1094 | else | 1095 | else |
1095 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1096 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1096 | item->updateItem(); | 1097 | item->updateItem(); |
1097 | } | 1098 | } |
1098 | 1099 | ||
1099 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1100 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1100 | { | 1101 | { |
1101 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1102 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1102 | 1103 | ||
1103 | mSelectedDates.clear(); | 1104 | mSelectedDates.clear(); |
1104 | // qDebug("KOAgendaView::showDates "); | 1105 | // qDebug("KOAgendaView::showDates "); |
1105 | QDate d = start; | 1106 | QDate d = start; |
1106 | while (d <= end) { | 1107 | while (d <= end) { |
1107 | mSelectedDates.append(d); | 1108 | mSelectedDates.append(d); |
1108 | d = d.addDays( 1 ); | 1109 | d = d.addDays( 1 ); |
1109 | } | 1110 | } |
1110 | 1111 | ||
1111 | // and update the view | 1112 | // and update the view |
1112 | fillAgenda(); | 1113 | fillAgenda(); |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | void KOAgendaView::showEvents(QPtrList<Event>) | 1117 | void KOAgendaView::showEvents(QPtrList<Event>) |
1117 | { | 1118 | { |
1118 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1119 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1119 | } | 1120 | } |
1120 | 1121 | ||
1121 | void KOAgendaView::changeEventDisplay(Event *, int) | 1122 | void KOAgendaView::changeEventDisplay(Event *, int) |
1122 | { | 1123 | { |
1123 | // qDebug("KOAgendaView::changeEventDisplay "); | 1124 | // qDebug("KOAgendaView::changeEventDisplay "); |
1124 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1125 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1125 | // this should be re-written to be MUCH smarter. Right now we | 1126 | // this should be re-written to be MUCH smarter. Right now we |
1126 | // are just playing dumb. | 1127 | // are just playing dumb. |
1127 | fillAgenda(); | 1128 | fillAgenda(); |
1128 | } | 1129 | } |
1129 | 1130 | ||
1130 | void KOAgendaView::fillAgenda(const QDate &) | 1131 | void KOAgendaView::fillAgenda(const QDate &) |
1131 | { | 1132 | { |
1132 | // qDebug("KOAgendaView::fillAgenda "); | 1133 | // qDebug("KOAgendaView::fillAgenda "); |
1133 | fillAgenda(); | 1134 | fillAgenda(); |
1134 | } | 1135 | } |
1135 | 1136 | ||
1136 | void KOAgendaView::fillAgenda() | 1137 | void KOAgendaView::fillAgenda() |
1137 | { | 1138 | { |