-rw-r--r-- | korganizer/calprintbase.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp index f66fddc..7b7d54c 100644 --- a/korganizer/calprintbase.cpp +++ b/korganizer/calprintbase.cpp @@ -623,98 +623,92 @@ void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, int currentyPos = int( y + startPrintDate.secsTo( startTime ) * minlen / 60. ); int currentWidth = width / item->subCells(); int currentX = x + item->subCell() * currentWidth; QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ " "+event->summary(); if ( !event->location().isEmpty() ) text += " (" +event->location()+")"; // p.save(); QPen pe = p.pen(); pe.setWidth( 2 ); p.setPen( pe ); p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, AlignLeft | AlignTop | AlignJustify | WordBreak, text); // p.restore(); } } void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, int x, int y, int width, int height, bool fullDate) { QString dayNumStr; QString ampm; const KLocale*local = KGlobal::locale(); // This has to be localized if (fullDate) { - /*int index; - dayNumStr= qd.toString(); - index = dayNumStr.find(' '); - dayNumStr.remove(0, index); - index = dayNumStr.findRev(' '); - dayNumStr.truncate(index);*/ - - const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); - dayNumStr = i18n("weekday month date", "%1 %2 %3") - .arg( calSys->weekDayName( qd ) ) - .arg( calSys->monthName( qd ) ) - .arg( qd.day() ); -// dayNumStr = local->formatDate(qd); + dayNumStr = local->formatDate(qd); } else { dayNumStr = QString::number( qd.day() ); } p.eraseRect( x, y, width, height ); p.drawRect( x, y, width, height ); // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); p.drawRect( x, y, width, mSubHeaderHeight ); //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); QString hstring; #ifndef KORG_NOPLUGINS hstring=KOCore::self()->holiday(qd); #endif if (!hstring.isEmpty()) { p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, hstring ); } p.setFont(QFont("helvetica", 10, QFont::Bold)); + if ( fullDate) { + // use short date format, if long date is too long + QFontMetrics fm ( p.font() ); + if ( fm.width( dayNumStr ) > width -10 ) + dayNumStr = local->formatDate(qd, true); + } p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, dayNumStr); Event::List eventList; eventList.fill( mCalendar->events( qd, true )); Todo::List todos; todos.fill( mCalendar->todos( qd )); QString outStr; p.setFont( QFont( "helvetica", 8 ) ); int lineSpacing = p.fontMetrics().lineSpacing(); int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry Event::List::ConstIterator it; int entryCount = eventList.count() +todos.count(); if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { p.setFont( QFont( "helvetica", 7 ) ); if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) p.setFont( QFont( "helvetica", 6 ) ); } lineSpacing = p.fontMetrics().lineSpacing()-1; } // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { Event *currEvent = *it; if (currEvent->doesFloat() || currEvent->isMultiDay()) outStr = currEvent->summary(); else { if ( fullDate ) { outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ " "+ currEvent->summary(); |