[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/korganizer/printing
From: Allen Winter <winter () kde ! org>
Date: 2010-08-02 14:33:01
Message-ID: 20100802143301.0A4E4AC7A9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1158329 by winterz:
forward port SVN commit 1155133 by winterz:
for Day prints, put the allday events in their own box at the top of
the agenda print, sorta like how agenda view looks.
kolab/issue4261
M +75 -14 calprintdefaultplugins.cpp
M +8 -8 calprintpluginbase.cpp
M +2 -6 calprintpluginbase.h
--- trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.cpp #1158328:1158329
@@ -38,7 +38,7 @@
#include <KCalendarSystem>
#include <KDateTime>
#include <KConfigGroup>
-#include <ksystemtimezone.h>
+#include <KSystemTimeZones>
#include <QDateTime>
#include <QPainter>
@@ -46,6 +46,12 @@
using namespace Akonadi;
+static QString cleanStr( const QString &instr )
+{
+ QString ret = instr;
+ return ret.replace( '\n', ' ' );
+}
+
/**************************************************************
* Print Incidence
**************************************************************/
@@ -409,10 +415,13 @@
box.width(), box.height() / 9 );
QRect attachmentsBox( box.left(), attendeesBox.top() - padding() - box.height() \
/ 9,
box.width() * 3 / 4 - padding(), box.height() / 9 );
- QRect optionsBox( isJournal ? box.left() : attachmentsBox.right() + padding(), \
attachmentsBox.top(), 0, 0 ); + QRect optionsBox( isJournal ? box.left() : \
attachmentsBox.right() + padding(), + attachmentsBox.top(), 0, 0 \
); optionsBox.setRight( box.right() );
optionsBox.setBottom( attachmentsBox.bottom() );
- QRect notesBox( optionsBox.left(), isJournal ? ( timesBox.bottom() + padding() ) \
: ( locationBox.bottom() + padding() ), + QRect notesBox( optionsBox.left(),
+ isJournal ? ( timesBox.bottom() + padding() ) :
+ ( locationBox.bottom() + padding() ),
optionsBox.width(), 0 );
notesBox.setBottom( optionsBox.top() - padding() );
QRect descriptionBox( notesBox );
@@ -824,15 +833,67 @@
Akonadi::EventSortStartDate,
Akonadi::SortDirectionAscending );
- p.setFont( QFont( "sans-serif", 12 ) );
+ // split out the all day events as they will be printed in a separate box
+ Item::List alldayEvents, timedEvents;
+ Item::List::ConstIterator it;
+ for ( it = eventList.begin(); it != eventList.end(); ++it ) {
+ Event::Ptr event = Akonadi::event( *it );
+ if ( event->allDay() ) {
+ alldayEvents.append( *it );
+ } else {
+ timedEvents.append( *it );
+ }
+ }
- // TODO: Find a good way to determine the height of the all-day box
+ int fontSize = 11;
+ QFont textFont( "sans-serif", fontSize, QFont::Normal );
+ p.setFont( textFont );
+ int lineSpacing = p.fontMetrics().lineSpacing();
+
+ int maxAllDayEvents = 8; // the max we allow to be printed, sorry.
+ int allDayHeight = qMin( alldayEvents.count(), maxAllDayEvents ) * lineSpacing;
+ allDayHeight = qMax( allDayHeight, ( 5 * lineSpacing ) ) + ( 2 * padding() );
QRect allDayBox( TIMELINE_WIDTH + padding(), headerBox.bottom() + padding(),
- 0, height - headerBox.bottom() - padding() );
- allDayBox.setRight( width );
+ width - TIMELINE_WIDTH - padding(), allDayHeight );
+ if ( alldayEvents.count() > 0 ) {
+ drawVerticalBox( p,
+ QRect( 0, headerBox.bottom() + padding(), TIMELINE_WIDTH, \
allDayHeight ), + i18n( "Today's Events" ),
+ Qt::AlignHCenter | Qt::AlignVCenter | Qt::SingleLine );
+ drawBox( p, BOX_BORDER_WIDTH, allDayBox );
+
+ Item::List::ConstIterator it;
+ QRect eventBox( allDayBox );
+ eventBox.setLeft( TIMELINE_WIDTH + ( 2 * padding() ) );
+ eventBox.setTop( eventBox.top() + padding() );
+ eventBox.setBottom( eventBox.top() + lineSpacing );
+ int count = 0;
+ for ( it = alldayEvents.begin(); it != alldayEvents.end(); ++it ) {
+ Event::Ptr event = Akonadi::event( *it );
+ if ( count == maxAllDayEvents ) {
+ break;
+ }
+ count++;
+ QString str;
+ if ( event->location().isEmpty() ) {
+ str = cleanStr( event->summary() );
+ } else {
+ str = i18nc( "summary, location", "%1, %2",
+ cleanStr( event->summary() ), cleanStr( event->location() ) \
); + }
+ printEventString( p, eventBox, str );
+ eventBox.setTop( eventBox.bottom() );
+ eventBox.setBottom( eventBox.top() + lineSpacing );
+ }
+ } else {
+ allDayBox.setBottom( headerBox.bottom() );
+ }
+
QRect dayBox( allDayBox );
- drawAgendaDayBox( p, eventList, curDay, mIncludeAllEvents,
+ dayBox.setTop( allDayBox.bottom() + padding() );
+ dayBox.setBottom( height );
+ drawAgendaDayBox( p, timedEvents, curDay, mIncludeAllEvents,
curStartTime, curEndTime, dayBox,
mIncludeDescription, mExcludeTime,
mExcludeConfidential, mExcludePrivate );
@@ -1331,11 +1392,11 @@
if ( mTodoSortField != TodoFieldUnset ) {
// do not insert if already done so.
- cfg->mSortField->addItem( i18n( "Title" ) );
- cfg->mSortField->addItem( i18n( "Start Date" ) );
- cfg->mSortField->addItem( i18n( "Due Date" ) );
- cfg->mSortField->addItem( i18n( "Priority" ) );
- cfg->mSortField->addItem( i18n( "Percent Complete" ) );
+ cfg->mSortField->addItem( i18nc( "@option sort by title", "Title" ) );
+ cfg->mSortField->addItem( i18nc( "@option sort by start date/time", "Start \
Date" ) ); + cfg->mSortField->addItem( i18nc( "@option sort by due date/time", \
"Due Date" ) ); + cfg->mSortField->addItem( i18nc( "@option sort by priority", \
"Priority" ) ); + cfg->mSortField->addItem( i18nc( "@option sort by percent \
completed", "Percent Complete" ) ); cfg->mSortField->setCurrentIndex( mTodoSortField \
); }
@@ -1419,7 +1480,7 @@
}
outStr.truncate( 0 );
- outStr += i18n( "Title" );
+ outStr += i18nc( "@label to-do summary", "Title" );
p.drawText( possummary, mCurrentLinePos - 2, outStr );
if ( mIncludePercentComplete ) {
--- trunk/KDE/kdepim/korganizer/printing/calprintpluginbase.cpp #1158328:1158329
@@ -32,12 +32,11 @@
#include <akonadi/kcal/calendar.h>
#include <akonadi/kcal/utils.h>
-#include <kdebug.h>
-#include <kconfig.h>
-#include <kcalendarsystem.h>
-#include <kwordwrap.h>
-#include <kconfiggroup.h>
-#include <ksystemtimezone.h>
+#include <KDebug>
+#include <KCalendarSystem>
+#include <KConfigGroup>
+#include <KSystemTimeZones>
+#include <KWordWrap>
#include <QPainter>
#include <QLayout>
@@ -442,13 +441,14 @@
p.setFont( oldfont );
}
-void CalPrintPluginBase::drawVerticalBox( QPainter &p, const QRect &box, const \
QString &str ) +void CalPrintPluginBase::drawVerticalBox( QPainter &p, 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,
- Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine );
+ ( flags == -1 ) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine \
: flags );
p.restore();
}
--- trunk/KDE/kdepim/korganizer/printing/calprintpluginbase.h #1158328:1158329
@@ -32,12 +32,8 @@
#include <akonadi/kcal/calendar.h>
-#include <kcal/event.h>
-#include <kcal/todo.h>
+#include <KDateTime>
-#include <kdatetime.h>
-
-#include <QtCore/QDateTime>
#include <QtGui/QPainter>
#include <QtGui/QPrinter>
@@ -219,7 +215,7 @@
@param box Coordinates of the box
@param str ext to be printed inside the box
*/
- void drawVerticalBox( QPainter &p, const QRect &box, const QString &str );
+ void drawVerticalBox( QPainter &p, const QRect &box, const QString &str, int \
flags=-1 );
/**
Draw a component box with a heading (printed in bold).
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic