-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 @@ -639,66 +639,60 @@ void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, 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 ) ); |