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
@@ -1539,193 +1539,193 @@ void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
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;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 6965ba7..62281d4 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -334,207 +334,207 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
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{