summaryrefslogtreecommitdiffstats
path: root/korganizer/printing
diff options
context:
space:
mode:
Diffstat (limited to 'korganizer/printing')
-rw-r--r--korganizer/printing/calprintdefaultplugins.cpp372
-rw-r--r--korganizer/printing/calprintdefaultplugins.h136
-rw-r--r--korganizer/printing/calprintpluginbase.cpp276
-rw-r--r--korganizer/printing/calprintpluginbase.h70
4 files changed, 620 insertions, 234 deletions
diff --git a/korganizer/printing/calprintdefaultplugins.cpp b/korganizer/printing/calprintdefaultplugins.cpp
index bc4c6249..38d9b4b7 100644
--- a/korganizer/printing/calprintdefaultplugins.cpp
+++ b/korganizer/printing/calprintdefaultplugins.cpp
@@ -4,6 +4,7 @@
Copyright (c) 1998 Preston Brown <pbrown@kde.org>
Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
+ Copyright (c) 2008 Ron Goodheart <ron.goodheart@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,6 +39,8 @@
#include <knuminput.h>
#include <kcombobox.h>
+#include <libkcal/incidenceformatter.h>
+
#include "calprintdefaultplugins.h"
#include "calprintincidenceconfig_base.h"
@@ -46,7 +49,6 @@
#include "calprintmonthconfig_base.h"
#include "calprinttodoconfig_base.h"
-
/**************************************************************
* Print Incidence
**************************************************************/
@@ -131,18 +133,18 @@ class TimePrintStringsVisitor : public IncidenceBase::Visitor
protected:
bool visit( Event *event ) {
if ( event->dtStart().isValid() ) {
- mStartCaption = i18n("Start date: ");
- // Show date/time or only date, depending on whether it's an all-day event
-// TODO: Add shortfmt param to dtStartStr, dtEndStr and dtDueStr!!!
- mStartString = (event->doesFloat()) ? (event->dtStartDateStr(false)) : (event->dtStartStr());
+ mStartCaption = i18n( "Start date: " );
+ mStartString = IncidenceFormatter::dateTimeToString(
+ event->dtStart(), event->doesFloat(), false );
} else {
- mStartCaption = i18n("No start date");
+ mStartCaption = i18n( "No start date" );
mStartString = TQString::null;
}
-
+
if ( event->hasEndDate() ) {
- mEndCaption = i18n("End date: ");
- mEndString = (event->doesFloat()) ? (event->dtEndDateStr(false)) : (event->dtEndStr());
+ mEndCaption = i18n( "End date: " );
+ mEndString = IncidenceFormatter::dateTimeToString(
+ event->dtEnd(), event->doesFloat(), false );
} else if ( event->hasDuration() ) {
mEndCaption = i18n("Duration: ");
int mins = event->duration() / 60;
@@ -160,18 +162,18 @@ class TimePrintStringsVisitor : public IncidenceBase::Visitor
}
bool visit( Todo *todo ) {
if ( todo->hasStartDate() ) {
- mStartCaption = i18n("Start date: ");
- // Show date/time or only date, depending on whether it's an all-day event
-// TODO: Add shortfmt param to dtStartStr, dtEndStr and dtDueStr!!!
- mStartString = (todo->doesFloat()) ? (todo->dtStartDateStr(false)) : (todo->dtStartStr());
+ mStartCaption = i18n( "Start date: " );
+ mStartString = IncidenceFormatter::dateTimeToString(
+ todo->dtStart(), todo->doesFloat(), false );
} else {
- mStartCaption = i18n("No start date");
+ mStartCaption = i18n( "No start date" );
mStartString = TQString::null;
}
-
+
if ( todo->hasDueDate() ) {
- mEndCaption = i18n("Due date: ");
- mEndString = (todo->doesFloat()) ? (todo->dtDueDateStr(false)) : (todo->dtDueStr());
+ mEndCaption = i18n( "Due date: " );
+ mEndString = IncidenceFormatter::dateTimeToString(
+ todo->dtDue(), todo->doesFloat(), false );
} else {
mEndCaption = i18n("No due date");
mEndString = TQString::null;
@@ -179,9 +181,9 @@ class TimePrintStringsVisitor : public IncidenceBase::Visitor
return true;
}
bool visit( Journal *journal ) {
- mStartCaption = i18n("Start date: ");
-// TODO: Add shortfmt param to dtStartStr, dtEndStr and dtDueStr!!!
- mStartString = (journal->doesFloat()) ? (journal->dtStartDateStr(false)) : (journal->dtStartStr());
+ mStartCaption = i18n( "Start date: " );
+ mStartString = IncidenceFormatter::dateTimeToString(
+ journal->dtStart(), journal->doesFloat(), false );
mEndCaption = TQString::null;
mEndString = TQString::null;
return true;
@@ -210,8 +212,6 @@ int CalPrintIncidence::printCaptionAndText( TQPainter &p, const TQRect &box, con
#include <tqfontdatabase.h>
void CalPrintIncidence::print( TQPainter &p, int width, int height )
{
- KLocale *local = KGlobal::locale();
-
TQFont oldFont(p.font());
TQFont textFont( "sans-serif", 11, TQFont::Normal );
TQFont captionFont( "sans-serif", 11, TQFont::Bold );
@@ -267,7 +267,7 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
TQRect timesBox( titleBox );
timesBox.setTop( titleBox.bottom() + padding() );
timesBox.setHeight( height / 8 );
-
+
TimePrintStringsVisitor stringVis;
int h = timesBox.top();
if ( stringVis.act(*it) ) {
@@ -279,28 +279,41 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
textRect.setRight( timesBox.right() - padding() );
h = QMAX( printCaptionAndText( p, textRect, stringVis.mEndCaption, stringVis.mEndString, captionFont, textFont ), h );
}
-
-
+
+ // Convert recurrence to a string
if ( (*it)->doesRecur() ) {
TQRect recurBox( timesBox.left()+padding(), h+padding(), timesBox.right()-padding(), lineHeight );
- // TODO: Convert the recurrence to a string and print it out!
- TQString recurString( "TODO: Convert Repeat to String!" );
- h = QMAX( printCaptionAndText( p, recurBox, i18n("Repeats: "), recurString, captionFont, textFont ), h );
+ KCal::Recurrence *recurs = (*it)->recurrence();
+
+ TQString displayString = IncidenceFormatter::recurrenceString((*it));
+ // exception dates
+ TQString exceptString;
+ if ( !recurs->exDates().isEmpty() ) {
+ exceptString = i18n("except for listed dates", " except");
+ for ( uint i = 0; i < recurs->exDates().size(); i++ ) {
+ exceptString.append(" ");
+ exceptString.append( KGlobal::locale()->formatDate(recurs->exDates()[i],
+ true) );
+ }
+ }
+ displayString.append(exceptString);
+ h = QMAX( printCaptionAndText( p, recurBox, i18n( "Repeats: "), displayString, captionFont, textFont ), h );
}
-
+
+ // Alarms Printing
TQRect alarmBox( timesBox.left()+padding(), h+padding(), timesBox.right()-padding(), lineHeight );
Alarm::List alarms = (*it)->alarms();
if ( alarms.count() == 0 ) {
cap = i18n("No reminders");
- txt = TQString::null;
+ txt = TQString();
} else {
cap = i18n("Reminder: ", "%n reminders: ", alarms.count() );
-
+
TQStringList alarmStrings;
KCal::Alarm::List::ConstIterator it;
for ( it = alarms.begin(); it != alarms.end(); ++it ) {
Alarm *alarm = *it;
-
+
// Alarm offset, copied from koeditoralarms.cpp:
TQString offsetstr;
int offset = 0;
@@ -345,7 +358,7 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
TQRect organizerBox( timesBox.left()+padding(), h+padding(), timesBox.right()-padding(), lineHeight );
h = QMAX( printCaptionAndText( p, organizerBox, i18n("Organizer: "), (*it)->organizer().fullName(), captionFont, textFont ), h );
-
+
// Finally, draw the frame around the time information...
timesBox.setBottom( QMAX( timesBox.bottom(), h+padding() ) );
drawBox( p, BOX_BORDER_WIDTH, timesBox );
@@ -360,43 +373,67 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
// Now start constructing the boxes from the bottom:
- TQRect categoriesBox( locationBox );
- categoriesBox.setBottom( box.bottom() );
- categoriesBox.setTop( categoriesBox.bottom() - lineHeight - 2*padding() );
+ TQRect footerBox( locationBox );
+ footerBox.setBottom( box.bottom() );
+ footerBox.setTop( footerBox.bottom() - lineHeight - 2*padding() );
+ TQRect categoriesBox( footerBox );
+ categoriesBox.setBottom( footerBox.top() );
+ categoriesBox.setTop( categoriesBox.bottom() - lineHeight - 2*padding() );
TQRect attendeesBox( box.left(), categoriesBox.top()-padding()-box.height()/9, box.width(), box.height()/9 );
- if ( !mShowAttendees ) {
- attendeesBox.setTop( categoriesBox.top() );
- }
+
TQRect attachmentsBox( box.left(), attendeesBox.top()-padding()-box.height()/9, box.width()*3/4 - padding(), box.height()/9 );
TQRect optionsBox( attachmentsBox.right() + padding(), attachmentsBox.top(), 0, 0 );
optionsBox.setRight( box.right() );
optionsBox.setBottom( attachmentsBox.bottom() );
TQRect notesBox( optionsBox.left(), locationBox.bottom() + padding(), optionsBox.width(), 0 );
notesBox.setBottom( optionsBox.top() - padding() );
-
- // TODO: Adjust boxes depending on the show options...
-// if ( !mShowOptions ) {
-// optionsBox.left()
-// bool mShowOptions;
-// // bool mShowSubitemsNotes;
-// bool mShowAttendees;
-// bool mShowAttachments;
-
TQRect descriptionBox( notesBox );
descriptionBox.setLeft( box.left() );
- descriptionBox.setRight( mShowOptions?(attachmentsBox.right()):(box.right()) );
+ descriptionBox.setRight( attachmentsBox.right() );
+ // Adjust boxes depending on the show options...
+ if (!mShowSubitemsNotes) {
+ descriptionBox.setRight( box.right() );
+ }
+ if (!mShowAttachments || !mShowAttendees) {
+ descriptionBox.setBottom( attachmentsBox.bottom() );
+ optionsBox.setTop( attendeesBox.top() );
+ optionsBox.setBottom( attendeesBox.bottom() );
+ notesBox.setBottom( attachmentsBox.bottom() );
+ if (mShowOptions) {
+ attendeesBox.setRight( attachmentsBox.right() );
+ }
+ if (!mShowAttachments && !mShowAttendees) {
+ if (mShowSubitemsNotes) {
+ descriptionBox.setBottom( attendeesBox.bottom() );
+ }
+ if (!mShowOptions) {
+ descriptionBox.setBottom( attendeesBox.bottom() );
+ notesBox.setBottom( attendeesBox.bottom() );
+ }
+ }
+ }
+ if (mShowAttachments) {
+ if (!mShowOptions) {
+ attachmentsBox.setRight( box.right() );
+ attachmentsBox.setRight( box.right() );
+ }
+ if (!mShowAttendees) {
+ attachmentsBox.setTop( attendeesBox.top() );
+ attachmentsBox.setBottom( attendeesBox.bottom() );
+ }
+ }
- drawBoxWithCaption( p, descriptionBox, i18n("Description:"),
- (*it)->description(), /*sameLine=*/false,
+ drawBoxWithCaption( p, descriptionBox, i18n("Description:"),
+ (*it)->description(), /*sameLine=*/false,
/*expand=*/false, captionFont, textFont );
-
+
if ( mShowSubitemsNotes ) {
if ( (*it)->relations().isEmpty() || (*it)->type() != "Todo" ) {
- int notesPosition = drawBoxWithCaption( p, notesBox, i18n("Notes:"),
- TQString::null, /*sameLine=*/false, /*expand=*/false,
+ int notesPosition = drawBoxWithCaption( p, notesBox, i18n("Notes:"),
+ TQString::null, /*sameLine=*/false, /*expand=*/false,
captionFont, textFont );
TQPen oldPen( p.pen() );
p.setPen( Qt::DotLine );
@@ -405,18 +442,104 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
}
p.setPen( oldPen );
} else {
- int subitemsStart = drawBoxWithCaption( p, notesBox, i18n("Subitems:"),
- (*it)->description(), /*sameLine=*/false,
+ Incidence::List relations = (*it)->relations();
+ TQString subitemCaption;
+ if ( relations.count() == 0 ) {
+ subitemCaption = i18n( "No Subitems" );
+ txt == "";
+ } else {
+ subitemCaption = i18n( "1 Subitem:",
+ "%1 Subitems:",
+ relations.count() );
+ }
+ Incidence::List::ConstIterator rit;
+ TQString subitemString;
+ TQString statusString;
+ TQString datesString;
+ int count = 0;
+ for ( rit = relations.begin(); rit != relations.end(); ++rit ) {
+ ++count;
+ if ( !(*rit) ) { // defensive, skip any zero pointers
+ continue;
+ }
+ // format the status
+ statusString = (*rit)->statusStr();
+ if ( statusString.isEmpty() ) {
+ if ( (*rit)->status() == Incidence::StatusNone ) {
+ statusString = i18n( "no status", "none" );
+ } else {
+ statusString = i18n( "unknown status", "unknown" );
+ }
+ }
+ // format the dates if provided
+ datesString = "";
+ if ( (*rit)->dtStart().isValid() ) {
+ datesString += i18n(
+ "Start Date: %1\n").arg(
+ KGlobal::locale()->formatDate( (*rit)->dtStart().date(),
+ true ) );
+ if ( !(*rit)->doesFloat() ) {
+ datesString += i18n(
+ "Start Time: %1\n").arg(
+ KGlobal::locale()->formatTime((*rit)->dtStart().time(),
+ false, false) );
+ }
+ }
+ if ( (*rit)->dtEnd().isValid() ) {
+ subitemString += i18n(
+ "Due Date: %1\n").arg(
+ KGlobal::locale()->formatDate( (*rit)->dtEnd().date(),
+ true ) );
+ if ( !(*rit)->doesFloat() ) {
+ subitemString += i18n(
+ "subitem due time", "Due Time: %1\n").arg(
+ KGlobal::locale()->formatTime((*rit)->dtEnd().time(),
+ false, false) );
+ }
+ }
+ subitemString += i18n("subitem counter", "%1: ", count);
+ subitemString += (*rit)->summary();
+ subitemString += "\n";
+ if ( !datesString.isEmpty() ) {
+ subitemString += datesString;
+ subitemString += "\n";
+ }
+ subitemString += i18n( "subitem Status: statusString",
+ "Status: %1\n").arg( statusString );
+ subitemString += IncidenceFormatter::recurrenceString((*rit)) + "\n";
+ subitemString += i18n( "subitem Priority: N",
+ "Priority: %1\n").arg( (*rit)->priority() );
+ subitemString += i18n( "subitem Secrecy: secrecyString",
+ "Secrecy: %1\n").arg( (*rit)->secrecyStr() );
+ subitemString += "\n";
+ }
+ drawBoxWithCaption( p, notesBox, i18n("Subitems:"),
+ (*it)->description(), /*sameLine=*/false,
/*expand=*/false, captionFont, textFont );
- // TODO: Draw subitems
}
}
if ( mShowAttachments ) {
- int attachStart = drawBoxWithCaption( p, attachmentsBox,
- i18n("Attachments:"), TQString::null, /*sameLine=*/false,
- /*expand=*/false, captionFont, textFont );
- // TODO: Print out the attachments somehow
+ Attachment::List attachments = (*it)->attachments();
+ TQString attachmentCaption;
+ if ( attachments.count() == 0 ) {
+ attachmentCaption = i18n( "No Attachments" );
+ txt = TQString();
+ } else {
+ attachmentCaption = i18n( "1 Attachment:", "%1 Attachments:", attachments.count() );
+ }
+ TQString attachmentString;
+ Attachment::List::ConstIterator ait = attachments.begin();
+ for ( ; ait != attachments.end(); ++ait ) {
+ if (!attachmentString.isEmpty()) {
+ attachmentString += i18n( "Spacer for list of attachments", " " );
+ }
+ attachmentString.append((*ait)->label());
+ }
+ drawBoxWithCaption( p, attachmentsBox,
+ attachmentCaption, attachmentString,
+ /*sameLine=*/false, /*expand=*/false,
+ captionFont, textFont );
}
if ( mShowAttendees ) {
@@ -436,7 +559,7 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
.arg( (*ait)->fullName() )
.arg( (*ait)->roleStr() ).arg( (*ait)->statusStr() );
}
- drawBoxWithCaption( p, attendeesBox, i18n("Attendees:"), attendeeString,
+ drawBoxWithCaption( p, attendeesBox, i18n("Attendees:"), attendeeString,
/*sameLine=*/false, /*expand=*/false, captionFont, textFont );
}
@@ -470,10 +593,12 @@ void CalPrintIncidence::print( TQPainter &p, int width, int height )
drawBoxWithCaption( p, optionsBox, i18n("Settings: "),
optionsString, /*sameLine=*/false, /*expand=*/false, captionFont, textFont );
}
-
+
drawBoxWithCaption( p, categoriesBox, i18n("Categories: "),
(*it)->categories().join( i18n("Spacer for the joined list of categories", ", ") ),
/*sameLine=*/true, /*expand=*/false, captionFont, textFont );
+
+ drawFooter( p, footerBox );
}
p.setFont( oldFont );
}
@@ -570,6 +695,12 @@ void CalPrintDay::print( TQPainter &p, int width, int height )
{
TQDate curDay( mFromDate );
+ TQRect headerBox( 0, 0, width, headerHeight() );
+ TQRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+ height -= footerHeight();
+
+ KLocale *local = KGlobal::locale();
+
do {
TQTime curStartTime( mStartTime );
TQTime curEndTime( mEndTime );
@@ -581,35 +712,89 @@ void CalPrintDay::print( TQPainter &p, int width, int height )
curEndTime = curStartTime.addSecs( 3600 );
}
- KLocale *local = KGlobal::locale();
- TQRect headerBox( 0, 0, width, headerHeight() );
drawHeader( p, local->formatDate( curDay ), curDay, TQDate(), headerBox );
-
-
Event::List eventList = mCalendar->events( curDay,
EventSortStartDate,
SortDirectionAscending );
- p.setFont( TQFont( "sans-serif", 12 ) );
+ // split out the all day events as they will be printed in a separate box
+ Event::List alldayEvents, timedEvents;
+ Event::List::ConstIterator it;
+ for ( it = eventList.begin(); it != eventList.end(); ++it ) {
+ if ( (*it)->doesFloat() ) {
+ alldayEvents.append( *it );
+ } else {
+ timedEvents.append( *it );
+ }
+ }
+
+ int fontSize = 11;
+ TQFont textFont( "sans-serif", fontSize, TQFont::Normal );
+ p.setFont( textFont );
+ uint lineSpacing = p.fontMetrics().lineSpacing();
- // TODO: Find a good way to determine the height of the all-day box
+ uint maxAllDayEvents = 8; // the max we allow to be printed, sorry.
+ uint allDayHeight = QMIN( alldayEvents.count(), maxAllDayEvents ) * lineSpacing;
+ allDayHeight = QMAX( allDayHeight, ( 5 * lineSpacing ) ) + ( 2 * padding() );
TQRect allDayBox( TIMELINE_WIDTH + padding(), headerBox.bottom() + padding(),
- 0, height / 20 );
- allDayBox.setRight( width );
- int allDayHeight = drawAllDayBox( p, eventList, curDay, true, allDayBox );
+ width - TIMELINE_WIDTH - padding(), allDayHeight );
+ if ( alldayEvents.count() > 0 ) {
+ // draw the side bar for all-day events
+ TQFont oldFont( p.font() );
+ p.setFont( TQFont( "sans-serif", 9, TQFont::Normal ) );
+ drawVerticalBox( p,
+ BOX_BORDER_WIDTH,
+ TQRect( 0, headerBox.bottom() + padding(), TIMELINE_WIDTH, allDayHeight ),
+ i18n( "Today's Events" ),
+ TQt::AlignHCenter | TQt::AlignVCenter | TQt::WordBreak );
+ p.setFont( oldFont );
+
+ // now draw at most maxAllDayEvents in the all-day box
+ drawBox( p, BOX_BORDER_WIDTH, allDayBox );
+
+ Event::List::ConstIterator it;
+ TQRect eventBox( allDayBox );
+ eventBox.setLeft( TIMELINE_WIDTH + ( 2 * padding() ) );
+ eventBox.setTop( eventBox.top() + padding() );
+ eventBox.setBottom( eventBox.top() + lineSpacing );
+ uint count = 0;
+ for ( it = alldayEvents.begin(); it != alldayEvents.end(); ++it ) {
+ if ( count == maxAllDayEvents ) {
+ break;
+ }
+ count++;
+ TQString str;
+ if ( (*it)->location().isEmpty() ) {
+ str = cleanStr( (*it)->summary() );
+ } else {
+ str = i18n( "summary, location", "%1, %2" ).
+ arg( cleanStr( (*it)->summary() ), cleanStr( (*it)->location() ) );
+ }
+ printEventString( p, eventBox, str );
+ eventBox.setTop( eventBox.bottom() );
+ eventBox.setBottom( eventBox.top() + lineSpacing );
+ }
+ } else {
+ allDayBox.setBottom( headerBox.bottom() );
+ }
TQRect dayBox( allDayBox );
- dayBox.setTop( allDayHeight /*allDayBox.bottom()*/ );
+ dayBox.setTop( allDayBox.bottom() + padding() );
dayBox.setBottom( height );
- drawAgendaDayBox( p, eventList, curDay, mIncludeAllEvents,
+ drawAgendaDayBox( p, timedEvents, curDay, mIncludeAllEvents,
curStartTime, curEndTime, dayBox );
TQRect tlBox( dayBox );
tlBox.setLeft( 0 );
tlBox.setWidth( TIMELINE_WIDTH );
drawTimeLine( p, curStartTime, curEndTime, tlBox );
+
+ drawFooter( p, footerBox );
+
curDay = curDay.addDays( 1 );
- if ( curDay <= mToDate ) mPrinter->newPage();
+ if ( curDay <= mToDate ) {
+ mPrinter->newPage();
+ }
} while ( curDay <= mToDate );
}
@@ -728,6 +913,9 @@ void CalPrintWeek::print( TQPainter &p, int width, int height )
TQString line1, line2, title;
TQRect headerBox( 0, 0, width, headerHeight() );
+ TQRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+ height -= footerHeight();
+
TQRect weekBox( headerBox );
weekBox.setTop( headerBox.bottom() + padding() );
weekBox.setBottom( height );
@@ -744,7 +932,11 @@ void CalPrintWeek::print( TQPainter &p, int width, int height )
}
title = title.arg( line1 ).arg( line2 );
drawHeader( p, title, curWeek.addDays( -6 ), TQDate(), headerBox );
+
drawWeek( p, curWeek, weekBox );
+
+ drawFooter( p, footerBox );
+
curWeek = curWeek.addDays( 7 );
if ( curWeek <= toWeek )
mPrinter->newPage();
@@ -763,11 +955,14 @@ void CalPrintWeek::print( TQPainter &p, int width, int height )
}
title = title.arg( line1 ).arg( line2 ).arg( curWeek.weekNumber() );
drawHeader( p, title, curWeek, TQDate(), headerBox );
+
TQRect weekBox( headerBox );
weekBox.setTop( headerBox.bottom() + padding() );
weekBox.setBottom( height );
-
drawTimeTable( p, fromWeek, curWeek, mStartTime, mEndTime, weekBox );
+
+ drawFooter( p, footerBox );
+
fromWeek = fromWeek.addDays( 7 );
curWeek = fromWeek.addDays( 6 );
if ( curWeek <= toWeek )
@@ -792,6 +987,8 @@ void CalPrintWeek::print( TQPainter &p, int width, int height )
drawTimeTable( p, endLeft.addDays( 1 ), curWeek,
mStartTime, mEndTime, weekBox1 );
+ drawFooter( p, footerBox );
+
fromWeek = fromWeek.addDays( 7 );
curWeek = fromWeek.addDays( 6 );
if ( curWeek <= toWeek )
@@ -910,6 +1107,9 @@ void CalPrintMonth::print( TQPainter &p, int width, int height )
if ( !calSys ) return;
TQRect headerBox( 0, 0, width, headerHeight() );
+ TQRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+ height -= footerHeight();
+
TQRect monthBox( 0, 0, width, height );
monthBox.setTop( headerBox.bottom() + padding() );
@@ -924,6 +1124,9 @@ void CalPrintMonth::print( TQPainter &p, int width, int height )
drawHeader( p, title, curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
headerBox );
drawMonthTable( p, curMonth, mWeekNumbers, mRecurDaily, mRecurWeekly, monthBox );
+
+ drawFooter( p, footerBox );
+
curMonth = curMonth.addDays( curMonth.daysInMonth() );
if ( curMonth <= toMonth ) mPrinter->newPage();
} while ( curMonth <= toMonth );
@@ -1054,30 +1257,32 @@ void CalPrintTodos::saveConfig()
void CalPrintTodos::print( TQPainter &p, int width, int height )
{
// TODO: Find a good way to guarantee a nicely designed output
- int pospriority = 10;
- int possummary = 60;
+ int pospriority = 0;
+ int possummary = 100;
int posdue = width - 65;
int poscomplete = posdue - 70; //Complete column is to right of the Due column
int lineSpacing = 15;
int fontHeight = 10;
+ TQRect headerBox( 0, 0, width, headerHeight() );
+ TQRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+ height -= footerHeight();
+
// Draw the First Page Header
- drawHeader( p, mPageTitle, mFromDate, TQDate(),
- TQRect( 0, 0, width, headerHeight() ) );
+ drawHeader( p, mPageTitle, mFromDate, TQDate(), headerBox );
// Draw the Column Headers
int mCurrentLinePos = headerHeight() + 5;
TQString outStr;
TQFont oldFont( p.font() );
- p.setFont( TQFont( "sans-serif", 10, TQFont::Bold ) );
+ p.setFont( TQFont( "sans-serif", 9, TQFont::Bold ) );
lineSpacing = p.fontMetrics().lineSpacing();
mCurrentLinePos += lineSpacing;
if ( mIncludePriority ) {
outStr += i18n( "Priority" );
p.drawText( pospriority, mCurrentLinePos - 2, outStr );
} else {
- possummary = 10;
pospriority = -1;
}
@@ -1179,8 +1384,9 @@ void CalPrintTodos::print( TQPainter &p, int width, int height )
0, 0, mCurrentLinePos, width, height, todoList );
}
}
+
+ drawFooter( p, footerBox );
p.setFont( oldFont );
}
-
#endif
diff --git a/korganizer/printing/calprintdefaultplugins.h b/korganizer/printing/calprintdefaultplugins.h
index 79a909a8..a1652643 100644
--- a/korganizer/printing/calprintdefaultplugins.h
+++ b/korganizer/printing/calprintdefaultplugins.h
@@ -42,10 +42,20 @@ class CalPrintIncidence : public CalPrintPluginBase
public:
CalPrintIncidence();
virtual ~CalPrintIncidence();
- virtual TQString description() { return i18n("Print &incidence"); }
- virtual TQString info() { return i18n("Prints an incidence on one page"); }
- virtual int sortID() { return CalPrinterBase::Incidence; }
- // Enable the Print Incidence option only if there are selected incidences.
+ virtual TQString description()
+ {
+ return i18n( "Print &incidence" );
+ }
+ virtual TQString info()
+ {
+ return i18n( "Prints an incidence on one page" );
+ }
+ virtual int sortID()
+ {
+ return CalPrinterBase::Incidence;
+ }
+
+ // Enable the Print Incidence option only if there are selected incidences.
virtual bool enabled()
{
if ( mSelectedIncidences.count() > 0 ) {
@@ -54,9 +64,11 @@ class CalPrintIncidence : public CalPrintPluginBase
return false;
}
}
- virtual TQWidget *createConfigWidget(TQWidget*);
+ virtual TQWidget *createConfigWidget( TQWidget * );
virtual KPrinter::Orientation defaultOrientation()
- { return KPrinter::Portrait; }
+ {
+ return KPrinter::Portrait;
+ }
public:
void print( TQPainter &p, int width, int height );
@@ -66,7 +78,7 @@ class CalPrintIncidence : public CalPrintPluginBase
virtual void saveConfig();
protected:
int printCaptionAndText( TQPainter &p, const TQRect &box, const TQString &caption,
- const TQString &text, TQFont captionFont, TQFont textFont );
+ const TQString &text, TQFont captionFont, TQFont textFont );
protected:
@@ -82,10 +94,22 @@ class CalPrintDay : public CalPrintPluginBase
public:
CalPrintDay();
virtual ~CalPrintDay();
- virtual TQString description() { return i18n("Print da&y"); }
- virtual TQString info() { return i18n("Prints all events of a single day on one page"); }
- virtual int sortID() { return CalPrinterBase::Day; }
- virtual bool enabled() { return true; }
+ virtual TQString description()
+ {
+ return i18n( "Print da&y" );
+ }
+ virtual TQString info()
+ {
+ return i18n( "Prints all events of a single day on one page" );
+ }
+ virtual int sortID()
+ {
+ return CalPrinterBase::Day;
+ }
+ virtual bool enabled()
+ {
+ return true;
+ }
virtual TQWidget *createConfigWidget( TQWidget* );
public:
@@ -107,11 +131,24 @@ class CalPrintWeek : public CalPrintPluginBase
public:
CalPrintWeek();
virtual ~CalPrintWeek();
- virtual TQString description() { return i18n("Print &week"); }
- virtual TQString info() { return i18n("Prints all events of one week on one page"); }
- virtual int sortID() { return CalPrinterBase::Week; }
- virtual bool enabled() { return true; }
- virtual TQWidget *createConfigWidget(TQWidget*);
+ virtual TQString description()
+ {
+ return i18n( "Print &week" );
+ }
+ virtual TQString info()
+ {
+ return i18n( "Prints all events of one week on one page" );
+ }
+ virtual int sortID()
+ {
+ return CalPrinterBase::Week;
+ }
+ virtual bool enabled()
+ {
+ return true;
+ }
+ virtual TQWidget *createConfigWidget( TQWidget * );
+
/**
Returns the default orientation for the eWeekPrintType.
*/
@@ -136,12 +173,28 @@ class CalPrintMonth : public CalPrintPluginBase
public:
CalPrintMonth();
virtual ~CalPrintMonth();
- virtual TQString description() { return i18n("Print mont&h"); }
- virtual TQString info() { return i18n("Prints all events of one month on one page"); }
- virtual int sortID() { return CalPrinterBase::Month; }
- virtual bool enabled() { return true; }
- virtual TQWidget *createConfigWidget(TQWidget*);
- virtual KPrinter::Orientation defaultOrientation() { return KPrinter::Landscape; }
+ virtual TQString description()
+ {
+ return i18n( "Print mont&h" );
+ }
+ virtual TQString info()
+ {
+ return i18n( "Prints all events of one month on one page" );
+ }
+ virtual int sortID()
+ {
+ return CalPrinterBase::Month;
+ }
+ virtual bool enabled()
+ {
+ return true;
+ }
+ virtual TQWidget *createConfigWidget( TQWidget * );
+ virtual KPrinter::Orientation defaultOrientation()
+ {
+ return KPrinter::Landscape;
+ }
+
public:
void print(TQPainter &p, int width, int height);
@@ -163,11 +216,23 @@ class CalPrintTodos : public CalPrintPluginBase
public:
CalPrintTodos();
virtual ~CalPrintTodos();
- virtual TQString description() { return i18n("Print to-&dos"); }
- virtual TQString info() { return i18n("Prints all to-dos in a (tree-like) list"); }
- virtual int sortID() { return CalPrinterBase::Todolist; }
- virtual bool enabled() { return true; }
- virtual TQWidget *createConfigWidget(TQWidget*);
+ virtual TQString description()
+ {
+ return i18n( "Print to-&dos" );
+ }
+ virtual TQString info()
+ {
+ return i18n( "Prints all to-dos in a (tree-like) list" );
+ }
+ virtual int sortID()
+ {
+ return CalPrinterBase::Todolist;
+ }
+ virtual bool enabled()
+ {
+ return true;
+ }
+ virtual TQWidget *createConfigWidget( TQWidget * );
public:
void print( TQPainter &p, int width, int height );
@@ -180,18 +245,23 @@ class CalPrintTodos : public CalPrintPluginBase
TQString mPageTitle;
enum eTodoPrintType {
- TodosAll = 0, TodosUnfinished, TodosDueRange
+ TodosAll = 0,
+ TodosUnfinished,
+ TodosDueRange
} mTodoPrintType;
enum eTodoSortField {
- TodoFieldSummary=0,
- TodoFieldStartDate, TodoFieldDueDate,
- TodoFieldPriority, TodoFieldPercentComplete,
+ TodoFieldSummary = 0,
+ TodoFieldStartDate,
+ TodoFieldDueDate,
+ TodoFieldPriority,
+ TodoFieldPercentComplete,
TodoFieldUnset
} mTodoSortField;
enum eTodoSortDirection {
- TodoDirectionAscending=0, TodoDirectionDescending,
+ TodoDirectionAscending = 0,
+ TodoDirectionDescending,
TodoDirectionUnset
} mTodoSortDirection;
@@ -205,5 +275,7 @@ class CalPrintTodos : public CalPrintPluginBase
bool mSortDirection;
};
+
#endif
+
#endif
diff --git a/korganizer/printing/calprintpluginbase.cpp b/korganizer/printing/calprintpluginbase.cpp
index 6f676203..e16e72c6 100644
--- a/korganizer/printing/calprintpluginbase.cpp
+++ b/korganizer/printing/calprintpluginbase.cpp
@@ -39,9 +39,16 @@
#ifndef KORG_NOPRINTER
inline int round(const double x)
- {
- return int(x > 0.0 ? x + 0.5 : x - 0.5);
- }
+{
+ return int(x > 0.0 ? x + 0.5 : x - 0.5);
+}
+
+static TQString cleanStr( const TQString &instr )
+{
+ TQString ret = instr;
+ return ret.replace( '\n', ' ' );
+}
+
/******************************************************************
** The Todo positioning structure **
******************************************************************/
@@ -108,8 +115,8 @@ class PrintCellItem : public KOrg::CellItem
CalPrintPluginBase::CalPrintPluginBase() : PrintPlugin(), mUseColors( true ),
- mHeaderHeight(-1), mSubHeaderHeight( SUBHEADER_HEIGHT ),
- mMargin( MARGIN_SIZE ), mPadding( PADDING_SIZE), mCalSys( 0 )
+ mHeaderHeight( -1 ), mSubHeaderHeight( SUBHEADER_HEIGHT ), mFooterHeight( -1 ),
+ mMargin( MARGIN_SIZE ), mPadding( PADDING_SIZE), mCalSys( 0 )
{
}
CalPrintPluginBase::~CalPrintPluginBase()
@@ -245,9 +252,9 @@ void CalPrintPluginBase::setCategoryColors( TQPainter &p, Incidence *incidence )
TQColor CalPrintPluginBase::categoryBgColor( Incidence *incidence )
{
- if (mCoreHelper && incidence)
+ if (mCoreHelper && incidence)
return mCoreHelper->categoryColor( incidence->categories() );
- else
+ else
return TQColor();
}
@@ -314,6 +321,20 @@ void CalPrintPluginBase::setSubHeaderHeight( const int height )
mSubHeaderHeight = height;
}
+int CalPrintPluginBase::footerHeight() const
+{
+ if ( mFooterHeight >= 0 )
+ return mFooterHeight;
+ else if ( orientation() == KPrinter::Portrait )
+ return PORTRAIT_FOOTER_HEIGHT;
+ else
+ return LANDSCAPE_FOOTER_HEIGHT;
+}
+void CalPrintPluginBase::setFooterHeight( const int height )
+{
+ mFooterHeight = height;
+}
+
int CalPrintPluginBase::margin() const
{
return mMargin;
@@ -370,7 +391,8 @@ void CalPrintPluginBase::printEventString( TQPainter &p, const TQRect &box, cons
}
-void CalPrintPluginBase::showEventBox( TQPainter &p, const TQRect &box, Incidence *incidence, const TQString &str, int flags )
+void CalPrintPluginBase::showEventBox( TQPainter &p, int linewidth, const TQRect &box,
+ Incidence *incidence, const TQString &str, int flags )
{
TQPen oldpen( p.pen() );
TQBrush oldbrush( p.brush() );
@@ -380,7 +402,7 @@ void CalPrintPluginBase::showEventBox( TQPainter &p, const TQRect &box, Incidenc
} else {
p.setBrush( TQColor( 232, 232, 232 ) );
}
- drawBox( p, EVENT_BORDER_WIDTH, box );
+ drawBox( p, ( linewidth > 0 ) ? linewidth : EVENT_BORDER_WIDTH, box );
if ( mUseColors && bgColor.isValid() ) {
p.setPen( textColor( bgColor ) );
@@ -391,8 +413,7 @@ void CalPrintPluginBase::showEventBox( TQPainter &p, const TQRect &box, Incidenc
}
-void CalPrintPluginBase::drawSubHeaderBox(TQPainter &p, const TQString &str,
- const TQRect &box )
+void CalPrintPluginBase::drawSubHeaderBox(TQPainter &p, const TQString &str, const TQRect &box )
{
drawShadedBox( p, BOX_BORDER_WIDTH, TQColor( 232, 232, 232 ), box );
TQFont oldfont( p.font() );
@@ -401,12 +422,14 @@ void CalPrintPluginBase::drawSubHeaderBox(TQPainter &p, const TQString &str,
p.setFont( oldfont );
}
-void CalPrintPluginBase::drawVerticalBox( TQPainter &p, const TQRect &box, const TQString &str )
+void CalPrintPluginBase::drawVerticalBox( TQPainter &p, int linewidth, const TQRect &box,
+ const TQString &str, int flags )
{
p.save();
p.rotate( -90 );
TQRect rotatedBox( -box.top()-box.height(), box.left(), box.height(), box.width() );
- showEventBox( p, rotatedBox, 0, str, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine );
+ showEventBox( p, linewidth, rotatedBox, 0, str,
+ ( flags == -1 ) ? Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine : flags );
p.restore();
}
@@ -414,10 +437,10 @@ void CalPrintPluginBase::drawVerticalBox( TQPainter &p, const TQRect &box, const
///////////////////////////////////////////////////////////////////////////////
-// Return value: If expand, bottom of the printed box, otherwise vertical end
+// Return value: If expand, bottom of the printed box, otherwise vertical end
// of the printed contents inside the box.
-int CalPrintPluginBase::drawBoxWithCaption( TQPainter &p, const TQRect &allbox,
+int CalPrintPluginBase::drawBoxWithCaption( TQPainter &p, const TQRect &allbox,
const TQString &caption, const TQString &contents, bool sameLine, bool expand, const TQFont &captionFont, const TQFont &textFont )
{
TQFont oldFont( p.font() );
@@ -428,17 +451,17 @@ int CalPrintPluginBase::drawBoxWithCaption( TQPainter &p, const TQRect &allbox,
TQRect box( allbox );
-
+
// Bounding rectangle for caption, single-line, clip on the right
TQRect captionBox( box.left() + padding(), box.top() + padding(), 0, 0 );
p.setFont( captionFont );
captionBox = p.boundingRect( captionBox, Qt::AlignLeft | Qt::AlignTop | Qt::SingleLine, caption );
p.setFont( oldFont );
- if ( captionBox.right() > box.right() )
+ if ( captionBox.right() > box.right() )
captionBox.setRight( box.right() );
- if ( expand && captionBox.bottom() + padding() > box.bottom() )
+ if ( expand && captionBox.bottom() + padding() > box.bottom() )
box.setBottom( captionBox.bottom() + padding() );
-
+
// Bounding rectangle for the contents (if any), word break, clip on the bottom
TQRect textBox( captionBox );
if ( !contents.isEmpty() ) {
@@ -460,7 +483,7 @@ int CalPrintPluginBase::drawBoxWithCaption( TQPainter &p, const TQRect &allbox,
}
}
}
-
+
drawBox( p, BOX_BORDER_WIDTH, box );
p.setFont( captionFont );
p.drawText( captionBox, Qt::AlignLeft | Qt::AlignTop | Qt::SingleLine, caption );
@@ -469,7 +492,7 @@ int CalPrintPluginBase::drawBoxWithCaption( TQPainter &p, const TQRect &allbox,
p.drawText( textBox, Qt::WordBreak | Qt::AlignTop | Qt::AlignLeft, contents );
}
p.setFont( oldFont );
-
+
if ( expand ) {
return box.bottom();
} else {
@@ -494,8 +517,8 @@ int CalPrintPluginBase::drawHeader( TQPainter &p, TQString title,
TQRect textRect( allbox );
textRect.addCoords( 5, 0, 0, 0 );
textRect.setRight( right );
-
-
+
+
TQFont oldFont( p.font() );
TQFont newFont("sans-serif", (textRect.height()<60)?16:18, TQFont::Bold);
if ( expand ) {
@@ -525,11 +548,24 @@ int CalPrintPluginBase::drawHeader( TQPainter &p, TQString title,
p.setFont( newFont );
p.drawText( textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::WordBreak, title );
p.setFont( oldFont );
-
+
return textRect.bottom();
}
+int CalPrintPluginBase::drawFooter( TQPainter &p, TQRect &footbox )
+{
+ TQFont oldfont( p.font() );
+ p.setFont( TQFont( "sans-serif", 6 ) );
+ TQFontMetrics fm( p.font() );
+ TQString dateStr = KGlobal::locale()->formatDateTime( TQDateTime::currentDateTime(), false );
+ p.drawText( footbox, TQt::AlignCenter | TQt::AlignVCenter | TQt::SingleLine,
+ i18n( "print date: formatted-datetime", "printed: %1" ).arg( dateStr ) );
+ p.setFont( oldfont );
+
+ return footbox.bottom();
+}
+
void CalPrintPluginBase::drawSmallMonth(TQPainter &p, const TQDate &qd,
const TQRect &box )
{
@@ -623,79 +659,78 @@ void CalPrintPluginBase::drawDaysOfWeekBox(TQPainter &p, const TQDate &qd,
}
-void CalPrintPluginBase::drawTimeLine(TQPainter &p,
- const TQTime &fromTime, const TQTime &toTime,
- const TQRect &box)
+void CalPrintPluginBase::drawTimeLine( TQPainter &p, const TQTime &fromTime,
+ const TQTime &toTime, const TQRect &box )
{
drawBox( p, BOX_BORDER_WIDTH, box );
- int totalsecs=fromTime.secsTo(toTime);
- float minlen=(float)box.height()*60./(float)totalsecs;
- float cellHeight=(60.*(float)minlen);
- float currY=box.top();
+ int totalsecs = fromTime.secsTo( toTime );
+ float minlen = (float)box.height() * 60. / (float)totalsecs;
+ float cellHeight = ( 60. * (float)minlen );
+ float currY = box.top();
// TODO: Don't use half of the width, but less, for the minutes!
- int xcenter = box.left()+box.width()/2;
+ int xcenter = box.left() + box.width() / 2;
TQTime curTime( fromTime );
TQTime endTime( toTime );
- if ( fromTime.minute() > 30 )
+ if ( fromTime.minute() > 30 ) {
curTime = TQTime( fromTime.hour()+1, 0, 0 );
- else if ( fromTime.minute() > 0 ) {
+ } else if ( fromTime.minute() > 0 ) {
curTime = TQTime( fromTime.hour(), 30, 0 );
- float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.;
+ float yy = currY + minlen * (float)fromTime.secsTo( curTime ) / 60.;
p.drawLine( xcenter, (int)yy, box.right(), (int)yy );
- curTime = TQTime( fromTime.hour()+1, 0, 0 );
+ curTime = TQTime( fromTime.hour() + 1, 0, 0 );
}
- currY += ( float( fromTime.secsTo(curTime)*minlen ) / 60. );
+ currY += ( float( fromTime.secsTo( curTime ) * minlen ) / 60. );
while ( curTime < endTime ) {
p.drawLine( box.left(), (int)currY, box.right(), (int)currY );
- int newY=(int)(currY+cellHeight/2.);
+ int newY = (int)( currY + cellHeight / 2. );
TQString numStr;
if ( newY < box.bottom() ) {
TQFont oldFont( p.font() );
// draw the time:
if ( !KGlobal::locale()->use12Clock() ) {
- p.drawLine( xcenter, (int)newY, box.right(), (int)newY);
- numStr.setNum(curTime.hour());
- if (cellHeight > 30) {
- p.setFont(TQFont("sans-serif", 16, TQFont::Bold));
+ p.drawLine( xcenter, (int)newY, box.right(), (int)newY );
+ numStr.setNum( curTime.hour() );
+ if ( cellHeight > 30 ) {
+ p.setFont( TQFont( "sans-serif", 14, TQFont::Bold ) );
} else {
- p.setFont(TQFont("sans-serif", 12, TQFont::Bold));
+ p.setFont( TQFont( "sans-serif", 12, TQFont::Bold ) );
}
- p.drawText( box.left()+2, (int)currY+2, box.width()/2-2, (int)cellHeight,
- Qt::AlignTop | Qt::AlignRight, numStr);
- p.setFont(TQFont("sans-serif", 10, TQFont::Normal));
- p.drawText( xcenter, (int)currY+2, box.width()/2+2, (int)(cellHeight/2)-3,
- Qt::AlignTop | Qt::AlignLeft, "00");
+ p.drawText( box.left() + 4, (int)currY + 2, box.width() / 2 - 2, (int)cellHeight,
+ Qt::AlignTop | Qt::AlignRight, numStr );
+ p.setFont( TQFont ( "helvetica", 10, TQFont::Normal ) );
+ p.drawText( xcenter + 4, (int)currY + 2, box.width() / 2 + 2, (int)(cellHeight / 2 ) - 3,
+ Qt::AlignTop | Qt::AlignLeft, "00" );
} else {
- p.drawLine( box.left(), (int)newY, box.right(), (int)newY);
+ p.drawLine( box.left(), (int)newY, box.right(), (int)newY );
TQTime time( curTime.hour(), 0 );
numStr = KGlobal::locale()->formatTime( time );
if ( box.width() < 60 ) {
- p.setFont(TQFont("sans-serif", 8, TQFont::Bold)); // for weekprint
+ p.setFont( TQFont( "sans-serif", 7, TQFont::Bold ) ); // for weekprint
} else {
- p.setFont(TQFont("sans-serif", 12, TQFont::Bold)); // for dayprint
+ p.setFont( TQFont( "sans-serif", 12, TQFont::Bold ) ); // for dayprint
}
- p.drawText(box.left()+2, (int)currY+2, box.width()-4, (int)cellHeight/2-3,
- Qt::AlignTop|Qt::AlignLeft, numStr);
+ p.drawText( box.left() + 2, (int)currY + 2, box.width() - 4, (int)cellHeight / 2 - 3,
+ Qt::AlignTop|Qt::AlignLeft, numStr );
}
- currY+=cellHeight;
+ currY += cellHeight;
p.setFont( oldFont );
} // enough space for half-hour line and time
- if (curTime.secsTo(endTime)>3600)
- curTime=curTime.addSecs(3600);
- else curTime=endTime;
+ if ( curTime.secsTo( endTime ) > 3600 ) {
+ curTime = curTime.addSecs( 3600 );
+ } else {
+ curTime = endTime;
+ }
} // currTime<endTime
}
-
-///////////////////////////////////////////////////////////////////////////////
-
-/** prints the all-day box for the agenda print view. if expandable is set,
- height is the cell height of a single cell, and the returned height will
- be the total height used for the all-day events. If !expandable, only one
- cell will be used, and multiple events are concatenated using ", ".
+/**
+ prints the all-day box for the agenda print view. if expandable is set,
+ height is the cell height of a single cell, and the returned height will
+ be the total height used for the all-day events. If !expandable, only one
+ cell will be used, and multiple events are concatenated using ", ".
*/
int CalPrintPluginBase::drawAllDayBox(TQPainter &p, Event::List &eventList,
const TQDate &qd, bool expandable, const TQRect &box )
@@ -721,7 +756,7 @@ int CalPrintPluginBase::drawAllDayBox(TQPainter &p, Event::List &eventList,
if ( expandable ) {
TQRect 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() ) multiDayStr += ", ";
@@ -867,7 +902,22 @@ void CalPrintPluginBase::drawAgendaItem( PrintCellItem *item, TQPainter &p,
int currentHeight = int( box.top() + startPrintDate.secsTo( endTime ) * minlen / 60. ) - currentYPos;
TQRect eventBox( currentX, currentYPos, currentWidth, currentHeight );
- showEventBox( p, eventBox, event, event->summary() );
+ TQString str;
+ if ( event->location().isEmpty() ) {
+ str = i18n( "starttime - endtime summary",
+ "%1-%2 %3" ).
+ arg( KGlobal::locale()->formatTime( startTime.time() ) ).
+ arg( KGlobal::locale()->formatTime( endTime.time() ) ).
+ arg( cleanStr( event->summary() ) );
+ } else {
+ str = i18n( "starttime - endtime summary, location",
+ "%1-%2 %3, %4" ).
+ arg( KGlobal::locale()->formatTime( startTime.time() ) ).
+ arg( KGlobal::locale()->formatTime( endTime.time() ) ).
+ arg( cleanStr( event->summary() ) ).
+ arg( cleanStr( event->location() ) );
+ }
+ showEventBox( p, EVENT_BORDER_WIDTH, eventBox, event, str );
}
}
@@ -877,10 +927,8 @@ void CalPrintPluginBase::drawDayBox( TQPainter &p, const TQDate &qd,
bool fullDate, bool printRecurDaily, bool printRecurWeekly )
{
TQString dayNumStr;
- TQString ampm;
const KLocale*local = KGlobal::locale();
-
// This has to be localized
if ( fullDate && mCalSys ) {
@@ -915,7 +963,7 @@ void CalPrintPluginBase::drawDayBox( TQPainter &p, const TQDate &qd,
Event::List eventList = mCalendar->events( qd,
EventSortStartDate,
SortDirectionAscending );
- TQString text;
+ TQString timeText;
p.setFont( TQFont( "sans-serif", 8 ) );
int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry
@@ -925,28 +973,60 @@ void CalPrintPluginBase::drawDayBox( TQPainter &p, const TQDate &qd,
Event *currEvent = *it;
if ( ( !printRecurDaily && currEvent->recurrenceType() == Recurrence::rDaily ) ||
( !printRecurWeekly && currEvent->recurrenceType() == Recurrence::rWeekly ) ) {
- continue; }
- if ( currEvent->doesFloat() || currEvent->isMultiDay() )
- text = "";
- else
- text = local->formatTime( currEvent->dtStart().time() );
+ continue;
+ }
+ if ( currEvent->doesFloat() || currEvent->isMultiDay() ) {
+ timeText = "";
+ } else {
+ timeText = local->formatTime( currEvent->dtStart().time() );
+ }
- drawIncidence( p, box, text, currEvent->summary(), textY );
+ TQString str;
+ if ( !currEvent->location().isEmpty() ) {
+ str = i18n( "summary, location", "%1, %2" ).
+ arg( currEvent->summary() ).arg( currEvent->location() );
+ } else {
+ str = currEvent->summary();
+ }
+ drawIncidence( p, box, timeText, str, textY );
}
- if ( textY<box.height() ) {
+ if ( textY < box.height() ) {
Todo::List todos = mCalendar->todos( qd );
Todo::List::ConstIterator it2;
- for( it2 = todos.begin(); it2 != todos.end() && textY<box.height(); ++it2 ) {
+ for ( it2 = todos.begin(); it2 != todos.end() && textY <box.height(); ++it2 ) {
Todo *todo = *it2;
if ( ( !printRecurDaily && todo->recurrenceType() == Recurrence::rDaily ) ||
- ( !printRecurWeekly && todo->recurrenceType() == Recurrence::rWeekly ) )
+ ( !printRecurWeekly && todo->recurrenceType() == Recurrence::rWeekly ) ) {
continue;
- if ( todo->hasDueDate() && !todo->doesFloat() )
- text += KGlobal::locale()->formatTime(todo->dtDue().time()) + " ";
- else
- text = "";
- drawIncidence( p, box, text, i18n("To-do: %1").arg(todo->summary()), textY );
+ }
+ if ( todo->hasStartDate() && !todo->doesFloat() ) {
+ timeText = KGlobal::locale()->formatTime( todo->dtStart().time() ) + " ";
+ } else {
+ timeText = "";
+ }
+ TQString summaryStr;
+ if ( !todo->location().isEmpty() ) {
+ summaryStr = i18n( "summary, location", "%1, %2" ).
+ arg( todo->summary() ).arg( todo->location() );
+ } else {
+ summaryStr = todo->summary();
+ }
+ TQString str;
+ if ( todo->hasDueDate() ) {
+ if ( !todo->doesFloat() ) {
+ str = i18n( "%1 (Due: %2)" ).
+ arg( summaryStr ).
+ arg( KGlobal::locale()->formatDateTime( todo->dtDue() ) );
+ } else {
+ str = i18n( "%1 (Due: %2)" ).
+ arg( summaryStr ).
+ arg( KGlobal::locale()->formatDate( todo->dtDue().date(), true ) );
+ }
+ } else {
+ str = summaryStr;
+ }
+ drawIncidence( p, box, timeText, i18n("To-do: %1").arg( str ), textY );
}
}
@@ -1088,14 +1168,14 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
int daysinmonth = calsys->daysInMonth( dt );
if ( maxdays <= 0 ) maxdays = daysinmonth;
-
+
int d;
float dayheight = float(daysBox.height()) / float( maxdays );
-
+
TQColor holidayColor( 240, 240, 240 );
TQColor workdayColor( 255, 255, 255 );
int dayNrWidth = p.fontMetrics().width( "99" );
-
+
// Fill the remaining space (if a month has less days than others) with a crossed-out pattern
if ( daysinmonth<maxdays ) {
TQRect dayBox( box.left(), daysBox.top() + round(dayheight*daysinmonth), box.width(), 0 );
@@ -1110,12 +1190,12 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
TQRect dayBox( daysBox.left()/*+rand()%50*/, daysBox.top() + round(dayheight*d), daysBox.width()/*-rand()%50*/, 0 );
// FIXME: When using a border width of 0 for event boxes, don't let the rectangles overlap, i.e. subtract 1 from the top or bottom!
dayBox.setBottom( daysBox.top()+round(dayheight*(d+1)) - 1 );
-
+
p.setBrush( isWorkingDay( day )?workdayColor:holidayColor );
p.drawRect( dayBox );
TQRect dateBox( dayBox );
dateBox.setWidth( dayNrWidth+3 );
- p.drawText( dateBox, Qt::AlignRight | Qt::AlignVCenter | Qt::SingleLine,
+ p.drawText( dateBox, Qt::AlignRight | Qt::AlignVCenter | Qt::SingleLine,
TQString::number(d+1) );
}
p.setBrush( oldbrush );
@@ -1154,16 +1234,16 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
}
}
}
-
+
TQValueList<MonthEventStruct> monthentries;
- for ( Event::List::ConstIterator evit = events.begin();
+ for ( Event::List::ConstIterator evit = events.begin();
evit != events.end(); ++evit ) {
Event *e = (*evit);
if (!e) continue;
if ( e->doesRecur() ) {
if ( e->recursOn( start ) ) {
- // This occurrence has possibly started before the beginning of the
+ // This occurrence has possibly started before the beginning of the
// month, so obtain the start date before the beginning of the month
TQValueList<TQDateTime> starttimes = e->startDateTimesForDate( start );
TQValueList<TQDateTime>::ConstIterator it = starttimes.begin();
@@ -1171,8 +1251,8 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
monthentries.append( MonthEventStruct( *it, e->endDateForStart( *it ), e ) );
}
}
- // Loop through all remaining days of the month and check if the event
- // begins on that day (don't use Event::recursOn, as that will
+ // Loop through all remaining days of the month and check if the event
+ // begins on that day (don't use Event::recursOn, as that will
// also return events that have started earlier. These start dates
// however, have already been treated!
Recurrence *recur = e->recurrence();
@@ -1216,7 +1296,7 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
timeboxItems.append( new PrintCellItem( (*mit).event, thisstart, thisend ) );
}
}
-
+
// For Multi-day events, line them up nicely so that the boxes don't overlap
TQPtrListIterator<KOrg::CellItem> it1( timeboxItems );
for( it1.toFirst(); it1.current(); ++it1 ) {
@@ -1225,7 +1305,7 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
}
TQDateTime starttime( start, TQTime( 0, 0, 0 ) );
int newxstartcont = xstartcont;
-
+
TQFont oldfont( p.font() );
p.setFont( TQFont( "sans-serif", 7 ) );
for( it1.toFirst(); it1.current(); ++it1 ) {
@@ -1233,11 +1313,11 @@ void CalPrintPluginBase::drawMonth( TQPainter &p, const TQDate &dt, const TQRect
int minsToStart = starttime.secsTo( placeItem->start() )/60;
int minsToEnd = starttime.secsTo( placeItem->end() )/60;
- TQRect eventBox( xstartcont + placeItem->subCell()*17,
- daysBox.top() + round( double( minsToStart*daysBox.height()) / double(maxdays*24*60) ),
+ TQRect eventBox( xstartcont + placeItem->subCell()*17,
+ daysBox.top() + round( double( minsToStart*daysBox.height()) / double(maxdays*24*60) ),
14, 0 );
eventBox.setBottom( daysBox.top() + round( 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;
diff --git a/korganizer/printing/calprintpluginbase.h b/korganizer/printing/calprintpluginbase.h
index 16a3374d..b845b379 100644
--- a/korganizer/printing/calprintpluginbase.h
+++ b/korganizer/printing/calprintpluginbase.h
@@ -48,6 +48,8 @@ using namespace KCal;
#define PORTRAIT_HEADER_HEIGHT 72 // header height, for portrait orientation
#define LANDSCAPE_HEADER_HEIGHT 54 // header height, for landscape orientation
#define SUBHEADER_HEIGHT 20 // subheader height, for all orientations
+#define PORTRAIT_FOOTER_HEIGHT 16 // footer height, for portrait orientation
+#define LANDSCAPE_FOOTER_HEIGHT 14 // footer height, for landscape orientation
#define MARGIN_SIZE 36 // margins, for all orientations
#define PADDING_SIZE 7 // padding between the various top-level boxes
#define BOX_BORDER_WIDTH 2 // width of the border of all top-level boxes
@@ -115,7 +117,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
void setKOrgCoreHelper( KOrg::CoreHelper*helper );
bool useColors() const;
void setUseColors( bool useColors );
-
+
/** Helper functions to hide the KOrg::CoreHelper */
TQColor categoryBgColor( Incidence *incidence );
TQColor textColor( const TQColor &color );
@@ -123,7 +125,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
bool isWorkingDay( const TQDate &dt );
TQString holidayString( const TQDate &dt );
Event *holiday( const TQDate &dt );
-
+
/**
Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the
start of the week setting into account as given in kcontrol.
@@ -135,7 +137,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
KPrinter::Orientation orientation() const;
/** Returns the height of the page header. If the height was explicitly
- set using setHeaderHeight, that value is returned, otherwise a
+ set using setHeaderHeight, that value is returned, otherwise a
default value based on the printer orientation.
\return height of the page header of the printout
*/
@@ -145,12 +147,20 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
int subHeaderHeight() const;
void setSubHeaderHeight( const int height );
+ /** Returns the height of the page footer. If the height was explicitly
+ set using setFooterHeight, that value is returned, otherwise a
+ default value based on the printer orientation.
+ \return height of the page footer of the printout
+ */
+ int footerHeight() const;
+ void setFooterHeight( const int height );
+
int margin() const;
void setMargin( const int margin );
-
+
int padding() const;
void setPadding( const int margin );
-
+
int borderWidth() const;
void setBorderWidth( const int border );
@@ -161,7 +171,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
/*****************************************************************
** PRINTING HELPER FUNCTIONS **
*****************************************************************/
- public:
+ public:
/**
Draw a box with given width at the given coordinates.
\param p The printer to be used
@@ -177,44 +187,51 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
\param rect The rectangle of the box
*/
static void drawShadedBox( TQPainter &p, int linewidth, const TQBrush &brush, const TQRect &rect );
-
+
/**
Print the given string (event summary) in the given rectangle. Margins
and justification (centered or not) are automatically adjusted.
\param p TQPainter of the printout
\param box Coordinates of the surrounding event box
\param str The text to be printed in the box
+ \param flags is a bitwise OR of TQt::AlignmentFlags and TQt::TextFlags values.
*/
void printEventString( TQPainter &p, const TQRect &box, const TQString &str, int flags = -1 );
/**
Print the box for the given event with the given string.
\param p QPainer 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 TQt::AlignmentFlags and TQt::TextFlags values.
*/
- void showEventBox( TQPainter &p, const TQRect &box, Incidence *incidence, const TQString &str, int flags = -1 );
-
- /**
+ void showEventBox( TQPainter &p, int linewidth, const TQRect &box, Incidence *incidence,
+ const TQString &str, int flags = -1 );
+
+ /**
Draw a subheader box with a shaded background and the given string
\param p TQPainter of the printout
\param str Text to be printed inside the box
\param box Coordinates of the box
*/
void drawSubHeaderBox(TQPainter &p, const TQString &str, const TQRect &box );
-
+
/**
Draw an event box with vertical text.
\param p TQPainter 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 TQt::AlignmentFlags and TQt::TextFlags values.
*/
- void drawVerticalBox( TQPainter &p, const TQRect &box, const TQString &str );
-
+ void drawVerticalBox( TQPainter &p, int linewidth, const TQRect &box, const TQString &str,
+ int flags=-1 );
+
/**
- Draw a component box with a heading (printed in bold).
+ Draw a component box with a heading (printed in bold).
\param p TQPainter of the printout
\param box Coordinates of the box
\param caption Caption string to be printed inside the box
@@ -222,7 +239,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
then no text will be printed, only the caption.
\param sameLine Whether the contents should start on the same line as
the caption (the space below the caption text will be
- used as indentation in the subsequent lines) or on the
+ used as indentation in the subsequent lines) or on the
next line (no indentation of the contents)
\param expand Whether to expand the box vertically to fit the
whole text in it.
@@ -234,7 +251,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
custom contents in that case.
*/
int drawBoxWithCaption( TQPainter &p, const TQRect &box, const TQString &caption,
- const TQString &contents,
+ const TQString &contents,
bool sameLine, bool expand, const TQFont &captionFont, const TQFont &textFont );
/**
@@ -260,13 +277,23 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
\param box coordinates of the title bar
\param expand Whether to expand the box vertically to fit the
whole title in it.
- \return The bottom of the printed box. If expand==false, this
+ \return The bottom of the printed box. If expand==false, this
is box.bottom, otherwise it is larger than box.bottom
and matches the y-coordinate of the surrounding rectangle.
*/
int drawHeader( TQPainter &p, TQString title,
const TQDate &month1, const TQDate &month2,
const TQRect &box, bool expand = false );
+
+ /**
+ Draw a page footer containing the printing date and possibly
+ other things, like a page number.
+ \param p TQPainter of the printout
+ \param box coordinates of the footer
+ \return The bottom of the printed box.
+ */
+ int drawFooter( TQPainter &p, TQRect &box );
+
/**
Draw a small calendar with the days of a month into the given area.
Used for example in the title bar of the sheet.
@@ -309,7 +336,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
void drawTimeLine( TQPainter &p,
const TQTime &fromTime, const TQTime &toTime,
const TQRect &box );
-
+
/**
Draw the all-day box for the agenda print view (the box on top which
doesn't have a time on the time scale associated). If expandable is set,
@@ -359,7 +386,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
const TQDateTime &startPrintDate,
const TQDateTime &endPrintDate,
float minlen, const TQRect &box );
-
+
/**
Draw the box containing a list of all events of the given day (with their times,
of course). Used in the Filofax and the month print style.
@@ -429,8 +456,8 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
\param dt Arbitrary date within the month to be printed
\param box coordinates of the box reserved for the month
\param maxdays Days to print. If a value of -1 is given, the number of days
- is deduced from the month. If maxdays is larger than the
- number of days in the month, the remaining boxes are
+ is deduced from the month. If maxdays is larger than the
+ number of days in the month, the remaining boxes are
shaded to indicate they are not days of the month.
\param subDailyFlags Bitfield consisting of DisplayFlags flags to determine
how events that do not cross midnight should be printed.
@@ -501,6 +528,7 @@ class KDE_EXPORT CalPrintPluginBase : public KOrg::PrintPlugin
bool mUseColors;
int mHeaderHeight;
int mSubHeaderHeight;
+ int mFooterHeight;
int mMargin;
int mPadding;
int mBorder;