-rw-r--r-- | korganizer/calprintbase.cpp | 20 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 2 |
2 files changed, 8 insertions, 14 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index f66fddc..7b7d54c 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp | |||
@@ -399,546 +399,540 @@ void CalPrintBase::drawTimeLine(QPainter &p, | |||
399 | p.setFont(QFont("helvetica", 16, QFont::Bold)); | 399 | p.setFont(QFont("helvetica", 16, QFont::Bold)); |
400 | } else { | 400 | } else { |
401 | p.setFont(QFont("helvetica", 12, QFont::Bold)); | 401 | p.setFont(QFont("helvetica", 12, QFont::Bold)); |
402 | } | 402 | } |
403 | p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight, | 403 | p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight, |
404 | AlignTop|AlignRight, numStr); | 404 | AlignTop|AlignRight, numStr); |
405 | p.setFont(QFont("helvetica", 10, QFont::Normal)); | 405 | p.setFont(QFont("helvetica", 10, QFont::Normal)); |
406 | p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3, | 406 | p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3, |
407 | AlignTop | AlignLeft, "00"); | 407 | AlignTop | AlignLeft, "00"); |
408 | } else { | 408 | } else { |
409 | QTime time( curTime.hour(), 0 ); | 409 | QTime time( curTime.hour(), 0 ); |
410 | numStr = KGlobal::locale()->formatTime( time ); | 410 | numStr = KGlobal::locale()->formatTime( time ); |
411 | p.setFont(QFont("helvetica", 14, QFont::Bold)); | 411 | p.setFont(QFont("helvetica", 14, QFont::Bold)); |
412 | p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3, | 412 | p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3, |
413 | AlignTop|AlignLeft, numStr); | 413 | AlignTop|AlignLeft, numStr); |
414 | } | 414 | } |
415 | currY+=cellHeight; | 415 | currY+=cellHeight; |
416 | } // enough space for half-hour line and time | 416 | } // enough space for half-hour line and time |
417 | if (curTime.secsTo(endTime)>3600) | 417 | if (curTime.secsTo(endTime)>3600) |
418 | curTime=curTime.addSecs(3600); | 418 | curTime=curTime.addSecs(3600); |
419 | else curTime=endTime; | 419 | else curTime=endTime; |
420 | } // currTime<endTime | 420 | } // currTime<endTime |
421 | } | 421 | } |
422 | 422 | ||
423 | 423 | ||
424 | /////////////////////////////////////////////////////////////////////////////// | 424 | /////////////////////////////////////////////////////////////////////////////// |
425 | 425 | ||
426 | /** prints the all-day box for the agenda print view. if expandable is set, | 426 | /** prints the all-day box for the agenda print view. if expandable is set, |
427 | height is the cell height of a single cell, and the returned height will | 427 | height is the cell height of a single cell, and the returned height will |
428 | be the total height used for the all-day events. If !expandable, only one | 428 | be the total height used for the all-day events. If !expandable, only one |
429 | cell will be used, and multiple events are concatenated using ", ". | 429 | cell will be used, and multiple events are concatenated using ", ". |
430 | */ | 430 | */ |
431 | void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, | 431 | void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, |
432 | const QDate &qd, bool expandable, | 432 | const QDate &qd, bool expandable, |
433 | int x, int y, int width, int &height) | 433 | int x, int y, int width, int &height) |
434 | { | 434 | { |
435 | Event::List::Iterator it, itold; | 435 | Event::List::Iterator it, itold; |
436 | 436 | ||
437 | int offset=y; | 437 | int offset=y; |
438 | 438 | ||
439 | //p.setBrush(QBrush(Dense7Pattern)); | 439 | //p.setBrush(QBrush(Dense7Pattern)); |
440 | QPen oldPen(p.pen()); | 440 | QPen oldPen(p.pen()); |
441 | QColor oldBgColor(p.backgroundColor()); | 441 | QColor oldBgColor(p.backgroundColor()); |
442 | QBrush oldBrush(p.brush()); | 442 | QBrush oldBrush(p.brush()); |
443 | QString multiDayStr; | 443 | QString multiDayStr; |
444 | 444 | ||
445 | it = eventList.begin(); | 445 | it = eventList.begin(); |
446 | #ifndef KORG_NOPLUGINS | 446 | #ifndef KORG_NOPLUGINS |
447 | QString hstring(KOCore::self()->holiday(qd)); | 447 | QString hstring(KOCore::self()->holiday(qd)); |
448 | if (!hstring.isEmpty()) { | 448 | if (!hstring.isEmpty()) { |
449 | Event*holiday=new Event(); | 449 | Event*holiday=new Event(); |
450 | holiday->setDtStart(qd); | 450 | holiday->setDtStart(qd); |
451 | holiday->setDtEnd(qd); | 451 | holiday->setDtEnd(qd); |
452 | holiday->setFloats(true); | 452 | holiday->setFloats(true); |
453 | holiday->setCategories(i18n("Holiday")); | 453 | holiday->setCategories(i18n("Holiday")); |
454 | eventList.prepend(holiday); | 454 | eventList.prepend(holiday); |
455 | } | 455 | } |
456 | #endif | 456 | #endif |
457 | Event *currEvent = 0; | 457 | Event *currEvent = 0; |
458 | // First, print all floating events | 458 | // First, print all floating events |
459 | while( it!=eventList.end() ) { | 459 | while( it!=eventList.end() ) { |
460 | currEvent=*it; | 460 | currEvent=*it; |
461 | itold=it; | 461 | itold=it; |
462 | ++it; | 462 | ++it; |
463 | if ( currEvent->doesFloat() ) { | 463 | if ( currEvent->doesFloat() ) { |
464 | // set the colors according to the categories | 464 | // set the colors according to the categories |
465 | QString text = currEvent->summary() ; | 465 | QString text = currEvent->summary() ; |
466 | if ( ! currEvent->location().isEmpty() ) | 466 | if ( ! currEvent->location().isEmpty() ) |
467 | text += " ("+currEvent->location()+")"; | 467 | text += " ("+currEvent->location()+")"; |
468 | if (expandable) { | 468 | if (expandable) { |
469 | if (mUseColors) | 469 | if (mUseColors) |
470 | setCategoryColors(p, currEvent); | 470 | setCategoryColors(p, currEvent); |
471 | 471 | ||
472 | p.drawRect( x, offset, width, height ); | 472 | p.drawRect( x, offset, width, height ); |
473 | 473 | ||
474 | p.drawText( x+5, offset+5, width-10, height-10, | 474 | p.drawText( x+5, offset+5, width-10, height-10, |
475 | AlignCenter | AlignVCenter | AlignJustify | WordBreak, | 475 | AlignCenter | AlignVCenter | AlignJustify | WordBreak, |
476 | text ); | 476 | text ); |
477 | // reset the colors | 477 | // reset the colors |
478 | p.setBrush( oldBrush ); | 478 | p.setBrush( oldBrush ); |
479 | p.setPen( oldPen ); | 479 | p.setPen( oldPen ); |
480 | p.setBackgroundColor(oldBgColor); | 480 | p.setBackgroundColor(oldBgColor); |
481 | 481 | ||
482 | offset += height; | 482 | offset += height; |
483 | } else { | 483 | } else { |
484 | //if (!multiDayStr.isEmpty()) multiDayStr+=", "; | 484 | //if (!multiDayStr.isEmpty()) multiDayStr+=", "; |
485 | multiDayStr += text+"\n"; | 485 | multiDayStr += text+"\n"; |
486 | } | 486 | } |
487 | eventList.remove( itold ); | 487 | eventList.remove( itold ); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | 490 | ||
491 | if (!expandable) { | 491 | if (!expandable) { |
492 | p.drawRect(x, offset, width, height); | 492 | p.drawRect(x, offset, width, height); |
493 | if (!multiDayStr.isEmpty()) { | 493 | if (!multiDayStr.isEmpty()) { |
494 | // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) ); | 494 | // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) ); |
495 | p.drawText( x+5, offset+5, width-10, height-10, | 495 | p.drawText( x+5, offset+5, width-10, height-10, |
496 | AlignLeft | AlignTop | AlignJustify , | 496 | AlignLeft | AlignTop | AlignJustify , |
497 | multiDayStr); | 497 | multiDayStr); |
498 | } | 498 | } |
499 | } else { | 499 | } else { |
500 | height=offset-y; | 500 | height=offset-y; |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, | 505 | void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, |
506 | const QDate &qd, bool expandable, | 506 | const QDate &qd, bool expandable, |
507 | QTime &fromTime, QTime &toTime, | 507 | QTime &fromTime, QTime &toTime, |
508 | int x, int y, int width, int height ) | 508 | int x, int y, int width, int height ) |
509 | { | 509 | { |
510 | p.drawRect( x, y, width, height ); | 510 | p.drawRect( x, y, width, height ); |
511 | 511 | ||
512 | Event *event; | 512 | Event *event; |
513 | 513 | ||
514 | if ( expandable ) { | 514 | if ( expandable ) { |
515 | // Adapt start/end times to include complete events | 515 | // Adapt start/end times to include complete events |
516 | Event::List::ConstIterator it; | 516 | Event::List::ConstIterator it; |
517 | for ( it = events.begin(); it != events.end(); ++it ) { | 517 | for ( it = events.begin(); it != events.end(); ++it ) { |
518 | event = *it; | 518 | event = *it; |
519 | if ( event->dtStart().time() < fromTime ) | 519 | if ( event->dtStart().time() < fromTime ) |
520 | fromTime = event->dtStart().time(); | 520 | fromTime = event->dtStart().time(); |
521 | if ( event->dtEnd().time() > toTime ) | 521 | if ( event->dtEnd().time() > toTime ) |
522 | toTime = event->dtEnd().time(); | 522 | toTime = event->dtEnd().time(); |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | // Show at least one hour | 526 | // Show at least one hour |
527 | if ( fromTime.secsTo( toTime ) < 3600 ) { | 527 | if ( fromTime.secsTo( toTime ) < 3600 ) { |
528 | fromTime = QTime( fromTime.hour(), 0, 0 ); | 528 | fromTime = QTime( fromTime.hour(), 0, 0 ); |
529 | toTime = fromTime.addSecs( 3600 ); | 529 | toTime = fromTime.addSecs( 3600 ); |
530 | } | 530 | } |
531 | 531 | ||
532 | // calculate the height of a cell and of a minute | 532 | // calculate the height of a cell and of a minute |
533 | int totalsecs = fromTime.secsTo( toTime ); | 533 | int totalsecs = fromTime.secsTo( toTime ); |
534 | float minlen = height * 60. / totalsecs; | 534 | float minlen = height * 60. / totalsecs; |
535 | float cellHeight = 60. * minlen; | 535 | float cellHeight = 60. * minlen; |
536 | float currY = y; | 536 | float currY = y; |
537 | 537 | ||
538 | // print grid: | 538 | // print grid: |
539 | QTime curTime( QTime( fromTime.hour(), 0, 0 ) ); | 539 | QTime curTime( QTime( fromTime.hour(), 0, 0 ) ); |
540 | currY += fromTime.secsTo( curTime ) * minlen / 60; | 540 | currY += fromTime.secsTo( curTime ) * minlen / 60; |
541 | 541 | ||
542 | while ( curTime < toTime && curTime.isValid() ) { | 542 | while ( curTime < toTime && curTime.isValid() ) { |
543 | if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) ); | 543 | if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) ); |
544 | currY += cellHeight / 2; | 544 | currY += cellHeight / 2; |
545 | if ( ( currY > y ) && ( currY < y + height ) ) { | 545 | if ( ( currY > y ) && ( currY < y + height ) ) { |
546 | QPen oldPen( p.pen() ); | 546 | QPen oldPen( p.pen() ); |
547 | p.setPen( QColor( 192, 192, 192 ) ); | 547 | p.setPen( QColor( 192, 192, 192 ) ); |
548 | p.drawLine( x, int( currY ), x + width, int( currY ) ); | 548 | p.drawLine( x, int( currY ), x + width, int( currY ) ); |
549 | p.setPen( oldPen ); | 549 | p.setPen( oldPen ); |
550 | } // enough space for half-hour line | 550 | } // enough space for half-hour line |
551 | if ( curTime.secsTo( toTime ) > 3600 ) | 551 | if ( curTime.secsTo( toTime ) > 3600 ) |
552 | curTime = curTime.addSecs( 3600 ); | 552 | curTime = curTime.addSecs( 3600 ); |
553 | else curTime = toTime; | 553 | else curTime = toTime; |
554 | currY += cellHeight / 2; | 554 | currY += cellHeight / 2; |
555 | } | 555 | } |
556 | 556 | ||
557 | QDateTime startPrintDate = QDateTime( qd, fromTime ); | 557 | QDateTime startPrintDate = QDateTime( qd, fromTime ); |
558 | QDateTime endPrintDate = QDateTime( qd, toTime ); | 558 | QDateTime endPrintDate = QDateTime( qd, toTime ); |
559 | 559 | ||
560 | // Calculate horizontal positions and widths of events taking into account | 560 | // Calculate horizontal positions and widths of events taking into account |
561 | // overlapping events | 561 | // overlapping events |
562 | 562 | ||
563 | QPtrList<KOrg::CellItem> cells; | 563 | QPtrList<KOrg::CellItem> cells; |
564 | cells.setAutoDelete( true ); | 564 | cells.setAutoDelete( true ); |
565 | 565 | ||
566 | Event::List::ConstIterator itEvents; | 566 | Event::List::ConstIterator itEvents; |
567 | for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { | 567 | for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { |
568 | cells.append( new PrintCellItem( *itEvents, qd ) ); | 568 | cells.append( new PrintCellItem( *itEvents, qd ) ); |
569 | } | 569 | } |
570 | 570 | ||
571 | QPtrListIterator<KOrg::CellItem> it1( cells ); | 571 | QPtrListIterator<KOrg::CellItem> it1( cells ); |
572 | for( it1.toFirst(); it1.current(); ++it1 ) { | 572 | for( it1.toFirst(); it1.current(); ++it1 ) { |
573 | KOrg::CellItem *placeItem = it1.current(); | 573 | KOrg::CellItem *placeItem = it1.current(); |
574 | 574 | ||
575 | KOrg::CellItem::placeItem( cells, placeItem ); | 575 | KOrg::CellItem::placeItem( cells, placeItem ); |
576 | } | 576 | } |
577 | 577 | ||
578 | QPen oldPen = p.pen(); | 578 | QPen oldPen = p.pen(); |
579 | QColor oldBgColor = p.backgroundColor(); | 579 | QColor oldBgColor = p.backgroundColor(); |
580 | QBrush oldBrush = p.brush(); | 580 | QBrush oldBrush = p.brush(); |
581 | 581 | ||
582 | p.setFont( QFont( "helvetica", 10 ) ); | 582 | p.setFont( QFont( "helvetica", 10 ) ); |
583 | //p.setBrush( QBrush( Dense7Pattern ) ); | 583 | //p.setBrush( QBrush( Dense7Pattern ) ); |
584 | 584 | ||
585 | for( it1.toFirst(); it1.current(); ++it1 ) { | 585 | for( it1.toFirst(); it1.current(); ++it1 ) { |
586 | PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() ); | 586 | PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() ); |
587 | 587 | ||
588 | drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x, | 588 | drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x, |
589 | y, width ); | 589 | y, width ); |
590 | 590 | ||
591 | p.setBrush( oldBrush ); | 591 | p.setBrush( oldBrush ); |
592 | p.setPen( oldPen ); | 592 | p.setPen( oldPen ); |
593 | p.setBackgroundColor( oldBgColor ); | 593 | p.setBackgroundColor( oldBgColor ); |
594 | } | 594 | } |
595 | 595 | ||
596 | p.setBrush( QBrush( NoBrush ) ); | 596 | p.setBrush( QBrush( NoBrush ) ); |
597 | } | 597 | } |
598 | 598 | ||
599 | 599 | ||
600 | void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, | 600 | void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, |
601 | const QDate &qd, | 601 | const QDate &qd, |
602 | const QDateTime &startPrintDate, | 602 | const QDateTime &startPrintDate, |
603 | const QDateTime &endPrintDate, | 603 | const QDateTime &endPrintDate, |
604 | float minlen, int x, int y, int width ) | 604 | float minlen, int x, int y, int width ) |
605 | { | 605 | { |
606 | Event *event = item->event(); | 606 | Event *event = item->event(); |
607 | 607 | ||
608 | // set the colors according to the categories | 608 | // set the colors according to the categories |
609 | if ( mUseColors ) setCategoryColors( p, event ); | 609 | if ( mUseColors ) setCategoryColors( p, event ); |
610 | else p.setBrush( Qt::white ); | 610 | else p.setBrush( Qt::white ); |
611 | // start/end of print area for event | 611 | // start/end of print area for event |
612 | QDateTime startTime = event->dtStart(); | 612 | QDateTime startTime = event->dtStart(); |
613 | QDateTime endTime = event->dtEnd(); | 613 | QDateTime endTime = event->dtEnd(); |
614 | if ( event->doesRecur() ) { | 614 | if ( event->doesRecur() ) { |
615 | startTime.setDate( qd ); | 615 | startTime.setDate( qd ); |
616 | endTime.setDate( qd ); | 616 | endTime.setDate( qd ); |
617 | } | 617 | } |
618 | if ( ( startTime < endPrintDate && endTime > startPrintDate ) || | 618 | if ( ( startTime < endPrintDate && endTime > startPrintDate ) || |
619 | ( endTime > startPrintDate && startTime < endPrintDate ) ) { | 619 | ( endTime > startPrintDate && startTime < endPrintDate ) ) { |
620 | if ( startTime < startPrintDate ) startTime = startPrintDate; | 620 | if ( startTime < startPrintDate ) startTime = startPrintDate; |
621 | if ( endTime > endPrintDate ) endTime = endPrintDate; | 621 | if ( endTime > endPrintDate ) endTime = endPrintDate; |
622 | int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen ); | 622 | int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen ); |
623 | int currentyPos = int( y + startPrintDate.secsTo( startTime ) * | 623 | int currentyPos = int( y + startPrintDate.secsTo( startTime ) * |
624 | minlen / 60. ); | 624 | minlen / 60. ); |
625 | int currentWidth = width / item->subCells(); | 625 | int currentWidth = width / item->subCells(); |
626 | int currentX = x + item->subCell() * currentWidth; | 626 | int currentX = x + item->subCell() * currentWidth; |
627 | QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ | 627 | QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ |
628 | "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ | 628 | "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ |
629 | " "+event->summary(); | 629 | " "+event->summary(); |
630 | if ( !event->location().isEmpty() ) | 630 | if ( !event->location().isEmpty() ) |
631 | text += " (" +event->location()+")"; | 631 | text += " (" +event->location()+")"; |
632 | // p.save(); | 632 | // p.save(); |
633 | QPen pe = p.pen(); | 633 | QPen pe = p.pen(); |
634 | pe.setWidth( 2 ); | 634 | pe.setWidth( 2 ); |
635 | p.setPen( pe ); | 635 | p.setPen( pe ); |
636 | p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); | 636 | p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); |
637 | p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, | 637 | p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, |
638 | AlignLeft | AlignTop | AlignJustify | WordBreak, | 638 | AlignLeft | AlignTop | AlignJustify | WordBreak, |
639 | text); | 639 | text); |
640 | // p.restore(); | 640 | // p.restore(); |
641 | } | 641 | } |
642 | } | 642 | } |
643 | 643 | ||
644 | void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, | 644 | void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, |
645 | int x, int y, int width, int height, | 645 | int x, int y, int width, int height, |
646 | bool fullDate) | 646 | bool fullDate) |
647 | { | 647 | { |
648 | QString dayNumStr; | 648 | QString dayNumStr; |
649 | QString ampm; | 649 | QString ampm; |
650 | const KLocale*local = KGlobal::locale(); | 650 | const KLocale*local = KGlobal::locale(); |
651 | 651 | ||
652 | 652 | ||
653 | // This has to be localized | 653 | // This has to be localized |
654 | if (fullDate) { | 654 | if (fullDate) { |
655 | /*int index; | 655 | dayNumStr = local->formatDate(qd); |
656 | dayNumStr= qd.toString(); | ||
657 | index = dayNumStr.find(' '); | ||
658 | dayNumStr.remove(0, index); | ||
659 | index = dayNumStr.findRev(' '); | ||
660 | dayNumStr.truncate(index);*/ | ||
661 | |||
662 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | ||
663 | dayNumStr = i18n("weekday month date", "%1 %2 %3") | ||
664 | .arg( calSys->weekDayName( qd ) ) | ||
665 | .arg( calSys->monthName( qd ) ) | ||
666 | .arg( qd.day() ); | ||
667 | // dayNumStr = local->formatDate(qd); | ||
668 | } else { | 656 | } else { |
669 | dayNumStr = QString::number( qd.day() ); | 657 | dayNumStr = QString::number( qd.day() ); |
670 | } | 658 | } |
671 | 659 | ||
672 | p.eraseRect( x, y, width, height ); | 660 | p.eraseRect( x, y, width, height ); |
673 | p.drawRect( x, y, width, height ); | 661 | p.drawRect( x, y, width, height ); |
674 | // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); | 662 | // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); |
675 | p.drawRect( x, y, width, mSubHeaderHeight ); | 663 | p.drawRect( x, y, width, mSubHeaderHeight ); |
676 | //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); | 664 | //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); |
677 | QString hstring; | 665 | QString hstring; |
678 | #ifndef KORG_NOPLUGINS | 666 | #ifndef KORG_NOPLUGINS |
679 | hstring=KOCore::self()->holiday(qd); | 667 | hstring=KOCore::self()->holiday(qd); |
680 | #endif | 668 | #endif |
681 | 669 | ||
682 | if (!hstring.isEmpty()) { | 670 | if (!hstring.isEmpty()) { |
683 | p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); | 671 | p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); |
684 | 672 | ||
685 | p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, | 673 | p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, |
686 | hstring ); | 674 | hstring ); |
687 | } | 675 | } |
688 | p.setFont(QFont("helvetica", 10, QFont::Bold)); | 676 | p.setFont(QFont("helvetica", 10, QFont::Bold)); |
677 | if ( fullDate) { | ||
678 | // use short date format, if long date is too long | ||
679 | QFontMetrics fm ( p.font() ); | ||
680 | if ( fm.width( dayNumStr ) > width -10 ) | ||
681 | dayNumStr = local->formatDate(qd, true); | ||
682 | } | ||
689 | p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, | 683 | p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, |
690 | dayNumStr); | 684 | dayNumStr); |
691 | Event::List eventList; | 685 | Event::List eventList; |
692 | eventList.fill( mCalendar->events( qd, true )); | 686 | eventList.fill( mCalendar->events( qd, true )); |
693 | Todo::List todos; | 687 | Todo::List todos; |
694 | todos.fill( mCalendar->todos( qd )); | 688 | todos.fill( mCalendar->todos( qd )); |
695 | QString outStr; | 689 | QString outStr; |
696 | p.setFont( QFont( "helvetica", 8 ) ); | 690 | p.setFont( QFont( "helvetica", 8 ) ); |
697 | int lineSpacing = p.fontMetrics().lineSpacing(); | 691 | int lineSpacing = p.fontMetrics().lineSpacing(); |
698 | 692 | ||
699 | int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry | 693 | int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry |
700 | Event::List::ConstIterator it; | 694 | Event::List::ConstIterator it; |
701 | int entryCount = eventList.count() +todos.count(); | 695 | int entryCount = eventList.count() +todos.count(); |
702 | if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { | 696 | if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { |
703 | if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { | 697 | if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { |
704 | p.setFont( QFont( "helvetica", 7 ) ); | 698 | p.setFont( QFont( "helvetica", 7 ) ); |
705 | if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) | 699 | if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) |
706 | p.setFont( QFont( "helvetica", 6 ) ); | 700 | p.setFont( QFont( "helvetica", 6 ) ); |
707 | } | 701 | } |
708 | lineSpacing = p.fontMetrics().lineSpacing()-1; | 702 | lineSpacing = p.fontMetrics().lineSpacing()-1; |
709 | } | 703 | } |
710 | // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); | 704 | // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); |
711 | for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { | 705 | for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { |
712 | Event *currEvent = *it; | 706 | Event *currEvent = *it; |
713 | if (currEvent->doesFloat() || currEvent->isMultiDay()) | 707 | if (currEvent->doesFloat() || currEvent->isMultiDay()) |
714 | outStr = currEvent->summary(); | 708 | outStr = currEvent->summary(); |
715 | 709 | ||
716 | else { | 710 | else { |
717 | if ( fullDate ) { | 711 | if ( fullDate ) { |
718 | outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ | 712 | outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ |
719 | "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ | 713 | "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ |
720 | " "+ currEvent->summary(); | 714 | " "+ currEvent->summary(); |
721 | if ( ! currEvent->location().isEmpty() ) | 715 | if ( ! currEvent->location().isEmpty() ) |
722 | outStr += " (" + currEvent->location()+")"; | 716 | outStr += " (" + currEvent->location()+")"; |
723 | } else { | 717 | } else { |
724 | QTime t1 = currEvent->dtStart().time(); | 718 | QTime t1 = currEvent->dtStart().time(); |
725 | 719 | ||
726 | outStr = local->formatTime(t1); | 720 | outStr = local->formatTime(t1); |
727 | outStr += " " + currEvent->summary(); | 721 | outStr += " " + currEvent->summary(); |
728 | } | 722 | } |
729 | 723 | ||
730 | } // doesFloat | 724 | } // doesFloat |
731 | 725 | ||
732 | p.drawText(x+5, y+textY, width-10, lineSpacing, | 726 | p.drawText(x+5, y+textY, width-10, lineSpacing, |
733 | AlignLeft|AlignBottom, outStr); | 727 | AlignLeft|AlignBottom, outStr); |
734 | textY+=lineSpacing; | 728 | textY+=lineSpacing; |
735 | } | 729 | } |
736 | 730 | ||
737 | if ( textY<height ) { | 731 | if ( textY<height ) { |
738 | 732 | ||
739 | Todo::List::ConstIterator it2; | 733 | Todo::List::ConstIterator it2; |
740 | for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { | 734 | for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { |
741 | Todo *todo = *it2; | 735 | Todo *todo = *it2; |
742 | QString text; | 736 | QString text; |
743 | if (todo->hasDueDate()) { | 737 | if (todo->hasDueDate()) { |
744 | if (!todo->doesFloat()) { | 738 | if (!todo->doesFloat()) { |
745 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 739 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
746 | text += " "; | 740 | text += " "; |
747 | } | 741 | } |
748 | } | 742 | } |
749 | text += i18n("To-Do: %1").arg(todo->summary()); | 743 | text += i18n("To-Do: %1").arg(todo->summary()); |
750 | 744 | ||
751 | p.drawText(x+5, y+textY, width-10, lineSpacing, | 745 | p.drawText(x+5, y+textY, width-10, lineSpacing, |
752 | AlignLeft|AlignBottom, text); | 746 | AlignLeft|AlignBottom, text); |
753 | textY+=lineSpacing; | 747 | textY+=lineSpacing; |
754 | } | 748 | } |
755 | } | 749 | } |
756 | } | 750 | } |
757 | 751 | ||
758 | 752 | ||
759 | /////////////////////////////////////////////////////////////////////////////// | 753 | /////////////////////////////////////////////////////////////////////////////// |
760 | 754 | ||
761 | void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, | 755 | void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, |
762 | int x, int y, int width, int height) | 756 | int x, int y, int width, int height) |
763 | { | 757 | { |
764 | QDate weekDate = qd; | 758 | QDate weekDate = qd; |
765 | bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); | 759 | bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); |
766 | int cellWidth, cellHeight; | 760 | int cellWidth, cellHeight; |
767 | int vcells; | 761 | int vcells; |
768 | if (portrait) { | 762 | if (portrait) { |
769 | cellWidth = width/2; | 763 | cellWidth = width/2; |
770 | vcells=3; | 764 | vcells=3; |
771 | } else { | 765 | } else { |
772 | cellWidth = width/6; | 766 | cellWidth = width/6; |
773 | vcells=1; | 767 | vcells=1; |
774 | } | 768 | } |
775 | cellHeight = height/vcells; | 769 | cellHeight = height/vcells; |
776 | 770 | ||
777 | // correct begin of week | 771 | // correct begin of week |
778 | int weekdayCol = weekdayColumn( qd.dayOfWeek() ); | 772 | int weekdayCol = weekdayColumn( qd.dayOfWeek() ); |
779 | weekDate = qd.addDays( -weekdayCol ); | 773 | weekDate = qd.addDays( -weekdayCol ); |
780 | 774 | ||
781 | for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { | 775 | for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { |
782 | if (i<5) { | 776 | if (i<5) { |
783 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), | 777 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), |
784 | cellWidth, cellHeight, true); | 778 | cellWidth, cellHeight, true); |
785 | } else if (i==5) { | 779 | } else if (i==5) { |
786 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), | 780 | drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), |
787 | cellWidth, cellHeight/2, true); | 781 | cellWidth, cellHeight/2, true); |
788 | } else if (i==6) { | 782 | } else if (i==6) { |
789 | drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), | 783 | drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), |
790 | y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); | 784 | y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); |
791 | } | 785 | } |
792 | } // for i through all weekdays | 786 | } // for i through all weekdays |
793 | } | 787 | } |
794 | 788 | ||
795 | 789 | ||
796 | void CalPrintBase::drawTimeTable(QPainter &p, | 790 | void CalPrintBase::drawTimeTable(QPainter &p, |
797 | const QDate &fromDate, const QDate &toDate, | 791 | const QDate &fromDate, const QDate &toDate, |
798 | QTime &fromTime, QTime &toTime, | 792 | QTime &fromTime, QTime &toTime, |
799 | int x, int y, int width, int height) | 793 | int x, int y, int width, int height) |
800 | { | 794 | { |
801 | // timeline is 1.5 hours: | 795 | // timeline is 1.5 hours: |
802 | int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); | 796 | int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); |
803 | int timelineWidth = 60; | 797 | int timelineWidth = 60; |
804 | int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); | 798 | int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); |
805 | int currY=y; | 799 | int currY=y; |
806 | int currX=x; | 800 | int currX=x; |
807 | 801 | ||
808 | drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); | 802 | drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); |
809 | currY+=mSubHeaderHeight; | 803 | currY+=mSubHeaderHeight; |
810 | drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, | 804 | drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, |
811 | timelineWidth, height-mSubHeaderHeight-alldayHeight ); | 805 | timelineWidth, height-mSubHeaderHeight-alldayHeight ); |
812 | 806 | ||
813 | currX=x+timelineWidth; | 807 | currX=x+timelineWidth; |
814 | // draw each day | 808 | // draw each day |
815 | QDate curDate(fromDate); | 809 | QDate curDate(fromDate); |
816 | while (curDate<=toDate) {Event::List eventList; | 810 | while (curDate<=toDate) {Event::List eventList; |
817 | eventList.fill( mCalendar->events(curDate, true)); | 811 | eventList.fill( mCalendar->events(curDate, true)); |
818 | drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); | 812 | drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); |
819 | drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, | 813 | drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, |
820 | currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); | 814 | currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); |
821 | currX+=cellWidth; | 815 | currX+=cellWidth; |
822 | curDate=curDate.addDays(1); | 816 | curDate=curDate.addDays(1); |
823 | } | 817 | } |
824 | 818 | ||
825 | } | 819 | } |
826 | 820 | ||
827 | 821 | ||
828 | /////////////////////////////////////////////////////////////////////////////// | 822 | /////////////////////////////////////////////////////////////////////////////// |
829 | 823 | ||
830 | void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, | 824 | void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, |
831 | int x, int y, int width, int height) | 825 | int x, int y, int width, int height) |
832 | { | 826 | { |
833 | 827 | ||
834 | int yoffset = mSubHeaderHeight; | 828 | int yoffset = mSubHeaderHeight; |
835 | int xoffset = 0; | 829 | int xoffset = 0; |
836 | 830 | ||
837 | QDate monthDate(QDate(qd.year(), qd.month(), 1)); | 831 | QDate monthDate(QDate(qd.year(), qd.month(), 1)); |
838 | QDate monthFirst(monthDate); | 832 | QDate monthFirst(monthDate); |
839 | QDate monthLast(monthDate.addMonths(1).addDays(-1)); | 833 | QDate monthLast(monthDate.addMonths(1).addDays(-1)); |
840 | 834 | ||
841 | 835 | ||
842 | int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); | 836 | int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); |
843 | monthDate = monthDate.addDays(-weekdayCol); | 837 | monthDate = monthDate.addDays(-weekdayCol); |
844 | 838 | ||
845 | int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; | 839 | int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; |
846 | int cellHeight = (height-yoffset) / rows; | 840 | int cellHeight = (height-yoffset) / rows; |
847 | 841 | ||
848 | if (weeknumbers) { | 842 | if (weeknumbers) { |
849 | QFont oldFont(p.font()); | 843 | QFont oldFont(p.font()); |
850 | QFont newFont(p.font()); | 844 | QFont newFont(p.font()); |
851 | newFont.setPointSize(7); | 845 | newFont.setPointSize(7); |
852 | p.setFont(newFont); | 846 | p.setFont(newFont); |
853 | xoffset += 18; | 847 | xoffset += 18; |
854 | QDate weekDate(monthDate); | 848 | QDate weekDate(monthDate); |
855 | for (int row = 0; row<rows; row++) { | 849 | for (int row = 0; row<rows; row++) { |
856 | int calWeek = weekDate.weekNumber(); | 850 | int calWeek = weekDate.weekNumber(); |
857 | QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); | 851 | QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); |
858 | p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); | 852 | p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); |
859 | weekDate = weekDate.addDays(7); | 853 | weekDate = weekDate.addDays(7); |
860 | } | 854 | } |
861 | p.setFont(oldFont); | 855 | p.setFont(oldFont); |
862 | } | 856 | } |
863 | 857 | ||
864 | drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); | 858 | drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); |
865 | int cellWidth = (width-xoffset) / 7; | 859 | int cellWidth = (width-xoffset) / 7; |
866 | 860 | ||
867 | QColor back = p.backgroundColor(); | 861 | QColor back = p.backgroundColor(); |
868 | bool darkbg = false; | 862 | bool darkbg = false; |
869 | for (int row = 0; row < rows; row++) { | 863 | for (int row = 0; row < rows; row++) { |
870 | for (int col = 0; col < 7; col++) { | 864 | for (int col = 0; col < 7; col++) { |
871 | // show days from previous/next month with a grayed background | 865 | // show days from previous/next month with a grayed background |
872 | if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { | 866 | if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { |
873 | p.setBackgroundColor( QColor( 240, 240, 240) ); | 867 | p.setBackgroundColor( QColor( 240, 240, 240) ); |
874 | darkbg = true; | 868 | darkbg = true; |
875 | } | 869 | } |
876 | drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); | 870 | drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); |
877 | if ( darkbg ) { | 871 | if ( darkbg ) { |
878 | p.setBackgroundColor( back ); | 872 | p.setBackgroundColor( back ); |
879 | darkbg = false; | 873 | darkbg = false; |
880 | } | 874 | } |
881 | monthDate = monthDate.addDays(1); | 875 | monthDate = monthDate.addDays(1); |
882 | } | 876 | } |
883 | } | 877 | } |
884 | } | 878 | } |
885 | 879 | ||
886 | 880 | ||
887 | /////////////////////////////////////////////////////////////////////////////// | 881 | /////////////////////////////////////////////////////////////////////////////// |
888 | 882 | ||
889 | void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, | 883 | void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, |
890 | bool desc, int pospriority, int possummary, int posDueDt, int level, | 884 | bool desc, int pospriority, int possummary, int posDueDt, int level, |
891 | int x, int &y, int width, int &height, int pageHeight, | 885 | int x, int &y, int width, int &height, int pageHeight, |
892 | TodoParentStart *r ) | 886 | TodoParentStart *r ) |
893 | { | 887 | { |
894 | if ( !completed && item->isCompleted() ) | 888 | if ( !completed && item->isCompleted() ) |
895 | return; | 889 | return; |
896 | QString outStr; | 890 | QString outStr; |
897 | // int fontHeight = 10; | 891 | // int fontHeight = 10; |
898 | const KLocale *local = KGlobal::locale(); | 892 | const KLocale *local = KGlobal::locale(); |
899 | int priority=item->priority(); | 893 | int priority=item->priority(); |
900 | int posdue=posDueDt; | 894 | int posdue=posDueDt; |
901 | if (posdue<0) posdue=x+width; | 895 | if (posdue<0) posdue=x+width; |
902 | QRect rect; | 896 | QRect rect; |
903 | TodoParentStart startpt; | 897 | TodoParentStart startpt; |
904 | // This list keeps all starting points of the parent todos so the connection | 898 | // This list keeps all starting points of the parent todos so the connection |
905 | // lines of the tree can easily be drawn (needed if a new page is started) | 899 | // lines of the tree can easily be drawn (needed if a new page is started) |
906 | static QPtrList<TodoParentStart> startPoints; | 900 | static QPtrList<TodoParentStart> startPoints; |
907 | if (level<1) { | 901 | if (level<1) { |
908 | startPoints.clear(); | 902 | startPoints.clear(); |
909 | } | 903 | } |
910 | 904 | ||
911 | // size of item | 905 | // size of item |
912 | outStr=item->summary(); | 906 | outStr=item->summary(); |
913 | if ( ! item->location().isEmpty() ) | 907 | if ( ! item->location().isEmpty() ) |
914 | outStr += " ("+item->location()+")"; | 908 | outStr += " ("+item->location()+")"; |
915 | if ( item->hasDueDate() && posDueDt>=0 ) { | 909 | if ( item->hasDueDate() && posDueDt>=0 ) { |
916 | outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; | 910 | outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; |
917 | } | 911 | } |
918 | int left = possummary+(level*10); | 912 | int left = possummary+(level*10); |
919 | rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); | 913 | rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); |
920 | //qDebug("bottom1 %d ", rect.bottom() ); | 914 | //qDebug("bottom1 %d ", rect.bottom() ); |
921 | if ( !item->description().isEmpty() && desc ) { | 915 | if ( !item->description().isEmpty() && desc ) { |
922 | outStr = item->description(); | 916 | outStr = item->description(); |
923 | rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, | 917 | rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, |
924 | WordBreak, outStr ); | 918 | WordBreak, outStr ); |
925 | } | 919 | } |
926 | //qDebug("bottom2 %d y+h %d y %d ph %d", rect.bottom(), y+height, y , pageHeight ); | 920 | //qDebug("bottom2 %d y+h %d y %d ph %d", rect.bottom(), y+height, y , pageHeight ); |
927 | // if too big make new page | 921 | // if too big make new page |
928 | if ( rect.bottom() > y+height) { | 922 | if ( rect.bottom() > y+height) { |
929 | // first draw the connection lines from parent todos: | 923 | // first draw the connection lines from parent todos: |
930 | if (level > 0 && connectSubTodos) { | 924 | if (level > 0 && connectSubTodos) { |
931 | TodoParentStart *rct; | 925 | TodoParentStart *rct; |
932 | for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { | 926 | for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { |
933 | int start; | 927 | int start; |
934 | int center = rct->mRect.left() + (rct->mRect.width()/2); | 928 | int center = rct->mRect.left() + (rct->mRect.width()/2); |
935 | int to = p.viewport().bottom(); | 929 | int to = p.viewport().bottom(); |
936 | 930 | ||
937 | // draw either from start point of parent or from top of the page | 931 | // draw either from start point of parent or from top of the page |
938 | if (rct->mSamePage) | 932 | if (rct->mSamePage) |
939 | start = rct->mRect.bottom() + 1; | 933 | start = rct->mRect.bottom() + 1; |
940 | else | 934 | else |
941 | start = p.viewport().top(); | 935 | start = p.viewport().top(); |
942 | p.moveTo( center, start ); | 936 | p.moveTo( center, start ); |
943 | p.lineTo( center, to ); | 937 | p.lineTo( center, to ); |
944 | rct->mSamePage=false; | 938 | rct->mSamePage=false; |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index e8b7c94..8c2996b 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1751,306 +1751,306 @@ void KOAgenda::computeSizes() | |||
1751 | int cw = contentsWidth(); | 1751 | int cw = contentsWidth(); |
1752 | int ch = contentsHeight(); | 1752 | int ch = contentsHeight(); |
1753 | if ( mAllDayMode ) { | 1753 | if ( mAllDayMode ) { |
1754 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1754 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1755 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1755 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1756 | paintPixAll->resize( cw, ch ); | 1756 | paintPixAll->resize( cw, ch ); |
1757 | } else { | 1757 | } else { |
1758 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1758 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1759 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1759 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1760 | KOAgendaItem::resizePixmap( cw , ch ); | 1760 | KOAgendaItem::resizePixmap( cw , ch ); |
1761 | } | 1761 | } |
1762 | 1762 | ||
1763 | checkScrollBoundaries(); | 1763 | checkScrollBoundaries(); |
1764 | marcus_bains(); | 1764 | marcus_bains(); |
1765 | drawContentsToPainter(); | 1765 | drawContentsToPainter(); |
1766 | viewport()->repaint(false); | 1766 | viewport()->repaint(false); |
1767 | } | 1767 | } |
1768 | 1768 | ||
1769 | void KOAgenda::scrollUp() | 1769 | void KOAgenda::scrollUp() |
1770 | { | 1770 | { |
1771 | scrollBy(0,-mScrollOffset); | 1771 | scrollBy(0,-mScrollOffset); |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | 1774 | ||
1775 | void KOAgenda::scrollDown() | 1775 | void KOAgenda::scrollDown() |
1776 | { | 1776 | { |
1777 | scrollBy(0,mScrollOffset); | 1777 | scrollBy(0,mScrollOffset); |
1778 | } | 1778 | } |
1779 | 1779 | ||
1780 | void KOAgenda::popupAlarm() | 1780 | void KOAgenda::popupAlarm() |
1781 | { | 1781 | { |
1782 | if (!mClickedItem) { | 1782 | if (!mClickedItem) { |
1783 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1783 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1784 | return; | 1784 | return; |
1785 | } | 1785 | } |
1786 | // TODO: deal correctly with multiple alarms | 1786 | // TODO: deal correctly with multiple alarms |
1787 | Alarm* alarm; | 1787 | Alarm* alarm; |
1788 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1788 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1789 | for(alarm=list.first();alarm;alarm=list.next()) { | 1789 | for(alarm=list.first();alarm;alarm=list.next()) { |
1790 | alarm->toggleAlarm(); | 1790 | alarm->toggleAlarm(); |
1791 | } | 1791 | } |
1792 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1792 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1793 | mClickedItem->paintMe( true ); | 1793 | mClickedItem->paintMe( true ); |
1794 | mClickedItem->repaint( false ); | 1794 | mClickedItem->repaint( false ); |
1795 | } | 1795 | } |
1796 | 1796 | ||
1797 | /* | 1797 | /* |
1798 | Calculates the minimum width | 1798 | Calculates the minimum width |
1799 | */ | 1799 | */ |
1800 | int KOAgenda::minimumWidth() const | 1800 | int KOAgenda::minimumWidth() const |
1801 | { | 1801 | { |
1802 | // TODO:: develop a way to dynamically determine the minimum width | 1802 | // TODO:: develop a way to dynamically determine the minimum width |
1803 | int min = 100; | 1803 | int min = 100; |
1804 | 1804 | ||
1805 | return min; | 1805 | return min; |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | void KOAgenda::updateConfig() | 1808 | void KOAgenda::updateConfig() |
1809 | { | 1809 | { |
1810 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1810 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1811 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1811 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1812 | if ( mAllDayMode ) { | 1812 | if ( mAllDayMode ) { |
1813 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1813 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1814 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1814 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1815 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1815 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1816 | // setMaximumHeight( mGridSpacingY+1 ); | 1816 | // setMaximumHeight( mGridSpacingY+1 ); |
1817 | viewport()->repaint( false ); | 1817 | viewport()->repaint( false ); |
1818 | //setFixedHeight( mGridSpacingY+1 ); | 1818 | //setFixedHeight( mGridSpacingY+1 ); |
1819 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1819 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1820 | } | 1820 | } |
1821 | else { | 1821 | else { |
1822 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1822 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1823 | calculateWorkingHours(); | 1823 | calculateWorkingHours(); |
1824 | marcus_bains(); | 1824 | marcus_bains(); |
1825 | } | 1825 | } |
1826 | } | 1826 | } |
1827 | 1827 | ||
1828 | void KOAgenda::checkScrollBoundaries() | 1828 | void KOAgenda::checkScrollBoundaries() |
1829 | { | 1829 | { |
1830 | // Invalidate old values to force update | 1830 | // Invalidate old values to force update |
1831 | mOldLowerScrollValue = -1; | 1831 | mOldLowerScrollValue = -1; |
1832 | mOldUpperScrollValue = -1; | 1832 | mOldUpperScrollValue = -1; |
1833 | 1833 | ||
1834 | checkScrollBoundaries(verticalScrollBar()->value()); | 1834 | checkScrollBoundaries(verticalScrollBar()->value()); |
1835 | } | 1835 | } |
1836 | 1836 | ||
1837 | void KOAgenda::checkScrollBoundaries(int v) | 1837 | void KOAgenda::checkScrollBoundaries(int v) |
1838 | { | 1838 | { |
1839 | if ( mGridSpacingY == 0 ) | 1839 | if ( mGridSpacingY == 0 ) |
1840 | return; | 1840 | return; |
1841 | int yMin = v/mGridSpacingY; | 1841 | int yMin = v/mGridSpacingY; |
1842 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1842 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1843 | 1843 | ||
1844 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1844 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1845 | 1845 | ||
1846 | if (yMin != mOldLowerScrollValue) { | 1846 | if (yMin != mOldLowerScrollValue) { |
1847 | mOldLowerScrollValue = yMin; | 1847 | mOldLowerScrollValue = yMin; |
1848 | emit lowerYChanged(yMin); | 1848 | emit lowerYChanged(yMin); |
1849 | } | 1849 | } |
1850 | if (yMax != mOldUpperScrollValue) { | 1850 | if (yMax != mOldUpperScrollValue) { |
1851 | mOldUpperScrollValue = yMax; | 1851 | mOldUpperScrollValue = yMax; |
1852 | emit upperYChanged(yMax); | 1852 | emit upperYChanged(yMax); |
1853 | } | 1853 | } |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | void KOAgenda::deselectItem() | 1856 | void KOAgenda::deselectItem() |
1857 | { | 1857 | { |
1858 | if (mSelectedItem.isNull()) return; | 1858 | if (mSelectedItem.isNull()) return; |
1859 | mSelectedItem->select(false); | 1859 | mSelectedItem->select(false); |
1860 | mSelectedItem = 0; | 1860 | mSelectedItem = 0; |
1861 | } | 1861 | } |
1862 | 1862 | ||
1863 | void KOAgenda::selectItem(KOAgendaItem *item) | 1863 | void KOAgenda::selectItem(KOAgendaItem *item) |
1864 | { | 1864 | { |
1865 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1865 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1866 | deselectItem(); | 1866 | deselectItem(); |
1867 | if (item == 0) { | 1867 | if (item == 0) { |
1868 | emit incidenceSelected( 0 ); | 1868 | emit incidenceSelected( 0 ); |
1869 | return; | 1869 | return; |
1870 | } | 1870 | } |
1871 | mSelectedItem = item; | 1871 | mSelectedItem = item; |
1872 | mSelectedItem->select(); | 1872 | mSelectedItem->select(); |
1873 | emit incidenceSelected( mSelectedItem->incidence() ); | 1873 | emit incidenceSelected( mSelectedItem->incidence() ); |
1874 | } | 1874 | } |
1875 | 1875 | ||
1876 | // This function seems never be called. | 1876 | // This function seems never be called. |
1877 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1877 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1878 | { | 1878 | { |
1879 | switch(kev->key()) { | 1879 | switch(kev->key()) { |
1880 | case Key_PageDown: | 1880 | case Key_PageDown: |
1881 | verticalScrollBar()->addPage(); | 1881 | verticalScrollBar()->addPage(); |
1882 | break; | 1882 | break; |
1883 | case Key_PageUp: | 1883 | case Key_PageUp: |
1884 | verticalScrollBar()->subtractPage(); | 1884 | verticalScrollBar()->subtractPage(); |
1885 | break; | 1885 | break; |
1886 | case Key_Down: | 1886 | case Key_Down: |
1887 | verticalScrollBar()->addLine(); | 1887 | verticalScrollBar()->addLine(); |
1888 | break; | 1888 | break; |
1889 | case Key_Up: | 1889 | case Key_Up: |
1890 | verticalScrollBar()->subtractLine(); | 1890 | verticalScrollBar()->subtractLine(); |
1891 | break; | 1891 | break; |
1892 | default: | 1892 | default: |
1893 | ; | 1893 | ; |
1894 | } | 1894 | } |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | void KOAgenda::calculateWorkingHours() | 1897 | void KOAgenda::calculateWorkingHours() |
1898 | { | 1898 | { |
1899 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1899 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1900 | mWorkingHoursEnable = !mAllDayMode; | 1900 | mWorkingHoursEnable = !mAllDayMode; |
1901 | 1901 | ||
1902 | mWorkingHoursYTop = mGridSpacingY * | 1902 | mWorkingHoursYTop = mGridSpacingY * |
1903 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1903 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1904 | mWorkingHoursYBottom = mGridSpacingY * | 1904 | mWorkingHoursYBottom = mGridSpacingY * |
1905 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1905 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1906 | } | 1906 | } |
1907 | 1907 | ||
1908 | 1908 | ||
1909 | DateList KOAgenda::dateList() const | 1909 | DateList KOAgenda::dateList() const |
1910 | { | 1910 | { |
1911 | return mSelectedDates; | 1911 | return mSelectedDates; |
1912 | } | 1912 | } |
1913 | 1913 | ||
1914 | void KOAgenda::setDateList(const DateList &selectedDates) | 1914 | void KOAgenda::setDateList(const DateList &selectedDates) |
1915 | { | 1915 | { |
1916 | mSelectedDates = selectedDates; | 1916 | mSelectedDates = selectedDates; |
1917 | marcus_bains(); | 1917 | marcus_bains(); |
1918 | } | 1918 | } |
1919 | 1919 | ||
1920 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1920 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1921 | { | 1921 | { |
1922 | mHolidayMask = mask; | 1922 | mHolidayMask = mask; |
1923 | 1923 | ||
1924 | /* | 1924 | /* |
1925 | kdDebug() << "HolidayMask: "; | 1925 | kdDebug() << "HolidayMask: "; |
1926 | for(uint i=0;i<mask->count();++i) { | 1926 | for(uint i=0;i<mask->count();++i) { |
1927 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1927 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1928 | } | 1928 | } |
1929 | kdDebug() << endl; | 1929 | kdDebug() << endl; |
1930 | */ | 1930 | */ |
1931 | } | 1931 | } |
1932 | 1932 | ||
1933 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1933 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1934 | { | 1934 | { |
1935 | 1935 | ||
1936 | QScrollView::contentsMousePressEvent(event); | 1936 | QScrollView::contentsMousePressEvent(event); |
1937 | } | 1937 | } |
1938 | 1938 | ||
1939 | void KOAgenda::storePosition() | 1939 | void KOAgenda::storePosition() |
1940 | { | 1940 | { |
1941 | //mContentPosition | 1941 | //mContentPosition |
1942 | int max = mGridSpacingY*4*24; | 1942 | int max = mGridSpacingY*4*24; |
1943 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1943 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1944 | mContentPosition = 0; | 1944 | mContentPosition = 0; |
1945 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1945 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1946 | mContentPosition = -1.0; | 1946 | mContentPosition = -1.0; |
1947 | else | 1947 | else |
1948 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1948 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1949 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1949 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1950 | 1950 | ||
1951 | } | 1951 | } |
1952 | void KOAgenda::restorePosition() | 1952 | void KOAgenda::restorePosition() |
1953 | { | 1953 | { |
1954 | int posY; | 1954 | int posY; |
1955 | int max = mGridSpacingY*4*24; | 1955 | int max = mGridSpacingY*4*24; |
1956 | if ( mContentPosition < 0 ) | 1956 | if ( mContentPosition < 0 ) |
1957 | posY = max-viewport()->height(); | 1957 | posY = max-viewport()->height(); |
1958 | else | 1958 | else |
1959 | if ( mContentPosition == 0 ) | 1959 | if ( mContentPosition == 0 ) |
1960 | posY = 0; | 1960 | posY = 0; |
1961 | else | 1961 | else |
1962 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1962 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1963 | setContentsPos (0, posY ); | 1963 | setContentsPos (0, posY ); |
1964 | //qDebug("posY %d hei %d", posY, max); | 1964 | //qDebug("posY %d hei %d", posY, max); |
1965 | 1965 | ||
1966 | } | 1966 | } |
1967 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1967 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1968 | { | 1968 | { |
1969 | ++x; | 1969 | ++x; |
1970 | QScrollView::moveChild( w, x , y ); | 1970 | QScrollView::moveChild( w, x , y ); |
1971 | } | 1971 | } |
1972 | #include <qmessagebox.h> | 1972 | #include <qmessagebox.h> |
1973 | #ifdef DESKTOP_VERSION | 1973 | #ifdef DESKTOP_VERSION |
1974 | #include <qprinter.h> | 1974 | #include <qprinter.h> |
1975 | #include <qpainter.h> | 1975 | #include <qpainter.h> |
1976 | #include <qpaintdevicemetrics.h> | 1976 | #include <qpaintdevicemetrics.h> |
1977 | 1977 | ||
1978 | #endif | 1978 | #endif |
1979 | void KOAgenda::printSelection() | 1979 | void KOAgenda::printSelection() |
1980 | { | 1980 | { |
1981 | #ifdef DESKTOP_VERSION | 1981 | #ifdef DESKTOP_VERSION |
1982 | if ( mStartCellY == mCurrentCellY ) { | 1982 | if ( mStartCellY == mCurrentCellY ) { |
1983 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1983 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1984 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1984 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1985 | i18n("OK"), 0, 0, | 1985 | i18n("OK"), 0, 0, |
1986 | 0, 1 ); | 1986 | 0, 1 ); |
1987 | return; | 1987 | return; |
1988 | } | 1988 | } |
1989 | 1989 | ||
1990 | float dx, dy; | 1990 | float dx, dy; |
1991 | int x,y,w,h; | 1991 | int x,y,w,h; |
1992 | x= 0; | 1992 | x= 0; |
1993 | w= contentsWidth()+2; | 1993 | w= contentsWidth()+2; |
1994 | // h= contentsHeight(); | 1994 | // h= contentsHeight(); |
1995 | y = mGridSpacingY*mStartCellY; | 1995 | y = mGridSpacingY*mStartCellY; |
1996 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 1996 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1997 | 1997 | ||
1998 | //return; | 1998 | //return; |
1999 | QPrinter* printer = new QPrinter(); | 1999 | QPrinter* printer = new QPrinter(); |
2000 | if ( !printer->setup()) { | 2000 | if ( !printer->setup()) { |
2001 | delete printer; | 2001 | delete printer; |
2002 | return; | 2002 | return; |
2003 | } | 2003 | } |
2004 | QPainter p( printer ); | 2004 | QPainter p( printer ); |
2005 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2005 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
2006 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2006 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
2007 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2007 | //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
2008 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2008 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
2009 | // p.drawText( 0, 0, date ); | 2009 | // p.drawText( 0, 0, date ); |
2010 | int offset = m.width()/8; | 2010 | int offset = m.width()/8; |
2011 | // compute the scale | 2011 | // compute the scale |
2012 | dx = ((float) m.width()-offset) / (float)w; | 2012 | dx = ((float) m.width()-offset) / (float)w; |
2013 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2013 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
2014 | float scale; | 2014 | float scale; |
2015 | // scale to fit the width or height of the paper | 2015 | // scale to fit the width or height of the paper |
2016 | if ( dx < dy ) | 2016 | if ( dx < dy ) |
2017 | scale = dx; | 2017 | scale = dx; |
2018 | else | 2018 | else |
2019 | scale = dy; | 2019 | scale = dy; |
2020 | // set the scale | 2020 | // set the scale |
2021 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2021 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2022 | 2022 | ||
2023 | int selDay; | 2023 | int selDay; |
2024 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2024 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2025 | float startX = 1; | 2025 | float startX = 1; |
2026 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2026 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2027 | { | 2027 | { |
2028 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2028 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2029 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2029 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2030 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2030 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2031 | startX += widOffset; | 2031 | startX += widOffset; |
2032 | 2032 | ||
2033 | } | 2033 | } |
2034 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2034 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2035 | p.scale( scale, scale ); | 2035 | p.scale( scale, scale ); |
2036 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2036 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2037 | // now printing with y offset: 2 hei | 2037 | // now printing with y offset: 2 hei |
2038 | // p.translate( 0, -y*scale); | 2038 | // p.translate( 0, -y*scale); |
2039 | 2039 | ||
2040 | drawContentsToPainter(&p, true ); | 2040 | drawContentsToPainter(&p, true ); |
2041 | globalFlagBlockAgendaItemUpdate = false; | 2041 | globalFlagBlockAgendaItemUpdate = false; |
2042 | KOAgendaItem *item; | 2042 | KOAgendaItem *item; |
2043 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2043 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2044 | item->select(false); | 2044 | item->select(false); |
2045 | item->paintMe( false, &p ); | 2045 | item->paintMe( false, &p ); |
2046 | } | 2046 | } |
2047 | globalFlagBlockAgendaItemUpdate = true; | 2047 | globalFlagBlockAgendaItemUpdate = true; |
2048 | p.end(); | 2048 | p.end(); |
2049 | delete printer; | 2049 | delete printer; |
2050 | #else | 2050 | #else |
2051 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2051 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2052 | i18n("Not supported \non PDA!\n"), | 2052 | i18n("Not supported \non PDA!\n"), |
2053 | i18n("OK"), 0, 0, | 2053 | i18n("OK"), 0, 0, |
2054 | 0, 1 ); | 2054 | 0, 1 ); |
2055 | #endif | 2055 | #endif |
2056 | } | 2056 | } |