Commit 72e45f70 authored by Allen Winter's avatar Allen Winter

forward port SVN commit 1158315 by winterz:

for the all-day sidebar:
- shrink the font a bit
- allow word-wrapping
- make the box border width consistent
kolab/issue4261

svn path=/trunk/KDE/kdepim/; revision=1158337
parent 3970c7c2
......@@ -856,11 +856,17 @@ void CalPrintDay::print( QPainter &p, int width, int height )
QRect allDayBox( TIMELINE_WIDTH + padding(), headerBox.bottom() + padding(),
width - TIMELINE_WIDTH - padding(), allDayHeight );
if ( alldayEvents.count() > 0 ) {
// draw the side bar for all-day events
QFont oldFont( p.font() );
p.setFont( QFont( "sans-serif", 9, QFont::Normal ) );
drawVerticalBox( p,
BOX_BORDER_WIDTH,
QRect( 0, headerBox.bottom() + padding(), TIMELINE_WIDTH, allDayHeight ),
i18n( "Today's Events" ),
Qt::AlignHCenter | Qt::AlignVCenter | Qt::SingleLine );
Qt::AlignHCenter | Qt::AlignVCenter | Qt::WordBreak );
p.setFont( oldFont );
// now draw at most maxAllDayEvents in the all-day box
drawBox( p, BOX_BORDER_WIDTH, allDayBox );
Item::List::ConstIterator it;
......
......@@ -410,7 +410,7 @@ void CalPrintPluginBase::printEventString( QPainter &p, const QRect &box,
( Qt::AlignTop | Qt::AlignJustify | Qt::BreakAnywhere ) : flags, str );
}
void CalPrintPluginBase::showEventBox( QPainter &p, const QRect &box,
void CalPrintPluginBase::showEventBox( QPainter &p, int linewidth, const QRect &box,
const Incidence::Ptr &incidence, const QString &str,
int flags )
{
......@@ -422,8 +422,7 @@ void CalPrintPluginBase::showEventBox( QPainter &p, const QRect &box,
} else {
p.setBrush( QColor( 232, 232, 232 ) );
}
drawBox( p, EVENT_BORDER_WIDTH, box );
drawBox( p, ( linewidth > 0 ) ? linewidth : EVENT_BORDER_WIDTH, box );
if ( mUseColors && bgColor.isValid() ) {
p.setPen( KOHelper::getTextColor( bgColor ) );
}
......@@ -441,13 +440,13 @@ void CalPrintPluginBase::drawSubHeaderBox( QPainter &p, const QString &str, cons
p.setFont( oldfont );
}
void CalPrintPluginBase::drawVerticalBox( QPainter &p, const QRect &box, const QString &str,
int flags )
void CalPrintPluginBase::drawVerticalBox( QPainter &p, int linewidth, const QRect &box,
const QString &str, int flags )
{
p.save();
p.rotate( -90 );
QRect rotatedBox( -box.top() - box.height(), box.left(), box.height(), box.width() );
showEventBox( p, rotatedBox, Incidence::Ptr(), str,
showEventBox( p, linewidth, rotatedBox, Incidence::Ptr(), str,
( flags == -1 ) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine : flags );
p.restore();
......@@ -817,7 +816,7 @@ int CalPrintPluginBase::drawAllDayBox( QPainter &p, const Item::List &eventList_
if ( expandable ) {
QRect eventBox( box );
eventBox.setTop( offset );
showEventBox( p, eventBox, currEvent, currEvent->summary() );
showEventBox( p, EVENT_BORDER_WIDTH, eventBox, currEvent, currEvent->summary() );
offset += box.height();
} else {
if ( !multiDayStr.isEmpty() ) {
......@@ -1008,7 +1007,7 @@ void CalPrintPluginBase::drawAgendaItem( PrintCellItem *item, QPainter &p,
str += event->description();
}
}
showEventBox( p, eventBox, event, str );
showEventBox( p, EVENT_BORDER_WIDTH, eventBox, event, str );
}
}
......@@ -1593,7 +1592,7 @@ void CalPrintPluginBase::drawMonth( QPainter &p, const QDate &dt,
eventBox.setBottom(
daysBox.top() + qRound(
double( minsToEnd * daysBox.height() ) / double( maxdays * 24 * 60 ) ) );
drawVerticalBox( p, eventBox, placeItem->event()->summary() );
drawVerticalBox( p, 0, eventBox, placeItem->event()->summary() );
newxstartcont = qMax( newxstartcont, eventBox.right() );
}
xstartcont = newxstartcont;
......
......@@ -192,14 +192,16 @@ class KORGANIZERPRIVATE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
void printEventString( QPainter &p, const QRect &box, const QString &str, int flags = -1 );
/**
Print the box for the given event with the given string.
@param p QPainer of the printout
@param p QPainter of the printout
@param linewidth is the width of the line used to draw the box, ignored if less than 1.
@param box Coordinates of the event's box
@param incidence The incidence (if available), from which the category
color will be deduced, if applicable.
@param str The string to print inside the box
@param flags is a bitwise OR of Qt::AlignmentFlags and Qt::TextFlags values.
*/
void showEventBox( QPainter &p, const QRect &box, const Incidence::Ptr &incidence,
const QString &str, int flags = -1 );
void showEventBox( QPainter &p, int linewidth, const QRect &box,
const Incidence::Ptr &incidence, const QString &str, int flags = -1 );
/**
Draw a subheader box with a shaded background and the given string
......@@ -212,10 +214,13 @@ class KORGANIZERPRIVATE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
/**
Draw an event box with vertical text.
@param p QPainter of the printout
@param linewidth is the width of the line used to draw the box, ignored if less than 1.
@param box Coordinates of the box
@param str ext to be printed inside the box
@param flags is a bitwise OR of Qt::AlignmentFlags and Qt::TextFlags values.
*/
void drawVerticalBox( QPainter &p, const QRect &box, const QString &str, int flags=-1 );
void drawVerticalBox( QPainter &p, int linewidth, const QRect &box, const QString &str,
int flags=-1 );
/**
Draw a component box with a heading (printed in bold).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment