summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-09 16:49:42 (UTC)
committer zautrix <zautrix>2005-04-09 16:49:42 (UTC)
commitd1982b1423417eb59c275bb09d4e3012a67ca086 (patch) (unidiff)
treef170a17f3d04e9d11d450233ea2d55f5803760fb
parent329ecb2c6b4153c51415513a28f2dc0576f4ddca (diff)
downloadkdepimpi-d1982b1423417eb59c275bb09d4e3012a67ca086.zip
kdepimpi-d1982b1423417eb59c275bb09d4e3012a67ca086.tar.gz
kdepimpi-d1982b1423417eb59c275bb09d4e3012a67ca086.tar.bz2
nf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp124
-rw-r--r--korganizer/koagendaitem.cpp11
-rw-r--r--korganizer/koagendaview.cpp30
3 files changed, 93 insertions, 72 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 148d914..18c506e 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1302,205 +1302,195 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1302 } else { 1302 } else {
1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1303 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1304 } 1304 }
1305 int x,y; 1305 int x,y;
1306 gridToContents(item->cellX(),item->cellYTop(),x,y); 1306 gridToContents(item->cellX(),item->cellYTop(),x,y);
1307 if (mAllDayMode) { 1307 if (mAllDayMode) {
1308 y += item->subCell() * newSubCellWidth; 1308 y += item->subCell() * newSubCellWidth;
1309 } else { 1309 } else {
1310 x += item->subCell() * newSubCellWidth; 1310 x += item->subCell() * newSubCellWidth;
1311 } 1311 }
1312 moveChild(item,x,y); 1312 moveChild(item,x,y);
1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1313 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1314 //item->updateItem(); 1314 //item->updateItem();
1315 } 1315 }
1316 // Adjust sub cell geometry of all conflict items of all conflict items 1316 // Adjust sub cell geometry of all conflict items of all conflict items
1317 for ( item=conflictItems.first(); item != 0; 1317 for ( item=conflictItems.first(); item != 0;
1318 item=conflictItems.next() ) { 1318 item=conflictItems.next() ) {
1319 if ( placeItem != item ) { 1319 if ( placeItem != item ) {
1320 KOAgendaItem *item2; 1320 KOAgendaItem *item2;
1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1321 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1322 for ( item2=conflictItems2.first(); item2 != 0; 1322 for ( item2=conflictItems2.first(); item2 != 0;
1323 item2=conflictItems2.next() ) { 1323 item2=conflictItems2.next() ) {
1324 if ( item2->subCells() != maxSubCells) { 1324 if ( item2->subCells() != maxSubCells) {
1325 item2->setSubCells(maxSubCells); 1325 item2->setSubCells(maxSubCells);
1326 if (mAllDayMode) { 1326 if (mAllDayMode) {
1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1327 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1328 } else { 1328 } else {
1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1329 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1330 } 1330 }
1331 int x,y; 1331 int x,y;
1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1332 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1333 if (mAllDayMode) { 1333 if (mAllDayMode) {
1334 y += item2->subCell() * newSubCellWidth; 1334 y += item2->subCell() * newSubCellWidth;
1335 } else { 1335 } else {
1336 x += item2->subCell() * newSubCellWidth; 1336 x += item2->subCell() * newSubCellWidth;
1337 } 1337 }
1338 moveChild(item2,x,y); 1338 moveChild(item2,x,y);
1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1339 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1340 } 1340 }
1341 } 1341 }
1342 } 1342 }
1343 } 1343 }
1344 } else { 1344 } else {
1345 placeItem->setSubCell(0); 1345 placeItem->setSubCell(0);
1346 placeItem->setSubCells(1); 1346 placeItem->setSubCells(1);
1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1347 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1348 else placeItem->resize(mGridSpacingX,placeItem->height()); 1348 else placeItem->resize(mGridSpacingX,placeItem->height());
1349 int x,y; 1349 int x,y;
1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1350 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1351 moveChild(placeItem,x,y); 1351 moveChild(placeItem,x,y);
1352 } 1352 }
1353 placeItem->setConflictItems(conflictItems); 1353 placeItem->setConflictItems(conflictItems);
1354 // for ( item=conflictItems.first(); item != 0; 1354 // for ( item=conflictItems.first(); item != 0;
1355// item=conflictItems.next() ) { 1355// item=conflictItems.next() ) {
1356// //item->updateItem(); 1356// //item->updateItem();
1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1357// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1358// } 1358// }
1359// placeItem->updateItem(); 1359// placeItem->updateItem();
1360} 1360}
1361 1361
1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1362void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1363{ 1363{
1364 if ( globalFlagBlockAgenda ) 1364 if ( globalFlagBlockAgenda )
1365 return; 1365 return;
1366 //qDebug("KOAgenda::drawContents "); 1366 if ( ! mAllDayMode ) {
1367 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1367 // currently not working for
1368 ;//drawContentsToPainter();
1369 1368
1370 QPaintDevice* pd = p->device(); 1369 //qDebug("KOAgenda::drawContents ");
1371 p->end(); 1370 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1372 int vx, vy; 1371 ;//drawContentsToPainter();
1373 int selectionX = KOGlobals::self()->reverseLayout() ? 1372
1373 QPaintDevice* pd = p->device();
1374 p->end();
1375 int vx, vy;
1376 int selectionX = KOGlobals::self()->reverseLayout() ?
1374 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1377 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1375 mSelectionCellX * mGridSpacingX; 1378 mSelectionCellX * mGridSpacingX;
1376 contentsToViewport ( cx, cy, vx,vy); 1379 contentsToViewport ( cx, cy, vx,vy);
1377 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1380 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1378 1381
1379 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1382 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1380 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1383 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1381 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1384 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1382 1385
1383 int vxSel, vySel; 1386 int vxSel, vySel;
1384 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1387 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1385 int off = mSelectionHeight; 1388 int off = mSelectionHeight;
1386 if ( vySel < 0 ) 1389 if ( vySel < 0 )
1387 off += vySel; 1390 off += vySel;
1388 //qDebug("OFF %d %d %d", off,vySel, vy ); 1391 //qDebug("OFF %d %d %d", off,vySel, vy );
1389 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1392 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1390 } else { 1393 } else {
1391 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1394 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1395 }
1392 } 1396 }
1393 } 1397 if ( mSelectionHeight > 0 ) {
1394 if ( mSelectionHeight > 0 ) { 1398 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1395 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1399 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1396 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1400 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1397 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1401 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1398 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1402 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1399 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1403 }
1400 } 1404 }
1401 } 1405 p->begin( pd );
1402 //qDebug("btbl "); 1406 } else {
1403 p->begin( pd ); 1407
1404 //qDebug("end "); 1408 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1405#if 0 1409 ;//drawContentsToPainter();
1406
1407 if ( globalFlagBlockAgenda )
1408 return;
1409 //qDebug("KOAgenda::drawContents ");
1410 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1411 ;//drawContentsToPainter();
1412 1410
1413 QPaintDevice* pd = p->device(); 1411 QPaintDevice* pd = p->device();
1414 p->end(); 1412 p->end();
1415 int vx, vy; 1413 int vx, vy;
1416 int selectionX = KOGlobals::self()->reverseLayout() ? 1414 int selectionX = KOGlobals::self()->reverseLayout() ?
1417 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1415 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1418 mSelectionCellX * mGridSpacingX; 1416 mSelectionCellX * mGridSpacingX;
1419 contentsToViewport ( cx, cy, vx,vy); 1417 contentsToViewport ( cx, cy, vx,vy);
1420 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1418 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1421 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1419 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1422 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1420 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1423 1421
1424 if ( mSelectionHeight > 0 ) { 1422 if ( mSelectionHeight > 0 ) {
1425 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1423 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1426 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1424 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1427 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1425 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1428 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1426 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1429 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1427 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1430 } 1428 }
1431 } 1429 }
1432 //qDebug("btbl "); 1430 p->begin( pd );
1433 p->begin( pd ); 1431 }
1434 //qDebug("end ");
1435
1436
1437
1438
1439
1440
1441 1432
1442#endif
1443} 1433}
1444 1434
1445void KOAgenda::finishUpdate() 1435void KOAgenda::finishUpdate()
1446{ 1436{
1447 1437
1448 KOAgendaItem *item; 1438 KOAgendaItem *item;
1449 globalFlagBlockAgendaItemPaint = 1; 1439 globalFlagBlockAgendaItemPaint = 1;
1450 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1440 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1451 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1441 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1452 if ( !item->checkLayout() ) { 1442 if ( !item->checkLayout() ) {
1453 //qDebug(" conflictitem found "); 1443 //qDebug(" conflictitem found ");
1454 int newSubCellWidth; 1444 int newSubCellWidth;
1455 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1445 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1456 else newSubCellWidth = mGridSpacingX / item->subCells(); 1446 else newSubCellWidth = mGridSpacingX / item->subCells();
1457 1447
1458 if (mAllDayMode) { 1448 if (mAllDayMode) {
1459 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1449 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1460 } else { 1450 } else {
1461 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1451 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1462 } 1452 }
1463 int x,y; 1453 int x,y;
1464 gridToContents(item->cellX(),item->cellYTop(),x,y); 1454 gridToContents(item->cellX(),item->cellYTop(),x,y);
1465 if (mAllDayMode) { 1455 if (mAllDayMode) {
1466 y += item->subCell() * newSubCellWidth; 1456 y += item->subCell() * newSubCellWidth;
1467 } else { 1457 } else {
1468 x += item->subCell() * newSubCellWidth; 1458 x += item->subCell() * newSubCellWidth;
1469 } 1459 }
1470 moveChild(item,x,y); 1460 moveChild(item,x,y);
1471 } 1461 }
1472 } 1462 }
1473 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1463 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1474 if ( !item->isVisible() ) 1464 if ( !item->isVisible() )
1475 item->show(); 1465 item->show();
1476 1466
1477 } 1467 }
1478 globalFlagBlockAgendaItemUpdate = 0; 1468 globalFlagBlockAgendaItemUpdate = 0;
1479 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1469 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1480 item->repaintMe( ); 1470 item->repaintMe( );
1481 } 1471 }
1482 globalFlagBlockAgendaItemUpdate = 1; 1472 globalFlagBlockAgendaItemUpdate = 1;
1483 qApp->processEvents(); 1473 qApp->processEvents();
1484 globalFlagBlockAgendaItemPaint = 0; 1474 globalFlagBlockAgendaItemPaint = 0;
1485 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1475 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1486 item->repaint( false ); 1476 item->repaint( false );
1487 } 1477 }
1488 1478
1489} 1479}
1490 1480
1491/* 1481/*
1492 Draw grid in the background of the agenda. 1482 Draw grid in the background of the agenda.
1493*/ 1483*/
1494void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1484void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1495{ 1485{
1496 1486
1497 1487
1498 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1488 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1499 return; 1489 return;
1500 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1490 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1501 return; 1491 return;
1502 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1492 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1503 if ( ch < 1 ) 1493 if ( ch < 1 )
1504 ch = 1; 1494 ch = 1;
1505 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1495 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1506 mPaintPixmap.resize( contentsWidth()+42, ch ); 1496 mPaintPixmap.resize( contentsWidth()+42, ch );
@@ -1906,129 +1896,129 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1906 int cellX,cellYTop,cellYBottom; 1896 int cellX,cellYTop,cellYBottom;
1907 QString newtext; 1897 QString newtext;
1908 int width = XEnd - XBegin + 1; 1898 int width = XEnd - XBegin + 1;
1909 int count = 0; 1899 int count = 0;
1910 KOAgendaItem *current = 0; 1900 KOAgendaItem *current = 0;
1911 QPtrList<KOAgendaItem> multiItems; 1901 QPtrList<KOAgendaItem> multiItems;
1912 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1902 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1913 if (cellX == XBegin) cellYTop = YTop; 1903 if (cellX == XBegin) cellYTop = YTop;
1914 else cellYTop = 0; 1904 else cellYTop = 0;
1915 if (cellX == XEnd) cellYBottom = YBottom; 1905 if (cellX == XEnd) cellYBottom = YBottom;
1916 else cellYBottom = rows() - 1; 1906 else cellYBottom = rows() - 1;
1917 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1907 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1918 newtext.append(event->summary()); 1908 newtext.append(event->summary());
1919 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1909 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1920 current->setText(newtext); 1910 current->setText(newtext);
1921 multiItems.append(current); 1911 multiItems.append(current);
1922 } 1912 }
1923 1913
1924 KOAgendaItem *next = 0; 1914 KOAgendaItem *next = 0;
1925 KOAgendaItem *last = multiItems.last(); 1915 KOAgendaItem *last = multiItems.last();
1926 KOAgendaItem *first = multiItems.first(); 1916 KOAgendaItem *first = multiItems.first();
1927 KOAgendaItem *setFirst,*setLast; 1917 KOAgendaItem *setFirst,*setLast;
1928 current = first; 1918 current = first;
1929 while (current) { 1919 while (current) {
1930 next = multiItems.next(); 1920 next = multiItems.next();
1931 if (current == first) setFirst = 0; 1921 if (current == first) setFirst = 0;
1932 else setFirst = first; 1922 else setFirst = first;
1933 if (current == last) setLast = 0; 1923 if (current == last) setLast = 0;
1934 else setLast = last; 1924 else setLast = last;
1935 1925
1936 current->setMultiItem(setFirst,next,setLast); 1926 current->setMultiItem(setFirst,next,setLast);
1937 current = next; 1927 current = next;
1938 } 1928 }
1939 1929
1940 marcus_bains(); 1930 marcus_bains();
1941} 1931}
1942 1932
1943 1933
1944//QSizePolicy KOAgenda::sizePolicy() const 1934//QSizePolicy KOAgenda::sizePolicy() const
1945//{ 1935//{
1946 // Thought this would make the all-day event agenda minimum size and the 1936 // Thought this would make the all-day event agenda minimum size and the
1947 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1937 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1948 // don´t seem to think that an Expanding widget needs more space than a 1938 // don´t seem to think that an Expanding widget needs more space than a
1949 // Preferred one. 1939 // Preferred one.
1950 // But it doesn´t hurt, so it stays. 1940 // But it doesn´t hurt, so it stays.
1951// if (mAllDayMode) { 1941// if (mAllDayMode) {
1952// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1942// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1953// } else { 1943// } else {
1954// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1944// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1955// } 1945// }
1956//} 1946//}
1957void KOAgenda::finishResize ( ) 1947void KOAgenda::finishResize ( )
1958{ 1948{
1959 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1949 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1960 if ( globalFlagBlockAgenda == 0 ) { 1950 if ( globalFlagBlockAgenda == 0 ) {
1961 finishUpdate(); 1951 finishUpdate();
1962 //qDebug("finishUpdate() called "); 1952 //qDebug("finishUpdate() called ");
1963 } 1953 }
1964} 1954}
1965/* 1955/*
1966 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1956 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1967*/ 1957*/
1968void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1958void KOAgenda::resizeEvent ( QResizeEvent *ev )
1969{ 1959{
1970 1960 mSelectionHeight = 0;
1971 mResizeTimer.start( 150 , true ); 1961 mResizeTimer.start( 150 , true );
1972 computeSizes(); 1962 computeSizes();
1973 return; 1963 return;
1974 1964
1975} 1965}
1976void KOAgenda::computeSizes() 1966void KOAgenda::computeSizes()
1977{ 1967{
1978 if ( globalFlagBlockStartup ) 1968 if ( globalFlagBlockStartup )
1979 return; 1969 return;
1980 int frameOffset = frameWidth() * 2 +1; 1970 int frameOffset = frameWidth() * 2 +1;
1981 if (mAllDayMode) { 1971 if (mAllDayMode) {
1982 mGridSpacingX = (width()-frameOffset) / mColumns; 1972 mGridSpacingX = (width()-frameOffset) / mColumns;
1983 mGridSpacingY = height() - 2 * frameWidth() - 1; 1973 mGridSpacingY = height() - 2 * frameWidth() - 1;
1984 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1974 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1985 // mGridSpacingY = height(); 1975 // mGridSpacingY = height();
1986 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1976 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1987 1977
1988 KOAgendaItem *item; 1978 KOAgendaItem *item;
1989 int subCellWidth; 1979 int subCellWidth;
1990 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1980 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1991 subCellWidth = mGridSpacingY / item->subCells(); 1981 subCellWidth = mGridSpacingY / item->subCells();
1992 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1982 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1993 moveChild(item,KOGlobals::self()->reverseLayout() ? 1983 moveChild(item,KOGlobals::self()->reverseLayout() ?
1994 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1984 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1995 item->cellX() * mGridSpacingX, 1985 item->cellX() * mGridSpacingX,
1996 item->subCell() * subCellWidth); 1986 item->subCell() * subCellWidth);
1997 } 1987 }
1998 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1988 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1999 } else { 1989 } else {
2000 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1990 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
2001 if (height() > mGridSpacingY * mRows + 1 ) { 1991 if (height() > mGridSpacingY * mRows + 1 ) {
2002 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1992 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
2003 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1993 mGridSpacingY = KOPrefs::instance()->mHourSize ;
2004 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1994 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
2005 emit resizedSignal(); 1995 emit resizedSignal();
2006 } else 1996 } else
2007 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1997 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
2008 KOAgendaItem *item; 1998 KOAgendaItem *item;
2009 int subCellWidth; 1999 int subCellWidth;
2010 2000
2011 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2001 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2012 subCellWidth = mGridSpacingX / item->subCells(); 2002 subCellWidth = mGridSpacingX / item->subCells();
2013 item->resize(subCellWidth,item->height()); 2003 item->resize(subCellWidth,item->height());
2014 moveChild(item,(KOGlobals::self()->reverseLayout() ? 2004 moveChild(item,(KOGlobals::self()->reverseLayout() ?
2015 (mColumns - 1 - item->cellX()) * mGridSpacingX : 2005 (mColumns - 1 - item->cellX()) * mGridSpacingX :
2016 item->cellX() * mGridSpacingX) + 2006 item->cellX() * mGridSpacingX) +
2017 item->subCell() * subCellWidth,childY(item)); 2007 item->subCell() * subCellWidth,childY(item));
2018 } 2008 }
2019 } 2009 }
2020 int cw = contentsWidth(); 2010 int cw = contentsWidth();
2021 int ch = contentsHeight(); 2011 int ch = contentsHeight();
2022 if ( mAllDayMode ) { 2012 if ( mAllDayMode ) {
2023 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 2013 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
2024 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) 2014 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
2025 paintPixAll->resize( cw, ch ); 2015 paintPixAll->resize( cw, ch );
2026 } else { 2016 } else {
2027 QPixmap* paintPix = KOAgendaItem::paintPix(); 2017 QPixmap* paintPix = KOAgendaItem::paintPix();
2028 if ( paintPix->width() < cw || paintPix->height() < ch ) 2018 if ( paintPix->width() < cw || paintPix->height() < ch )
2029 KOAgendaItem::resizePixmap( cw , ch ); 2019 KOAgendaItem::resizePixmap( cw , ch );
2030 } 2020 }
2031 2021
2032 checkScrollBoundaries(); 2022 checkScrollBoundaries();
2033 marcus_bains(); 2023 marcus_bains();
2034 drawContentsToPainter(); 2024 drawContentsToPainter();
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index c9e307f..1801d7e 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -487,133 +487,136 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
487 487
488 if ( xPaintCoord != xx || yPaintCoord != yy || 488 if ( xPaintCoord != xx || yPaintCoord != yy ||
489 wPaintCoord != width() || hPaintCoord != height()) { 489 wPaintCoord != width() || hPaintCoord != height()) {
490 xPaintCoord= xx; 490 xPaintCoord= xx;
491 yPaintCoord = yy; 491 yPaintCoord = yy;
492 wPaintCoord = width(); 492 wPaintCoord = width();
493 hPaintCoord = height(); 493 hPaintCoord = height();
494 globalFlagBlockAgendaItemUpdate = 0; 494 globalFlagBlockAgendaItemUpdate = 0;
495 paintMe( mSelected ); 495 paintMe( mSelected );
496 //qDebug("calling paintMe "); 496 //qDebug("calling paintMe ");
497 globalFlagBlockAgendaItemUpdate = 1; 497 globalFlagBlockAgendaItemUpdate = 1;
498 } 498 }
499 int rx, ry, rw, rh; 499 int rx, ry, rw, rh;
500 rx = e->rect().x(); 500 rx = e->rect().x();
501 ry = e->rect().y(); 501 ry = e->rect().y();
502 rw = e->rect().width(); 502 rw = e->rect().width();
503 rh = e->rect().height(); 503 rh = e->rect().height();
504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
505 505
506 QPixmap* paintFrom ; 506 QPixmap* paintFrom ;
507 if ( mSelected ) { 507 if ( mSelected ) {
508 paintFrom = paintPixSel(); 508 paintFrom = paintPixSel();
509 } else { 509 } else {
510 if ( mAllDay ) 510 if ( mAllDay )
511 paintFrom = paintPixAllday(); 511 paintFrom = paintPixAllday();
512 else 512 else
513 paintFrom = paintPix(); 513 paintFrom = paintPix();
514 } 514 }
515 xx += rx; 515 xx += rx;
516 516
517 if ( xx < 0 ) { 517 if ( xx < 0 ) {
518 rw = rw + xx; 518 rw = rw + xx;
519 rx -= xx; 519 rx -= xx;
520 xx = 0; 520 xx = 0;
521 if ( rw <= 1 ) { 521 if ( rw <= 1 ) {
522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
523 return; 523 return;
524 } 524 }
525 } 525 }
526 if ( paintFrom->width() < xx+rw ) { 526 if ( paintFrom->width() < xx+rw ) {
527 rw = paintFrom->width() - xx; 527 rw = paintFrom->width() - xx;
528 if ( rw <= 1 ) { 528 if ( rw <= 1 ) {
529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
530 return; 530 return;
531 } 531 }
532 } 532 }
533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
535} 535}
536void KOAgendaItem::computeText() 536void KOAgendaItem::computeText()
537{ 537{
538 mDisplayedText = mIncidence->summary(); 538 mDisplayedText = mIncidence->summary();
539 if ( (mIncidence->type() == "Todo") ) { 539 if ( (mIncidence->type() == "Todo") ) {
540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
543 else if ( !(mIncidence->doesFloat())) 543 else if ( !(mIncidence->doesFloat()))
544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
545 } 545 }
546 } else { 546 } else {
547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
549 549
550 if ( mAllDay ) { 550 if ( mAllDay ) {
551 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 551 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
552 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 552 if ( mIncidence->doesRecur() ) {
553 } 553 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
554 } else {
555 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
556 }
557 }
554 } 558 }
555
556 } 559 }
557 560
558 if ( !mIncidence->location().isEmpty() ) { 561 if ( !mIncidence->location().isEmpty() ) {
559 if ( mAllDay ) 562 if ( mAllDay )
560 mDisplayedText += " ("; 563 mDisplayedText += " (";
561 else 564 else
562 mDisplayedText += "\n("; 565 mDisplayedText += "\n(";
563 mDisplayedText += mIncidence->location() +")"; 566 mDisplayedText += mIncidence->location() +")";
564 } 567 }
565#ifdef DESKTOP_VERSION 568#ifdef DESKTOP_VERSION
566 QString tipText = mIncidence->summary(); 569 QString tipText = mIncidence->summary();
567 if ( !mIncidence->doesFloat() ) { 570 if ( !mIncidence->doesFloat() ) {
568 if ( mIncidence->type() == "Event" ) { 571 if ( mIncidence->type() == "Event" ) {
569 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 572 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
570 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 573 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
571 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 574 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
572 } 575 }
573 else { 576 else {
574 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 577 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
575 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 578 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
576 } 579 }
577 } 580 }
578 else if ( mIncidence->type() == "Todo" ) { 581 else if ( mIncidence->type() == "Todo" ) {
579 if (mIncidence->hasStartDate()) 582 if (mIncidence->hasStartDate())
580 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 583 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
581 if (((Todo*)mIncidence)->hasDueDate()) 584 if (((Todo*)mIncidence)->hasDueDate())
582 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 585 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
583 } 586 }
584 } else if ( mIncidence->type() == "Todo" ) { 587 } else if ( mIncidence->type() == "Todo" ) {
585 if (mIncidence->hasStartDate()) 588 if (mIncidence->hasStartDate())
586 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 589 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
587 if (((Todo*)mIncidence)->hasDueDate()) 590 if (((Todo*)mIncidence)->hasDueDate())
588 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 591 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
589 } 592 }
590 593
591 if (!mIncidence->location().isEmpty()) { 594 if (!mIncidence->location().isEmpty()) {
592 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 595 tipText += "\n"+i18n("Location: ")+mIncidence->location();
593 } 596 }
594 QToolTip::add(this,tipText,toolTipGroup(),""); 597 QToolTip::add(this,tipText,toolTipGroup(),"");
595#endif 598#endif
596} 599}
597void KOAgendaItem::updateItem() 600void KOAgendaItem::updateItem()
598{ 601{
599 computeText(); 602 computeText();
600 603
601 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 604 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
602 paintMe( mSelected ); 605 paintMe( mSelected );
603 repaint( false); 606 repaint( false);
604} 607}
605 608
606void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 609void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
607{ 610{
608 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 611 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
609 paintMe( mSelected ); 612 paintMe( mSelected );
610 repaint( false ); 613 repaint( false );
611} 614}
612 615
613/* 616/*
614 Return height of item in units of agenda cells 617 Return height of item in units of agenda cells
615*/ 618*/
616int KOAgendaItem::cellHeight() 619int KOAgendaItem::cellHeight()
617{ 620{
618 int ret = mCellYBottom - mCellYTop + 1; 621 int ret = mCellYBottom - mCellYTop + 1;
619 if ( ret <= 0 ) { 622 if ( ret <= 0 ) {
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 76d5c4b..f53e5d5 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1099,129 +1099,157 @@ void KOAgendaView::fillAgenda()
1099 onlyOne = true; 1099 onlyOne = true;
1100 //if ( globalFlagBlockAgenda == 2 ) 1100 //if ( globalFlagBlockAgenda == 2 )
1101 //globalFlagBlockAgenda = 0; 1101 //globalFlagBlockAgenda = 0;
1102 // globalFlagBlockPainting = false; 1102 // globalFlagBlockPainting = false;
1103 if ( globalFlagBlockAgenda == 0 ) 1103 if ( globalFlagBlockAgenda == 0 )
1104 globalFlagBlockAgenda = 1; 1104 globalFlagBlockAgenda = 1;
1105 // clearView(); 1105 // clearView();
1106 //qDebug("fillAgenda()++++ "); 1106 //qDebug("fillAgenda()++++ ");
1107 globalFlagBlockAgendaItemPaint = 1; 1107 globalFlagBlockAgendaItemPaint = 1;
1108 1108
1109 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1109 mAllDayAgenda->changeColumns(mSelectedDates.count());
1110 mAgenda->changeColumns(mSelectedDates.count()); 1110 mAgenda->changeColumns(mSelectedDates.count());
1111 qApp->processEvents(); 1111 qApp->processEvents();
1112 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1112 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1113 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1114 setHolidayMasks(); 1114 setHolidayMasks();
1115 1115
1116 //mAgenda->hideUnused(); 1116 //mAgenda->hideUnused();
1117 //mAllDayAgenda->hideUnused(); 1117 //mAllDayAgenda->hideUnused();
1118 1118
1119 // mAgenda->blockNextRepaint( false ); 1119 // mAgenda->blockNextRepaint( false );
1120 // mAgenda->viewport()->repaint(); 1120 // mAgenda->viewport()->repaint();
1121 // mAgenda->blockNextRepaint( true ); 1121 // mAgenda->blockNextRepaint( true );
1122 mMinY.resize(mSelectedDates.count()); 1122 mMinY.resize(mSelectedDates.count());
1123 mMaxY.resize(mSelectedDates.count()); 1123 mMaxY.resize(mSelectedDates.count());
1124 1124
1125 QPtrList<Event> dayEvents; 1125 QPtrList<Event> dayEvents;
1126 1126
1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1127 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1128 // Therefore, gtodoset all of them. 1128 // Therefore, gtodoset all of them.
1129 QPtrList<Todo> todos = calendar()->todos(); 1129 QPtrList<Todo> todos = calendar()->todos();
1130 1130
1131 mAgenda->setDateList(mSelectedDates); 1131 mAgenda->setDateList(mSelectedDates);
1132 1132
1133 QDate today = QDate::currentDate(); 1133 QDate today = QDate::currentDate();
1134 1134
1135 DateList::ConstIterator dit; 1135 DateList::ConstIterator dit;
1136 int curCol = 0; 1136 int curCol = 0;
1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1137 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1138 QDate currentDate = *dit; 1138 QDate currentDate = *dit;
1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1139 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1140 // << endl; 1140 // << endl;
1141 1141
1142 dayEvents = calendar()->events(currentDate,true); 1142 dayEvents = calendar()->events(currentDate,true);
1143 1143
1144 // Default values, which can never be reached 1144 // Default values, which can never be reached
1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1145 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1146 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1147 1147
1148 unsigned int numEvent; 1148 unsigned int numEvent;
1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1149 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1150 Event *event = dayEvents.at(numEvent); 1150 Event *event = dayEvents.at(numEvent);
1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1151 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1152 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1152 if ( event->uid().left(15) == QString("last-syncEvent-") )
1153 continue; 1153 continue;
1154 // kdDebug() << " Event: " << event->summary() << endl; 1154 // kdDebug() << " Event: " << event->summary() << endl;
1155 1155
1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1156 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1157 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1158 1158
1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1159 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1160 1160
1161 if (event->doesFloat()) { 1161 if (event->doesFloat()) {
1162 if (event->recurrence()->doesRecur()) { 1162 if (event->recurrence()->doesRecur()) {
1163 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1163 if (event->isMultiDay() ) {
1164 endX = endX - beginX;// endX is now number of days
1165 if ( event->recursOn( currentDate ) ) {
1166 endX += curCol;
1167 beginX = curCol;
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } else {
1170 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1171 QDate dateit = currentDate.addDays( -endX );
1172 if ( event->recursOn( dateit ) ) {
1173 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1174 if ( curCol-endX < 0 ) {
1175 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1176 }
1177 }
1178 }
1179 } else {
1180 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1181 }
1182#if 0
1183 if (beginX <= 0 && curCol == 0) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } else if (beginX == curCol) {
1186 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1187 } else {
1188 qDebug("skipped %d %d %d ",beginX , endX, curCol);
1189 }
1190#endif
1191 //mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1164 } else { 1192 } else {
1165 if (beginX <= 0 && curCol == 0) { 1193 if (beginX <= 0 && curCol == 0) {
1166 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1194 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1167 } else if (beginX == curCol) { 1195 } else if (beginX == curCol) {
1168 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1196 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1169 } 1197 }
1170 } 1198 }
1171 } else if (event->isMultiDay()) { 1199 } else if (event->isMultiDay()) {
1172 if ( event->doesRecur () ) { 1200 if ( event->doesRecur () ) {
1173 QDate dateit = currentDate; 1201 QDate dateit = currentDate;
1174 int count = 0; 1202 int count = 0;
1175 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1203 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1176 while (! event->recursOn( dateit ) && count <= max ) { 1204 while (! event->recursOn( dateit ) && count <= max ) {
1177 ++count; 1205 ++count;
1178 dateit = dateit.addDays( -1 ); 1206 dateit = dateit.addDays( -1 );
1179 } 1207 }
1180 bool ok; 1208 bool ok;
1181 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1209 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1182 if ( ok ) 1210 if ( ok )
1183 { 1211 {
1184 int secs = event->dtStart().secsTo( event->dtEnd() ); 1212 int secs = event->dtStart().secsTo( event->dtEnd() );
1185 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1213 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1186 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1214 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1187 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1215 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1188 1216
1189 } 1217 }
1190 } 1218 }
1191 int startY = mAgenda->timeToY(event->dtStart().time()); 1219 int startY = mAgenda->timeToY(event->dtStart().time());
1192 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1220 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1193 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1221 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1194 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1222 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1195 //qDebug("insert!!! "); 1223 //qDebug("insert!!! ");
1196 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1224 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1197 } 1225 }
1198 if (beginX == curCol) { 1226 if (beginX == curCol) {
1199 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1227 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1200 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1228 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1201 } else if (endX == curCol) { 1229 } else if (endX == curCol) {
1202 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1230 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1203 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1204 } else { 1232 } else {
1205 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1233 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1206 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1234 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1207 } 1235 }
1208 } else { 1236 } else {
1209 int startY = mAgenda->timeToY(event->dtStart().time()); 1237 int startY = mAgenda->timeToY(event->dtStart().time());
1210 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1238 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1211 if (endY < startY) endY = startY; 1239 if (endY < startY) endY = startY;
1212 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1240 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1213 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1241 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1214 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1242 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1215 } 1243 }
1216 } 1244 }
1217 // ---------- [display Todos -------------- 1245 // ---------- [display Todos --------------
1218 unsigned int numTodo; 1246 unsigned int numTodo;
1219 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1247 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1220 Todo *todo = todos.at(numTodo); 1248 Todo *todo = todos.at(numTodo);
1221 1249
1222 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1250 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1223 1251
1224 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1252 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1225 // Already completed items can be displayed on their original due date 1253 // Already completed items can be displayed on their original due date
1226 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1254 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1227 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1255 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;