summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-08 00:02:17 (UTC)
committer zautrix <zautrix>2005-01-08 00:02:17 (UTC)
commit430d67f339232b6cf745840eaa2aaceb14bdc8c7 (patch) (unidiff)
treeec63659a3ce6a87d75d5d7b29e1c1cb1df33381a /korganizer
parent5e7c3e3e51fa939e97b73e6443089edcec8dc663 (diff)
downloadkdepimpi-430d67f339232b6cf745840eaa2aaceb14bdc8c7.zip
kdepimpi-430d67f339232b6cf745840eaa2aaceb14bdc8c7.tar.gz
kdepimpi-430d67f339232b6cf745840eaa2aaceb14bdc8c7.tar.bz2
fix crash and to
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp2
-rw-r--r--korganizer/koagendaitem.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index eb3791e..7e0b216 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1443,385 +1443,385 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1443} 1443}
1444/* 1444/*
1445 Insert KOAgendaItem into agenda. 1445 Insert KOAgendaItem into agenda.
1446*/ 1446*/
1447KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1447KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1448{ 1448{
1449 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; 1449 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1450 1450
1451 if (mAllDayMode) { 1451 if (mAllDayMode) {
1452 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1452 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1453 return 0; 1453 return 0;
1454 } 1454 }
1455 1455
1456 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1456 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1457 //agendaItem->setFrameStyle(WinPanel|Raised); 1457 //agendaItem->setFrameStyle(WinPanel|Raised);
1458 1458
1459 int YSize = YBottom - YTop + 1; 1459 int YSize = YBottom - YTop + 1;
1460 if (YSize < 0) { 1460 if (YSize < 0) {
1461 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1461 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1462 YSize = 1; 1462 YSize = 1;
1463 } 1463 }
1464 int iheight = mGridSpacingY * YSize; 1464 int iheight = mGridSpacingY * YSize;
1465 1465
1466 agendaItem->resize(mGridSpacingX,iheight ); 1466 agendaItem->resize(mGridSpacingX,iheight );
1467 agendaItem->setCellXY(X,YTop,YBottom); 1467 agendaItem->setCellXY(X,YTop,YBottom);
1468 agendaItem->setCellXWidth(X); 1468 agendaItem->setCellXWidth(X);
1469 1469
1470 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1470 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1471 mItems.append(agendaItem); 1471 mItems.append(agendaItem);
1472 1472
1473 placeSubCells(agendaItem); 1473 placeSubCells(agendaItem);
1474 1474
1475 //agendaItem->show(); 1475 //agendaItem->show();
1476 1476
1477 marcus_bains(); 1477 marcus_bains();
1478 1478
1479 return agendaItem; 1479 return agendaItem;
1480} 1480}
1481 1481
1482 1482
1483/* 1483/*
1484 Insert all-day KOAgendaItem into agenda. 1484 Insert all-day KOAgendaItem into agenda.
1485*/ 1485*/
1486KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1486KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1487{ 1487{
1488 if (!mAllDayMode) { 1488 if (!mAllDayMode) {
1489 return 0; 1489 return 0;
1490 } 1490 }
1491 1491
1492 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1492 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1493 1493
1494 agendaItem->setCellXY(XBegin,0,0); 1494 agendaItem->setCellXY(XBegin,0,0);
1495 agendaItem->setCellXWidth(XEnd); 1495 agendaItem->setCellXWidth(XEnd);
1496 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1496 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1497 1497
1498 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1498 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1499 mItems.append(agendaItem); 1499 mItems.append(agendaItem);
1500 1500
1501 placeSubCells(agendaItem); 1501 placeSubCells(agendaItem);
1502 1502
1503 //agendaItem->show(); 1503 //agendaItem->show();
1504 1504
1505 return agendaItem; 1505 return agendaItem;
1506} 1506}
1507 1507
1508 1508
1509void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1509void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1510 int YTop,int YBottom) 1510 int YTop,int YBottom)
1511{ 1511{
1512 if (mAllDayMode) { 1512 if (mAllDayMode) {
1513 ; 1513 ;
1514 return; 1514 return;
1515 } 1515 }
1516 1516
1517 int cellX,cellYTop,cellYBottom; 1517 int cellX,cellYTop,cellYBottom;
1518 QString newtext; 1518 QString newtext;
1519 int width = XEnd - XBegin + 1; 1519 int width = XEnd - XBegin + 1;
1520 int count = 0; 1520 int count = 0;
1521 KOAgendaItem *current = 0; 1521 KOAgendaItem *current = 0;
1522 QPtrList<KOAgendaItem> multiItems; 1522 QPtrList<KOAgendaItem> multiItems;
1523 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1523 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1524 if (cellX == XBegin) cellYTop = YTop; 1524 if (cellX == XBegin) cellYTop = YTop;
1525 else cellYTop = 0; 1525 else cellYTop = 0;
1526 if (cellX == XEnd) cellYBottom = YBottom; 1526 if (cellX == XEnd) cellYBottom = YBottom;
1527 else cellYBottom = rows() - 1; 1527 else cellYBottom = rows() - 1;
1528 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1528 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1529 newtext.append(event->summary()); 1529 newtext.append(event->summary());
1530 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1530 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1531 current->setText(newtext); 1531 current->setText(newtext);
1532 multiItems.append(current); 1532 multiItems.append(current);
1533 } 1533 }
1534 1534
1535 KOAgendaItem *next = 0; 1535 KOAgendaItem *next = 0;
1536 KOAgendaItem *last = multiItems.last(); 1536 KOAgendaItem *last = multiItems.last();
1537 KOAgendaItem *first = multiItems.first(); 1537 KOAgendaItem *first = multiItems.first();
1538 KOAgendaItem *setFirst,*setLast; 1538 KOAgendaItem *setFirst,*setLast;
1539 current = first; 1539 current = first;
1540 while (current) { 1540 while (current) {
1541 next = multiItems.next(); 1541 next = multiItems.next();
1542 if (current == first) setFirst = 0; 1542 if (current == first) setFirst = 0;
1543 else setFirst = first; 1543 else setFirst = first;
1544 if (current == last) setLast = 0; 1544 if (current == last) setLast = 0;
1545 else setLast = last; 1545 else setLast = last;
1546 1546
1547 current->setMultiItem(setFirst,next,setLast); 1547 current->setMultiItem(setFirst,next,setLast);
1548 current = next; 1548 current = next;
1549 } 1549 }
1550 1550
1551 marcus_bains(); 1551 marcus_bains();
1552} 1552}
1553 1553
1554 1554
1555//QSizePolicy KOAgenda::sizePolicy() const 1555//QSizePolicy KOAgenda::sizePolicy() const
1556//{ 1556//{
1557 // Thought this would make the all-day event agenda minimum size and the 1557 // Thought this would make the all-day event agenda minimum size and the
1558 // normal agenda take the remaining space. But it doesnīt work. The QSplitter 1558 // normal agenda take the remaining space. But it doesnīt work. The QSplitter
1559 // donīt seem to think that an Expanding widget needs more space than a 1559 // donīt seem to think that an Expanding widget needs more space than a
1560 // Preferred one. 1560 // Preferred one.
1561 // But it doesnīt hurt, so it stays. 1561 // But it doesnīt hurt, so it stays.
1562// if (mAllDayMode) { 1562// if (mAllDayMode) {
1563// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1563// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1564// } else { 1564// } else {
1565// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1565// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1566// } 1566// }
1567//} 1567//}
1568void KOAgenda::finishResize ( ) 1568void KOAgenda::finishResize ( )
1569{ 1569{
1570 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1570 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1571 if ( globalFlagBlockAgenda == 0 ) { 1571 if ( globalFlagBlockAgenda == 0 ) {
1572 finishUpdate(); 1572 finishUpdate();
1573 //qDebug("finishUpdate() called "); 1573 //qDebug("finishUpdate() called ");
1574 } 1574 }
1575} 1575}
1576/* 1576/*
1577 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1577 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1578*/ 1578*/
1579void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1579void KOAgenda::resizeEvent ( QResizeEvent *ev )
1580{ 1580{
1581 1581
1582 mResizeTimer.start( 150 , true ); 1582 mResizeTimer.start( 150 , true );
1583 computeSizes(); 1583 computeSizes();
1584 return; 1584 return;
1585 1585
1586} 1586}
1587void KOAgenda::computeSizes() 1587void KOAgenda::computeSizes()
1588{ 1588{
1589 if ( globalFlagBlockStartup ) 1589 if ( globalFlagBlockStartup )
1590 return; 1590 return;
1591 1591
1592 if (mAllDayMode) { 1592 if (mAllDayMode) {
1593 mGridSpacingX = (width()-3) / mColumns; 1593 mGridSpacingX = (width()-3) / mColumns;
1594 mGridSpacingY = height() - 2 * frameWidth() - 1; 1594 mGridSpacingY = height() - 2 * frameWidth() - 1;
1595 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1595 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1596// mGridSpacingY = height(); 1596// mGridSpacingY = height();
1597// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1597// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1598 1598
1599 KOAgendaItem *item; 1599 KOAgendaItem *item;
1600 int subCellWidth; 1600 int subCellWidth;
1601 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1601 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1602 subCellWidth = mGridSpacingY / item->subCells(); 1602 subCellWidth = mGridSpacingY / item->subCells();
1603 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1603 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1604 moveChild(item,KOGlobals::self()->reverseLayout() ? 1604 moveChild(item,KOGlobals::self()->reverseLayout() ?
1605 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1605 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1606 item->cellX() * mGridSpacingX, 1606 item->cellX() * mGridSpacingX,
1607 item->subCell() * subCellWidth); 1607 item->subCell() * subCellWidth);
1608 } 1608 }
1609 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1609 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1610 } else { 1610 } else {
1611 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1611 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1612 if (height() > mGridSpacingY * mRows + 1 ) { 1612 if (height() > mGridSpacingY * mRows + 1 ) {
1613 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1613 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1614 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1614 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1615 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1616 emit resizedSignal(); 1616 emit resizedSignal();
1617 } else 1617 } else
1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1618 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1619 KOAgendaItem *item; 1619 KOAgendaItem *item;
1620 int subCellWidth; 1620 int subCellWidth;
1621 1621
1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1622 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1623 subCellWidth = mGridSpacingX / item->subCells(); 1623 subCellWidth = mGridSpacingX / item->subCells();
1624 item->resize(subCellWidth,item->height()); 1624 item->resize(subCellWidth,item->height());
1625 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1625 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1626 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1626 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1627 item->cellX() * mGridSpacingX) + 1627 item->cellX() * mGridSpacingX) +
1628 item->subCell() * subCellWidth,childY(item)); 1628 item->subCell() * subCellWidth,childY(item));
1629 } 1629 }
1630 } 1630 }
1631 int cw = contentsWidth(); 1631 int cw = contentsWidth();
1632 int ch = contentsHeight(); 1632 int ch = contentsHeight();
1633 if ( mAllDayMode ) { 1633 if ( mAllDayMode ) {
1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1634 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1635 if ( paintPixAll->width() < cw || paintPixAll->height() < ch ) 1635 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 )
1636 paintPixAll->resize( cw, ch ); 1636 paintPixAll->resize( cw, ch );
1637 } else { 1637 } else {
1638 QPixmap* paintPix = KOAgendaItem::paintPix(); 1638 QPixmap* paintPix = KOAgendaItem::paintPix();
1639 if ( paintPix->width() < cw || paintPix->height() < ch ) 1639 if ( paintPix->width() < cw || paintPix->height() < ch )
1640 KOAgendaItem::resizePixmap( cw , ch ); 1640 KOAgendaItem::resizePixmap( cw , ch );
1641 } 1641 }
1642 1642
1643 checkScrollBoundaries(); 1643 checkScrollBoundaries();
1644 marcus_bains(); 1644 marcus_bains();
1645 drawContentsToPainter(); 1645 drawContentsToPainter();
1646 viewport()->repaint(false); 1646 viewport()->repaint(false);
1647} 1647}
1648 1648
1649void KOAgenda::scrollUp() 1649void KOAgenda::scrollUp()
1650{ 1650{
1651 scrollBy(0,-mScrollOffset); 1651 scrollBy(0,-mScrollOffset);
1652} 1652}
1653 1653
1654 1654
1655void KOAgenda::scrollDown() 1655void KOAgenda::scrollDown()
1656{ 1656{
1657 scrollBy(0,mScrollOffset); 1657 scrollBy(0,mScrollOffset);
1658} 1658}
1659 1659
1660void KOAgenda::popupAlarm() 1660void KOAgenda::popupAlarm()
1661{ 1661{
1662 if (!mClickedItem) { 1662 if (!mClickedItem) {
1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; 1663 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
1664 return; 1664 return;
1665 } 1665 }
1666// TODO: deal correctly with multiple alarms 1666// TODO: deal correctly with multiple alarms
1667 Alarm* alarm; 1667 Alarm* alarm;
1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1668 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1669 for(alarm=list.first();alarm;alarm=list.next()) { 1669 for(alarm=list.first();alarm;alarm=list.next()) {
1670 alarm->toggleAlarm(); 1670 alarm->toggleAlarm();
1671 } 1671 }
1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1672 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1673 mClickedItem->paintMe( true ); 1673 mClickedItem->paintMe( true );
1674 mClickedItem->repaint( false ); 1674 mClickedItem->repaint( false );
1675} 1675}
1676 1676
1677/* 1677/*
1678 Calculates the minimum width 1678 Calculates the minimum width
1679*/ 1679*/
1680int KOAgenda::minimumWidth() const 1680int KOAgenda::minimumWidth() const
1681{ 1681{
1682 // TODO:: develop a way to dynamically determine the minimum width 1682 // TODO:: develop a way to dynamically determine the minimum width
1683 int min = 100; 1683 int min = 100;
1684 1684
1685 return min; 1685 return min;
1686} 1686}
1687 1687
1688void KOAgenda::updateConfig() 1688void KOAgenda::updateConfig()
1689{ 1689{
1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1690 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1691 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1692 if ( mAllDayMode ) { 1692 if ( mAllDayMode ) {
1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1693 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1694 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1695 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1696 // setMaximumHeight( mGridSpacingY+1 ); 1696 // setMaximumHeight( mGridSpacingY+1 );
1697 viewport()->repaint( false ); 1697 viewport()->repaint( false );
1698 //setFixedHeight( mGridSpacingY+1 ); 1698 //setFixedHeight( mGridSpacingY+1 );
1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1699 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1700 } 1700 }
1701 else { 1701 else {
1702 mGridSpacingY = KOPrefs::instance()->mHourSize; 1702 mGridSpacingY = KOPrefs::instance()->mHourSize;
1703 calculateWorkingHours(); 1703 calculateWorkingHours();
1704 marcus_bains(); 1704 marcus_bains();
1705 } 1705 }
1706} 1706}
1707 1707
1708void KOAgenda::checkScrollBoundaries() 1708void KOAgenda::checkScrollBoundaries()
1709{ 1709{
1710 // Invalidate old values to force update 1710 // Invalidate old values to force update
1711 mOldLowerScrollValue = -1; 1711 mOldLowerScrollValue = -1;
1712 mOldUpperScrollValue = -1; 1712 mOldUpperScrollValue = -1;
1713 1713
1714 checkScrollBoundaries(verticalScrollBar()->value()); 1714 checkScrollBoundaries(verticalScrollBar()->value());
1715} 1715}
1716 1716
1717void KOAgenda::checkScrollBoundaries(int v) 1717void KOAgenda::checkScrollBoundaries(int v)
1718{ 1718{
1719 if ( mGridSpacingY == 0 ) 1719 if ( mGridSpacingY == 0 )
1720 return; 1720 return;
1721 int yMin = v/mGridSpacingY; 1721 int yMin = v/mGridSpacingY;
1722 int yMax = (v+visibleHeight())/mGridSpacingY; 1722 int yMax = (v+visibleHeight())/mGridSpacingY;
1723 1723
1724// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1724// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1725 1725
1726 if (yMin != mOldLowerScrollValue) { 1726 if (yMin != mOldLowerScrollValue) {
1727 mOldLowerScrollValue = yMin; 1727 mOldLowerScrollValue = yMin;
1728 emit lowerYChanged(yMin); 1728 emit lowerYChanged(yMin);
1729 } 1729 }
1730 if (yMax != mOldUpperScrollValue) { 1730 if (yMax != mOldUpperScrollValue) {
1731 mOldUpperScrollValue = yMax; 1731 mOldUpperScrollValue = yMax;
1732 emit upperYChanged(yMax); 1732 emit upperYChanged(yMax);
1733 } 1733 }
1734} 1734}
1735 1735
1736void KOAgenda::deselectItem() 1736void KOAgenda::deselectItem()
1737{ 1737{
1738 if (mSelectedItem.isNull()) return; 1738 if (mSelectedItem.isNull()) return;
1739 mSelectedItem->select(false); 1739 mSelectedItem->select(false);
1740 mSelectedItem = 0; 1740 mSelectedItem = 0;
1741} 1741}
1742 1742
1743void KOAgenda::selectItem(KOAgendaItem *item) 1743void KOAgenda::selectItem(KOAgendaItem *item)
1744{ 1744{
1745 if ((KOAgendaItem *)mSelectedItem == item) return; 1745 if ((KOAgendaItem *)mSelectedItem == item) return;
1746 deselectItem(); 1746 deselectItem();
1747 if (item == 0) { 1747 if (item == 0) {
1748 emit incidenceSelected( 0 ); 1748 emit incidenceSelected( 0 );
1749 return; 1749 return;
1750 } 1750 }
1751 mSelectedItem = item; 1751 mSelectedItem = item;
1752 mSelectedItem->select(); 1752 mSelectedItem->select();
1753 emit incidenceSelected( mSelectedItem->incidence() ); 1753 emit incidenceSelected( mSelectedItem->incidence() );
1754} 1754}
1755 1755
1756// This function seems never be called. 1756// This function seems never be called.
1757void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1757void KOAgenda::keyPressEvent( QKeyEvent *kev )
1758{ 1758{
1759 switch(kev->key()) { 1759 switch(kev->key()) {
1760 case Key_PageDown: 1760 case Key_PageDown:
1761 verticalScrollBar()->addPage(); 1761 verticalScrollBar()->addPage();
1762 break; 1762 break;
1763 case Key_PageUp: 1763 case Key_PageUp:
1764 verticalScrollBar()->subtractPage(); 1764 verticalScrollBar()->subtractPage();
1765 break; 1765 break;
1766 case Key_Down: 1766 case Key_Down:
1767 verticalScrollBar()->addLine(); 1767 verticalScrollBar()->addLine();
1768 break; 1768 break;
1769 case Key_Up: 1769 case Key_Up:
1770 verticalScrollBar()->subtractLine(); 1770 verticalScrollBar()->subtractLine();
1771 break; 1771 break;
1772 default: 1772 default:
1773 ; 1773 ;
1774 } 1774 }
1775} 1775}
1776 1776
1777void KOAgenda::calculateWorkingHours() 1777void KOAgenda::calculateWorkingHours()
1778{ 1778{
1779// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1779// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1780 mWorkingHoursEnable = !mAllDayMode; 1780 mWorkingHoursEnable = !mAllDayMode;
1781 1781
1782 mWorkingHoursYTop = mGridSpacingY * 1782 mWorkingHoursYTop = mGridSpacingY *
1783 KOPrefs::instance()->mWorkingHoursStart * 4; 1783 KOPrefs::instance()->mWorkingHoursStart * 4;
1784 mWorkingHoursYBottom = mGridSpacingY * 1784 mWorkingHoursYBottom = mGridSpacingY *
1785 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1785 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1786} 1786}
1787 1787
1788 1788
1789DateList KOAgenda::dateList() const 1789DateList KOAgenda::dateList() const
1790{ 1790{
1791 return mSelectedDates; 1791 return mSelectedDates;
1792} 1792}
1793 1793
1794void KOAgenda::setDateList(const DateList &selectedDates) 1794void KOAgenda::setDateList(const DateList &selectedDates)
1795{ 1795{
1796 mSelectedDates = selectedDates; 1796 mSelectedDates = selectedDates;
1797 marcus_bains(); 1797 marcus_bains();
1798} 1798}
1799 1799
1800void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 1800void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1801{ 1801{
1802 mHolidayMask = mask; 1802 mHolidayMask = mask;
1803 1803
1804/* 1804/*
1805 kdDebug() << "HolidayMask: "; 1805 kdDebug() << "HolidayMask: ";
1806 for(uint i=0;i<mask->count();++i) { 1806 for(uint i=0;i<mask->count();++i) {
1807 kdDebug() << (mask->at(i) ? "*" : "o"); 1807 kdDebug() << (mask->at(i) ? "*" : "o");
1808 } 1808 }
1809 kdDebug() << endl; 1809 kdDebug() << endl;
1810*/ 1810*/
1811} 1811}
1812 1812
1813void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 1813void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1814{ 1814{
1815 1815
1816 QScrollView::contentsMousePressEvent(event); 1816 QScrollView::contentsMousePressEvent(event);
1817} 1817}
1818 1818
1819void KOAgenda::storePosition() 1819void KOAgenda::storePosition()
1820{ 1820{
1821 //mContentPosition 1821 //mContentPosition
1822 int max = mGridSpacingY*4*24; 1822 int max = mGridSpacingY*4*24;
1823 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 1823 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1824 mContentPosition = 0; 1824 mContentPosition = 0;
1825 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 1825 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
1826 mContentPosition = -1.0; 1826 mContentPosition = -1.0;
1827 else 1827 else
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 6965ba7..62281d4 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -238,399 +238,399 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
238 } 238 }
239 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 239 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
240 if ( horLayout ) 240 if ( horLayout )
241 ++xOff; 241 ++xOff;
242 else 242 else
243 ++yOff; 243 ++yOff;
244 244
245 } 245 }
246 246
247 } 247 }
248 return ( yOff || xOff ); 248 return ( yOff || xOff );
249} 249}
250 250
251 251
252void KOAgendaItem::select(bool selected) 252void KOAgendaItem::select(bool selected)
253{ 253{
254 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 254 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
255 if (mSelected == selected) return; 255 if (mSelected == selected) return;
256 mSelected = selected; 256 mSelected = selected;
257 if ( ! isVisible() ) 257 if ( ! isVisible() )
258 return; 258 return;
259 if ( firstMultiItem() ) 259 if ( firstMultiItem() )
260 firstMultiItem()->select( selected ); 260 firstMultiItem()->select( selected );
261 if ( !firstMultiItem() && nextMultiItem() ) { 261 if ( !firstMultiItem() && nextMultiItem() ) {
262 KOAgendaItem * placeItem = nextMultiItem(); 262 KOAgendaItem * placeItem = nextMultiItem();
263 while ( placeItem ) { 263 while ( placeItem ) {
264 placeItem->select( selected ); 264 placeItem->select( selected );
265 placeItem = placeItem->nextMultiItem(); 265 placeItem = placeItem->nextMultiItem();
266 } 266 }
267 } 267 }
268 globalFlagBlockAgendaItemUpdate = 0; 268 globalFlagBlockAgendaItemUpdate = 0;
269 paintMe( selected ); 269 paintMe( selected );
270 globalFlagBlockAgendaItemUpdate = 1; 270 globalFlagBlockAgendaItemUpdate = 1;
271 repaint( false ); 271 repaint( false );
272} 272}
273 273
274 274
275/* 275/*
276 The eventFilter has to filter the mouse events of the agenda item childs. The 276 The eventFilter has to filter the mouse events of the agenda item childs. The
277 events are fed into the event handling method of KOAgendaItem. This allows the 277 events are fed into the event handling method of KOAgendaItem. This allows the
278 KOAgenda to handle the KOAgendaItems by using an eventFilter. 278 KOAgenda to handle the KOAgendaItems by using an eventFilter.
279*/ 279*/
280bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 280bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
281{ 281{
282 if (e->type() == QEvent::MouseButtonPress || 282 if (e->type() == QEvent::MouseButtonPress ||
283 e->type() == QEvent::MouseButtonDblClick || 283 e->type() == QEvent::MouseButtonDblClick ||
284 e->type() == QEvent::MouseButtonRelease || 284 e->type() == QEvent::MouseButtonRelease ||
285 e->type() == QEvent::MouseMove) { 285 e->type() == QEvent::MouseMove) {
286 QMouseEvent *me = (QMouseEvent *)e; 286 QMouseEvent *me = (QMouseEvent *)e;
287 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 287 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
288 mapToGlobal(me->pos())); 288 mapToGlobal(me->pos()));
289 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 289 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
290 return event(&returnEvent); 290 return event(&returnEvent);
291 } else { 291 } else {
292 return false; 292 return false;
293 } 293 }
294} 294}
295void KOAgendaItem::repaintMe( ) 295void KOAgendaItem::repaintMe( )
296{ 296{
297 paintMe ( mSelected ); 297 paintMe ( mSelected );
298} 298}
299void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 299void KOAgendaItem::paintMe( bool selected, QPainter* paint )
300{ 300{
301 if ( globalFlagBlockAgendaItemUpdate && ! selected) 301 if ( globalFlagBlockAgendaItemUpdate && ! selected)
302 return; 302 return;
303 QPainter pa; 303 QPainter pa;
304 304
305 if ( mSelected ) { 305 if ( mSelected ) {
306 pa.begin( paintPixSel() ); 306 pa.begin( paintPixSel() );
307 } else { 307 } else {
308 if ( mAllDay ) 308 if ( mAllDay )
309 pa.begin( paintPixAllday() ); 309 pa.begin( paintPixAllday() );
310 else 310 else
311 pa.begin( paintPix() ); 311 pa.begin( paintPix() );
312 } 312 }
313 int x, yy, w, h; 313 int x, yy, w, h;
314 float nfh; 314 float nfh;
315 x = pos().x(); w = width(); h = height (); 315 x = pos().x(); w = width(); h = height ();
316 if ( mAllDay ) 316 if ( mAllDay )
317 yy = y(); 317 yy = y();
318 else 318 else
319 yy = mCellYTop * ( height() / cellHeight() ); 319 yy = mCellYTop * ( height() / cellHeight() );
320 xPaintCoord= x; 320 xPaintCoord= x;
321 yPaintCoord = yy; 321 yPaintCoord = yy;
322 wPaintCoord = width(); 322 wPaintCoord = width();
323 hPaintCoord = height(); 323 hPaintCoord = height();
324 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 324 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
325 if ( paint == 0 ) 325 if ( paint == 0 )
326 paint = &pa; 326 paint = &pa;
327 bool horLayout = ( w < h ); 327 bool horLayout = ( w < h );
328 int maxhei = mFontPixelSize+4; 328 int maxhei = mFontPixelSize+4;
329 if ( horLayout ) 329 if ( horLayout )
330 maxhei += AGENDA_ICON_SIZE -4; 330 maxhei += AGENDA_ICON_SIZE -4;
331 bool small = ( h < maxhei ); 331 bool small = ( h < maxhei );
332 if ( ! small ) 332 if ( ! small )
333 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 333 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
334 else { 334 else {
335 QFont f = KOPrefs::instance()->mAgendaViewFont; 335 QFont f = KOPrefs::instance()->mAgendaViewFont;
336 f.setBold( false ); 336 f.setBold( false );
337 int fh = f.pointSize(); 337 int fh = f.pointSize();
338 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 338 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
339 if ( nfh < 6 ) 339 if ( nfh < 6 )
340 nfh = 6; 340 nfh = 6;
341 f.setPointSize( nfh ); 341 f.setPointSize( nfh );
342 paint->setFont(f); 342 paint->setFont(f);
343 } 343 }
344 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 344 paint->fillRect ( x, yy, w, h, mBackgroundColor );
345 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 345 static const QPixmap completedPxmp = SmallIcon("greenhook16");
346 static const QPixmap overduePxmp = SmallIcon("redcross16"); 346 static const QPixmap overduePxmp = SmallIcon("redcross16");
347 if ( mIncidence->type() == "Todo" ) { 347 if ( mIncidence->type() == "Todo" ) {
348 Todo* tempTodo = static_cast<Todo*>(mIncidence); 348 Todo* tempTodo = static_cast<Todo*>(mIncidence);
349 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 349 int xx = pos().x()+(width()-completedPxmp.width()-3 );
350 int yyy = yy+3; 350 int yyy = yy+3;
351 if ( tempTodo->isCompleted() ) 351 if ( tempTodo->isCompleted() )
352 paint->drawPixmap ( xx, yyy, completedPxmp ); 352 paint->drawPixmap ( xx, yyy, completedPxmp );
353 else { 353 else {
354 paint->drawPixmap ( xx, yyy, overduePxmp ); 354 paint->drawPixmap ( xx, yyy, overduePxmp );
355 355
356 } 356 }
357 } 357 }
358 bool addIcon = false; 358 bool addIcon = false;
359 if ( ! small || w > 3 * h || h > 3* w ) 359 if ( ! small || w > 3 * h || h > 3* w )
360 addIcon = updateIcons( paint, horLayout ); 360 addIcon = updateIcons( paint, horLayout );
361 361
362 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 362 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
363 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 363 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
364 if ( ! small ) { 364 if ( ! small ) {
365 x += 3; yy += 3;w -= 6; h-= 5; 365 x += 3; yy += 3;w -= 6; h-= 5;
366 } else { 366 } else {
367 x += 2; yy += 1;w -= 4; h-= 4; 367 x += 2; yy += 1;w -= 4; h-= 4;
368 if ( nfh < 6.01 ) { 368 if ( nfh < 6.01 ) {
369 yy -= 2; 369 yy -= 2;
370 h += 4; 370 h += 4;
371 } 371 }
372 else 372 else
373 if ( nfh < h -2 ) 373 if ( nfh < h -2 )
374 ++yy; 374 ++yy;
375 } 375 }
376 int align; 376 int align;
377#ifndef DESKTOP_VERSION 377#ifndef DESKTOP_VERSION
378 align = ( AlignLeft|WordBreak|AlignTop); 378 align = ( AlignLeft|WordBreak|AlignTop);
379#else 379#else
380 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 380 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
381#endif 381#endif
382 if ( addIcon ) { 382 if ( addIcon ) {
383 if ( ! horLayout ) { 383 if ( ! horLayout ) {
384 x += AGENDA_ICON_SIZE+3; 384 x += AGENDA_ICON_SIZE+3;
385 w -= (AGENDA_ICON_SIZE+3); 385 w -= (AGENDA_ICON_SIZE+3);
386 } 386 }
387 else { 387 else {
388 yy+= AGENDA_ICON_SIZE+2; 388 yy+= AGENDA_ICON_SIZE+2;
389 h -=(AGENDA_ICON_SIZE+3); 389 h -=(AGENDA_ICON_SIZE+3);
390 } 390 }
391 } 391 }
392 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 392 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
393 if ( colsum < 250 ) 393 if ( colsum < 250 )
394 paint->setPen ( white); 394 paint->setPen ( white);
395 if ( x < 0 ) { 395 if ( x < 0 ) {
396 w = w+x-3; 396 w = w+x-3;
397 x = 3; 397 x = 3;
398 if ( w > parentWidget()->width() ){ 398 if ( w > parentWidget()->width() ){
399 w = parentWidget()->width() - 6; 399 w = parentWidget()->width() - 6;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 align = ( AlignCenter|WordBreak); 401 align = ( AlignCenter|WordBreak);
402#else 402#else
403 align = ( AlignCenter|BreakAnywhere|WordBreak); 403 align = ( AlignCenter|BreakAnywhere|WordBreak);
404#endif 404#endif
405 405
406 } 406 }
407 } 407 }
408 QRect dr; 408 QRect dr;
409 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 409 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
410 if ( mIncidence->cancelled() ){ 410 if ( mIncidence->cancelled() ){
411 if ( ! small ) { 411 if ( ! small ) {
412 QFontMetrics fm ( paint->font() ); 412 QFontMetrics fm ( paint->font() );
413 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 413 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
414 } 414 }
415 415
416 } 416 }
417 pa.end(); 417 pa.end();
418 418
419} 419}
420void KOAgendaItem::resizePixmap( int w , int h ) 420void KOAgendaItem::resizePixmap( int w , int h )
421{ 421{
422 paintPix()->resize( w, h ); 422 paintPix()->resize( w, h );
423 paintPixSel()->resize( w, h ); 423 paintPixSel()->resize( w, h );
424 424
425} 425}
426QPixmap * KOAgendaItem::paintPix() 426QPixmap * KOAgendaItem::paintPix()
427{ 427{
428 static QPixmap* mPaintPix = 0; 428 static QPixmap* mPaintPix = 0;
429 if ( ! mPaintPix ) 429 if ( ! mPaintPix )
430 mPaintPix = new QPixmap(); 430 mPaintPix = new QPixmap(1,1);
431 return mPaintPix ; 431 return mPaintPix ;
432} 432}
433QPixmap * KOAgendaItem::paintPixAllday() 433QPixmap * KOAgendaItem::paintPixAllday()
434{ 434{
435 static QPixmap* mPaintPixA = 0; 435 static QPixmap* mPaintPixA = 0;
436 if ( ! mPaintPixA ) 436 if ( ! mPaintPixA )
437 mPaintPixA = new QPixmap(); 437 mPaintPixA = new QPixmap(1,1);
438 return mPaintPixA ; 438 return mPaintPixA ;
439} 439}
440QPixmap * KOAgendaItem::paintPixSel() 440QPixmap * KOAgendaItem::paintPixSel()
441{ 441{
442 static QPixmap* mPaintPixSel = 0; 442 static QPixmap* mPaintPixSel = 0;
443 if ( ! mPaintPixSel ) 443 if ( ! mPaintPixSel )
444 mPaintPixSel = new QPixmap(); 444 mPaintPixSel = new QPixmap(1,1);
445 return mPaintPixSel ; 445 return mPaintPixSel ;
446} 446}
447void KOAgendaItem::paintEvent ( QPaintEvent *e ) 447void KOAgendaItem::paintEvent ( QPaintEvent *e )
448{ 448{
449 449
450 if ( globalFlagBlockAgendaItemPaint ) 450 if ( globalFlagBlockAgendaItemPaint )
451 return; 451 return;
452 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 452 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
453 return; 453 return;
454 int yy; 454 int yy;
455 if ( mAllDay ) 455 if ( mAllDay )
456 yy = y(); 456 yy = y();
457 else 457 else
458 yy = mCellYTop * ( height() / cellHeight() ); 458 yy = mCellYTop * ( height() / cellHeight() );
459 int xx = x(); 459 int xx = x();
460 if ( xPaintCoord != xx || yPaintCoord != yy || 460 if ( xPaintCoord != xx || yPaintCoord != yy ||
461 wPaintCoord != width() || hPaintCoord != height()) { 461 wPaintCoord != width() || hPaintCoord != height()) {
462 xPaintCoord= xx; 462 xPaintCoord= xx;
463 yPaintCoord = yy; 463 yPaintCoord = yy;
464 wPaintCoord = width(); 464 wPaintCoord = width();
465 hPaintCoord = height(); 465 hPaintCoord = height();
466 globalFlagBlockAgendaItemUpdate = 0; 466 globalFlagBlockAgendaItemUpdate = 0;
467 paintMe( mSelected ); 467 paintMe( mSelected );
468 //qDebug("calling paintMe "); 468 //qDebug("calling paintMe ");
469 globalFlagBlockAgendaItemUpdate = 1; 469 globalFlagBlockAgendaItemUpdate = 1;
470 } 470 }
471 int rx, ry, rw, rh; 471 int rx, ry, rw, rh;
472 rx = e->rect().x(); 472 rx = e->rect().x();
473 ry = e->rect().y(); 473 ry = e->rect().y();
474 rw = e->rect().width(); 474 rw = e->rect().width();
475 rh = e->rect().height(); 475 rh = e->rect().height();
476 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 476 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
477 477
478 QPixmap* paintFrom ; 478 QPixmap* paintFrom ;
479 if ( mSelected ) { 479 if ( mSelected ) {
480 paintFrom = paintPixSel(); 480 paintFrom = paintPixSel();
481 } else { 481 } else {
482 if ( mAllDay ) 482 if ( mAllDay )
483 paintFrom = paintPixAllday(); 483 paintFrom = paintPixAllday();
484 else 484 else
485 paintFrom = paintPix(); 485 paintFrom = paintPix();
486 } 486 }
487 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 487 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
488} 488}
489void KOAgendaItem::computeText() 489void KOAgendaItem::computeText()
490{ 490{
491 mDisplayedText = mIncidence->summary(); 491 mDisplayedText = mIncidence->summary();
492 if ( (mIncidence->type() == "Todo") ) { 492 if ( (mIncidence->type() == "Todo") ) {
493 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 493 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
495 else if ( !(mIncidence->doesFloat())) 495 else if ( !(mIncidence->doesFloat()))
496 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 496 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
497 497
498 498
499 499
500 } else { 500 } else {
501 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 501 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
502 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 502 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
503 503
504 if ( mAllDay ) { 504 if ( mAllDay ) {
505 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 505 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
506 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 506 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
507 } 507 }
508 } 508 }
509 509
510 } 510 }
511 511
512 if ( !mIncidence->location().isEmpty() ) { 512 if ( !mIncidence->location().isEmpty() ) {
513 if ( mAllDay ) 513 if ( mAllDay )
514 mDisplayedText += " ("; 514 mDisplayedText += " (";
515 else 515 else
516 mDisplayedText += "\n("; 516 mDisplayedText += "\n(";
517 mDisplayedText += mIncidence->location() +")"; 517 mDisplayedText += mIncidence->location() +")";
518 } 518 }
519} 519}
520void KOAgendaItem::updateItem() 520void KOAgendaItem::updateItem()
521{ 521{
522 computeText(); 522 computeText();
523 523
524 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 524 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
525 paintMe( mSelected ); 525 paintMe( mSelected );
526 repaint( false); 526 repaint( false);
527} 527}
528 528
529void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 529void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
530{ 530{
531 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 531 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
532 paintMe( mSelected ); 532 paintMe( mSelected );
533 repaint( false ); 533 repaint( false );
534} 534}
535 535
536/* 536/*
537 Return height of item in units of agenda cells 537 Return height of item in units of agenda cells
538*/ 538*/
539int KOAgendaItem::cellHeight() 539int KOAgendaItem::cellHeight()
540{ 540{
541 int ret = mCellYBottom - mCellYTop + 1; 541 int ret = mCellYBottom - mCellYTop + 1;
542 if ( ret <= 0 ) { 542 if ( ret <= 0 ) {
543 ret = 1; 543 ret = 1;
544 mCellYBottom = 0; 544 mCellYBottom = 0;
545 mCellYTop = 0; 545 mCellYTop = 0;
546 } 546 }
547 return ret; 547 return ret;
548} 548}
549 549
550/* 550/*
551 Return height of item in units of agenda cells 551 Return height of item in units of agenda cells
552*/ 552*/
553int KOAgendaItem::cellWidth() 553int KOAgendaItem::cellWidth()
554{ 554{
555 return mCellXWidth - mCellX + 1; 555 return mCellXWidth - mCellX + 1;
556} 556}
557 557
558void KOAgendaItem::setItemDate(QDate qd) 558void KOAgendaItem::setItemDate(QDate qd)
559{ 559{
560 mDate = qd; 560 mDate = qd;
561} 561}
562 562
563void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 563void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
564{ 564{
565 mCellX = X; 565 mCellX = X;
566 mCellYTop = YTop; 566 mCellYTop = YTop;
567 mCellYBottom = YBottom; 567 mCellYBottom = YBottom;
568} 568}
569 569
570void KOAgendaItem::setCellXWidth(int xwidth) 570void KOAgendaItem::setCellXWidth(int xwidth)
571{ 571{
572 mCellXWidth = xwidth; 572 mCellXWidth = xwidth;
573} 573}
574 574
575void KOAgendaItem::setCellX(int XLeft, int XRight) 575void KOAgendaItem::setCellX(int XLeft, int XRight)
576{ 576{
577 mCellX = XLeft; 577 mCellX = XLeft;
578 mCellXWidth = XRight; 578 mCellXWidth = XRight;
579} 579}
580 580
581void KOAgendaItem::setCellY(int YTop, int YBottom) 581void KOAgendaItem::setCellY(int YTop, int YBottom)
582{ 582{
583 mCellYTop = YTop; 583 mCellYTop = YTop;
584 mCellYBottom = YBottom; 584 mCellYBottom = YBottom;
585} 585}
586 586
587void KOAgendaItem::setSubCell(int subCell) 587void KOAgendaItem::setSubCell(int subCell)
588{ 588{
589 mSubCell = subCell; 589 mSubCell = subCell;
590} 590}
591 591
592void KOAgendaItem::setSubCells(int subCells) 592void KOAgendaItem::setSubCells(int subCells)
593{ 593{
594 mSubCells = subCells; 594 mSubCells = subCells;
595} 595}
596 596
597void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 597void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
598 KOAgendaItem *last) 598 KOAgendaItem *last)
599{ 599{
600 mFirstMultiItem = first; 600 mFirstMultiItem = first;
601 mNextMultiItem = next; 601 mNextMultiItem = next;
602 mLastMultiItem = last; 602 mLastMultiItem = last;
603} 603}
604 604
605void KOAgendaItem::startMove() 605void KOAgendaItem::startMove()
606{ 606{
607 mStartCellX = mCellX; 607 mStartCellX = mCellX;
608 mStartCellXWidth = mCellXWidth; 608 mStartCellXWidth = mCellXWidth;
609 mStartCellYTop = mCellYTop; 609 mStartCellYTop = mCellYTop;
610 mStartCellYBottom = mCellYBottom; 610 mStartCellYBottom = mCellYBottom;
611} 611}
612 612
613void KOAgendaItem::resetMove() 613void KOAgendaItem::resetMove()
614{ 614{
615 mCellX = mStartCellX; 615 mCellX = mStartCellX;
616 mCellXWidth = mStartCellXWidth; 616 mCellXWidth = mStartCellXWidth;
617 mCellYTop = mStartCellYTop; 617 mCellYTop = mStartCellYTop;
618 mCellYBottom = mStartCellYBottom; 618 mCellYBottom = mStartCellYBottom;
619} 619}
620 620
621void KOAgendaItem::moveRelative(int dx, int dy) 621void KOAgendaItem::moveRelative(int dx, int dy)
622{ 622{
623 int newX = cellX() + dx; 623 int newX = cellX() + dx;
624 int newXWidth = cellXWidth() + dx; 624 int newXWidth = cellXWidth() + dx;
625 int newYTop = cellYTop() + dy; 625 int newYTop = cellYTop() + dy;
626 int newYBottom = cellYBottom() + dy; 626 int newYBottom = cellYBottom() + dy;
627 setCellXY(newX,newYTop,newYBottom); 627 setCellXY(newX,newYTop,newYBottom);
628 setCellXWidth(newXWidth); 628 setCellXWidth(newXWidth);
629} 629}
630 630
631void KOAgendaItem::expandTop(int dy) 631void KOAgendaItem::expandTop(int dy)
632{ 632{
633 int newYTop = cellYTop() + dy; 633 int newYTop = cellYTop() + dy;
634 int newYBottom = cellYBottom(); 634 int newYBottom = cellYBottom();
635 if (newYTop > newYBottom) newYTop = newYBottom; 635 if (newYTop > newYBottom) newYTop = newYBottom;
636 setCellY(newYTop, newYBottom); 636 setCellY(newYTop, newYBottom);