summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calprintbase.cpp26
-rw-r--r--korganizer/calprinter.cpp2
2 files changed, 18 insertions, 10 deletions
diff --git a/korganizer/calprintbase.cpp b/korganizer/calprintbase.cpp
index 6bb407d..f66fddc 100644
--- a/korganizer/calprintbase.cpp
+++ b/korganizer/calprintbase.cpp
@@ -1,1304 +1,1312 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com> 5 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qfontmetrics.h> 32#include <qfontmetrics.h>
33 33
34#include <kglobal.h> 34#include <kglobal.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kconfig.h> 37#include <kconfig.h>
38#include <kcalendarsystem.h> 38#include <kcalendarsystem.h>
39#include <kprinter.h> 39#include <kprinter.h>
40 40
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42#include <libkcal/event.h> 42#include <libkcal/event.h>
43#include <libkcal/calendar.h> 43#include <libkcal/calendar.h>
44 44
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47#ifndef KORG_NOPLUGINS 47#ifndef KORG_NOPLUGINS
48#include "kocore.h" 48#include "kocore.h"
49#endif 49#endif
50#include "cellitem.h" 50#include "cellitem.h"
51 51
52#include "calprintbase.h" 52#include "calprintbase.h"
53 53
54#ifndef KORG_NOPRINTER 54#ifndef KORG_NOPRINTER
55//#include "calprintbase.moc" 55//#include "calprintbase.moc"
56 56
57int CalPrintBase::mHeaderHeight=90; 57int CalPrintBase::mHeaderHeight=90;
58int CalPrintBase::mSubHeaderHeight=20; 58int CalPrintBase::mSubHeaderHeight=20;
59int CalPrintBase::mMargin=36; 59int CalPrintBase::mMargin=36;
60 60
61 61
62 62
63class CalPrintBase::TodoParentStart 63class CalPrintBase::TodoParentStart
64{ 64{
65 public: 65 public:
66 TodoParentStart( QRect pt = QRect(), bool page = true ) 66 TodoParentStart( QRect pt = QRect(), bool page = true )
67 : mRect( pt ), mSamePage( page ) {} 67 : mRect( pt ), mSamePage( page ) {}
68 68
69 QRect mRect; 69 QRect mRect;
70 bool mSamePage; 70 bool mSamePage;
71}; 71};
72 72
73class PrintCellItem : public KOrg::CellItem 73class PrintCellItem : public KOrg::CellItem
74{ 74{
75 public: 75 public:
76 PrintCellItem( Event *event, const QDate &day ) 76 PrintCellItem( Event *event, const QDate &day )
77 : mEvent( event ), mDay( day ) 77 : mEvent( event ), mDay( day )
78 { 78 {
79 } 79 }
80 80
81 Event *event() const { return mEvent; } 81 Event *event() const { return mEvent; }
82 82
83 QString label() const { return mEvent->summary(); } 83 QString label() const { return mEvent->summary(); }
84 84
85 bool overlaps( KOrg::CellItem *o ) const 85 bool overlaps( KOrg::CellItem *o ) const
86 { 86 {
87 PrintCellItem *other = static_cast<PrintCellItem *>( o ); 87 PrintCellItem *other = static_cast<PrintCellItem *>( o );
88 88
89 QDateTime start = event()->dtStart(); 89 QDateTime start = event()->dtStart();
90 QDateTime end = event()->dtEnd(); 90 QDateTime end = event()->dtEnd();
91 if ( event()->doesRecur() ) { 91 if ( event()->doesRecur() ) {
92 start.setDate( mDay ); 92 start.setDate( mDay );
93 end.setDate( mDay ); 93 end.setDate( mDay );
94 } 94 }
95 QDateTime otherStart = other->event()->dtStart(); 95 QDateTime otherStart = other->event()->dtStart();
96 QDateTime otherEnd = other->event()->dtEnd(); 96 QDateTime otherEnd = other->event()->dtEnd();
97 if ( other->event()->doesRecur() ) { 97 if ( other->event()->doesRecur() ) {
98 otherStart.setDate( mDay ); 98 otherStart.setDate( mDay );
99 otherEnd.setDate( mDay ); 99 otherEnd.setDate( mDay );
100 } 100 }
101 101
102#if 0 102#if 0
103 kdDebug() << "PrintCellItem::overlaps() " << event()->summary() 103 kdDebug() << "PrintCellItem::overlaps() " << event()->summary()
104 << " <-> " << other->event()->summary() << endl; 104 << " <-> " << other->event()->summary() << endl;
105 kdDebug() << " start : " << start.toString() << endl; 105 kdDebug() << " start : " << start.toString() << endl;
106 kdDebug() << " end : " << end.toString() << endl; 106 kdDebug() << " end : " << end.toString() << endl;
107 kdDebug() << " otherStart: " << otherStart.toString() << endl; 107 kdDebug() << " otherStart: " << otherStart.toString() << endl;
108 kdDebug() << " otherEnd : " << otherEnd.toString() << endl; 108 kdDebug() << " otherEnd : " << otherEnd.toString() << endl;
109#endif 109#endif
110 110
111 return !( otherStart >= end || otherEnd <= start ); 111 return !( otherStart >= end || otherEnd <= start );
112 } 112 }
113 113
114 private: 114 private:
115 Event *mEvent; 115 Event *mEvent;
116 QDate mDay; 116 QDate mDay;
117}; 117};
118 118
119void setCategoryColors( QPainter &p, Incidence *incidence) 119void setCategoryColors( QPainter &p, Incidence *incidence)
120{ 120{
121 QColor bgColor; 121 QColor bgColor;
122 QStringList categories = incidence->categories(); 122 QStringList categories = incidence->categories();
123 QString cat = categories.first(); 123 QString cat = categories.first();
124 if (cat.isEmpty()) 124 if (cat.isEmpty())
125 bgColor = KOPrefs::instance()->mEventColor; 125 bgColor = KOPrefs::instance()->mEventColor;
126 else 126 else
127 bgColor = *(KOPrefs::instance()->categoryColor(cat)); 127 bgColor = *(KOPrefs::instance()->categoryColor(cat));
128 QColor textColor = Qt::black;//getTextColor(bgColor); 128 QColor textColor = Qt::black;//getTextColor(bgColor);
129 p.setPen( textColor ); 129 p.setPen( textColor );
130 p.setBrush( bgColor ); 130 p.setBrush( bgColor );
131} 131}
132 132
133 133
134 134
135CalPrintBase::CalPrintBase( KPrinter *printer, Calendar *cal, KConfig *cfg ) 135CalPrintBase::CalPrintBase( KPrinter *printer, Calendar *cal, KConfig *cfg )
136 : QObject(), mPrinter( printer ), mCalendar( cal ), mConfig( cfg ) 136 : QObject(), mPrinter( printer ), mCalendar( cal ), mConfig( cfg )
137{ 137{
138} 138}
139 139
140CalPrintBase::~CalPrintBase() 140CalPrintBase::~CalPrintBase()
141{ 141{
142} 142}
143 143
144 144
145 145
146QWidget *CalPrintBase::configWidget( QWidget *w ) 146QWidget *CalPrintBase::configWidget( QWidget *w )
147{ 147{
148 QFrame *wdg = new QFrame( w ); 148 QFrame *wdg = new QFrame( w );
149 QVBoxLayout *layout = new QVBoxLayout( wdg ); 149 QVBoxLayout *layout = new QVBoxLayout( wdg );
150 150
151 QLabel *title = new QLabel( description(), wdg ); 151 QLabel *title = new QLabel( description(), wdg );
152 QFont titleFont( title->font() ); 152 QFont titleFont( title->font() );
153 titleFont.setPointSize( 20 ); 153 titleFont.setPointSize( 20 );
154 titleFont.setBold( true ); 154 titleFont.setBold( true );
155 title->setFont( titleFont ); 155 title->setFont( titleFont );
156 156
157 layout->addWidget( title ); 157 layout->addWidget( title );
158 layout->addWidget( new QLabel( longDescription(), wdg ) ); 158 layout->addWidget( new QLabel( longDescription(), wdg ) );
159 layout->addSpacing( 20 ); 159 layout->addSpacing( 20 );
160 layout->addWidget( new QLabel( i18n("This printing style does not " 160 layout->addWidget( new QLabel( i18n("This printing style does not "
161 "have any configuration options."), 161 "have any configuration options."),
162 wdg ) ); 162 wdg ) );
163 layout->addStretch(); 163 layout->addStretch();
164 return wdg; 164 return wdg;
165} 165}
166#include <qapplication.h> 166#include <qapplication.h>
167void CalPrintBase::doPrint() 167void CalPrintBase::doPrint()
168{ 168{
169 QPainter p; 169 QPainter p;
170 170
171 mPrinter->setColorMode( (mUseColors)?(KPrinter::Color):(KPrinter::GrayScale)); 171 mPrinter->setColorMode( (mUseColors)?(KPrinter::Color):(KPrinter::GrayScale));
172 //#define DUMMY_PRINTER 172 //#define DUMMY_PRINTER
173#ifdef DUMMY_PRINTER 173#ifdef DUMMY_PRINTER
174 174
175 static QWidget* dummy = 0; 175 static QWidget* dummy = 0;
176 if ( ! dummy ) 176 if ( ! dummy )
177 dummy = new QWidget( ); 177 dummy = new QWidget( );
178 else { 178 else {
179 delete dummy; 179 delete dummy;
180 dummy = new QWidget( ); 180 dummy = new QWidget( );
181 181
182 } 182 }
183 dummy->resize( 1024, 1024 ); 183 dummy->resize( 1024, 1024 );
184 dummy->repaint(); 184 dummy->repaint();
185 dummy->show(); 185 dummy->show();
186 dummy->raise(); 186 dummy->raise();
187 dummy->setBackgroundColor( Qt::white); 187 dummy->setBackgroundColor( Qt::white);
188 qApp->processEvents(); 188 qApp->processEvents();
189 p.begin(dummy); 189 p.begin(dummy);
190#else 190#else
191 p.begin(mPrinter); 191 p.begin(mPrinter);
192#endif 192#endif
193 // the painter initially begins at 72 dpi per the Qt docs. 193 // the painter initially begins at 72 dpi per the Qt docs.
194 // we want half-inch margins. 194 // we want half-inch margins.
195 p.setViewport(mMargin, mMargin, 195 p.setViewport(mMargin, mMargin,
196 p.viewport().width()-mMargin, 196 p.viewport().width()-mMargin,
197 p.viewport().height()-mMargin); 197 p.viewport().height()-mMargin);
198 int pageWidth = p.viewport().width(); 198 int pageWidth = p.viewport().width();
199 int pageHeight = p.viewport().height(); 199 int pageHeight = p.viewport().height();
200 200
201 print(p, pageWidth, pageHeight); 201 print(p, pageWidth, pageHeight);
202 202
203 p.end(); 203 p.end();
204} 204}
205 205
206void CalPrintBase::doLoadConfig() 206void CalPrintBase::doLoadConfig()
207{ 207{
208 if ( mConfig ) { 208 if ( mConfig ) {
209 mConfig->setGroup(description()); 209 mConfig->setGroup(description());
210 //KConfigGroupSaver saver( mConfig, description() ); 210 //KConfigGroupSaver saver( mConfig, description() );
211 mConfig->sync(); 211 mConfig->sync();
212 QDateTime currDate( QDate::currentDate() ); 212 QDateTime currDate( QDate::currentDate() );
213 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date(); 213 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date();
214 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date(); 214 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date();
215 mUseColors = mConfig->readBoolEntry( "UseColors", false ); 215 mUseColors = mConfig->readBoolEntry( "UseColors", false );
216 loadConfig(); 216 loadConfig();
217 } else { 217 } else {
218 qDebug("no config in CalPrintBase::doLoadConfig "); 218 qDebug("no config in CalPrintBase::doLoadConfig ");
219 } 219 }
220} 220}
221 221
222void CalPrintBase::doSaveConfig() 222void CalPrintBase::doSaveConfig()
223{ 223{
224 if ( mConfig ) { 224 if ( mConfig ) {
225 mConfig->setGroup(description()); 225 mConfig->setGroup(description());
226 // KConfigGroupSaver saver( mConfig, description() ); 226 // KConfigGroupSaver saver( mConfig, description() );
227 saveConfig(); 227 saveConfig();
228 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) ); 228 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) );
229 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) ); 229 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) );
230 mConfig->writeEntry( "UseColors", mUseColors ); 230 mConfig->writeEntry( "UseColors", mUseColors );
231 mConfig->sync(); 231 mConfig->sync();
232 } else { 232 } else {
233 qDebug("no config in CalPrintBase::doSveConfig "); 233 qDebug("no config in CalPrintBase::doSveConfig ");
234 } 234 }
235} 235}
236 236
237/////////////////////////////////////////////////////////////////////////////// 237///////////////////////////////////////////////////////////////////////////////
238 238
239void CalPrintBase::drawHeader( QPainter &p, QString title, 239void CalPrintBase::drawHeader( QPainter &p, QString title,
240 const QDate &month1, const QDate &month2, 240 const QDate &month1, const QDate &month2,
241 int x, int y, int width, int height ) 241 int x, int y, int width, int height )
242{ 242{
243 p.drawRect(x, y, width, height); 243 p.drawRect(x, y, width, height);
244 // p.fillRect( x+1, y+1, 244 // p.fillRect( x+1, y+1,
245// width-2,height-2, 245// width-2,height-2,
246// QBrush(Dense7Pattern) ); 246// QBrush(Dense7Pattern) );
247 247
248 QString myOwner(mCalendar->getOwner()); 248 QString myOwner(mCalendar->getOwner());
249 249
250 int right=x+width; 250 int right=x+width;
251 251
252 // print previous month for month view, print current for todo, day and week 252 // print previous month for month view, print current for todo, day and week
253 int smallMonthWidth=width/4-10; 253 int smallMonthWidth=width/4-10;
254 if (smallMonthWidth>100) smallMonthWidth=100; 254 if (smallMonthWidth>100) smallMonthWidth=100;
255 if (month2.isValid()) { 255 if (month2.isValid()) {
256 right -= (10+smallMonthWidth); 256 right -= (10+smallMonthWidth);
257 drawSmallMonth(p, QDate(month2.year(), month2.month(), 1), 257 drawSmallMonth(p, QDate(month2.year(), month2.month(), 1),
258 right, y+2, smallMonthWidth, height-4); 258 right, y+2, smallMonthWidth, height-4);
259 right-=10; 259 right-=10;
260 } 260 }
261 if (month1.isValid()) { 261 if (month1.isValid()) {
262 right -= (10+smallMonthWidth); 262 right -= (10+smallMonthWidth);
263 drawSmallMonth(p, QDate(month1.year(), month1.month(), 1), 263 drawSmallMonth(p, QDate(month1.year(), month1.month(), 1),
264 right, y+2, smallMonthWidth, height-4); 264 right, y+2, smallMonthWidth, height-4);
265 right-=10; 265 right-=10;
266 } 266 }
267 267
268 // Print the titles... 268 // Print the titles...
269 QFont font("helvetica", 18, QFont::Bold); 269 QFont font("helvetica", 18, QFont::Bold);
270 p.setFont(font); 270 p.setFont(font);
271 QRect textRect( x+5, y+5, right-10-x, height-10 ); 271 QRect textRect( x+5, y+5, right-10-x, height-10 );
272 p.drawText( textRect, Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak, title ); 272 p.drawText( textRect, Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak, title );
273} 273}
274 274
275 275
276void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd, 276void CalPrintBase::drawSmallMonth(QPainter &p, const QDate &qd,
277 int x, int y, int width, int height) 277 int x, int y, int width, int height)
278{ 278{
279 bool firstCol = true; 279 bool firstCol = true;
280 QDate monthDate(QDate(qd.year(), qd.month(), 1)); 280 QDate monthDate(QDate(qd.year(), qd.month(), 1));
281 QDate monthDate2; 281 QDate monthDate2;
282 int month = monthDate.month(); 282 int month = monthDate.month();
283 283
284 // draw the title 284 // draw the title
285 p.setFont(QFont("helvetica", 7, QFont::Bold)); 285 p.setFont(QFont("helvetica", 7, QFont::Bold));
286 // int lineSpacing = p.fontMetrics().lineSpacing(); 286 // int lineSpacing = p.fontMetrics().lineSpacing();
287 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 287 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
288 p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) ); 288 p.drawText(x, y, width, height/4, AlignCenter, calSys->monthName( qd ) );
289 289
290 int cellWidth = width/7; 290 int cellWidth = width/7;
291 int cellHeight = height/8; 291 int cellHeight = height/8;
292 QString tmpStr; 292 QString tmpStr;
293 293
294 // correct begin of week 294 // correct begin of week
295 int weekdayCol = weekdayColumn( qd.dayOfWeek() ); 295 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
296 monthDate2 = monthDate.addDays(-weekdayCol); 296 monthDate2 = monthDate.addDays(-weekdayCol);
297 297
298 // draw days of week 298 // draw days of week
299 p.setFont(QFont("helvetica", 7, QFont::Bold)); 299 p.setFont(QFont("helvetica", 7, QFont::Bold));
300 for (int col = 0; col < 7; col++) { 300 for (int col = 0; col < 7; col++) {
301 // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek())); 301 // tmpStr.sprintf("%c",(const char*)monthDate2.dayName(monthDate2.dayOfWeek()));
302 tmpStr=calSys->weekDayName( monthDate2 )[0].upper(); 302 tmpStr=calSys->weekDayName( monthDate2 )[0].upper();
303 p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight, 303 p.drawText(x+col*cellWidth, y+height/4, cellWidth, cellHeight,
304 AlignCenter, tmpStr); 304 AlignCenter, tmpStr);
305 monthDate2 = monthDate2.addDays(1); 305 monthDate2 = monthDate2.addDays(1);
306 } 306 }
307 307
308 // draw separator line 308 // draw separator line
309 p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight); 309 p.drawLine(x, y+height/4+cellHeight, x+width, y+height/4+cellHeight);
310 310
311 for (int row = 0; row < 5; row++) { 311 for (int row = 0; row < 5; row++) {
312 for (int col = 0; col < 7; col++) { 312 for (int col = 0; col < 7; col++) {
313 if (monthDate.month() != month) 313 if (monthDate.month() != month)
314 break; 314 break;
315 if (firstCol) { 315 if (firstCol) {
316 firstCol = true; 316 firstCol = true;
317 col = weekdayColumn( monthDate.dayOfWeek() ); 317 col = weekdayColumn( monthDate.dayOfWeek() );
318 } 318 }
319 p.drawText( x+col*cellWidth, 319 p.drawText( x+col*cellWidth,
320 y+height/4+cellHeight+(row*cellHeight), 320 y+height/4+cellHeight+(row*cellHeight),
321 cellWidth, cellHeight, AlignCenter, 321 cellWidth, cellHeight, AlignCenter,
322 tmpStr.setNum(monthDate.day()) ); 322 tmpStr.setNum(monthDate.day()) );
323 monthDate = monthDate.addDays(1); 323 monthDate = monthDate.addDays(1);
324 } 324 }
325 } 325 }
326} 326}
327 327
328 328
329/////////////////////////////////////////////////////////////////////////////// 329///////////////////////////////////////////////////////////////////////////////
330 330
331/* 331/*
332 * This routine draws a header box over the main part of the calendar 332 * This routine draws a header box over the main part of the calendar
333 * containing the days of the week. 333 * containing the days of the week.
334 */ 334 */
335void CalPrintBase::drawDaysOfWeek(QPainter &p, 335void CalPrintBase::drawDaysOfWeek(QPainter &p,
336 const QDate &fromDate, const QDate &toDate, 336 const QDate &fromDate, const QDate &toDate,
337 int x, int y, int width, int height) 337 int x, int y, int width, int height)
338{ 338{
339 int cellWidth = width/(fromDate.daysTo( toDate )+1); 339 int cellWidth = width/(fromDate.daysTo( toDate )+1);
340 int currx=x; 340 int currx=x;
341 QDate cellDate(fromDate); 341 QDate cellDate(fromDate);
342 342
343 while (cellDate<=toDate) { 343 while (cellDate<=toDate) {
344 drawDaysOfWeekBox(p, cellDate, currx, y, cellWidth, height); 344 drawDaysOfWeekBox(p, cellDate, currx, y, cellWidth, height);
345 currx+=cellWidth; 345 currx+=cellWidth;
346 cellDate = cellDate.addDays(1); 346 cellDate = cellDate.addDays(1);
347 } 347 }
348} 348}
349 349
350 350
351void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd, 351void CalPrintBase::drawDaysOfWeekBox(QPainter &p, const QDate &qd,
352 int x, int y, int width, int height) 352 int x, int y, int width, int height)
353{ 353{
354 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 354 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
355 355
356 p.setFont( QFont( "helvetica", 10, QFont::Bold ) ); 356 p.setFont( QFont( "helvetica", 10, QFont::Bold ) );
357 p.drawRect( x, y, width, height ); 357 p.drawRect( x, y, width, height );
358// p.fillRect( x+1, y+1, 358// p.fillRect( x+1, y+1,
359// width-2, height-2, 359// width-2, height-2,
360// QBrush( Dense7Pattern ) ); 360// QBrush( Dense7Pattern ) );
361 p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter, 361 p.drawText( x+5, y, width-10, height, AlignCenter | AlignVCenter,
362 calSys->weekDayName( qd ) ); 362 calSys->weekDayName( qd ) );
363} 363}
364 364
365 365
366void CalPrintBase::drawTimeLine(QPainter &p, 366void CalPrintBase::drawTimeLine(QPainter &p,
367 const QTime &fromTime, const QTime &toTime, 367 const QTime &fromTime, const QTime &toTime,
368 int x, int y, int width, int height) 368 int x, int y, int width, int height)
369{ 369{
370 p.drawRect(x, y, width, height); 370 p.drawRect(x, y, width, height);
371 371
372 int totalsecs=fromTime.secsTo(toTime); 372 int totalsecs=fromTime.secsTo(toTime);
373 float minlen=(float)height*60./(float)totalsecs; 373 float minlen=(float)height*60./(float)totalsecs;
374 float cellHeight=(60.*(float)minlen); 374 float cellHeight=(60.*(float)minlen);
375 float currY=y; 375 float currY=y;
376 376
377 QTime curTime( fromTime ); 377 QTime curTime( fromTime );
378 QTime endTime( toTime ); 378 QTime endTime( toTime );
379 if ( fromTime.minute() > 30 ) 379 if ( fromTime.minute() > 30 )
380 curTime = QTime( fromTime.hour()+1, 0, 0 ); 380 curTime = QTime( fromTime.hour()+1, 0, 0 );
381 else if ( fromTime.minute() > 0 ) { 381 else if ( fromTime.minute() > 0 ) {
382 curTime = QTime( fromTime.hour(), 30, 0 ); 382 curTime = QTime( fromTime.hour(), 30, 0 );
383 float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.; 383 float yy = currY + minlen*(float)fromTime.secsTo( curTime )/60.;
384 p.drawLine( x+width/2, (int)yy, x+width, (int)yy ); 384 p.drawLine( x+width/2, (int)yy, x+width, (int)yy );
385 curTime = QTime( fromTime.hour()+1, 0, 0 ); 385 curTime = QTime( fromTime.hour()+1, 0, 0 );
386 } 386 }
387 currY += ( fromTime.secsTo(curTime)*minlen/60 ); 387 currY += ( fromTime.secsTo(curTime)*minlen/60 );
388 388
389 while ( curTime < endTime ) { 389 while ( curTime < endTime ) {
390 p.drawLine( x, (int)currY, x+width, (int)currY ); 390 p.drawLine( x, (int)currY, x+width, (int)currY );
391 int newY=(int)(currY+cellHeight/2.); 391 int newY=(int)(currY+cellHeight/2.);
392 QString numStr; 392 QString numStr;
393 if (newY < y+height) { 393 if (newY < y+height) {
394 p.drawLine(x+width/2, (int)newY, x+width, (int)newY); 394 p.drawLine(x+width/2, (int)newY, x+width, (int)newY);
395 // draw the time: 395 // draw the time:
396 if ( !KGlobal::locale()->use12Clock() ) { 396 if ( !KGlobal::locale()->use12Clock() ) {
397 numStr.setNum(curTime.hour()); 397 numStr.setNum(curTime.hour());
398 if (cellHeight > 30) { 398 if (cellHeight > 30) {
399 p.setFont(QFont("helvetica", 16, QFont::Bold)); 399 p.setFont(QFont("helvetica", 16, QFont::Bold));
400 } else { 400 } else {
401 p.setFont(QFont("helvetica", 12, QFont::Bold)); 401 p.setFont(QFont("helvetica", 12, QFont::Bold));
402 } 402 }
403 p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight, 403 p.drawText(x+2, (int)currY+2, width/2-2, (int)cellHeight,
404 AlignTop|AlignRight, numStr); 404 AlignTop|AlignRight, numStr);
405 p.setFont(QFont("helvetica", 10, QFont::Normal)); 405 p.setFont(QFont("helvetica", 10, QFont::Normal));
406 p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3, 406 p.drawText(x+width/2, (int)currY+2, width/2+2, (int)(cellHeight/2)-3,
407 AlignTop | AlignLeft, "00"); 407 AlignTop | AlignLeft, "00");
408 } else { 408 } else {
409 QTime time( curTime.hour(), 0 ); 409 QTime time( curTime.hour(), 0 );
410 numStr = KGlobal::locale()->formatTime( time ); 410 numStr = KGlobal::locale()->formatTime( time );
411 p.setFont(QFont("helvetica", 14, QFont::Bold)); 411 p.setFont(QFont("helvetica", 14, QFont::Bold));
412 p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3, 412 p.drawText(x+2, (int)currY+2, width-4, (int)cellHeight/2-3,
413 AlignTop|AlignLeft, numStr); 413 AlignTop|AlignLeft, numStr);
414 } 414 }
415 currY+=cellHeight; 415 currY+=cellHeight;
416 } // enough space for half-hour line and time 416 } // enough space for half-hour line and time
417 if (curTime.secsTo(endTime)>3600) 417 if (curTime.secsTo(endTime)>3600)
418 curTime=curTime.addSecs(3600); 418 curTime=curTime.addSecs(3600);
419 else curTime=endTime; 419 else curTime=endTime;
420 } // currTime<endTime 420 } // currTime<endTime
421} 421}
422 422
423 423
424/////////////////////////////////////////////////////////////////////////////// 424///////////////////////////////////////////////////////////////////////////////
425 425
426/** prints the all-day box for the agenda print view. if expandable is set, 426/** prints the all-day box for the agenda print view. if expandable is set,
427 height is the cell height of a single cell, and the returned height will 427 height is the cell height of a single cell, and the returned height will
428 be the total height used for the all-day events. If !expandable, only one 428 be the total height used for the all-day events. If !expandable, only one
429 cell will be used, and multiple events are concatenated using ", ". 429 cell will be used, and multiple events are concatenated using ", ".
430*/ 430*/
431void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList, 431void CalPrintBase::drawAllDayBox(QPainter &p, Event::List &eventList,
432 const QDate &qd, bool expandable, 432 const QDate &qd, bool expandable,
433 int x, int y, int width, int &height) 433 int x, int y, int width, int &height)
434{ 434{
435 Event::List::Iterator it, itold; 435 Event::List::Iterator it, itold;
436 436
437 int offset=y; 437 int offset=y;
438 438
439 //p.setBrush(QBrush(Dense7Pattern)); 439 //p.setBrush(QBrush(Dense7Pattern));
440 QPen oldPen(p.pen()); 440 QPen oldPen(p.pen());
441 QColor oldBgColor(p.backgroundColor()); 441 QColor oldBgColor(p.backgroundColor());
442 QBrush oldBrush(p.brush()); 442 QBrush oldBrush(p.brush());
443 QString multiDayStr; 443 QString multiDayStr;
444 444
445 it = eventList.begin(); 445 it = eventList.begin();
446#ifndef KORG_NOPLUGINS 446#ifndef KORG_NOPLUGINS
447 QString hstring(KOCore::self()->holiday(qd)); 447 QString hstring(KOCore::self()->holiday(qd));
448 if (!hstring.isEmpty()) { 448 if (!hstring.isEmpty()) {
449 Event*holiday=new Event(); 449 Event*holiday=new Event();
450 holiday->setDtStart(qd); 450 holiday->setDtStart(qd);
451 holiday->setDtEnd(qd); 451 holiday->setDtEnd(qd);
452 holiday->setFloats(true); 452 holiday->setFloats(true);
453 holiday->setCategories(i18n("Holiday")); 453 holiday->setCategories(i18n("Holiday"));
454 eventList.prepend(holiday); 454 eventList.prepend(holiday);
455 } 455 }
456#endif 456#endif
457 Event *currEvent = 0; 457 Event *currEvent = 0;
458 // First, print all floating events 458 // First, print all floating events
459 while( it!=eventList.end() ) { 459 while( it!=eventList.end() ) {
460 currEvent=*it; 460 currEvent=*it;
461 itold=it; 461 itold=it;
462 ++it; 462 ++it;
463 if ( currEvent->doesFloat() ) { 463 if ( currEvent->doesFloat() ) {
464 // set the colors according to the categories 464 // set the colors according to the categories
465 QString text = currEvent->summary() ; 465 QString text = currEvent->summary() ;
466 if ( ! currEvent->location().isEmpty() ) 466 if ( ! currEvent->location().isEmpty() )
467 text += " ("+currEvent->location()+")"; 467 text += " ("+currEvent->location()+")";
468 if (expandable) { 468 if (expandable) {
469 if (mUseColors) 469 if (mUseColors)
470 setCategoryColors(p, currEvent); 470 setCategoryColors(p, currEvent);
471 471
472 p.drawRect( x, offset, width, height ); 472 p.drawRect( x, offset, width, height );
473 473
474 p.drawText( x+5, offset+5, width-10, height-10, 474 p.drawText( x+5, offset+5, width-10, height-10,
475 AlignCenter | AlignVCenter | AlignJustify | WordBreak, 475 AlignCenter | AlignVCenter | AlignJustify | WordBreak,
476 text ); 476 text );
477 // reset the colors 477 // reset the colors
478 p.setBrush( oldBrush ); 478 p.setBrush( oldBrush );
479 p.setPen( oldPen ); 479 p.setPen( oldPen );
480 p.setBackgroundColor(oldBgColor); 480 p.setBackgroundColor(oldBgColor);
481 481
482 offset += height; 482 offset += height;
483 } else { 483 } else {
484 //if (!multiDayStr.isEmpty()) multiDayStr+=", "; 484 //if (!multiDayStr.isEmpty()) multiDayStr+=", ";
485 multiDayStr += text+"\n"; 485 multiDayStr += text+"\n";
486 } 486 }
487 eventList.remove( itold ); 487 eventList.remove( itold );
488 } 488 }
489 } 489 }
490 490
491 if (!expandable) { 491 if (!expandable) {
492 p.drawRect(x, offset, width, height); 492 p.drawRect(x, offset, width, height);
493 if (!multiDayStr.isEmpty()) { 493 if (!multiDayStr.isEmpty()) {
494 // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) ); 494 // p.fillRect(x+1, offset+1, width-2, height-2, QBrush(Dense5Pattern) );
495 p.drawText( x+5, offset+5, width-10, height-10, 495 p.drawText( x+5, offset+5, width-10, height-10,
496 AlignLeft | AlignTop | AlignJustify , 496 AlignLeft | AlignTop | AlignJustify ,
497 multiDayStr); 497 multiDayStr);
498 } 498 }
499 } else { 499 } else {
500 height=offset-y; 500 height=offset-y;
501 } 501 }
502} 502}
503 503
504 504
505void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events, 505void CalPrintBase::drawAgendaDayBox( QPainter &p, Event::List &events,
506 const QDate &qd, bool expandable, 506 const QDate &qd, bool expandable,
507 QTime &fromTime, QTime &toTime, 507 QTime &fromTime, QTime &toTime,
508 int x, int y, int width, int height ) 508 int x, int y, int width, int height )
509{ 509{
510 p.drawRect( x, y, width, height ); 510 p.drawRect( x, y, width, height );
511 511
512 Event *event; 512 Event *event;
513 513
514 if ( expandable ) { 514 if ( expandable ) {
515 // Adapt start/end times to include complete events 515 // Adapt start/end times to include complete events
516 Event::List::ConstIterator it; 516 Event::List::ConstIterator it;
517 for ( it = events.begin(); it != events.end(); ++it ) { 517 for ( it = events.begin(); it != events.end(); ++it ) {
518 event = *it; 518 event = *it;
519 if ( event->dtStart().time() < fromTime ) 519 if ( event->dtStart().time() < fromTime )
520 fromTime = event->dtStart().time(); 520 fromTime = event->dtStart().time();
521 if ( event->dtEnd().time() > toTime ) 521 if ( event->dtEnd().time() > toTime )
522 toTime = event->dtEnd().time(); 522 toTime = event->dtEnd().time();
523 } 523 }
524 } 524 }
525 525
526 // Show at least one hour 526 // Show at least one hour
527 if ( fromTime.secsTo( toTime ) < 3600 ) { 527 if ( fromTime.secsTo( toTime ) < 3600 ) {
528 fromTime = QTime( fromTime.hour(), 0, 0 ); 528 fromTime = QTime( fromTime.hour(), 0, 0 );
529 toTime = fromTime.addSecs( 3600 ); 529 toTime = fromTime.addSecs( 3600 );
530 } 530 }
531 531
532 // calculate the height of a cell and of a minute 532 // calculate the height of a cell and of a minute
533 int totalsecs = fromTime.secsTo( toTime ); 533 int totalsecs = fromTime.secsTo( toTime );
534 float minlen = height * 60. / totalsecs; 534 float minlen = height * 60. / totalsecs;
535 float cellHeight = 60. * minlen; 535 float cellHeight = 60. * minlen;
536 float currY = y; 536 float currY = y;
537 537
538 // print grid: 538 // print grid:
539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) ); 539 QTime curTime( QTime( fromTime.hour(), 0, 0 ) );
540 currY += fromTime.secsTo( curTime ) * minlen / 60; 540 currY += fromTime.secsTo( curTime ) * minlen / 60;
541 541
542 while ( curTime < toTime && curTime.isValid() ) { 542 while ( curTime < toTime && curTime.isValid() ) {
543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) ); 543 if ( currY > y ) p.drawLine( x, int( currY ), x + width, int( currY ) );
544 currY += cellHeight / 2; 544 currY += cellHeight / 2;
545 if ( ( currY > y ) && ( currY < y + height ) ) { 545 if ( ( currY > y ) && ( currY < y + height ) ) {
546 QPen oldPen( p.pen() ); 546 QPen oldPen( p.pen() );
547 p.setPen( QColor( 192, 192, 192 ) ); 547 p.setPen( QColor( 192, 192, 192 ) );
548 p.drawLine( x, int( currY ), x + width, int( currY ) ); 548 p.drawLine( x, int( currY ), x + width, int( currY ) );
549 p.setPen( oldPen ); 549 p.setPen( oldPen );
550 } // enough space for half-hour line 550 } // enough space for half-hour line
551 if ( curTime.secsTo( toTime ) > 3600 ) 551 if ( curTime.secsTo( toTime ) > 3600 )
552 curTime = curTime.addSecs( 3600 ); 552 curTime = curTime.addSecs( 3600 );
553 else curTime = toTime; 553 else curTime = toTime;
554 currY += cellHeight / 2; 554 currY += cellHeight / 2;
555 } 555 }
556 556
557 QDateTime startPrintDate = QDateTime( qd, fromTime ); 557 QDateTime startPrintDate = QDateTime( qd, fromTime );
558 QDateTime endPrintDate = QDateTime( qd, toTime ); 558 QDateTime endPrintDate = QDateTime( qd, toTime );
559 559
560 // Calculate horizontal positions and widths of events taking into account 560 // Calculate horizontal positions and widths of events taking into account
561 // overlapping events 561 // overlapping events
562 562
563 QPtrList<KOrg::CellItem> cells; 563 QPtrList<KOrg::CellItem> cells;
564 cells.setAutoDelete( true ); 564 cells.setAutoDelete( true );
565 565
566 Event::List::ConstIterator itEvents; 566 Event::List::ConstIterator itEvents;
567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) { 567 for( itEvents = events.begin(); itEvents != events.end(); ++itEvents ) {
568 cells.append( new PrintCellItem( *itEvents, qd ) ); 568 cells.append( new PrintCellItem( *itEvents, qd ) );
569 } 569 }
570 570
571 QPtrListIterator<KOrg::CellItem> it1( cells ); 571 QPtrListIterator<KOrg::CellItem> it1( cells );
572 for( it1.toFirst(); it1.current(); ++it1 ) { 572 for( it1.toFirst(); it1.current(); ++it1 ) {
573 KOrg::CellItem *placeItem = it1.current(); 573 KOrg::CellItem *placeItem = it1.current();
574 574
575 KOrg::CellItem::placeItem( cells, placeItem ); 575 KOrg::CellItem::placeItem( cells, placeItem );
576 } 576 }
577 577
578 QPen oldPen = p.pen(); 578 QPen oldPen = p.pen();
579 QColor oldBgColor = p.backgroundColor(); 579 QColor oldBgColor = p.backgroundColor();
580 QBrush oldBrush = p.brush(); 580 QBrush oldBrush = p.brush();
581 581
582 p.setFont( QFont( "helvetica", 10 ) ); 582 p.setFont( QFont( "helvetica", 10 ) );
583 //p.setBrush( QBrush( Dense7Pattern ) ); 583 //p.setBrush( QBrush( Dense7Pattern ) );
584 584
585 for( it1.toFirst(); it1.current(); ++it1 ) { 585 for( it1.toFirst(); it1.current(); ++it1 ) {
586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() ); 586 PrintCellItem *placeItem = static_cast<PrintCellItem *>( it1.current() );
587 587
588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x, 588 drawAgendaItem( placeItem, p, qd, startPrintDate, endPrintDate, minlen, x,
589 y, width ); 589 y, width );
590 590
591 p.setBrush( oldBrush ); 591 p.setBrush( oldBrush );
592 p.setPen( oldPen ); 592 p.setPen( oldPen );
593 p.setBackgroundColor( oldBgColor ); 593 p.setBackgroundColor( oldBgColor );
594 } 594 }
595 595
596 p.setBrush( QBrush( NoBrush ) ); 596 p.setBrush( QBrush( NoBrush ) );
597} 597}
598 598
599 599
600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p, 600void CalPrintBase::drawAgendaItem( PrintCellItem *item, QPainter &p,
601 const QDate &qd, 601 const QDate &qd,
602 const QDateTime &startPrintDate, 602 const QDateTime &startPrintDate,
603 const QDateTime &endPrintDate, 603 const QDateTime &endPrintDate,
604 float minlen, int x, int y, int width ) 604 float minlen, int x, int y, int width )
605{ 605{
606 Event *event = item->event(); 606 Event *event = item->event();
607 607
608 // set the colors according to the categories 608 // set the colors according to the categories
609 if ( mUseColors ) setCategoryColors( p, event ); 609 if ( mUseColors ) setCategoryColors( p, event );
610 else p.setBrush( Qt::white ); 610 else p.setBrush( Qt::white );
611 // start/end of print area for event 611 // start/end of print area for event
612 QDateTime startTime = event->dtStart(); 612 QDateTime startTime = event->dtStart();
613 QDateTime endTime = event->dtEnd(); 613 QDateTime endTime = event->dtEnd();
614 if ( event->doesRecur() ) { 614 if ( event->doesRecur() ) {
615 startTime.setDate( qd ); 615 startTime.setDate( qd );
616 endTime.setDate( qd ); 616 endTime.setDate( qd );
617 } 617 }
618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) || 618 if ( ( startTime < endPrintDate && endTime > startPrintDate ) ||
619 ( endTime > startPrintDate && startTime < endPrintDate ) ) { 619 ( endTime > startPrintDate && startTime < endPrintDate ) ) {
620 if ( startTime < startPrintDate ) startTime = startPrintDate; 620 if ( startTime < startPrintDate ) startTime = startPrintDate;
621 if ( endTime > endPrintDate ) endTime = endPrintDate; 621 if ( endTime > endPrintDate ) endTime = endPrintDate;
622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen ); 622 int eventLength = int( startTime.secsTo( endTime ) / 60. * minlen );
623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) * 623 int currentyPos = int( y + startPrintDate.secsTo( startTime ) *
624 minlen / 60. ); 624 minlen / 60. );
625 int currentWidth = width / item->subCells(); 625 int currentWidth = width / item->subCells();
626 int currentX = x + item->subCell() * currentWidth; 626 int currentX = x + item->subCell() * currentWidth;
627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+ 627 QString text = KGlobal::locale()->formatTime(event->dtStart().time())+
628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+ 628 "-"+KGlobal::locale()->formatTime(event->dtEnd().time())+
629 " "+event->summary(); 629 " "+event->summary();
630 if ( !event->location().isEmpty() ) 630 if ( !event->location().isEmpty() )
631 text += " (" +event->location()+")"; 631 text += " (" +event->location()+")";
632 // p.save(); 632 // p.save();
633 QPen pe = p.pen(); 633 QPen pe = p.pen();
634 pe.setWidth( 2 ); 634 pe.setWidth( 2 );
635 p.setPen( pe ); 635 p.setPen( pe );
636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 ); 636 p.drawRect( currentX, currentyPos+1, currentWidth+1, eventLength+1 );
637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3, 637 p.drawText( currentX+3, currentyPos+2, currentWidth-5, eventLength-3,
638 AlignLeft | AlignTop | AlignJustify | WordBreak, 638 AlignLeft | AlignTop | AlignJustify | WordBreak,
639 text); 639 text);
640 // p.restore(); 640 // p.restore();
641 } 641 }
642} 642}
643 643
644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd, 644void CalPrintBase::drawDayBox(QPainter &p, const QDate &qd,
645 int x, int y, int width, int height, 645 int x, int y, int width, int height,
646 bool fullDate) 646 bool fullDate)
647{ 647{
648 QString dayNumStr; 648 QString dayNumStr;
649 QString ampm; 649 QString ampm;
650 const KLocale*local = KGlobal::locale(); 650 const KLocale*local = KGlobal::locale();
651 651
652 652
653 // This has to be localized 653 // This has to be localized
654 if (fullDate) { 654 if (fullDate) {
655 /*int index; 655 /*int index;
656 dayNumStr= qd.toString(); 656 dayNumStr= qd.toString();
657 index = dayNumStr.find(' '); 657 index = dayNumStr.find(' ');
658 dayNumStr.remove(0, index); 658 dayNumStr.remove(0, index);
659 index = dayNumStr.findRev(' '); 659 index = dayNumStr.findRev(' ');
660 dayNumStr.truncate(index);*/ 660 dayNumStr.truncate(index);*/
661 661
662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 662 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
663 dayNumStr = i18n("weekday month date", "%1 %2 %3") 663 dayNumStr = i18n("weekday month date", "%1 %2 %3")
664 .arg( calSys->weekDayName( qd ) ) 664 .arg( calSys->weekDayName( qd ) )
665 .arg( calSys->monthName( qd ) ) 665 .arg( calSys->monthName( qd ) )
666 .arg( qd.day() ); 666 .arg( qd.day() );
667// dayNumStr = local->formatDate(qd); 667// dayNumStr = local->formatDate(qd);
668 } else { 668 } else {
669 dayNumStr = QString::number( qd.day() ); 669 dayNumStr = QString::number( qd.day() );
670 } 670 }
671 671
672 p.eraseRect( x, y, width, height ); 672 p.eraseRect( x, y, width, height );
673 p.drawRect( x, y, width, height ); 673 p.drawRect( x, y, width, height );
674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) ); 674 // p.fillRect( x+1, y+1, width-2,height, QBrush(Dense7Pattern) );
675 p.drawRect( x, y, width, mSubHeaderHeight ); 675 p.drawRect( x, y, width, mSubHeaderHeight );
676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) ); 676 //p.fillRect( x+1, y+1, width-2, mSubHeaderHeight-2, QBrush(Dense7Pattern) );
677 QString hstring; 677 QString hstring;
678#ifndef KORG_NOPLUGINS 678#ifndef KORG_NOPLUGINS
679 hstring=KOCore::self()->holiday(qd); 679 hstring=KOCore::self()->holiday(qd);
680#endif 680#endif
681 681
682 if (!hstring.isEmpty()) { 682 if (!hstring.isEmpty()) {
683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) ); 683 p.setFont( QFont( "helvetica", 8, QFont::Bold, true ) );
684 684
685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter, 685 p.drawText( x+5, y, width-25, mSubHeaderHeight, AlignLeft | AlignVCenter,
686 hstring ); 686 hstring );
687 } 687 }
688 p.setFont(QFont("helvetica", 10, QFont::Bold)); 688 p.setFont(QFont("helvetica", 10, QFont::Bold));
689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter, 689 p.drawText(x+5, y, width-10, mSubHeaderHeight, AlignRight | AlignVCenter,
690 dayNumStr); 690 dayNumStr);
691 Event::List eventList; 691 Event::List eventList;
692 eventList.fill( mCalendar->events( qd, true )); 692 eventList.fill( mCalendar->events( qd, true ));
693 Todo::List todos; 693 Todo::List todos;
694 todos.fill( mCalendar->todos( qd )); 694 todos.fill( mCalendar->todos( qd ));
695 QString outStr; 695 QString outStr;
696 p.setFont( QFont( "helvetica", 8 ) ); 696 p.setFont( QFont( "helvetica", 8 ) );
697 int lineSpacing = p.fontMetrics().lineSpacing(); 697 int lineSpacing = p.fontMetrics().lineSpacing();
698 698
699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry 699 int textY=mSubHeaderHeight+3; // gives the relative y-coord of the next printed entry
700 Event::List::ConstIterator it; 700 Event::List::ConstIterator it;
701 int entryCount = eventList.count() +todos.count(); 701 int entryCount = eventList.count() +todos.count();
702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) { 702 if ( p.fontMetrics().lineSpacing()* entryCount > height-textY ) {
703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) { 703 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) {
704 p.setFont( QFont( "helvetica", 7 ) ); 704 p.setFont( QFont( "helvetica", 7 ) );
705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY ) 705 if ( (p.fontMetrics().lineSpacing()-1) * entryCount > height-textY )
706 p.setFont( QFont( "helvetica", 6 ) ); 706 p.setFont( QFont( "helvetica", 6 ) );
707 } 707 }
708 lineSpacing = p.fontMetrics().lineSpacing()-1; 708 lineSpacing = p.fontMetrics().lineSpacing()-1;
709 } 709 }
710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY ); 710 // qDebug("fm %d %d %d ",p.fontMetrics().height(), eventList.count() , height-textY );
711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) { 711 for( it = eventList.begin(); it != eventList.end() && textY<height; ++it ) {
712 Event *currEvent = *it; 712 Event *currEvent = *it;
713 if (currEvent->doesFloat() || currEvent->isMultiDay()) 713 if (currEvent->doesFloat() || currEvent->isMultiDay())
714 outStr = currEvent->summary(); 714 outStr = currEvent->summary();
715 715
716 else { 716 else {
717 if ( fullDate ) { 717 if ( fullDate ) {
718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+ 718 outStr = KGlobal::locale()->formatTime( currEvent->dtStart().time())+
719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+ 719 "-"+KGlobal::locale()->formatTime( currEvent->dtEnd().time())+
720 " "+ currEvent->summary(); 720 " "+ currEvent->summary();
721 if ( ! currEvent->location().isEmpty() ) 721 if ( ! currEvent->location().isEmpty() )
722 outStr += " (" + currEvent->location()+")"; 722 outStr += " (" + currEvent->location()+")";
723 } else { 723 } else {
724 QTime t1 = currEvent->dtStart().time(); 724 QTime t1 = currEvent->dtStart().time();
725 725
726 outStr = local->formatTime(t1); 726 outStr = local->formatTime(t1);
727 outStr += " " + currEvent->summary(); 727 outStr += " " + currEvent->summary();
728 } 728 }
729 729
730 } // doesFloat 730 } // doesFloat
731 731
732 p.drawText(x+5, y+textY, width-10, lineSpacing, 732 p.drawText(x+5, y+textY, width-10, lineSpacing,
733 AlignLeft|AlignBottom, outStr); 733 AlignLeft|AlignBottom, outStr);
734 textY+=lineSpacing; 734 textY+=lineSpacing;
735 } 735 }
736 736
737 if ( textY<height ) { 737 if ( textY<height ) {
738 738
739 Todo::List::ConstIterator it2; 739 Todo::List::ConstIterator it2;
740 for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) { 740 for( it2 = todos.begin(); it2 != todos.end() && textY<height; ++it2 ) {
741 Todo *todo = *it2; 741 Todo *todo = *it2;
742 QString text; 742 QString text;
743 if (todo->hasDueDate()) { 743 if (todo->hasDueDate()) {
744 if (!todo->doesFloat()) { 744 if (!todo->doesFloat()) {
745 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 745 text += KGlobal::locale()->formatTime(todo->dtDue().time());
746 text += " "; 746 text += " ";
747 } 747 }
748 } 748 }
749 text += i18n("To-Do: %1").arg(todo->summary()); 749 text += i18n("To-Do: %1").arg(todo->summary());
750 750
751 p.drawText(x+5, y+textY, width-10, lineSpacing, 751 p.drawText(x+5, y+textY, width-10, lineSpacing,
752 AlignLeft|AlignBottom, text); 752 AlignLeft|AlignBottom, text);
753 textY+=lineSpacing; 753 textY+=lineSpacing;
754 } 754 }
755 } 755 }
756} 756}
757 757
758 758
759/////////////////////////////////////////////////////////////////////////////// 759///////////////////////////////////////////////////////////////////////////////
760 760
761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd, 761void CalPrintBase::drawWeek(QPainter &p, const QDate &qd,
762 int x, int y, int width, int height) 762 int x, int y, int width, int height)
763{ 763{
764 QDate weekDate = qd; 764 QDate weekDate = qd;
765 bool portrait = ( mPrinter->orientation() == KPrinter::Portrait ); 765 bool portrait = ( mPrinter->orientation() == KPrinter::Portrait );
766 int cellWidth, cellHeight; 766 int cellWidth, cellHeight;
767 int vcells; 767 int vcells;
768 if (portrait) { 768 if (portrait) {
769 cellWidth = width/2; 769 cellWidth = width/2;
770 vcells=3; 770 vcells=3;
771 } else { 771 } else {
772 cellWidth = width/6; 772 cellWidth = width/6;
773 vcells=1; 773 vcells=1;
774 } 774 }
775 cellHeight = height/vcells; 775 cellHeight = height/vcells;
776 776
777 // correct begin of week 777 // correct begin of week
778 int weekdayCol = weekdayColumn( qd.dayOfWeek() ); 778 int weekdayCol = weekdayColumn( qd.dayOfWeek() );
779 weekDate = qd.addDays( -weekdayCol ); 779 weekDate = qd.addDays( -weekdayCol );
780 780
781 for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) { 781 for (int i = 0; i < 7; i++, weekDate = weekDate.addDays(1)) {
782 if (i<5) { 782 if (i<5) {
783 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), 783 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
784 cellWidth, cellHeight, true); 784 cellWidth, cellHeight, true);
785 } else if (i==5) { 785 } else if (i==5) {
786 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells), 786 drawDayBox(p, weekDate, x+cellWidth*(int)(i/vcells), y+cellHeight*(i%vcells),
787 cellWidth, cellHeight/2, true); 787 cellWidth, cellHeight/2, true);
788 } else if (i==6) { 788 } else if (i==6) {
789 drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells), 789 drawDayBox(p, weekDate, x+cellWidth*(int)((i-1)/vcells),
790 y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true); 790 y+cellHeight*((i-1)%vcells)+cellHeight/2, cellWidth, cellHeight/2, true);
791 } 791 }
792 } // for i through all weekdays 792 } // for i through all weekdays
793} 793}
794 794
795 795
796void CalPrintBase::drawTimeTable(QPainter &p, 796void CalPrintBase::drawTimeTable(QPainter &p,
797 const QDate &fromDate, const QDate &toDate, 797 const QDate &fromDate, const QDate &toDate,
798 QTime &fromTime, QTime &toTime, 798 QTime &fromTime, QTime &toTime,
799 int x, int y, int width, int height) 799 int x, int y, int width, int height)
800{ 800{
801 // timeline is 1.5 hours: 801 // timeline is 1.5 hours:
802 int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) ); 802 int alldayHeight = (int)( 3600.*height/(fromTime.secsTo(toTime)+3600.) );
803 int timelineWidth = 60; 803 int timelineWidth = 60;
804 int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) ); 804 int cellWidth = (int)( (width-timelineWidth)/(fromDate.daysTo(toDate)+1) );
805 int currY=y; 805 int currY=y;
806 int currX=x; 806 int currX=x;
807 807
808 drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight); 808 drawDaysOfWeek( p, fromDate, toDate, x+timelineWidth, currY, width-timelineWidth, mSubHeaderHeight);
809 currY+=mSubHeaderHeight; 809 currY+=mSubHeaderHeight;
810 drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight, 810 drawTimeLine( p, fromTime, toTime, x, currY+alldayHeight,
811 timelineWidth, height-mSubHeaderHeight-alldayHeight ); 811 timelineWidth, height-mSubHeaderHeight-alldayHeight );
812 812
813 currX=x+timelineWidth; 813 currX=x+timelineWidth;
814 // draw each day 814 // draw each day
815 QDate curDate(fromDate); 815 QDate curDate(fromDate);
816 while (curDate<=toDate) {Event::List eventList; 816 while (curDate<=toDate) {Event::List eventList;
817 eventList.fill( mCalendar->events(curDate, true)); 817 eventList.fill( mCalendar->events(curDate, true));
818 drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight); 818 drawAllDayBox( p, eventList, curDate, false, currX, currY, cellWidth, alldayHeight);
819 drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX, 819 drawAgendaDayBox( p, eventList, curDate, false, fromTime, toTime, currX,
820 currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight ); 820 currY+alldayHeight, cellWidth, height-mSubHeaderHeight-alldayHeight );
821 currX+=cellWidth; 821 currX+=cellWidth;
822 curDate=curDate.addDays(1); 822 curDate=curDate.addDays(1);
823 } 823 }
824 824
825} 825}
826 826
827 827
828/////////////////////////////////////////////////////////////////////////////// 828///////////////////////////////////////////////////////////////////////////////
829 829
830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers, 830void CalPrintBase::drawMonth(QPainter &p, const QDate &qd, bool weeknumbers,
831 int x, int y, int width, int height) 831 int x, int y, int width, int height)
832{ 832{
833 833
834 int yoffset = mSubHeaderHeight; 834 int yoffset = mSubHeaderHeight;
835 int xoffset = 0; 835 int xoffset = 0;
836 836
837 QDate monthDate(QDate(qd.year(), qd.month(), 1)); 837 QDate monthDate(QDate(qd.year(), qd.month(), 1));
838 QDate monthFirst(monthDate); 838 QDate monthFirst(monthDate);
839 QDate monthLast(monthDate.addMonths(1).addDays(-1)); 839 QDate monthLast(monthDate.addMonths(1).addDays(-1));
840 840
841 841
842 int weekdayCol = weekdayColumn( monthDate.dayOfWeek() ); 842 int weekdayCol = weekdayColumn( monthDate.dayOfWeek() );
843 monthDate = monthDate.addDays(-weekdayCol); 843 monthDate = monthDate.addDays(-weekdayCol);
844 844
845 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1; 845 int rows=(weekdayCol + qd.daysInMonth() - 1)/7 +1;
846 int cellHeight = (height-yoffset) / rows; 846 int cellHeight = (height-yoffset) / rows;
847 847
848 if (weeknumbers) { 848 if (weeknumbers) {
849 QFont oldFont(p.font()); 849 QFont oldFont(p.font());
850 QFont newFont(p.font()); 850 QFont newFont(p.font());
851 newFont.setPointSize(7); 851 newFont.setPointSize(7);
852 p.setFont(newFont); 852 p.setFont(newFont);
853 xoffset += 18; 853 xoffset += 18;
854 QDate weekDate(monthDate); 854 QDate weekDate(monthDate);
855 for (int row = 0; row<rows; row++) { 855 for (int row = 0; row<rows; row++) {
856 int calWeek = weekDate.weekNumber(); 856 int calWeek = weekDate.weekNumber();
857 QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight); 857 QRect rc(x, y+yoffset+cellHeight*row, xoffset-1, cellHeight);
858 p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) ); 858 p.drawText( rc, AlignRight|AlignVCenter, QString::number(calWeek) );
859 weekDate = weekDate.addDays(7); 859 weekDate = weekDate.addDays(7);
860 } 860 }
861 p.setFont(oldFont); 861 p.setFont(oldFont);
862 } 862 }
863 863
864 drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight ); 864 drawDaysOfWeek( p, monthDate, monthDate.addDays(6), x+xoffset, y, width-xoffset, mSubHeaderHeight );
865 int cellWidth = (width-xoffset) / 7; 865 int cellWidth = (width-xoffset) / 7;
866 866
867 QColor back = p.backgroundColor(); 867 QColor back = p.backgroundColor();
868 bool darkbg = false; 868 bool darkbg = false;
869 for (int row = 0; row < rows; row++) { 869 for (int row = 0; row < rows; row++) {
870 for (int col = 0; col < 7; col++) { 870 for (int col = 0; col < 7; col++) {
871 // show days from previous/next month with a grayed background 871 // show days from previous/next month with a grayed background
872 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) { 872 if ( (monthDate < monthFirst) || (monthDate > monthLast) ) {
873 p.setBackgroundColor( QColor( 240, 240, 240) ); 873 p.setBackgroundColor( QColor( 240, 240, 240) );
874 darkbg = true; 874 darkbg = true;
875 } 875 }
876 drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight); 876 drawDayBox(p, monthDate, x+xoffset+col*cellWidth, y+yoffset+row*cellHeight, cellWidth, cellHeight);
877 if ( darkbg ) { 877 if ( darkbg ) {
878 p.setBackgroundColor( back ); 878 p.setBackgroundColor( back );
879 darkbg = false; 879 darkbg = false;
880 } 880 }
881 monthDate = monthDate.addDays(1); 881 monthDate = monthDate.addDays(1);
882 } 882 }
883 } 883 }
884} 884}
885 885
886 886
887/////////////////////////////////////////////////////////////////////////////// 887///////////////////////////////////////////////////////////////////////////////
888 888
889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos, 889void CalPrintBase::drawTodo( bool completed, int &count, Todo * item, QPainter &p, bool connectSubTodos,
890 bool desc, int pospriority, int possummary, int posDueDt, int level, 890 bool desc, int pospriority, int possummary, int posDueDt, int level,
891 int x, int &y, int width, int &height, int pageHeight, 891 int x, int &y, int width, int &height, int pageHeight,
892 TodoParentStart *r ) 892 TodoParentStart *r )
893{ 893{
894 if ( !completed && item->isCompleted() ) 894 if ( !completed && item->isCompleted() )
895 return; 895 return;
896 QString outStr; 896 QString outStr;
897// int fontHeight = 10; 897// int fontHeight = 10;
898 const KLocale *local = KGlobal::locale(); 898 const KLocale *local = KGlobal::locale();
899 int priority=item->priority(); 899 int priority=item->priority();
900 int posdue=posDueDt; 900 int posdue=posDueDt;
901 if (posdue<0) posdue=x+width; 901 if (posdue<0) posdue=x+width;
902 QRect rect; 902 QRect rect;
903 TodoParentStart startpt; 903 TodoParentStart startpt;
904 // This list keeps all starting points of the parent todos so the connection 904 // This list keeps all starting points of the parent todos so the connection
905 // lines of the tree can easily be drawn (needed if a new page is started) 905 // lines of the tree can easily be drawn (needed if a new page is started)
906 static QPtrList<TodoParentStart> startPoints; 906 static QPtrList<TodoParentStart> startPoints;
907 if (level<1) { 907 if (level<1) {
908 startPoints.clear(); 908 startPoints.clear();
909 } 909 }
910 910
911 // size of item 911 // size of item
912 outStr=item->summary(); 912 outStr=item->summary();
913 if ( ! item->location().isEmpty() ) 913 if ( ! item->location().isEmpty() )
914 outStr += " ("+item->location()+")"; 914 outStr += " ("+item->location()+")";
915 if ( item->hasDueDate() && posDueDt>=0 ) { 915 if ( item->hasDueDate() && posDueDt>=0 ) {
916 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; 916 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]";
917 } 917 }
918 int left = possummary+(level*10); 918 int left = possummary+(level*10);
919 rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr); 919 rect = p.boundingRect(left, y, (posdue-left-5),-1, WordBreak, outStr);
920 //qDebug("bottom1 %d ", rect.bottom() );
920 if ( !item->description().isEmpty() && desc ) { 921 if ( !item->description().isEmpty() && desc ) {
921 outStr = item->description(); 922 outStr = item->description();
922 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1, 923 rect = p.boundingRect( left+20, rect.bottom()+5, width-(left+10-x), -1,
923 WordBreak, outStr ); 924 WordBreak, outStr );
924 } 925 }
926 //qDebug("bottom2 %d y+h %d y %d ph %d", rect.bottom(), y+height, y , pageHeight );
925 // if too big make new page 927 // if too big make new page
926 if ( rect.bottom() > y+height) { 928 if ( rect.bottom() > y+height) {
927 // first draw the connection lines from parent todos: 929 // first draw the connection lines from parent todos:
928 if (level > 0 && connectSubTodos) { 930 if (level > 0 && connectSubTodos) {
929 TodoParentStart *rct; 931 TodoParentStart *rct;
930 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) { 932 for ( rct = startPoints.first(); rct; rct = startPoints.next() ) {
931 int start; 933 int start;
932 int center = rct->mRect.left() + (rct->mRect.width()/2); 934 int center = rct->mRect.left() + (rct->mRect.width()/2);
933 int to = p.viewport().bottom(); 935 int to = p.viewport().bottom();
934 936
935 // draw either from start point of parent or from top of the page 937 // draw either from start point of parent or from top of the page
936 if (rct->mSamePage) 938 if (rct->mSamePage)
937 start = rct->mRect.bottom() + 1; 939 start = rct->mRect.bottom() + 1;
938 else 940 else
939 start = p.viewport().top(); 941 start = p.viewport().top();
940 p.moveTo( center, start ); 942 p.moveTo( center, start );
941 p.lineTo( center, to ); 943 p.lineTo( center, to );
942 rct->mSamePage=false; 944 rct->mSamePage=false;
943 } 945 }
944 } 946 }
945 y=0; 947 y=0;
946 height=pageHeight-y; 948 height=pageHeight-y;
947 mPrinter->newPage(); 949 mPrinter->newPage();
948 } 950 }
949 951
950 // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up 952 // If this is a sub-item, r will not be 0, and we want the LH side of the priority line up
951 //to the RH side of the parent item's priority 953 //to the RH side of the parent item's priority
952 if (r && pospriority >= 0 ) { 954 if (r && pospriority >= 0 ) {
953 pospriority = r->mRect.right() + 1; 955 pospriority = r->mRect.right() + 1;
954 } 956 }
955 957
956 // Priority 958 // Priority
957 outStr.setNum(priority); 959 outStr.setNum(priority);
958 rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr); 960 rect = p.boundingRect(pospriority, y + 10, 5, -1, AlignCenter, outStr);
959 // Make it a more reasonable size 961 // Make it a more reasonable size
960 rect.setWidth(19); 962 rect.setWidth(19);
961 rect.setHeight(19); 963 rect.setHeight(19);
962 if ( priority > 0 && pospriority>=0 ) { 964 if ( priority > 0 && pospriority>=0 ) {
963 p.drawText(rect, AlignCenter, outStr); 965 p.drawText(rect, AlignCenter, outStr);
964 p.drawRect(rect); 966 p.drawRect(rect);
965 // cross out the rectangle for completed items 967 // cross out the rectangle for completed items
966 if ( item->isCompleted() ) { 968 if ( item->isCompleted() ) {
967 p.drawLine( rect.topLeft(), rect.bottomRight() ); 969 p.drawLine( rect.topLeft(), rect.bottomRight() );
968 p.drawLine( rect.topRight(), rect.bottomLeft() ); 970 p.drawLine( rect.topRight(), rect.bottomLeft() );
971 } else if (item->cancelled() ) {
972 QPen pen = p.pen();
973 p.setPen ( QPen ( black, 2) );
974 p.drawLine( rect.left()+2,rect.top()+rect.height()/2, rect.right()-2, +rect.top()+rect.height()/2 );
975 p.setPen( pen );
969 } 976 }
970 } 977 }
971 startpt.mRect = rect; //save for later 978 startpt.mRect = rect; //save for later
972 979
973 // Connect the dots 980 // Connect the dots
974 if (level > 0 && connectSubTodos) { 981 if (level > 0 && connectSubTodos) {
975 int bottom; 982 int bottom;
976 int center( r->mRect.left() + (r->mRect.width()/2)+1 ); 983 int center( r->mRect.left() + (r->mRect.width()/2)+1 );
977 if (r->mSamePage ) 984 if (r->mSamePage )
978 bottom = r->mRect.bottom();//lutz + 1; 985 bottom = r->mRect.bottom();//lutz + 1;
979 else 986 else
980 bottom = 0; 987 bottom = 0;
981 int to( rect.top() + (rect.height()/2)+1 ); 988 int to( rect.top() + (rect.height()/2)+1 );
982 int endx( rect.left() ); 989 int endx( rect.left() );
983 p.moveTo(center, bottom); 990 p.moveTo(center, bottom);
984 p.lineTo(center, to); 991 p.lineTo(center, to);
985 p.lineTo(endx, to); 992 p.lineTo(endx, to);
986 } 993 }
987 994
988 // if completed, use strike out font 995 // if completed, use strike out font
989 QFont ft=p.font(); 996 // LR does not work - font is underlined, not striked out
990 ft.setStrikeOut( item->isCompleted() ); 997 //QFont ft=p.font();
991 p.setFont( ft ); 998 //ft.setStrikeOut( item->isCompleted() );
999 //p.setFont( ft );
992 // summary 1000 // summary
993 outStr=item->summary(); 1001 outStr=item->summary();
994 if ( ! item->location().isEmpty() ) 1002 if ( ! item->location().isEmpty() )
995 outStr += " ("+item->location()+")"; 1003 outStr += " ("+item->location()+")";
996 if ( item->hasDueDate() && posDueDt>=0 ) { 1004 if ( item->hasDueDate() && posDueDt>=0 ) {
997 outStr += " [" +local->formatDate(item->dtDue().date(),true)+"]"; 1005 outStr += " [" +item->dtDueStr(true)+"]";
998 } 1006 }
999 rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)), 1007 rect = p.boundingRect( left, rect.top(), (posdue-(left + rect.width() + 5)),
1000 -1, WordBreak, outStr); 1008 -1, WordBreak, outStr);
1001 QRect newrect; 1009 QRect newrect;
1002 p.drawText( rect, WordBreak, outStr, -1, &newrect ); 1010 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1003 ft.setStrikeOut(false); 1011 //ft.setStrikeOut(false);
1004 p.setFont(ft); 1012 // p.setFont(ft);
1005 1013
1006 // due 1014 // due
1007 // if ( item->hasDueDate() && posDueDt>=0 ) { 1015 // if ( item->hasDueDate() && posDueDt>=0 ) {
1008// outStr = local->formatDate(item->dtDue().date(),true); 1016// outStr = local->formatDate(item->dtDue().date(),true);
1009// rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr); 1017// rect = p.boundingRect(posdue, y, x+width, -1, AlignTop|AlignLeft, outStr);
1010// p.drawText(rect, AlignTop|AlignLeft, outStr); 1018// p.drawText(rect, AlignTop|AlignLeft, outStr);
1011// } 1019// }
1012 1020
1013 if ( !item->description().isEmpty() && desc ) { 1021 if ( !item->description().isEmpty() && desc ) {
1014 y=newrect.bottom() + 5; 1022 y=newrect.bottom() + 5;
1015 outStr = item->description(); 1023 outStr = item->description();
1016 rect = p.boundingRect( left+20, y, x+width-(left+10), -1, 1024 rect = p.boundingRect( left+20, y, x+width-(left+10), -1,
1017 WordBreak, outStr ); 1025 WordBreak, outStr );
1018 p.drawText( rect, WordBreak, outStr, -1, &newrect ); 1026 p.drawText( rect, WordBreak, outStr, -1, &newrect );
1019 } 1027 }
1020 1028
1021 // Set the new line position 1029 // Set the new line position
1022 y=newrect.bottom() + 10; //set the line position 1030 y=newrect.bottom() + 10; //set the line position
1023 1031
1024 // If the item has subitems, we need to call ourselves recursively 1032 // If the item has subitems, we need to call ourselves recursively
1025 Incidence::List l;l.fill( item->relations()); 1033 Incidence::List l;l.fill( item->relations());
1026 Incidence::List::ConstIterator it; 1034 Incidence::List::ConstIterator it;
1027 startPoints.append( &startpt ); 1035 startPoints.append( &startpt );
1028 for( it = l.begin(); it != l.end(); ++it ) { 1036 for( it = l.begin(); it != l.end(); ++it ) {
1029 count++; 1037 count++;
1030 drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos, 1038 drawTodo( completed, count, static_cast<Todo *>( *it ), p, connectSubTodos,
1031 desc, pospriority, possummary, posDueDt, level+1, 1039 desc, pospriority, possummary, posDueDt, level+1,
1032 x, y, width, height, pageHeight, &startpt); 1040 x, y, width, height, pageHeight, &startpt);
1033 } 1041 }
1034 startPoints.remove(&startpt); 1042 startPoints.remove(&startpt);
1035} 1043}
1036 1044
1037int CalPrintBase::weekdayColumn( int weekday ) 1045int CalPrintBase::weekdayColumn( int weekday )
1038{ 1046{
1039 return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7; 1047 return ( weekday + 7 - KGlobal::locale()->weekStartDay() ) % 7;
1040} 1048}
1041 1049
1042void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd, 1050void CalPrintBase::drawSplitWeek( QPainter &p, const QDate &fd,
1043 const QDate &td ) 1051 const QDate &td )
1044{ 1052{
1045 QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek; 1053 QDate curDay, fromDay, toDay, curWeek, fromWeek, toWeek;
1046 1054
1047 mPrinter->setOrientation(KPrinter::Portrait); 1055 mPrinter->setOrientation(KPrinter::Portrait);
1048 1056
1049 int minus = 0; 1057 int minus = 0;
1050 if (KGlobal::locale()->weekStartsMonday()) { 1058 if (KGlobal::locale()->weekStartsMonday()) {
1051 // correct to monday 1059 // correct to monday
1052 fromWeek = fd.addDays(-(fd.dayOfWeek()-1)); 1060 fromWeek = fd.addDays(-(fd.dayOfWeek()-1));
1053 // correct to sunday 1061 // correct to sunday
1054 toWeek = td.addDays(7-fd.dayOfWeek()); 1062 toWeek = td.addDays(7-fd.dayOfWeek());
1055 minus = 1; 1063 minus = 1;
1056 } else { 1064 } else {
1057 // correct to sunday 1065 // correct to sunday
1058 fromWeek = fd.addDays(-(fd.dayOfWeek()%7)); 1066 fromWeek = fd.addDays(-(fd.dayOfWeek()%7));
1059 // correct to saturday 1067 // correct to saturday
1060 toWeek = td.addDays(6-td.dayOfWeek()); 1068 toWeek = td.addDays(6-td.dayOfWeek());
1061 } 1069 }
1062 1070
1063 fromDay = fd; 1071 fromDay = fd;
1064 curDay = fd; 1072 curDay = fd;
1065 toDay = td; 1073 toDay = td;
1066 p.setFont( QFont("Helvetica") ); 1074 p.setFont( QFont("Helvetica") );
1067 // the painter initially begins at 72 dpi per the Qt docs. 1075 // the painter initially begins at 72 dpi per the Qt docs.
1068 int pageWidth = p.viewport().width(); 1076 int pageWidth = p.viewport().width();
1069 int pageHeight = p.viewport().height(); 1077 int pageHeight = p.viewport().height();
1070 int margin=0; 1078 int margin=0;
1071 mHeaderHeight = 110; 1079 mHeaderHeight = 110;
1072 mSubHeaderHeight = 20; 1080 mSubHeaderHeight = 20;
1073 1081
1074 p.setViewport(margin, margin, 1082 p.setViewport(margin, margin,
1075 p.viewport().width()-margin, 1083 p.viewport().width()-margin,
1076 p.viewport().height()-margin); 1084 p.viewport().height()-margin);
1077 1085
1078 curWeek = fromWeek.addDays(6); 1086 curWeek = fromWeek.addDays(6);
1079 1087
1080 int columnWidth = int( pageWidth / 4.5 ); 1088 int columnWidth = int( pageWidth / 4.5 );
1081 1089
1082 do { 1090 do {
1083 1091
1084 // if ( (curDay.dayOfWeek()-1)%7 < 3 ) 1092 // if ( (curDay.dayOfWeek()-1)%7 < 3 )
1085 switch((curDay.dayOfWeek()-minus)%7){ 1093 switch((curDay.dayOfWeek()-minus)%7){
1086 case 0: 1094 case 0:
1087 drawSplitTimes( p, pageWidth, columnWidth, pageHeight ); 1095 drawSplitTimes( p, pageWidth, columnWidth, pageHeight );
1088 drawSplitDay( p, curDay, columnWidth, pageHeight, 1096 drawSplitDay( p, curDay, columnWidth, pageHeight,
1089 int( columnWidth * 0.5 ) ); 1097 int( columnWidth * 0.5 ) );
1090 break; 1098 break;
1091 case 1: 1099 case 1:
1092 drawSplitDay( p, curDay, columnWidth, pageHeight, 1100 drawSplitDay( p, curDay, columnWidth, pageHeight,
1093 int( columnWidth * 1.5 ) ); 1101 int( columnWidth * 1.5 ) );
1094 break; 1102 break;
1095 case 2: 1103 case 2:
1096 drawSplitDay( p, curDay, columnWidth, pageHeight, 1104 drawSplitDay( p, curDay, columnWidth, pageHeight,
1097 int( columnWidth * 2.5 ) ); 1105 int( columnWidth * 2.5 ) );
1098 break; 1106 break;
1099 case 3: 1107 case 3:
1100 drawSplitDay( p, curDay, columnWidth, pageHeight, 1108 drawSplitDay( p, curDay, columnWidth, pageHeight,
1101 int( columnWidth * 3.5 ) ); 1109 int( columnWidth * 3.5 ) );
1102 mPrinter->newPage(); 1110 mPrinter->newPage();
1103 break; 1111 break;
1104 case 4: 1112 case 4:
1105 drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth, 1113 drawSplitTimes( p, int( pageWidth * ( 3.5/ 4.5 ) ), columnWidth,
1106 pageHeight ); 1114 pageHeight );
1107 drawSplitDay( p, curDay, columnWidth, pageHeight, 1115 drawSplitDay( p, curDay, columnWidth, pageHeight,
1108 int( columnWidth * 0.5 ) ); 1116 int( columnWidth * 0.5 ) );
1109 drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek, 1117 drawSplitHeaderRight( p, curWeek.addDays( -6 ), curWeek,
1110 curWeek, pageWidth, mHeaderHeight ); 1118 curWeek, pageWidth, mHeaderHeight );
1111 break; 1119 break;
1112 case 5: 1120 case 5:
1113 drawSplitDay( p, curDay, columnWidth, pageHeight, 1121 drawSplitDay( p, curDay, columnWidth, pageHeight,
1114 int( columnWidth * 1.5 ) ); 1122 int( columnWidth * 1.5 ) );
1115 break; 1123 break;
1116 case 6: 1124 case 6:
1117 drawSplitDay( p, curDay, columnWidth, pageHeight, 1125 drawSplitDay( p, curDay, columnWidth, pageHeight,
1118 int( columnWidth * 2.5 ) ); 1126 int( columnWidth * 2.5 ) );
1119 if ( curDay < toDay ) 1127 if ( curDay < toDay )
1120 mPrinter->newPage(); 1128 mPrinter->newPage();
1121 curWeek = curWeek.addDays( 7 ); 1129 curWeek = curWeek.addDays( 7 );
1122 break; 1130 break;
1123 } 1131 }
1124 curDay = curDay.addDays(1); 1132 curDay = curDay.addDays(1);
1125 1133
1126 } while (curDay <= toDay); 1134 } while (curDay <= toDay);
1127 1135
1128} 1136}
1129 1137
1130void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd, 1138void CalPrintBase::drawSplitHeaderRight( QPainter &p, const QDate &fd,
1131 const QDate &td, 1139 const QDate &td,
1132 const QDate &, 1140 const QDate &,
1133 int width, int ) 1141 int width, int )
1134{ 1142{
1135 int tempStore = mSubHeaderHeight; 1143 int tempStore = mSubHeaderHeight;
1136 mSubHeaderHeight+= mSubHeaderHeight; 1144 mSubHeaderHeight+= mSubHeaderHeight;
1137 KLocale *local = KGlobal::locale(); 1145 KLocale *local = KGlobal::locale();
1138 QFont font("helvetica", 18, QFont::Bold); 1146 QFont font("helvetica", 18, QFont::Bold);
1139 QPen penA( black,0); 1147 QPen penA( black,0);
1140 QPen penB( black,3); 1148 QPen penB( black,3);
1141 p.setFont(font); 1149 p.setFont(font);
1142 int lineSpacing = p.fontMetrics().lineSpacing(); 1150 int lineSpacing = p.fontMetrics().lineSpacing();
1143 QString title; 1151 QString title;
1144 QString myOwner(mCalendar->getOwner()); 1152 QString myOwner(mCalendar->getOwner());
1145 if ( fd.month() == td.month() ) { 1153 if ( fd.month() == td.month() ) {
1146 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' 1154 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1147 + '-' + ' ' + QString::number(td.day()); 1155 + '-' + ' ' + QString::number(td.day());
1148 } else { 1156 } else {
1149 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' ' 1157 title = local->monthName(fd.month(), false) + ' ' + QString::number(fd.day()) + ' '
1150 + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day()); 1158 + '-' + ' ' + local->monthName(td.month(), false) + ' ' + QString::number(td.day());
1151 } 1159 }
1152 1160
1153// Grrrrrrr! why can't I set the font to a serif font?!?!? 1161// Grrrrrrr! why can't I set the font to a serif font?!?!?
1154 QFont serifFont("Helvetica", 30); 1162 QFont serifFont("Helvetica", 30);
1155// serifFont.setFamily("Serif"); 1163// serifFont.setFamily("Serif");
1156// serifFont.setWeight(87); 1164// serifFont.setWeight(87);
1157// serifFont.setItalic(true); 1165// serifFont.setItalic(true);
1158 p.setFont(serifFont); 1166 p.setFont(serifFont);
1159 QFontInfo info(p.font()); 1167 QFontInfo info(p.font());
1160 1168
1161 lineSpacing = p.fontMetrics().lineSpacing(); 1169 lineSpacing = p.fontMetrics().lineSpacing();
1162 p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title ); 1170 p.drawText(0, lineSpacing * 0, width, lineSpacing, AlignRight |AlignTop, title );
1163 1171
1164 title.truncate(0); 1172 title.truncate(0);
1165 1173
1166 p.setPen(penB ); 1174 p.setPen(penB );
1167 p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1); 1175 p.drawLine(200, lineSpacing * 1, width, lineSpacing * 1);
1168 p.setPen(penA ); 1176 p.setPen(penA );
1169 1177
1170 p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE)); 1178 p.setFont(QFont("Helvetica", 20, QFont::Bold, TRUE));
1171 title += QString::number(fd.year()); 1179 title += QString::number(fd.year());
1172 p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title ); 1180 p.drawText(0, lineSpacing * 1, width, lineSpacing, AlignRight |AlignTop, title );
1173 mSubHeaderHeight = tempStore ; 1181 mSubHeaderHeight = tempStore ;
1174} 1182}
1175 1183
1176void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width, 1184void CalPrintBase::drawSplitDay( QPainter &p, const QDate &qd, int width,
1177 int height, int offsetLeft ) 1185 int height, int offsetLeft )
1178{ 1186{
1179 int tempStore = mSubHeaderHeight; 1187 int tempStore = mSubHeaderHeight;
1180 mSubHeaderHeight+= mSubHeaderHeight; 1188 mSubHeaderHeight+= mSubHeaderHeight;
1181 int startHour = KOPrefs::instance()->mDayBegins; 1189 int startHour = KOPrefs::instance()->mDayBegins;
1182 int endHour = 20; 1190 int endHour = 20;
1183 int offset = mHeaderHeight + mSubHeaderHeight + 10; 1191 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1184 Event::List eventList; eventList.fill( mCalendar->events( qd, true )); 1192 Event::List eventList; eventList.fill( mCalendar->events( qd, true ));
1185 Event::List::Iterator it; 1193 Event::List::Iterator it;
1186 Event *currEvent; 1194 Event *currEvent;
1187 KLocale *local = KGlobal::locale(); 1195 KLocale *local = KGlobal::locale();
1188 QString dayName; 1196 QString dayName;
1189 1197
1190 dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day()); 1198 dayName = local->weekDayName(qd.dayOfWeek()) + ' ' + ' ' + QString::number(qd.day());
1191 //p.setBrush(QBrush(black)); 1199 //p.setBrush(QBrush(black));
1192// width+1 to make sure there's a continuous, black bar across the top. 1200// width+1 to make sure there's a continuous, black bar across the top.
1193 p.setPen( QPen(Qt::black,2)); 1201 p.setPen( QPen(Qt::black,2));
1194 p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight); 1202 p.drawRect(offsetLeft, mHeaderHeight + 5, width +1, mSubHeaderHeight);
1195 p.setPen( Qt::black); 1203 p.setPen( Qt::black);
1196 p.setFont(QFont("helvetica", 12, QFont::Bold, true)); 1204 p.setFont(QFont("helvetica", 12, QFont::Bold, true));
1197 p.drawText(offsetLeft, mHeaderHeight + 5, 1205 p.drawText(offsetLeft, mHeaderHeight + 5,
1198 width, mSubHeaderHeight, AlignHCenter | AlignVCenter, 1206 width, mSubHeaderHeight, AlignHCenter | AlignVCenter,
1199 dayName); 1207 dayName);
1200 1208
1201 p.setPen( QPen(Qt::black,2)); 1209 p.setPen( QPen(Qt::black,2));
1202 p.setFont(QFont("helvetica", 12)); 1210 p.setFont(QFont("helvetica", 12));
1203 p.setBrush(Qt::white); 1211 p.setBrush(Qt::white);
1204 it = eventList.begin(); 1212 it = eventList.begin();
1205 int allDays = 0; 1213 int allDays = 0;
1206 /* 1214 /*
1207 while( it != eventList.end() ) { 1215 while( it != eventList.end() ) {
1208 Event *currEvent = *it; 1216 Event *currEvent = *it;
1209 if ( currEvent->doesFloat() ) { 1217 if ( currEvent->doesFloat() ) {
1210 p.drawRect( offsetLeft, offset, width, 35 ); 1218 p.drawRect( offsetLeft, offset, width, 35 );
1211 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30, 1219 p.drawText( offsetLeft + 5, offset + 10, width - 10, 30,
1212 AlignLeft | AlignTop, currEvent->summary() ); 1220 AlignLeft | AlignTop, currEvent->summary() );
1213 offset += 40; 1221 offset += 40;
1214 allDays++; 1222 allDays++;
1215 it = eventList.remove( it ); 1223 it = eventList.remove( it );
1216 } else { 1224 } else {
1217 ++it; 1225 ++it;
1218 } 1226 }
1219 } 1227 }
1220 */ 1228 */
1221 //p.setBrush(QBrush()); 1229 //p.setBrush(QBrush());
1222 int tmpEnd; 1230 int tmpEnd;
1223 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1231 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1224 Event *currEvent = *it; 1232 Event *currEvent = *it;
1225 tmpEnd = currEvent->dtEnd().time().hour(); 1233 tmpEnd = currEvent->dtEnd().time().hour();
1226 if (currEvent->dtEnd().time().minute() > 0) 1234 if (currEvent->dtEnd().time().minute() > 0)
1227 tmpEnd++; 1235 tmpEnd++;
1228 if (tmpEnd > endHour) 1236 if (tmpEnd > endHour)
1229 endHour = tmpEnd; 1237 endHour = tmpEnd;
1230 } 1238 }
1231 int hours = endHour - startHour; 1239 int hours = endHour - startHour;
1232 int cellHeight = (height-offset) / hours; // hour increments. 1240 int cellHeight = (height-offset) / hours; // hour increments.
1233 1241
1234 p.setFont(QFont("helvetica", 12)); 1242 p.setFont(QFont("helvetica", 12));
1235 //p.setBrush(QBrush(Dense7Pattern)); 1243 //p.setBrush(QBrush(Dense7Pattern));
1236 p.setBrush(Qt::white); 1244 p.setBrush(Qt::white);
1237 for ( it = eventList.begin(); it != eventList.end(); ++it ) { 1245 for ( it = eventList.begin(); it != eventList.end(); ++it ) {
1238 Event *currEvent = *it; 1246 Event *currEvent = *it;
1239 int startTime = currEvent->dtStart().time().hour(); 1247 int startTime = currEvent->dtStart().time().hour();
1240 int endTime = currEvent->dtEnd().time().hour(); 1248 int endTime = currEvent->dtEnd().time().hour();
1241 float minuteInc = cellHeight / 60.0; 1249 float minuteInc = cellHeight / 60.0;
1242 if ((startTime >= startHour) && (endTime <= (startHour + hours))) { 1250 if ((startTime >= startHour) && (endTime <= (startHour + hours))) {
1243 startTime -= startHour; 1251 startTime -= startHour;
1244 int startMinuteOff = (int) (minuteInc * 1252 int startMinuteOff = (int) (minuteInc *
1245 currEvent->dtStart().time().minute()); 1253 currEvent->dtStart().time().minute());
1246 QString text = currEvent->summary() ; 1254 QString text = currEvent->summary() ;
1247 if ( ! currEvent->location().isEmpty() ) 1255 if ( ! currEvent->location().isEmpty() )
1248 text += "\n("+currEvent->location()+")"; 1256 text += "\n("+currEvent->location()+")";
1249 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute()); 1257 int endMinuteOff = (int) (minuteInc * currEvent->dtEnd().time().minute());
1250 int cheight = (int) (minuteInc * 1258 int cheight = (int) (minuteInc *
1251 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 ); 1259 currEvent->dtStart().secsTo(currEvent->dtEnd()) / 60 );
1252 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight, 1260 p.drawRect(offsetLeft+2, 1+offset+startMinuteOff+startTime*cellHeight,
1253 width-4, cheight); 1261 width-4, cheight);
1254 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24, 1262 p.drawText(offsetLeft+12, offset+startMinuteOff+startTime*cellHeight+5, width-24,
1255 cheight-10, AlignHCenter | AlignTop, text); 1263 cheight-10, AlignHCenter | AlignTop, text);
1256 } 1264 }
1257 } 1265 }
1258 p.setBrush(QBrush(NoBrush)); 1266 p.setBrush(QBrush(NoBrush));
1259 mSubHeaderHeight = tempStore ; 1267 mSubHeaderHeight = tempStore ;
1260} 1268}
1261 1269
1262void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth, 1270void CalPrintBase::drawSplitTimes( QPainter &p, int width, int timeWidth,
1263 int height ) 1271 int height )
1264{ 1272{
1265 int tempStore = mSubHeaderHeight; 1273 int tempStore = mSubHeaderHeight;
1266 mSubHeaderHeight+= mSubHeaderHeight; 1274 mSubHeaderHeight+= mSubHeaderHeight;
1267 int startHour = KOPrefs::instance()->mDayBegins; 1275 int startHour = KOPrefs::instance()->mDayBegins;
1268 int endHour = 20; 1276 int endHour = 20;
1269 int offset = mHeaderHeight + mSubHeaderHeight + 10; 1277 int offset = mHeaderHeight + mSubHeaderHeight + 10;
1270 int hours = endHour - startHour; 1278 int hours = endHour - startHour;
1271 int cellHeight = (height-offset) / hours; // hour increments. 1279 int cellHeight = (height-offset) / hours; // hour increments.
1272 1280
1273 QString numStr; 1281 QString numStr;
1274 for (int i = 0; i < hours; i++) { 1282 for (int i = 0; i < hours; i++) {
1275 p.setPen(QPen(black,1)); 1283 p.setPen(QPen(black,1));
1276 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight); 1284 p.drawLine(0, offset+i*cellHeight, width, offset+i*cellHeight);
1277 p.setPen(QPen(gray,0)); 1285 p.setPen(QPen(gray,0));
1278 p.drawLine(37, offset+i*cellHeight+(cellHeight/2), 1286 p.drawLine(37, offset+i*cellHeight+(cellHeight/2),
1279 width, offset+i*cellHeight+(cellHeight/2)); 1287 width, offset+i*cellHeight+(cellHeight/2));
1280 p.setPen(QPen(black,0)); 1288 p.setPen(QPen(black,0));
1281 1289
1282 if ( !KGlobal::locale()->use12Clock() ) { 1290 if ( !KGlobal::locale()->use12Clock() ) {
1283 numStr.setNum(i+startHour); 1291 numStr.setNum(i+startHour);
1284 if (cellHeight > 40) { 1292 if (cellHeight > 40) {
1285 p.setFont(QFont("helvetica", 16, QFont::Bold)); 1293 p.setFont(QFont("helvetica", 16, QFont::Bold));
1286 } else { 1294 } else {
1287 p.setFont(QFont("helvetica", 14, QFont::Bold)); 1295 p.setFont(QFont("helvetica", 14, QFont::Bold));
1288 } 1296 }
1289 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2, 1297 p.drawText(0, offset+i*cellHeight, 33, cellHeight/2,
1290 AlignTop|AlignRight, numStr); 1298 AlignTop|AlignRight, numStr);
1291 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1299 p.setFont(QFont("helvetica", 12, QFont::Bold));
1292 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2, 1300 p.drawText(37, offset+i*cellHeight, 45, cellHeight/2,
1293 AlignTop | AlignLeft, "00"); 1301 AlignTop | AlignLeft, "00");
1294 } else { 1302 } else {
1295 QTime time( i + startHour, 0 ); 1303 QTime time( i + startHour, 0 );
1296 numStr = KGlobal::locale()->formatTime( time ); 1304 numStr = KGlobal::locale()->formatTime( time );
1297 p.setFont(QFont("helvetica", 12, QFont::Bold)); 1305 p.setFont(QFont("helvetica", 12, QFont::Bold));
1298 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2, 1306 p.drawText(4, offset+i*cellHeight, 70, cellHeight/2,
1299 AlignTop|AlignLeft, numStr); 1307 AlignTop|AlignLeft, numStr);
1300 } 1308 }
1301 } mSubHeaderHeight = tempStore ; 1309 } mSubHeaderHeight = tempStore ;
1302} 1310}
1303 1311
1304#endif 1312#endif
diff --git a/korganizer/calprinter.cpp b/korganizer/calprinter.cpp
index 6b5b0fe..0cdf28e 100644
--- a/korganizer/calprinter.cpp
+++ b/korganizer/calprinter.cpp
@@ -1,299 +1,299 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qvbuttongroup.h> 24#include <qvbuttongroup.h>
25#include <qwidgetstack.h> 25#include <qwidgetstack.h>
26#include <qradiobutton.h> 26#include <qradiobutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qsplitter.h> 32#include <qsplitter.h>
33 33
34#include <kprinter.h> 34#include <kprinter.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <ksimpleconfig.h> 36#include <ksimpleconfig.h>
37#include <kmessagebox.h> 37#include <kmessagebox.h>
38#include <kdebug.h> 38#include <kdebug.h>
39//#include <kdeversion.h> 39//#include <kdeversion.h>
40 40
41#include "koprefsdialog.h" 41#include "koprefsdialog.h"
42 42
43#include "calprinter.h" 43#include "calprinter.h"
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45//#include "calprinter.moc" 45//#include "calprinter.moc"
46 46
47#include "calprintplugins.h" 47#include "calprintplugins.h"
48 48
49CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar ) 49CalPrinter::CalPrinter( QWidget *parent, Calendar *calendar )
50 : QObject( parent, "CalPrinter" ) 50 : QObject( parent, "CalPrinter" )
51{ 51{
52 mCalendar = calendar; 52 mCalendar = calendar;
53 mParent = parent; 53 mParent = parent;
54 mPrinter = new KPrinter; 54 mPrinter = new KPrinter;
55 mPrinter->setOrientation( KPrinter::Portrait ); 55 mPrinter->setOrientation( KPrinter::Portrait );
56 mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" )); 56 mConfig = new KConfig(locateLocal("config","korganizer_printing.rc" ));
57 //KSimpleConfig( "korganizer_printing.rc" ); 57 //KSimpleConfig( "korganizer_printing.rc" );
58 58
59 init( mPrinter, calendar ); 59 init( mPrinter, calendar );
60} 60}
61 61
62CalPrinter::~CalPrinter() 62CalPrinter::~CalPrinter()
63{ 63{
64 kdDebug() << "~CalPrinter()" << endl; 64 kdDebug() << "~CalPrinter()" << endl;
65 65
66 CalPrintBase *plug = mPrintPlugins.first(); 66 CalPrintBase *plug = mPrintPlugins.first();
67 while ( plug ) { 67 while ( plug ) {
68 plug->doSaveConfig(); 68 plug->doSaveConfig();
69 plug = mPrintPlugins.next(); 69 plug = mPrintPlugins.next();
70 } 70 }
71 mConfig->sync(); 71 mConfig->sync();
72 delete mConfig; 72 delete mConfig;
73 delete mPrintDialog; 73 delete mPrintDialog;
74 delete mPrinter; 74 delete mPrinter;
75} 75}
76 76
77void CalPrinter::init( KPrinter *printer, Calendar *calendar ) 77void CalPrinter::init( KPrinter *printer, Calendar *calendar )
78{ 78{
79 mPrintPlugins.setAutoDelete( true ); 79 mPrintPlugins.setAutoDelete( true );
80 mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) ); 80 mPrintPlugins.append( new CalPrintDay( printer, calendar, mConfig ) );
81 mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) ); 81 mPrintPlugins.append( new CalPrintWeek( printer, calendar, mConfig ) );
82 mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) ); 82 mPrintPlugins.append( new CalPrintMonth( printer, calendar, mConfig ) );
83 mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) ); 83 mPrintPlugins.append( new CalPrintTodos( printer, calendar, mConfig ) );
84 84
85 // TODO_RK: Add a plugin interface here 85 // TODO_RK: Add a plugin interface here
86 mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent ); 86 mPrintDialog = new CalPrintDialog( mPrintPlugins, mPrinter, mParent );
87 87
88 CalPrintBase *plug = mPrintPlugins.first(); 88 CalPrintBase *plug = mPrintPlugins.first();
89 while ( plug ) { 89 while ( plug ) {
90 connect( mPrintDialog, SIGNAL( okClicked() ), 90 connect( mPrintDialog, SIGNAL( okClicked() ),
91 plug, SLOT( readSettingsWidget() ) ); 91 plug, SLOT( readSettingsWidget() ) );
92 92
93 plug->doLoadConfig(); 93 plug->doLoadConfig();
94 94
95 plug = mPrintPlugins.next(); 95 plug = mPrintPlugins.next();
96 } 96 }
97} 97}
98 98
99void CalPrinter::setupPrinter() 99void CalPrinter::setupPrinter()
100{ 100{
101 KMessageBox::sorry( mParent, i18n("Not implemented.") ); 101 KMessageBox::sorry( mParent, i18n("Not implemented.") );
102#if 0 102#if 0
103 KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent); 103 KOPrefsDialog *optionsDlg = new KOPrefsDialog(mParent);
104 optionsDlg->readConfig(); 104 optionsDlg->readConfig();
105 optionsDlg->showPrinterTab(); 105 optionsDlg->showPrinterTab();
106 connect(optionsDlg, SIGNAL(configChanged()), 106 connect(optionsDlg, SIGNAL(configChanged()),
107 mParent, SLOT(updateConfig())); 107 mParent, SLOT(updateConfig()));
108 optionsDlg->show(); 108 optionsDlg->show();
109#endif 109#endif
110} 110}
111 111
112void CalPrinter::setDateRange( const QDate &fd, const QDate &td ) 112void CalPrinter::setDateRange( const QDate &fd, const QDate &td )
113{ 113{
114 CalPrintBase *plug = mPrintPlugins.first(); 114 CalPrintBase *plug = mPrintPlugins.first();
115 while ( plug ) { 115 while ( plug ) {
116 plug->setDateRange( fd, td ); 116 plug->setDateRange( fd, td );
117 plug = mPrintPlugins.next(); 117 plug = mPrintPlugins.next();
118 } 118 }
119} 119}
120 120
121void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td ) 121void CalPrinter::preview( PrintType type, const QDate &fd, const QDate &td )
122{ 122{
123 mPrintDialog->setPreview( true ); 123 mPrintDialog->setPreview( true );
124 mPrintDialog->setPrintType( int( type ) ); 124 mPrintDialog->setPrintType( int( type ) );
125 setDateRange( fd, td ); 125 setDateRange( fd, td );
126 126
127 if ( mPrintDialog->exec() == QDialog::Accepted ) { 127 if ( mPrintDialog->exec() == QDialog::Accepted ) {
128 doPrint( mPrintDialog->selectedPlugin(), true ); 128 doPrint( mPrintDialog->selectedPlugin(), true );
129 } 129 }
130} 130}
131 131
132void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td ) 132void CalPrinter::print( PrintType type, const QDate &fd, const QDate &td )
133{ 133{
134 mPrintDialog->resize( 640, 380 ); 134 mPrintDialog->resize( 640, 440 );
135 mPrintDialog->setPreview( false ); 135 mPrintDialog->setPreview( false );
136 mPrintDialog->setPrintType( int( type ) ); 136 mPrintDialog->setPrintType( int( type ) );
137 setDateRange( fd, td ); 137 setDateRange( fd, td );
138 138
139 if ( mPrintDialog->exec() == QDialog::Accepted ) { 139 if ( mPrintDialog->exec() == QDialog::Accepted ) {
140 doPrint( mPrintDialog->selectedPlugin(), false ); 140 doPrint( mPrintDialog->selectedPlugin(), false );
141 } 141 }
142} 142}
143 143
144void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview ) 144void CalPrinter::doPrint( CalPrintBase *selectedStyle, bool preview )
145{ 145{
146 // FIXME: add a better caption to the Printingdialog 146 // FIXME: add a better caption to the Printingdialog
147 //mPrinter->setPreviewOnly( preview ); 147 //mPrinter->setPreviewOnly( preview );
148 if ( preview || mPrinter->setup( mParent ) ) { 148 if ( preview || mPrinter->setup( mParent ) ) {
149 switch ( mPrintDialog->orientation() ) { 149 switch ( mPrintDialog->orientation() ) {
150 case eOrientPlugin: 150 case eOrientPlugin:
151 mPrinter->setOrientation( selectedStyle->orientation()); 151 mPrinter->setOrientation( selectedStyle->orientation());
152 break; 152 break;
153 case eOrientPortrait: 153 case eOrientPortrait:
154 mPrinter->setOrientation( KPrinter::Portrait ); 154 mPrinter->setOrientation( KPrinter::Portrait );
155 break; 155 break;
156 case eOrientLandscape: 156 case eOrientLandscape:
157 mPrinter->setOrientation( KPrinter::Landscape ); 157 mPrinter->setOrientation( KPrinter::Landscape );
158 break; 158 break;
159 case eOrientPrinter: 159 case eOrientPrinter:
160 default: 160 default:
161 break; 161 break;
162 } 162 }
163 selectedStyle->doPrint(); 163 selectedStyle->doPrint();
164 } 164 }
165 //mPrinter->setPreviewOnly( false ); 165 //mPrinter->setPreviewOnly( false );
166} 166}
167 167
168/////////////////////////////////////////////////////////////////////////////// 168///////////////////////////////////////////////////////////////////////////////
169 169
170void CalPrinter::updateConfig() 170void CalPrinter::updateConfig()
171{ 171{
172} 172}
173 173
174 174
175/****************************************************************************/ 175/****************************************************************************/
176 176
177CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p, 177CalPrintDialog::CalPrintDialog( QPtrList<CalPrintBase> plugins, KPrinter *p,
178 QWidget *parent, const char *name ) 178 QWidget *parent, const char *name )
179 : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ), 179 : KDialogBase( parent, name, /*modal*/true, i18n("Print"), Ok | Cancel ),
180 mPrinter( p ), mPrintPlugins( plugins ) 180 mPrinter( p ), mPrintPlugins( plugins )
181{ 181{
182 QVBox *page = new QVBox(this);//makeVBoxMainWidget(); 182 QVBox *page = new QVBox(this);//makeVBoxMainWidget();
183 setMainWidget( page ); 183 setMainWidget( page );
184 QHBox *printerLayout = new QHBox( page ); 184 QHBox *printerLayout = new QHBox( page );
185 185
186 mPrinterLabel = new QLabel( printerLayout ); 186 mPrinterLabel = new QLabel( printerLayout );
187 QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."), 187 QPushButton *setupButton = new QPushButton( i18n("&Setup Printer..."),
188 printerLayout ); 188 printerLayout );
189 setupButton->setSizePolicy( QSizePolicy( 189 setupButton->setSizePolicy( QSizePolicy(
190 (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0, 190 (QSizePolicy::SizeType)4, (QSizePolicy::SizeType)0,
191 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) ); 191 0, 0, setupButton->sizePolicy().hasHeightForWidth() ) );
192 192
193 QSplitter *splitter = new QSplitter( page ); 193 QSplitter *splitter = new QSplitter( page );
194 splitter->setOrientation( QSplitter::Horizontal ); 194 splitter->setOrientation( QSplitter::Horizontal );
195 195
196 mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" ); 196 mTypeGroup = new QVButtonGroup( i18n("View Type"), splitter, "buttonGroup" );
197 // use the minimal width possible = max width of the radio buttons, not extensible 197 // use the minimal width possible = max width of the radio buttons, not extensible
198/* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4, 198/* mTypeGroup->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)4,
199 (QSizePolicy::SizeType)5, 0, 0, 199 (QSizePolicy::SizeType)5, 0, 0,
200 mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/ 200 mTypeGroup->sizePolicy().hasHeightForWidth() ) );*/
201 201
202 QWidget *splitterRight = new QWidget( splitter, "splitterRight" ); 202 QWidget *splitterRight = new QWidget( splitter, "splitterRight" );
203 QGridLayout *splitterRightLayout = new QGridLayout( splitterRight ); 203 QGridLayout *splitterRightLayout = new QGridLayout( splitterRight );
204 splitterRightLayout->setMargin( marginHint() ); 204 splitterRightLayout->setMargin( marginHint() );
205 splitterRightLayout->setSpacing( spacingHint() ); 205 splitterRightLayout->setSpacing( spacingHint() );
206 206
207 mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" ); 207 mConfigArea = new QWidgetStack( splitterRight, "configWidgetStack" );
208 splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 ); 208 splitterRightLayout->addMultiCellWidget( mConfigArea, 0,0, 0,1 );
209 209
210 QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"), 210 QLabel *orientationLabel = new QLabel( i18n("Page &orientation:"),
211 splitterRight, "orientationLabel" ); 211 splitterRight, "orientationLabel" );
212 splitterRightLayout->addWidget( orientationLabel, 1, 0 ); 212 splitterRightLayout->addWidget( orientationLabel, 1, 0 );
213 213
214 mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" ); 214 mOrientationSelection = new QComboBox( splitterRight, "orientationCombo" );
215 mOrientationSelection->insertItem( i18n("Use Default of Selected Style") ); 215 mOrientationSelection->insertItem( i18n("Use Default of Selected Style") );
216 mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") ); 216 mOrientationSelection->insertItem( i18n("Use Default Setting of Printer") );
217 mOrientationSelection->insertItem( i18n("Portrait") ); 217 mOrientationSelection->insertItem( i18n("Portrait") );
218 mOrientationSelection->insertItem( i18n("Landscape") ); 218 mOrientationSelection->insertItem( i18n("Landscape") );
219 splitterRightLayout->addWidget( mOrientationSelection, 1, 1 ); 219 splitterRightLayout->addWidget( mOrientationSelection, 1, 1 );
220 220
221 // signals and slots connections 221 // signals and slots connections
222 connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) ); 222 connect( setupButton, SIGNAL( clicked() ), SLOT( setupPrinter() ) );
223 connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) ); 223 connect( mTypeGroup, SIGNAL( clicked( int ) ), SLOT( setPrintType( int ) ) );
224 224
225 // buddies 225 // buddies
226 orientationLabel->setBuddy( mOrientationSelection ); 226 orientationLabel->setBuddy( mOrientationSelection );
227 227
228 CalPrintBase *plug = mPrintPlugins.first(); 228 CalPrintBase *plug = mPrintPlugins.first();
229 QRadioButton *radioButton; 229 QRadioButton *radioButton;
230 int id = 0; 230 int id = 0;
231 while ( plug ) { 231 while ( plug ) {
232 radioButton = new QRadioButton( plug->description(), mTypeGroup ); 232 radioButton = new QRadioButton( plug->description(), mTypeGroup );
233 mTypeGroup->insert( radioButton, id ); 233 mTypeGroup->insert( radioButton, id );
234 //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 ); 234 //radioButton->setMinimumHeight( radioButton->sizeHint().height() - 5 );
235 235
236 mConfigArea->addWidget( plug->configWidget( mConfigArea ), id ); 236 mConfigArea->addWidget( plug->configWidget( mConfigArea ), id );
237 237
238 plug = mPrintPlugins.next(); 238 plug = mPrintPlugins.next();
239 id++; 239 id++;
240 } 240 }
241 241
242 // setMinimumSize( minimumSizeHint() ); 242 // setMinimumSize( minimumSizeHint() );
243 //resize( minimumSizeHint() ); 243 //resize( minimumSizeHint() );
244} 244}
245 245
246CalPrintDialog::~CalPrintDialog() 246CalPrintDialog::~CalPrintDialog()
247{ 247{
248} 248}
249 249
250void CalPrintDialog::setupPrinter() 250void CalPrintDialog::setupPrinter()
251{ 251{
252 if ( mPrinter->setup( this ) ) { 252 if ( mPrinter->setup( this ) ) {
253 setPrinterLabel(); 253 setPrinterLabel();
254 } 254 }
255} 255}
256 256
257void CalPrintDialog::setPreview(bool preview) 257void CalPrintDialog::setPreview(bool preview)
258{ 258{
259 259
260 setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") ); 260 setButtonText(KDialogBase::Ok, preview ? i18n("&Preview") : i18n("&Print...") );
261 261
262 mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>") 262 mPreviewText = preview ? i18n("<qt>Preview for printer <b>%1</b></qt>")
263 : i18n( "<qt>Printing on printer <b>%1</b></qt>"); 263 : i18n( "<qt>Printing on printer <b>%1</b></qt>");
264 setPrinterLabel(); 264 setPrinterLabel();
265} 265}
266 266
267void CalPrintDialog::setPrinterLabel() 267void CalPrintDialog::setPrinterLabel()
268{ 268{
269 QString printerName( mPrinter->printerName() ); 269 QString printerName( mPrinter->printerName() );
270 if ( printerName.isEmpty() ) 270 if ( printerName.isEmpty() )
271 mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) ); 271 mPrinterLabel->setText( mPreviewText.arg( i18n("[Unconfigured]") ) );
272 else 272 else
273 mPrinterLabel->setText( mPreviewText.arg( printerName ) ); 273 mPrinterLabel->setText( mPreviewText.arg( printerName ) );
274} 274}
275 275
276void CalPrintDialog::setPrintType( int i ) 276void CalPrintDialog::setPrintType( int i )
277{ 277{
278 // TODO: Make a safe correlation between type and the radio button 278 // TODO: Make a safe correlation between type and the radio button
279 279
280 mTypeGroup->setButton( i ); 280 mTypeGroup->setButton( i );
281 mConfigArea->raiseWidget( i ); 281 mConfigArea->raiseWidget( i );
282} 282}
283 283
284CalPrintBase *CalPrintDialog::selectedPlugin() 284CalPrintBase *CalPrintDialog::selectedPlugin()
285{ 285{
286 int pos = mTypeGroup->id( mTypeGroup->selected() ); 286 int pos = mTypeGroup->id( mTypeGroup->selected() );
287 if ( pos < 0 ) return 0; 287 if ( pos < 0 ) return 0;
288 CalPrintBase *retval = mPrintPlugins.at( pos ); 288 CalPrintBase *retval = mPrintPlugins.at( pos );
289 return retval; 289 return retval;
290} 290}
291 291
292void CalPrintDialog::slotOk() 292void CalPrintDialog::slotOk()
293{ 293{
294 mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem(); 294 mOrientation = (CalPrinter::ePrintOrientation)mOrientationSelection->currentItem();
295 KDialogBase::slotOk(); 295 KDialogBase::slotOk();
296 emit okClicked(); 296 emit okClicked();
297} 297}
298 298
299#endif 299#endif