• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

korganizer

  • sources
  • kde-4.12
  • kdepim
  • korganizer
  • printing
calprintdefaultplugins.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KOrganizer.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (C) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
6  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7  Copyright (c) 2008 Ron Goodheart <rong.dev@gmail.com>
8  Copyright (c) 2010 Laurent Montel <montel@kde.org>
9  Copyright (c) 2012 Allen Winter <winter@kde.org>
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License along
22  with this program; if not, write to the Free Software Foundation, Inc.,
23  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 
25  As a special exception, permission is given to link this program
26  with any edition of Qt, and distribute the resulting executable,
27  without including the source code for Qt in the source distribution.
28 */
29 
30 #include "calprintdefaultplugins.h"
31 #include "koglobals.h"
32 
33 #include <Akonadi/Calendar/ETMCalendar>
34 #include <calendarsupport/kcalprefs.h>
35 #include <calendarsupport/utils.h>
36 
37 #include <KCalCore/Visitor>
38 
39 #include <KCalUtils/IncidenceFormatter>
40 #include <KCalUtils/Stringify>
41 
42 #include <KCalendarSystem>
43 #include <KDateTime>
44 #include <KConfigGroup>
45 #include <KSystemTimeZones>
46 
47 #include <QDateTime>
48 #include <QPainter>
49 #include <QPrinter>
50 
51 using namespace KCalUtils;
52 
53 static QString cleanStr( const QString &instr )
54 {
55  QString ret = instr;
56  return ret.replace( QLatin1Char('\n'), QLatin1Char(' ') );
57 }
58 
59 /**************************************************************
60  * Print Incidence
61  **************************************************************/
62 
63 CalPrintIncidence::CalPrintIncidence() : CalPrintPluginBase()
64 {
65 }
66 
67 CalPrintIncidence::~CalPrintIncidence()
68 {
69 }
70 
71 QWidget *CalPrintIncidence::createConfigWidget( QWidget *w )
72 {
73  return new CalPrintIncidenceConfig( w );
74 }
75 
76 void CalPrintIncidence::readSettingsWidget()
77 {
78  CalPrintIncidenceConfig *cfg =
79  dynamic_cast<CalPrintIncidenceConfig *>( ( QWidget* )mConfigWidget );
80  if ( cfg ) {
81  mUseColors = cfg->mColors->isChecked();
82  mPrintFooter = cfg->mPrintFooter->isChecked();
83  mShowOptions = cfg->mShowDetails->isChecked();
84  mShowSubitemsNotes = cfg->mShowSubitemsNotes->isChecked();
85  mShowAttendees = cfg->mShowAttendees->isChecked();
86  mShowAttachments = cfg->mShowAttachments->isChecked();
87  mShowNoteLines = cfg->mShowNoteLines->isChecked();
88  }
89 }
90 
91 void CalPrintIncidence::setSettingsWidget()
92 {
93  CalPrintIncidenceConfig *cfg =
94  dynamic_cast<CalPrintIncidenceConfig *>( ( QWidget* )mConfigWidget );
95  if ( cfg ) {
96  cfg->mColors->setChecked( mUseColors );
97  cfg->mPrintFooter->setChecked( mPrintFooter );
98  cfg->mShowDetails->setChecked( mShowOptions );
99  cfg->mShowSubitemsNotes->setChecked( mShowSubitemsNotes );
100  cfg->mShowAttendees->setChecked( mShowAttendees );
101  cfg->mShowAttachments->setChecked( mShowAttachments );
102  cfg->mShowNoteLines->setChecked( mShowNoteLines );
103  }
104 }
105 
106 void CalPrintIncidence::loadConfig()
107 {
108  if ( mConfig ) {
109  KConfigGroup grp( mConfig, groupName() );
110  mShowOptions = grp.readEntry( "Show Options", false );
111  mShowSubitemsNotes = grp.readEntry( "Show Subitems and Notes", false );
112  mShowAttendees = grp.readEntry( "Use Attendees", false );
113  mShowAttachments = grp.readEntry( "Use Attachments", false );
114  mShowNoteLines = grp.readEntry( "Note Lines", false );
115  }
116  setSettingsWidget();
117 }
118 
119 void CalPrintIncidence::saveConfig()
120 {
121  readSettingsWidget();
122  if ( mConfig ) {
123  KConfigGroup grp( mConfig, groupName() );
124  grp.writeEntry( "Show Options", mShowOptions );
125  grp.writeEntry( "Show Subitems and Notes", mShowSubitemsNotes );
126  grp.writeEntry( "Use Attendees", mShowAttendees );
127  grp.writeEntry( "Use Attachments", mShowAttachments );
128  grp.writeEntry( "Note Lines", mShowNoteLines );
129  }
130 }
131 
132 class TimePrintStringsVisitor : public Visitor
133 {
134  public:
135  TimePrintStringsVisitor() {}
136 
137  bool act( IncidenceBase::Ptr incidence )
138  {
139  return incidence->accept( *this, incidence );
140  }
141  QString mStartCaption, mStartString;
142  QString mEndCaption, mEndString;
143  QString mDurationCaption, mDurationString;
144 
145  protected:
146  bool visit( Event::Ptr event ) {
147  if ( event->dtStart().isValid() ) {
148  mStartCaption = i18n( "Start date: " );
149  mStartString = IncidenceFormatter::dateTimeToString(
150  event->dtStart(), event->allDay(), false );
151  } else {
152  mStartCaption = i18n( "No start date" );
153  mStartString.clear();
154  }
155 
156  if ( event->hasEndDate() ) {
157  mEndCaption = i18n( "End date: " );
158  mEndString = IncidenceFormatter::dateTimeToString(
159  event->dtEnd(), event->allDay(), false );
160  } else if ( event->hasDuration() ) {
161  mEndCaption = i18n( "Duration: " );
162  int mins = event->duration().asSeconds() / 60;
163  if ( mins >= 60 ) {
164  mEndString += i18np( "1 hour ", "%1 hours ", mins / 60 );
165  }
166  if ( mins % 60 > 0 ) {
167  mEndString += i18np( "1 minute ", "%1 minutes ", mins % 60 );
168  }
169  } else {
170  mEndCaption = i18n( "No end date" );
171  mEndString.clear();
172  }
173  return true;
174  }
175  bool visit( Todo::Ptr todo ) {
176  if ( todo->hasStartDate() ) {
177  mStartCaption = i18n( "Start date: " );
178  mStartString = IncidenceFormatter::dateTimeToString(
179  todo->dtStart(), todo->allDay(), false );
180  } else {
181  mStartCaption = i18n( "No start date" );
182  mStartString.clear();
183  }
184 
185  if ( todo->hasDueDate() ) {
186  mEndCaption = i18n( "Due date: " );
187  mEndString = IncidenceFormatter::dateTimeToString(
188  todo->dtDue(), todo->allDay(), false );
189  } else {
190  mEndCaption = i18n( "No due date" );
191  mEndString.clear();
192  }
193  return true;
194  }
195  bool visit( Journal::Ptr journal ) {
196  mStartCaption = i18n( "Start date: " );
197  mStartString = IncidenceFormatter::dateTimeToString(
198  journal->dtStart(), journal->allDay(), false );
199  mEndCaption.clear();
200  mEndString.clear();
201  return true;
202  }
203  bool visit( FreeBusy::Ptr fb ) {
204  Q_UNUSED( fb );
205  return true;
206  }
207 };
208 
209 int CalPrintIncidence::printCaptionAndText( QPainter &p, const QRect &box,
210  const QString &caption,
211  const QString &text,
212  QFont captionFont, QFont textFont )
213 {
214  QFontMetrics captionFM( captionFont );
215  int textWd = captionFM.width( caption );
216  QRect textRect( box );
217 
218  QFont oldFont( p.font() );
219  p.setFont( captionFont );
220  p.drawText( box, Qt::AlignLeft|Qt::AlignTop|Qt::TextSingleLine, caption );
221 
222  if ( !text.isEmpty() ) {
223  textRect.setLeft( textRect.left() + textWd );
224  p.setFont( textFont );
225  p.drawText( textRect, Qt::AlignLeft|Qt::AlignTop|Qt::TextSingleLine, text );
226  }
227  p.setFont( oldFont );
228  return textRect.bottom();
229 }
230 
231 void CalPrintIncidence::print( QPainter &p, int width, int height )
232 {
233  QFont oldFont( p.font() );
234  QFont textFont( QLatin1String("sans-serif"), 11, QFont::Normal );
235  QFont captionFont( QLatin1String("sans-serif"), 11, QFont::Bold );
236  p.setFont( textFont );
237  int lineHeight = p.fontMetrics().lineSpacing();
238  QString cap, txt;
239 
240  Incidence::List::ConstIterator it;
241  for ( it = mSelectedIncidences.constBegin(); it != mSelectedIncidences.constEnd(); ++it ) {
242  // don't do anything on a 0-pointer!
243  if ( !(*it) ) {
244  continue;
245  }
246  if ( it != mSelectedIncidences.constBegin() ) {
247  mPrinter->newPage();
248  }
249 
250  const bool isJournal = ( (*it)->type() == Incidence::TypeJournal );
251 
252  // PAGE Layout (same for landscape and portrait! astonishingly, it looks good with both!):
253  // +-----------------------------------+
254  // | Header: Summary |
255  // +===================================+
256  // | start: ______ end: _________ |
257  // | repeats: ___________________ |
258  // | reminder: __________________ |
259  // +-----------------------------------+
260  // | Location: ______________________ |
261  // +------------------------+----------+
262  // | Description: | Notes or |
263  // | | Subitems |
264  // | | |
265  // | | |
266  // | | |
267  // | | |
268  // | | |
269  // | | |
270  // | | |
271  // | | |
272  // +------------------------+----------+
273  // | Attachments: | Settings |
274  // | | |
275  // +------------------------+----------+
276  // | Attendees: |
277  // | |
278  // +-----------------------------------+
279  // | Categories: _____________________ |
280  // +-----------------------------------+
281 
282  QRect box( 0, 0, width, height );
283  QRect titleBox( box );
284  titleBox.setHeight( headerHeight() );
285  QColor headerColor = categoryBgColor( *it );
286  // Draw summary as header, no small calendars in title bar, expand height if needed
287  int titleBottom = drawHeader( p, (*it)->summary(), QDate(), QDate(),
288  titleBox, true, headerColor );
289  titleBox.setBottom( titleBottom );
290 
291  QRect timesBox( titleBox );
292  timesBox.setTop( titleBox.bottom() + padding() );
293  timesBox.setHeight( height / 8 );
294 
295  TimePrintStringsVisitor stringVis;
296  int h = timesBox.top();
297  if ( stringVis.act( *it ) ) {
298  QRect textRect( timesBox.left() + padding(),
299  timesBox.top() + padding(), 0, lineHeight );
300  textRect.setRight( timesBox.center().x() );
301  h = printCaptionAndText( p, textRect, stringVis.mStartCaption,
302  stringVis.mStartString, captionFont, textFont );
303 
304  textRect.setLeft( textRect.right() );
305  textRect.setRight( timesBox.right() - padding() );
306  h = qMax( printCaptionAndText( p, textRect, stringVis.mEndCaption,
307  stringVis.mEndString, captionFont, textFont ), h );
308  }
309 
310  // Recurrence Printing
311  if ( (*it)->recurs() ) {
312  QRect recurBox( timesBox.left() + padding(), h + padding(),
313  timesBox.right() - padding(), lineHeight );
314  KCalCore::Recurrence *recurs = (*it)->recurrence();
315  QString displayString = IncidenceFormatter::recurrenceString((*it));
316  // exception dates
317  QString exceptString;
318  if ( !recurs->exDates().isEmpty() ) {
319  exceptString = i18nc( "except for listed dates", " except" );
320  for ( int i = 0; i < recurs->exDates().size(); ++i ) {
321  exceptString.append( QLatin1String(" ") );
322  exceptString.append( KGlobal::locale()->formatDate( recurs->exDates()[i],
323  KLocale::ShortDate ) );
324  }
325  }
326  displayString.append( exceptString );
327  h = qMax( printCaptionAndText( p, recurBox, i18n( "Repeats: " ),
328  displayString, captionFont, textFont ), h );
329  }
330 
331  if ( !isJournal ) {
332  // Alarms Printing
333  QRect alarmBox( timesBox.left() + padding(), h + padding(),
334  timesBox.right() - padding(), lineHeight );
335  Alarm::List alarms = (*it)->alarms();
336  if ( alarms.count() == 0 ) {
337  cap = i18n( "No reminders" );
338  txt.clear();
339  } else {
340  cap = i18np( "Reminder: ", "%1 reminders: ", alarms.count() );
341 
342  QStringList alarmStrings;
343  KCalCore::Alarm::List::ConstIterator it;
344  for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it ) {
345  Alarm::Ptr alarm = *it;
346 
347  // Alarm offset, copied from koeditoralarms.cpp:
348  KLocalizedString offsetstr;
349  int offset = 0;
350  if ( alarm->hasStartOffset() ) {
351  offset = alarm->startOffset().asSeconds();
352  if ( offset < 0 ) {
353  offsetstr = ki18nc( "N days/hours/minutes before/after the start/end",
354  "%1 before the start" );
355  offset = -offset;
356  } else {
357  offsetstr = ki18nc( "N days/hours/minutes before/after the start/end",
358  "%1 after the start" );
359  }
360  } else if ( alarm->hasEndOffset() ) {
361  offset = alarm->endOffset().asSeconds();
362  if ( offset < 0 ) {
363  offsetstr = ki18nc( "N days/hours/minutes before/after the start/end",
364  "%1 before the end" );
365  offset = -offset;
366  } else {
367  offsetstr = ki18nc( "N days/hours/minutes before/after the start/end",
368  "%1 after the end" );
369  }
370  }
371 
372  offset = offset / 60; // make minutes
373  int useoffset = offset;
374 
375  if ( offset % ( 24 * 60 ) == 0 && offset > 0 ) { // divides evenly into days?
376  useoffset = offset / ( 24 * 60 );
377  offsetstr = offsetstr.subs( i18np( "1 day", "%1 days", useoffset ) );
378  } else if ( offset % 60 == 0 && offset > 0 ) { // divides evenly into hours?
379  useoffset = offset / 60;
380  offsetstr = offsetstr.subs( i18np( "1 hour", "%1 hours", useoffset ) );
381  } else {
382  useoffset = offset;
383  offsetstr = offsetstr.subs( i18np( "1 minute", "%1 minutes", useoffset ) );
384  }
385  alarmStrings << offsetstr.toString();
386  }
387  txt = alarmStrings.join( i18nc( "Spacer for the joined list of categories", ", " ) );
388 
389  }
390  h = qMax( printCaptionAndText( p, alarmBox, cap, txt, captionFont, textFont ), h );
391  }
392  QRect organizerBox( timesBox.left() + padding(), h + padding(),
393  timesBox.right() - padding(), lineHeight );
394  h = qMax( printCaptionAndText( p, organizerBox, i18n( "Organizer: " ),
395  (*it)->organizer()->fullName(), captionFont, textFont ), h );
396 
397  // Finally, draw the frame around the time information...
398  timesBox.setBottom( qMax( timesBox.bottom(), h + padding() ) );
399  drawBox( p, BOX_BORDER_WIDTH, timesBox );
400 
401  QRect locationBox( timesBox );
402  locationBox.setTop( timesBox.bottom() + padding() );
403  locationBox.setHeight( 0 );
404  int locationBottom = 0;
405  if ( !isJournal ) {
406  locationBottom = drawBoxWithCaption( p, locationBox, i18n( "Location: " ),
407  (*it)->location(), /*sameLine=*/true,
408  /*expand=*/true, captionFont, textFont );
409  }
410  locationBox.setBottom( locationBottom );
411 
412  // Now start constructing the boxes from the bottom:
413  QRect footerBox( locationBox );
414  footerBox.setBottom( box.bottom() );
415  footerBox.setTop( footerBox.bottom() - lineHeight - 2 * padding() );
416 
417  QRect categoriesBox( footerBox );
418  categoriesBox.setBottom( footerBox.top() );
419  categoriesBox.setTop( categoriesBox.bottom() - lineHeight - 2 * padding() );
420  QRect attendeesBox( box.left(), categoriesBox.top() - padding() - box.height() / 9,
421  box.width(), box.height() / 9 );
422  QRect attachmentsBox( box.left(), attendeesBox.top() - padding() - box.height() / 9,
423  box.width() * 3 / 4 - padding(), box.height() / 9 );
424  QRect optionsBox( isJournal ? box.left() : attachmentsBox.right() + padding(),
425  attachmentsBox.top(), 0, 0 );
426  optionsBox.setRight( box.right() );
427  optionsBox.setBottom( attachmentsBox.bottom() );
428  QRect notesBox( optionsBox.left(),
429  isJournal ? ( timesBox.bottom() + padding() ) :
430  ( locationBox.bottom() + padding() ),
431  optionsBox.width(), 0 );
432  notesBox.setBottom( optionsBox.top() - padding() );
433  QRect descriptionBox( notesBox );
434  descriptionBox.setLeft( box.left() );
435  descriptionBox.setRight( attachmentsBox.right() );
436 
437  // Adjust boxes depending on the show options...
438  if ( !mShowSubitemsNotes || isJournal ) {
439  descriptionBox.setRight( box.right() );
440  }
441  if ( !mShowAttachments || !mShowAttendees ) {
442  descriptionBox.setBottom( attachmentsBox.bottom() );
443  optionsBox.setTop( attendeesBox.top() );
444  optionsBox.setBottom( attendeesBox.bottom() );
445  notesBox.setBottom( attachmentsBox.bottom() );
446  if ( mShowOptions ) {
447  attendeesBox.setRight( attachmentsBox.right() );
448  }
449  if ( !mShowAttachments && !mShowAttendees ) {
450  if ( mShowSubitemsNotes ) {
451  descriptionBox.setBottom( attendeesBox.bottom() );
452  }
453  if ( !mShowOptions ) {
454  descriptionBox.setBottom( attendeesBox.bottom() );
455  notesBox.setBottom( attendeesBox.bottom() );
456  }
457  }
458  }
459  if ( mShowAttachments && !isJournal ) {
460  if ( !mShowOptions ) {
461  attachmentsBox.setRight( box.right() );
462  attachmentsBox.setRight( box.right() );
463  }
464  if ( !mShowAttendees ) {
465  attachmentsBox.setTop( attendeesBox.top() );
466  attachmentsBox.setBottom( attendeesBox.bottom() );
467  }
468  }
469  int newBottom = drawBoxWithCaption( p, descriptionBox, i18n( "Description:" ),
470  (*it)->description(), /*sameLine=*/false,
471  /*expand=*/false, captionFont, textFont,
472  (*it)->descriptionIsRich() );
473  if ( mShowNoteLines ) {
474  drawNoteLines( p, descriptionBox, newBottom );
475  }
476 
477  Akonadi::Item item = mCalendar->item( (*it)->uid() );
478  Akonadi::Item::List relations = mCalendar->childItems( item.id() );
479 
480  if ( mShowSubitemsNotes && !isJournal ) {
481  if ( relations.isEmpty() || (*it)->type() != Incidence::TypeTodo ) {
482  int notesPosition = drawBoxWithCaption( p, notesBox, i18n( "Notes:" ),
483  QString(), /*sameLine=*/false,
484  /*expand=*/false, captionFont, textFont );
485  drawNoteLines( p, notesBox, notesPosition );
486  } else {
487 
488  QString subitemCaption;
489  if ( relations.count() == 0 ) {
490  subitemCaption = i18n( "No Subitems" );
491  txt.clear();
492  } else {
493  subitemCaption = i18np( "1 Subitem:",
494  "%1 Subitems:",
495  relations.count() );
496  }
497 
498  QString subitemString;
499  QString statusString;
500  QString datesString;
501  int count = 0;
502  foreach ( const Akonadi::Item &item, relations ) {
503  Todo::Ptr todo = CalendarSupport::todo( item );
504  ++count;
505  if ( !todo ) { // defensive, skip any zero pointers
506  continue;
507  }
508  // format the status
509  statusString = Stringify::incidenceStatus( todo->status() );
510  if ( statusString.isEmpty() ) {
511  if ( todo->status() == Incidence::StatusNone ) {
512  statusString = i18nc( "no status", "none" );
513  } else {
514  statusString = i18nc( "unknown status", "unknown" );
515  }
516  }
517  // format the dates if provided
518  datesString.clear();
519  KDateTime::Spec spec = CalendarSupport::KCalPrefs::instance()->timeSpec();
520  if ( todo->dtStart().isValid() ) {
521  datesString += i18nc(
522  "subitem start date", "Start Date: %1\n",
523  KGlobal::locale()->formatDate( todo->dtStart().toTimeSpec( spec ).date(),
524  KLocale::ShortDate ) );
525  if ( !todo->allDay() ) {
526  datesString += i18nc(
527  "subitem start time", "Start Time: %1\n",
528  KGlobal::locale()->formatTime( todo->dtStart().toTimeSpec( spec ).time(),
529  false, false ) );
530  }
531  }
532  if ( todo->dateTime( Incidence::RoleEnd ).isValid() ) {
533  subitemString +=
534  i18nc( "subitem due date", "Due Date: %1\n",
535  KGlobal::locale()->formatDate(
536  todo->dateTime( Incidence::RoleEnd ).toTimeSpec( spec ).date(),
537  KLocale::ShortDate ) );
538 
539  if ( !todo->allDay() ) {
540  subitemString += i18nc(
541  "subitem due time", "Due Time: %1\n",
542  KGlobal::locale()->formatTime(
543  todo->dateTime( Incidence::RoleEnd ).toTimeSpec( spec ).time(),
544  false, false ) );
545  }
546  }
547  subitemString += i18nc( "subitem counter", "%1: ", count );
548  subitemString += todo->summary();
549  subitemString += QLatin1Char('\n');
550  if ( !datesString.isEmpty() ) {
551  subitemString += datesString;
552  subitemString += QLatin1Char('\n');
553  }
554  subitemString += i18nc( "subitem Status: statusString",
555  "Status: %1\n",
556  statusString );
557  subitemString += IncidenceFormatter::recurrenceString( todo ) + QLatin1Char('\n');
558  subitemString += i18nc( "subitem Priority: N",
559  "Priority: <numid>%1</numid>\n",
560  todo->priority() );
561  subitemString += i18nc( "subitem Secrecy: secrecyString",
562  "Secrecy: %1\n",
563  Stringify::incidenceSecrecy( todo->secrecy() ) );
564  subitemString += QLatin1Char('\n');
565  }
566  drawBoxWithCaption( p, notesBox, subitemCaption,
567  subitemString, /*sameLine=*/false,
568  /*expand=*/false, captionFont, textFont );
569  }
570  }
571 
572  if ( mShowAttachments && !isJournal ) {
573  Attachment::List attachments = (*it)->attachments();
574  QString attachmentCaption;
575  if ( attachments.count() == 0 ) {
576  attachmentCaption = i18n( "No Attachments" );
577  txt.clear();
578  } else {
579  attachmentCaption = i18np( "1 Attachment:",
580  "%1 Attachments:",
581  attachments.count() );
582  }
583  QString attachmentString;
584  Attachment::List::ConstIterator ait = attachments.constBegin();
585  for ( ; ait != attachments.constEnd(); ++ait ) {
586  if ( !attachmentString.isEmpty() ) {
587  attachmentString += i18nc( "Spacer for list of attachments", " " );
588  }
589  attachmentString.append( (*ait)->label() );
590  }
591  drawBoxWithCaption( p, attachmentsBox,
592  attachmentCaption, attachmentString,
593  /*sameLine=*/false, /*expand=*/false,
594  captionFont, textFont );
595  }
596  if ( mShowAttendees ) {
597  Attendee::List attendees = (*it)->attendees();
598  QString attendeeCaption;
599  if ( attendees.count() == 0 ) {
600  attendeeCaption = i18n( "No Attendees" );
601  } else {
602  attendeeCaption = i18np( "1 Attendee:",
603  "%1 Attendees:",
604  attendees.count() );
605  }
606  QString attendeeString;
607  Attendee::List::ConstIterator ait = attendees.constBegin();
608  for ( ; ait != attendees.constEnd(); ++ait ) {
609  if ( !attendeeString.isEmpty() ) {
610  attendeeString += QLatin1Char('\n');
611  }
612  attendeeString += i18nc(
613  "Formatting of an attendee: "
614  "'Name (Role): Status', e.g. 'Reinhold Kainhofer "
615  "<reinhold@kainhofer.com> (Participant): Awaiting Response'",
616  "%1 (%2): %3",
617  (*ait)->fullName(),
618  Stringify::attendeeRole( (*ait)->role() ),
619  Stringify::attendeeStatus( ( *ait )->status() ) );
620  }
621  drawBoxWithCaption( p, attendeesBox, attendeeCaption, attendeeString,
622  /*sameLine=*/false, /*expand=*/false,
623  captionFont, textFont );
624  }
625 
626  if ( mShowOptions ) {
627  QString optionsString;
628  if ( !Stringify::incidenceStatus( (*it)->status() ).isEmpty() ) {
629  optionsString += i18n( "Status: %1", Stringify::incidenceStatus( (*it)->status() ) );
630  optionsString += QLatin1Char('\n');
631  }
632  if ( !Stringify::incidenceSecrecy( (*it)->secrecy() ).isEmpty() ) {
633  optionsString += i18n( "Secrecy: %1", Stringify::incidenceSecrecy( (*it)->secrecy() ) );
634  optionsString += QLatin1Char('\n');
635  }
636  if ( (*it)->type() == Incidence::TypeEvent ) {
637  Event::Ptr e = (*it).staticCast<Event>();
638  if ( e->transparency() == Event::Opaque ) {
639  optionsString += i18n( "Show as: Busy" );
640  } else {
641  optionsString += i18n( "Show as: Free" );
642  }
643  optionsString += QLatin1Char('\n');
644  } else if ( (*it)->type() == Incidence::TypeTodo ) {
645  Todo::Ptr t = (*it).staticCast<Todo>();
646  if ( t->isOverdue() ) {
647  optionsString += i18n( "This task is overdue!" );
648  optionsString += QLatin1Char('\n');
649  }
650  } else if ( (*it)->type() == Incidence::TypeJournal ) {
651  //TODO: Anything Journal-specific?
652  }
653  drawBoxWithCaption( p, optionsBox, i18n( "Settings: " ),
654  optionsString, /*sameLine=*/false, /*expand=*/false,
655  captionFont, textFont );
656  }
657 
658  drawBoxWithCaption( p, categoriesBox, i18n( "Categories: " ),
659  (*it)->categories().join( i18nc( "Spacer for the joined list of categories", ", " ) ),
660  /*sameLine=*/true, /*expand=*/false, captionFont, textFont );
661 
662  if ( mPrintFooter ) {
663  drawFooter( p, footerBox );
664  }
665  }
666  p.setFont( oldFont );
667 }
668 
669 /**************************************************************
670  * Print Day
671  **************************************************************/
672 
673 CalPrintDay::CalPrintDay() : CalPrintPluginBase()
674 {
675 }
676 
677 CalPrintDay::~CalPrintDay()
678 {
679 }
680 
681 QWidget *CalPrintDay::createConfigWidget( QWidget *w )
682 {
683  return new CalPrintDayConfig( w );
684 }
685 
686 void CalPrintDay::readSettingsWidget()
687 {
688  CalPrintDayConfig *cfg =
689  dynamic_cast<CalPrintDayConfig *>( ( QWidget* )mConfigWidget );
690  if ( cfg ) {
691  mFromDate = cfg->mFromDate->date();
692  mToDate = cfg->mToDate->date();
693 
694  if ( cfg->mPrintTypeFilofax->isChecked() ) {
695  mDayPrintType = Filofax;
696  } else if ( cfg->mPrintTypeTimetable->isChecked() ) {
697  mDayPrintType = Timetable;
698  } else {
699  mDayPrintType = SingleTimetable;
700  }
701 
702  mStartTime = cfg->mFromTime->time();
703  mEndTime = cfg->mToTime->time();
704  mIncludeAllEvents = cfg->mIncludeAllEvents->isChecked();
705 
706  mIncludeDescription = cfg->mIncludeDescription->isChecked();
707  mSingleLineLimit = cfg->mSingleLineLimit->isChecked();
708  mIncludeTodos = cfg->mIncludeTodos->isChecked();
709  mUseColors = cfg->mColors->isChecked();
710  mPrintFooter = cfg->mPrintFooter->isChecked();
711  mShowNoteLines = cfg->mShowNoteLines->isChecked();
712  mExcludeTime = cfg->mExcludeTime->isChecked();
713  mExcludeConfidential = cfg->mExcludeConfidential->isChecked();
714  mExcludePrivate = cfg->mExcludePrivate->isChecked();
715  }
716 }
717 
718 void CalPrintDay::setSettingsWidget()
719 {
720  CalPrintDayConfig *cfg = dynamic_cast<CalPrintDayConfig *>( ( QWidget* )mConfigWidget );
721  if ( cfg ) {
722  cfg->mFromDate->setDate( mFromDate );
723  cfg->mToDate->setDate( mToDate );
724 
725  cfg->mPrintTypeFilofax->setChecked( mDayPrintType == Filofax );
726  cfg->mPrintTypeTimetable->setChecked( mDayPrintType == Timetable );
727  cfg->mPrintTypeSingleTimetable->setChecked( mDayPrintType == SingleTimetable );
728 
729  cfg->mFromTime->setTime( mStartTime );
730  cfg->mToTime->setTime( mEndTime );
731  cfg->mIncludeAllEvents->setChecked( mIncludeAllEvents );
732 
733  cfg->mIncludeDescription->setChecked( mIncludeDescription );
734  cfg->mSingleLineLimit->setChecked( mSingleLineLimit );
735  cfg->mIncludeTodos->setChecked( mIncludeTodos );
736  cfg->mColors->setChecked( mUseColors );
737  cfg->mPrintFooter->setChecked( mPrintFooter );
738  cfg->mShowNoteLines->setChecked( mShowNoteLines );
739  cfg->mExcludeTime->setChecked( mExcludeTime );
740  cfg->mExcludeConfidential->setChecked( mExcludeConfidential );
741  cfg->mExcludePrivate->setChecked( mExcludePrivate );
742  }
743 }
744 
745 void CalPrintDay::loadConfig()
746 {
747  if ( mConfig ) {
748  KConfigGroup grp( mConfig, groupName() );
749  QDate dt = QDate::currentDate(); // any valid QDate will do
750  QTime tm1( dayStart() );
751  QDateTime startTm( dt, tm1 );
752  QDateTime endTm( dt, tm1.addSecs( 12 * 60 * 60 ) );
753  mStartTime = grp.readEntry( "Start time", startTm ).time();
754  mEndTime = grp.readEntry( "End time", endTm ).time();
755  mIncludeDescription = grp.readEntry( "Include description", false );
756  mIncludeTodos = grp.readEntry( "Include todos", false );
757  mIncludeAllEvents = grp.readEntry( "Include all events", false );
758  mDayPrintType = (eDayPrintType)( grp.readEntry( "Print type", (int)Timetable ) );
759  mSingleLineLimit = grp.readEntry( "Single line limit", false );
760  mShowNoteLines = grp.readEntry( "Note Lines", false );
761  mExcludeTime = grp.readEntry( "Exclude time", false );
762  }
763  setSettingsWidget();
764 }
765 
766 void CalPrintDay::saveConfig()
767 {
768  readSettingsWidget();
769  if ( mConfig ) {
770  KConfigGroup grp( mConfig, groupName() );
771  QDateTime dt = QDateTime::currentDateTime(); // any valid QDateTime will do
772  dt.setTime( mStartTime );
773  grp.writeEntry( "Start time", dt );
774  dt.setTime( mEndTime );
775  grp.writeEntry( "End time", dt );
776  grp.writeEntry( "Include description", mIncludeDescription );
777  grp.writeEntry( "Include todos", mIncludeTodos );
778  grp.writeEntry( "Include all events", mIncludeAllEvents );
779  grp.writeEntry( "Print type", int( mDayPrintType ) );
780  grp.writeEntry( "Single line limit", mSingleLineLimit );
781  grp.writeEntry( "Note Lines", mShowNoteLines );
782  grp.writeEntry( "Exclude time", mExcludeTime );
783  }
784 }
785 
786 void CalPrintDay::setDateRange( const QDate &from, const QDate &to )
787 {
788  CalPrintPluginBase::setDateRange( from, to );
789  CalPrintDayConfig *cfg =
790  dynamic_cast<CalPrintDayConfig *>( ( QWidget* )mConfigWidget );
791  if ( cfg ) {
792  cfg->mFromDate->setDate( from );
793  cfg->mToDate->setDate( to );
794  }
795 }
796 
797 void CalPrintDay::print( QPainter &p, int width, int height )
798 {
799  QDate curDay( mFromDate );
800 
801  KDateTime::Spec timeSpec = KSystemTimeZones::local();
802 
803  QRect headerBox( 0, 0, width, headerHeight() );
804  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
805  height -= footerHeight();
806 
807  KLocale *local = KGlobal::locale();
808 
809  switch ( mDayPrintType ) {
810  case Filofax:
811  case SingleTimetable:
812  {
813  QRect daysBox( headerBox );
814  daysBox.setTop( headerBox.bottom() + padding() );
815  daysBox.setBottom( height );
816  QString line1 = local->formatDate( mFromDate );
817  QString line2 = local->formatDate( mToDate );
818  QString title;
819  if ( orientation() == QPrinter::Landscape ) {
820  title = i18nc( "date from-to", "%1 - %2", line1, line2 );
821  } else {
822  title = i18nc( "date from-\nto", "%1 -\n%2", line1, line2 );
823  }
824  drawHeader( p, title, mFromDate, QDate(), headerBox );
825  if ( mDayPrintType == Filofax ) {
826  drawDays( p, mFromDate, mToDate, mStartTime, mEndTime, daysBox,
827  mSingleLineLimit, mShowNoteLines,
828  mIncludeDescription, mExcludeConfidential, mExcludePrivate );
829  } else if ( mDayPrintType == SingleTimetable ) {
830  drawTimeTable( p, mFromDate, mToDate,
831  mIncludeAllEvents, mStartTime, mEndTime, daysBox,
832  mIncludeDescription, mExcludeTime, mExcludeConfidential,
833  mExcludePrivate );
834  }
835  if ( mPrintFooter ) {
836  drawFooter( p, footerBox );
837  }
838  }
839  break;
840 
841  case Timetable:
842  default:
843  do {
844  QTime curStartTime( mStartTime );
845  QTime curEndTime( mEndTime );
846 
847  // For an invalid time range, simply show one hour, starting at the hour
848  // before the given start time
849  if ( curEndTime <= curStartTime ) {
850  curStartTime = QTime( curStartTime.hour(), 0, 0 );
851  curEndTime = curStartTime.addSecs( 3600 );
852  }
853 
854  drawHeader( p, local->formatDate( curDay ), curDay, QDate(), headerBox );
855  KCalCore::Event::List eventList = mCalendar->events( curDay, timeSpec,
856  KCalCore::EventSortStartDate,
857  KCalCore::SortDirectionAscending );
858 
859  // split out the all day events as they will be printed in a separate box
860  KCalCore::Event::List alldayEvents, timedEvents;
861  foreach( const KCalCore::Event::Ptr &event, eventList ) {
862  if ( event->allDay() ) {
863  alldayEvents.append( event );
864  } else {
865  timedEvents.append( event );
866  }
867  }
868 
869  int fontSize = 11;
870  QFont textFont( QLatin1String("sans-serif"), fontSize, QFont::Normal );
871  p.setFont( textFont );
872  int lineSpacing = p.fontMetrics().lineSpacing();
873 
874  int maxAllDayEvents = 8; // the max we allow to be printed, sorry.
875  int allDayHeight = qMin( alldayEvents.count(), maxAllDayEvents ) * lineSpacing;
876  allDayHeight = qMax( allDayHeight, ( 5 * lineSpacing ) ) + ( 2 * padding() );
877  QRect allDayBox( TIMELINE_WIDTH + padding(), headerBox.bottom() + padding(),
878  width - TIMELINE_WIDTH - padding(), allDayHeight );
879  if ( alldayEvents.count() > 0 ) {
880  // draw the side bar for all-day events
881  QFont oldFont( p.font() );
882  p.setFont( QFont( QLatin1String("sans-serif"), 9, QFont::Normal ) );
883  drawVerticalBox( p,
884  BOX_BORDER_WIDTH,
885  QRect( 0, headerBox.bottom() + padding(), TIMELINE_WIDTH, allDayHeight ),
886  i18n( "Today's Events" ),
887  Qt::AlignHCenter | Qt::AlignVCenter | Qt::TextWordWrap );
888  p.setFont( oldFont );
889 
890  // now draw at most maxAllDayEvents in the all-day box
891  drawBox( p, BOX_BORDER_WIDTH, allDayBox );
892 
893  QRect eventBox( allDayBox );
894  eventBox.setLeft( TIMELINE_WIDTH + ( 2 * padding() ) );
895  eventBox.setTop( eventBox.top() + padding() );
896  eventBox.setBottom( eventBox.top() + lineSpacing );
897  int count = 0;
898  foreach ( const KCalCore::Event::Ptr &event, alldayEvents ) {
899  if ( count == maxAllDayEvents ) {
900  break;
901  }
902  count++;
903  QString str;
904  if ( event->location().isEmpty() ) {
905  str = cleanStr( event->summary() );
906  } else {
907  str = i18nc( "summary, location", "%1, %2",
908  cleanStr( event->summary() ), cleanStr( event->location() ) );
909  }
910  printEventString( p, eventBox, str );
911  eventBox.setTop( eventBox.bottom() );
912  eventBox.setBottom( eventBox.top() + lineSpacing );
913  }
914  } else {
915  allDayBox.setBottom( headerBox.bottom() );
916  }
917 
918  QRect dayBox( allDayBox );
919  dayBox.setTop( allDayBox.bottom() + padding() );
920  dayBox.setBottom( height );
921  QList<QDate> workDays = KOGlobals::self()->workDays( curDay, curDay );
922  drawAgendaDayBox( p, timedEvents, curDay, mIncludeAllEvents,
923  curStartTime, curEndTime, dayBox,
924  mIncludeDescription, mExcludeTime,
925  mExcludeConfidential, mExcludePrivate,
926  workDays );
927 
928  QRect tlBox( dayBox );
929  tlBox.setLeft( 0 );
930  tlBox.setWidth( TIMELINE_WIDTH );
931  drawTimeLine( p, curStartTime, curEndTime, tlBox );
932 
933  if ( mPrintFooter ) {
934  drawFooter( p, footerBox );
935  }
936 
937  curDay = curDay.addDays( 1 );
938  if ( curDay <= mToDate ) {
939  mPrinter->newPage();
940  }
941  } while ( curDay <= mToDate );
942  } //switch
943 }
944 
945 /**************************************************************
946  * Print Week
947  **************************************************************/
948 
949 CalPrintWeek::CalPrintWeek() : CalPrintPluginBase()
950 {
951 }
952 
953 CalPrintWeek::~CalPrintWeek()
954 {
955 }
956 
957 QWidget *CalPrintWeek::createConfigWidget( QWidget *w )
958 {
959  return new CalPrintWeekConfig( w );
960 }
961 
962 void CalPrintWeek::readSettingsWidget()
963 {
964  CalPrintWeekConfig *cfg = dynamic_cast<CalPrintWeekConfig *>( ( QWidget* )mConfigWidget );
965  if ( cfg ) {
966  mFromDate = cfg->mFromDate->date();
967  mToDate = cfg->mToDate->date();
968 
969  if ( cfg->mPrintTypeFilofax->isChecked() ) {
970  mWeekPrintType = Filofax;
971  } else if ( cfg->mPrintTypeTimetable->isChecked() ) {
972  mWeekPrintType = Timetable;
973  } else if ( cfg->mPrintTypeSplitWeek->isChecked() ) {
974  mWeekPrintType = SplitWeek;
975  } else {
976  mWeekPrintType = Timetable;
977  }
978 
979  mStartTime = cfg->mFromTime->time();
980  mEndTime = cfg->mToTime->time();
981 
982  mShowNoteLines = cfg->mShowNoteLines->isChecked();
983  mSingleLineLimit = cfg->mSingleLineLimit->isChecked();
984  mIncludeTodos = cfg->mIncludeTodos->isChecked();
985  mUseColors = cfg->mColors->isChecked();
986  mPrintFooter = cfg->mPrintFooter->isChecked();
987  mIncludeDescription = cfg->mIncludeDescription->isChecked();
988  mExcludeTime = cfg->mExcludeTime->isChecked();
989  mExcludeConfidential = cfg->mExcludeConfidential->isChecked();
990  mExcludePrivate = cfg->mExcludePrivate->isChecked();
991  }
992 }
993 
994 void CalPrintWeek::setSettingsWidget()
995 {
996  CalPrintWeekConfig *cfg = dynamic_cast<CalPrintWeekConfig *>( ( QWidget* )mConfigWidget );
997  if ( cfg ) {
998  cfg->mFromDate->setDate( mFromDate );
999  cfg->mToDate->setDate( mToDate );
1000 
1001  cfg->mPrintTypeFilofax->setChecked( mWeekPrintType == Filofax );
1002  cfg->mPrintTypeTimetable->setChecked( mWeekPrintType == Timetable );
1003  cfg->mPrintTypeSplitWeek->setChecked( mWeekPrintType == SplitWeek );
1004 
1005  cfg->mFromTime->setTime( mStartTime );
1006  cfg->mToTime->setTime( mEndTime );
1007 
1008  cfg->mShowNoteLines->setChecked( mShowNoteLines );
1009  cfg->mSingleLineLimit->setChecked( mSingleLineLimit );
1010  cfg->mIncludeTodos->setChecked( mIncludeTodos );
1011  cfg->mColors->setChecked( mUseColors );
1012  cfg->mPrintFooter->setChecked( mPrintFooter );
1013  cfg->mIncludeDescription->setChecked( mIncludeDescription );
1014  cfg->mExcludeTime->setChecked( mExcludeTime );
1015  cfg->mExcludeConfidential->setChecked( mExcludeConfidential );
1016  cfg->mExcludePrivate->setChecked( mExcludePrivate );
1017  }
1018 }
1019 
1020 void CalPrintWeek::loadConfig()
1021 {
1022  if ( mConfig ) {
1023  KConfigGroup grp( mConfig, groupName() );
1024  QDate dt = QDate::currentDate(); // any valid QDate will do
1025  QTime tm1( dayStart() );
1026  QDateTime startTm( dt, tm1 );
1027  QDateTime endTm( dt, tm1.addSecs( 43200 ) );
1028  mStartTime = grp.readEntry( "Start time", startTm ).time();
1029  mEndTime = grp.readEntry( "End time", endTm ).time();
1030  mShowNoteLines = grp.readEntry( "Note Lines", false );
1031  mSingleLineLimit = grp.readEntry( "Single line limit", false );
1032  mIncludeTodos = grp.readEntry( "Include todos", false );
1033  mWeekPrintType = (eWeekPrintType)( grp.readEntry( "Print type", (int)Filofax ) );
1034  mIncludeDescription = grp.readEntry( "Include Description", false );
1035  mExcludeTime = grp.readEntry( "Exclude Time", false );
1036  }
1037  setSettingsWidget();
1038 }
1039 
1040 void CalPrintWeek::saveConfig()
1041 {
1042  readSettingsWidget();
1043  if ( mConfig ) {
1044  KConfigGroup grp( mConfig, groupName() );
1045  QDateTime dt = QDateTime::currentDateTime(); // any valid QDateTime will do
1046  dt.setTime( mStartTime );
1047  grp.writeEntry( "Start time", dt );
1048  dt.setTime( mEndTime );
1049  grp.writeEntry( "End time", dt );
1050  grp.writeEntry( "Note Lines", mShowNoteLines );
1051  grp.writeEntry( "Single line limit", mSingleLineLimit );
1052  grp.writeEntry( "Include todos", mIncludeTodos );
1053  grp.writeEntry( "Print type", int( mWeekPrintType ) );
1054  grp.writeEntry( "Include Description", mIncludeDescription );
1055  grp.writeEntry( "Exclude Time", mExcludeTime );
1056  }
1057 }
1058 
1059 QPrinter::Orientation CalPrintWeek::defaultOrientation()
1060 {
1061  if ( mWeekPrintType == Filofax ) {
1062  return QPrinter::Portrait;
1063  } else if ( mWeekPrintType == SplitWeek ) {
1064  return QPrinter::Portrait;
1065  } else {
1066  return QPrinter::Landscape;
1067  }
1068 }
1069 
1070 void CalPrintWeek::setDateRange( const QDate &from, const QDate &to )
1071 {
1072  CalPrintPluginBase::setDateRange( from, to );
1073  CalPrintWeekConfig *cfg =
1074  dynamic_cast<CalPrintWeekConfig *>( ( QWidget* )mConfigWidget );
1075  if ( cfg ) {
1076  cfg->mFromDate->setDate( from );
1077  cfg->mToDate->setDate( to );
1078  }
1079 }
1080 
1081 void CalPrintWeek::print( QPainter &p, int width, int height )
1082 {
1083  QDate curWeek, fromWeek, toWeek;
1084 
1085  // correct begin and end to first and last day of week
1086  int weekdayCol = weekdayColumn( mFromDate.dayOfWeek() );
1087  fromWeek = mFromDate.addDays( -weekdayCol );
1088  weekdayCol = weekdayColumn( mToDate.dayOfWeek() );
1089  toWeek = mToDate.addDays( 6 - weekdayCol );
1090 
1091  curWeek = fromWeek.addDays( 6 );
1092  KLocale *local = KGlobal::locale();
1093 
1094  QString line1, line2, title;
1095  QRect headerBox( 0, 0, width, headerHeight() );
1096  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
1097  height -= footerHeight();
1098 
1099  QRect weekBox( headerBox );
1100  weekBox.setTop( headerBox.bottom() + padding() );
1101  weekBox.setBottom( height );
1102 
1103  switch ( mWeekPrintType ) {
1104  case Filofax:
1105  do {
1106  line1 = local->formatDate( curWeek.addDays( -6 ) );
1107  line2 = local->formatDate( curWeek );
1108  if ( orientation() == QPrinter::Landscape ) {
1109  title = i18nc( "date from-to", "%1 - %2", line1, line2 );
1110  } else {
1111  title = i18nc( "date from-\nto", "%1 -\n%2", line1, line2 );
1112  }
1113  drawHeader( p, title, curWeek.addDays( -6 ), QDate(), headerBox );
1114 
1115  drawWeek( p, curWeek, mStartTime, mEndTime, weekBox, mSingleLineLimit,
1116  mShowNoteLines, mIncludeDescription,
1117  mExcludeConfidential, mExcludePrivate );
1118 
1119  if ( mPrintFooter ) {
1120  drawFooter( p, footerBox );
1121  }
1122 
1123  curWeek = curWeek.addDays( 7 );
1124  if ( curWeek <= toWeek ) {
1125  mPrinter->newPage();
1126  }
1127  } while ( curWeek <= toWeek );
1128  break;
1129 
1130  case Timetable:
1131  default:
1132  do {
1133  line1 = local->formatDate( curWeek.addDays( -6 ) );
1134  line2 = local->formatDate( curWeek );
1135  if ( orientation() == QPrinter::Landscape ) {
1136  title = i18nc( "date from - to (week number)", "%1 - %2 (Week %3)",
1137  line1, line2, curWeek.weekNumber() );
1138  } else {
1139  title = i18nc( "date from -\nto (week number)", "%1 -\n%2 (Week %3)",
1140  line1, line2, curWeek.weekNumber() );
1141  }
1142  drawHeader( p, title, curWeek, QDate(), headerBox );
1143 
1144  drawTimeTable( p, fromWeek, curWeek,
1145  false, mStartTime, mEndTime, weekBox,
1146  mIncludeDescription, mExcludeTime, mExcludeConfidential,
1147  mExcludePrivate );
1148 
1149  if ( mPrintFooter ) {
1150  drawFooter( p, footerBox );
1151  }
1152 
1153  fromWeek = fromWeek.addDays( 7 );
1154  curWeek = fromWeek.addDays( 6 );
1155  if ( curWeek <= toWeek ) {
1156  mPrinter->newPage();
1157  }
1158  } while ( curWeek <= toWeek );
1159  break;
1160 
1161  case SplitWeek:
1162  {
1163  QRect weekBox1( weekBox );
1164  // On the left side there are four days (mo-th) plus the timeline,
1165  // on the right there are only three days (fr-su) plus the timeline. Don't
1166  // use the whole width, but rather give them the same width as on the left.
1167  weekBox1.setRight( int( ( width - TIMELINE_WIDTH ) * 3. / 4. + TIMELINE_WIDTH ) );
1168  do {
1169  QDate endLeft( fromWeek.addDays( 3 ) );
1170  int hh = headerHeight();
1171 
1172  drawSplitHeaderRight( p, fromWeek, curWeek, QDate(), width, hh );
1173  drawTimeTable( p, fromWeek, endLeft,
1174  false, mStartTime, mEndTime, weekBox,
1175  mIncludeDescription, mExcludeTime,
1176  mExcludeConfidential, mExcludePrivate );
1177  if ( mPrintFooter ) {
1178  drawFooter( p, weekBox1 );
1179  }
1180  mPrinter->newPage();
1181  drawSplitHeaderRight( p, fromWeek, curWeek, QDate(), width, hh );
1182  drawTimeTable( p, endLeft.addDays( 1 ), curWeek,
1183  false, mStartTime, mEndTime, weekBox1,
1184  mIncludeDescription, mExcludeTime,
1185  mExcludeConfidential, mExcludePrivate );
1186 
1187  if ( mPrintFooter ) {
1188  drawFooter( p, footerBox );
1189  }
1190 
1191  fromWeek = fromWeek.addDays( 7 );
1192  curWeek = fromWeek.addDays( 6 );
1193  if ( curWeek <= toWeek ) {
1194  mPrinter->newPage();
1195  }
1196  } while ( curWeek <= toWeek );
1197  }
1198  break;
1199  }
1200 }
1201 
1202 /**************************************************************
1203  * Print Month
1204  **************************************************************/
1205 
1206 CalPrintMonth::CalPrintMonth() : CalPrintPluginBase()
1207 {
1208 }
1209 
1210 CalPrintMonth::~CalPrintMonth()
1211 {
1212 }
1213 
1214 QWidget *CalPrintMonth::createConfigWidget( QWidget *w )
1215 {
1216  return new CalPrintMonthConfig( w );
1217 }
1218 
1219 void CalPrintMonth::readSettingsWidget()
1220 {
1221  CalPrintMonthConfig *cfg = dynamic_cast<CalPrintMonthConfig *>( ( QWidget* )mConfigWidget );
1222 
1223  if ( cfg ) {
1224  mFromDate = QDate( cfg->mFromYear->value(), cfg->mFromMonth->currentIndex()+1, 1 );
1225  mToDate = QDate( cfg->mToYear->value(), cfg->mToMonth->currentIndex()+1, 1 );
1226 
1227  mWeekNumbers = cfg->mWeekNumbers->isChecked();
1228  mRecurDaily = cfg->mRecurDaily->isChecked();
1229  mRecurWeekly = cfg->mRecurWeekly->isChecked();
1230  mIncludeTodos = cfg->mIncludeTodos->isChecked();
1231  mShowNoteLines = cfg->mShowNoteLines->isChecked();
1232  mSingleLineLimit = cfg->mSingleLineLimit->isChecked();
1233  mUseColors = cfg->mColors->isChecked();
1234  mPrintFooter = cfg->mPrintFooter->isChecked();
1235  mIncludeDescription = cfg->mIncludeDescription->isChecked();
1236  mExcludeConfidential = cfg->mExcludeConfidential->isChecked();
1237  mExcludePrivate = cfg->mExcludePrivate->isChecked();
1238  }
1239 }
1240 
1241 void CalPrintMonth::setSettingsWidget()
1242 {
1243  CalPrintMonthConfig *cfg = dynamic_cast<CalPrintMonthConfig *>( ( QWidget* )mConfigWidget );
1244 
1245  if ( cfg ) {
1246  setDateRange( mFromDate, mToDate );
1247 
1248  cfg->mWeekNumbers->setChecked( mWeekNumbers );
1249  cfg->mRecurDaily->setChecked( mRecurDaily );
1250  cfg->mRecurWeekly->setChecked( mRecurWeekly );
1251  cfg->mIncludeTodos->setChecked( mIncludeTodos );
1252  cfg->mShowNoteLines->setChecked( mShowNoteLines );
1253  cfg->mSingleLineLimit->setChecked( mSingleLineLimit );
1254  cfg->mColors->setChecked( mUseColors );
1255  cfg->mPrintFooter->setChecked( mPrintFooter );
1256  cfg->mIncludeDescription->setChecked( mIncludeDescription );
1257  cfg->mExcludeConfidential->setChecked( mExcludeConfidential );
1258  cfg->mExcludePrivate->setChecked( mExcludePrivate );
1259  }
1260 }
1261 
1262 void CalPrintMonth::loadConfig()
1263 {
1264  if ( mConfig ) {
1265  KConfigGroup grp( mConfig, groupName() );
1266  mWeekNumbers = grp.readEntry( "Print week numbers", true );
1267  mRecurDaily = grp.readEntry( "Print daily incidences", true );
1268  mRecurWeekly = grp.readEntry( "Print weekly incidences", true );
1269  mIncludeTodos = grp.readEntry( "Include todos", false );
1270  mSingleLineLimit = grp.readEntry( "Single line limit", false );
1271  mShowNoteLines = grp.readEntry( "Note Lines", false );
1272  mIncludeDescription = grp.readEntry( "Include description", false );
1273  }
1274  setSettingsWidget();
1275 }
1276 
1277 void CalPrintMonth::saveConfig()
1278 {
1279  readSettingsWidget();
1280  if ( mConfig ) {
1281  KConfigGroup grp( mConfig, groupName() );
1282  grp.writeEntry( "Print week numbers", mWeekNumbers );
1283  grp.writeEntry( "Print daily incidences", mRecurDaily );
1284  grp.writeEntry( "Print weekly incidences", mRecurWeekly );
1285  grp.writeEntry( "Include todos", mIncludeTodos );
1286  grp.writeEntry( "Single line limit", mSingleLineLimit );
1287  grp.writeEntry( "Note Lines", mShowNoteLines );
1288  grp.writeEntry( "Include description", mIncludeDescription );
1289  }
1290 }
1291 
1292 void CalPrintMonth::setDateRange( const QDate &from, const QDate &to )
1293 {
1294  CalPrintPluginBase::setDateRange( from, to );
1295  CalPrintMonthConfig *cfg =
1296  dynamic_cast<CalPrintMonthConfig *>( ( QWidget* )mConfigWidget );
1297  const KCalendarSystem *calSys = calendarSystem();
1298  if ( cfg && calSys ) {
1299  cfg->mFromMonth->clear();
1300  for ( int i=0; i<calSys->monthsInYear( mFromDate ); ++i ) {
1301  cfg->mFromMonth->addItem( calSys->monthName( i+1, mFromDate.year() ) );
1302  }
1303  cfg->mToMonth->clear();
1304  for ( int i=0; i<calSys->monthsInYear( mToDate ); ++i ) {
1305  cfg->mToMonth->addItem( calSys->monthName( i+1, mToDate.year() ) );
1306  }
1307  }
1308  if ( cfg ) {
1309  cfg->mFromMonth->setCurrentIndex( from.month()-1 );
1310  cfg->mFromYear->setValue( to.year() );
1311  cfg->mToMonth->setCurrentIndex( mToDate.month()-1 );
1312  cfg->mToYear->setValue( mToDate.year() );
1313  }
1314 }
1315 
1316 void CalPrintMonth::print( QPainter &p, int width, int height )
1317 {
1318  QDate curMonth, fromMonth, toMonth;
1319 
1320  fromMonth = mFromDate.addDays( -( mFromDate.day() - 1 ) );
1321  toMonth = mToDate.addDays( mToDate.daysInMonth() - mToDate.day() );
1322 
1323  curMonth = fromMonth;
1324  const KCalendarSystem *calSys = calendarSystem();
1325  if ( !calSys ) {
1326  return;
1327  }
1328 
1329  QRect headerBox( 0, 0, width, headerHeight() );
1330  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
1331  height -= footerHeight();
1332 
1333  QRect monthBox( 0, 0, width, height );
1334  monthBox.setTop( headerBox.bottom() + padding() );
1335 
1336  do {
1337  QString title( i18nc( "monthname year", "%1 <numid>%2</numid>",
1338  calSys->monthName( curMonth ),
1339  curMonth.year() ) );
1340  QDate tmp( fromMonth );
1341  int weekdayCol = weekdayColumn( tmp.dayOfWeek() );
1342  tmp = tmp.addDays( -weekdayCol );
1343 
1344  drawHeader( p, title, curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
1345  headerBox );
1346  drawMonthTable( p,
1347  curMonth, QTime(), QTime(),
1348  mWeekNumbers,
1349  mRecurDaily, mRecurWeekly,
1350  mSingleLineLimit, mShowNoteLines, mIncludeDescription,
1351  mExcludeConfidential, mExcludePrivate, monthBox );
1352 
1353  if ( mPrintFooter ) {
1354  drawFooter( p, footerBox );
1355  }
1356 
1357  curMonth = curMonth.addDays( curMonth.daysInMonth() );
1358  if ( curMonth <= toMonth ) {
1359  mPrinter->newPage();
1360  }
1361  } while ( curMonth <= toMonth );
1362 
1363 }
1364 
1365 /**************************************************************
1366  * Print Todos
1367  **************************************************************/
1368 
1369 CalPrintTodos::CalPrintTodos() : CalPrintPluginBase()
1370 {
1371  mTodoSortField = TodoFieldUnset;
1372  mTodoSortDirection = TodoDirectionUnset;
1373 }
1374 
1375 CalPrintTodos::~CalPrintTodos()
1376 {
1377 }
1378 
1379 QWidget *CalPrintTodos::createConfigWidget( QWidget *w )
1380 {
1381  return new CalPrintTodoConfig( w );
1382 }
1383 
1384 void CalPrintTodos::readSettingsWidget()
1385 {
1386  CalPrintTodoConfig *cfg = dynamic_cast<CalPrintTodoConfig *>( ( QWidget* )mConfigWidget );
1387 
1388  if ( cfg ) {
1389  mPageTitle = cfg->mTitle->text();
1390 
1391  if ( cfg->mPrintAll->isChecked() ) {
1392  mTodoPrintType = TodosAll;
1393  } else if ( cfg->mPrintUnfinished->isChecked() ) {
1394  mTodoPrintType = TodosUnfinished;
1395  } else if ( cfg->mPrintDueRange->isChecked() ) {
1396  mTodoPrintType = TodosDueRange;
1397  } else {
1398  mTodoPrintType = TodosAll;
1399  }
1400 
1401  mFromDate = cfg->mFromDate->date();
1402  mToDate = cfg->mToDate->date();
1403 
1404  mIncludeDescription = cfg->mDescription->isChecked();
1405  mIncludePriority = cfg->mPriority->isChecked();
1406  mIncludeDueDate = cfg->mDueDate->isChecked();
1407  mIncludePercentComplete = cfg->mPercentComplete->isChecked();
1408  mConnectSubTodos = cfg->mConnectSubTodos->isChecked();
1409  mStrikeOutCompleted = cfg->mStrikeOutCompleted->isChecked();
1410  mExcludeConfidential = cfg->mExcludeConfidential->isChecked();
1411  mExcludePrivate = cfg->mExcludePrivate->isChecked();
1412 
1413  mTodoSortField = (eTodoSortField)cfg->mSortField->currentIndex();
1414  mTodoSortDirection = (eTodoSortDirection)cfg->mSortDirection->currentIndex();
1415 
1416  mPrintFooter = cfg->mPrintFooter->isChecked();
1417  }
1418 }
1419 
1420 void CalPrintTodos::setSettingsWidget()
1421 {
1422  CalPrintTodoConfig *cfg =
1423  dynamic_cast<CalPrintTodoConfig *>( ( QWidget* )mConfigWidget );
1424  if ( cfg ) {
1425  cfg->mTitle->setText( mPageTitle );
1426 
1427  cfg->mPrintAll->setChecked( mTodoPrintType == TodosAll );
1428  cfg->mPrintUnfinished->setChecked( mTodoPrintType == TodosUnfinished );
1429  cfg->mPrintDueRange->setChecked( mTodoPrintType == TodosDueRange );
1430 
1431  cfg->mFromDate->setDate( mFromDate );
1432  cfg->mToDate->setDate( mToDate );
1433 
1434  cfg->mDescription->setChecked( mIncludeDescription );
1435  cfg->mPriority->setChecked( mIncludePriority );
1436  cfg->mDueDate->setChecked( mIncludeDueDate );
1437  cfg->mPercentComplete->setChecked( mIncludePercentComplete );
1438  cfg->mConnectSubTodos->setChecked( mConnectSubTodos );
1439  cfg->mStrikeOutCompleted->setChecked( mStrikeOutCompleted );
1440  cfg->mExcludeConfidential->setChecked( mExcludeConfidential );
1441  cfg->mExcludePrivate->setChecked( mExcludePrivate );
1442 
1443  if ( mTodoSortField != TodoFieldUnset ) {
1444  // do not insert if already done so.
1445  cfg->mSortField->addItem( i18nc( "@option sort by title", "Title" ) );
1446  cfg->mSortField->addItem( i18nc( "@option sort by start date/time", "Start Date" ) );
1447  cfg->mSortField->addItem( i18nc( "@option sort by due date/time", "Due Date" ) );
1448  cfg->mSortField->addItem( i18nc( "@option sort by priority", "Priority" ) );
1449  cfg->mSortField->addItem( i18nc( "@option sort by percent completed", "Percent Complete" ) );
1450  cfg->mSortField->setCurrentIndex( mTodoSortField );
1451  }
1452 
1453  if ( mTodoSortDirection != TodoDirectionUnset ) {
1454  // do not insert if already done so.
1455  cfg->mSortDirection->addItem( i18nc( "@option sort in increasing order", "Ascending" ) );
1456  cfg->mSortDirection->addItem( i18nc( "@option sort in descreasing order", "Descending" ) );
1457  cfg->mSortDirection->setCurrentIndex( mTodoSortDirection );
1458  }
1459 
1460  cfg->mPrintFooter->setChecked( mPrintFooter );
1461  }
1462 }
1463 
1464 void CalPrintTodos::loadConfig()
1465 {
1466  if ( mConfig ) {
1467  KConfigGroup grp( mConfig, groupName() );
1468  mPageTitle = grp.readEntry( "Page title", i18n( "To-do list" ) );
1469  mTodoPrintType = (eTodoPrintType)grp.readEntry( "Print type", (int)TodosAll );
1470  mIncludeDescription = grp.readEntry( "Include description", true );
1471  mIncludePriority = grp.readEntry( "Include priority", true );
1472  mIncludeDueDate = grp.readEntry( "Include due date", true );
1473  mIncludePercentComplete = grp.readEntry( "Include percentage completed", true );
1474  mConnectSubTodos = grp.readEntry( "Connect subtodos", true );
1475  mStrikeOutCompleted = grp.readEntry( "Strike out completed summaries", true );
1476  mTodoSortField =
1477  (eTodoSortField)grp.readEntry( "Sort field", (int)TodoFieldSummary );
1478  mTodoSortDirection =
1479  (eTodoSortDirection)grp.readEntry( "Sort direction", (int)TodoDirectionAscending );
1480  }
1481  setSettingsWidget();
1482 }
1483 
1484 void CalPrintTodos::saveConfig()
1485 {
1486  readSettingsWidget();
1487  if ( mConfig ) {
1488  KConfigGroup grp( mConfig, groupName());
1489  grp.writeEntry( "Page title", mPageTitle );
1490  grp.writeEntry( "Print type", int( mTodoPrintType ) );
1491  grp.writeEntry( "Include description", mIncludeDescription );
1492  grp.writeEntry( "Include priority", mIncludePriority );
1493  grp.writeEntry( "Include due date", mIncludeDueDate );
1494  grp.writeEntry( "Include percentage completed", mIncludePercentComplete );
1495  grp.writeEntry( "Connect subtodos", mConnectSubTodos );
1496  grp.writeEntry( "Strike out completed summaries", mStrikeOutCompleted );
1497  grp.writeEntry( "Sort field", (int)mTodoSortField );
1498  grp.writeEntry( "Sort direction", (int)mTodoSortDirection );
1499  }
1500 }
1501 
1502 void CalPrintTodos::print( QPainter &p, int width, int height )
1503 {
1504  // TODO: Find a good way to guarantee a nicely designed output
1505  int pospriority = 0;
1506  int possummary = 100;
1507  int posdue = width - 65;
1508  int poscomplete = posdue - 70; //Complete column is to right of the Due column
1509  int lineSpacing = 15;
1510  //int fontHeight = 10;
1511 
1512  QRect headerBox( 0, 0, width, headerHeight() );
1513  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
1514  height -= footerHeight();
1515 
1516  // Draw the First Page Header
1517  drawHeader( p, mPageTitle, mFromDate, QDate(), headerBox );
1518 
1519  // Draw the Column Headers
1520  int mCurrentLinePos = headerHeight() + 5;
1521  QString outStr;
1522  QFont oldFont( p.font() );
1523 
1524  p.setFont( QFont( QLatin1String("sans-serif"), 9, QFont::Bold ) );
1525  lineSpacing = p.fontMetrics().lineSpacing();
1526  mCurrentLinePos += lineSpacing;
1527  if ( mIncludePriority ) {
1528  outStr += i18n( "Priority" );
1529  p.drawText( pospriority, mCurrentLinePos - 2, outStr );
1530  } else {
1531  pospriority = -1;
1532  }
1533 
1534  outStr.truncate( 0 );
1535  outStr += i18nc( "@label to-do summary", "Title" );
1536  p.drawText( possummary, mCurrentLinePos - 2, outStr );
1537 
1538  if ( mIncludePercentComplete ) {
1539  if ( !mIncludeDueDate ) { //move Complete column to the right
1540  poscomplete = posdue; //if not print the Due Date column
1541  }
1542  outStr.truncate( 0 );
1543  outStr += i18nc( "@label to-do percentage complete", "Complete" );
1544  p.drawText( poscomplete, mCurrentLinePos - 2, outStr );
1545  } else {
1546  poscomplete = -1;
1547  }
1548 
1549  if ( mIncludeDueDate ) {
1550  outStr.truncate( 0 );
1551  outStr += i18nc( "@label to-do due date", "Due" );
1552  p.drawText( posdue, mCurrentLinePos - 2, outStr );
1553  } else {
1554  posdue = -1;
1555  }
1556 
1557  p.setFont( QFont( QLatin1String("sans-serif"), 10 ) );
1558  //fontHeight = p.fontMetrics().height();
1559 
1560  KCalCore::Todo::List todoList;
1561  KCalCore::Todo::List tempList;
1562 
1563  KCalCore::SortDirection sortDirection = KCalCore::SortDirectionAscending;
1564  switch( mTodoSortDirection ) {
1565  case TodoDirectionAscending:
1566  sortDirection = KCalCore::SortDirectionAscending;
1567  break;
1568  case TodoDirectionDescending:
1569  sortDirection = KCalCore::SortDirectionDescending;
1570  break;
1571  case TodoDirectionUnset:
1572  break;
1573  }
1574 
1575  KCalCore::TodoSortField sortField = KCalCore::TodoSortSummary;
1576  switch( mTodoSortField ) {
1577  case TodoFieldSummary:
1578  sortField = KCalCore::TodoSortSummary;
1579  break;
1580  case TodoFieldStartDate:
1581  sortField = KCalCore::TodoSortStartDate;
1582  break;
1583  case TodoFieldDueDate:
1584  sortField = KCalCore::TodoSortDueDate;
1585  break;
1586  case TodoFieldPriority:
1587  sortField = KCalCore::TodoSortPriority;
1588  break;
1589  case TodoFieldPercentComplete:
1590  sortField = KCalCore::TodoSortPercentComplete;
1591  break;
1592  case TodoFieldUnset:
1593  break;
1594  }
1595 
1596  // Create list of to-dos which will be printed
1597  todoList = mCalendar->todos( sortField, sortDirection );
1598  switch( mTodoPrintType ) {
1599  case TodosAll:
1600  break;
1601  case TodosUnfinished:
1602  foreach( const KCalCore::Todo::Ptr& todo, todoList ) {
1603  Q_ASSERT( todo );
1604  if ( !todo->isCompleted() ) {
1605  tempList.append( todo );
1606  }
1607  }
1608  todoList = tempList;
1609  break;
1610  case TodosDueRange:
1611  foreach( const KCalCore::Todo::Ptr& todo, todoList ) {
1612  Q_ASSERT( todo );
1613  if ( todo->hasDueDate() ) {
1614  if ( todo->dtDue().date() >= mFromDate && todo->dtDue().date() <= mToDate ) {
1615  tempList.append( todo );
1616  }
1617  } else {
1618  tempList.append( todo );
1619  }
1620  }
1621  todoList = tempList;
1622  break;
1623  }
1624 
1625  // Print to-dos
1626  int count = 0;
1627  foreach( const KCalCore::Todo::Ptr& todo, todoList ) {
1628  if ( ( mExcludeConfidential && todo->secrecy() == Incidence::SecrecyConfidential ) ||
1629  ( mExcludePrivate && todo->secrecy() == Incidence::SecrecyPrivate ) ) {
1630  continue;
1631  }
1632  // Skip sub-to-dos. They will be printed recursively in drawTodo()
1633  if ( todo->relatedTo().isEmpty() ) { //review(AKONADI_PORT)
1634  count++;
1635  drawTodo( count, todo, p,
1636  sortField, sortDirection,
1637  mConnectSubTodos,
1638  mStrikeOutCompleted, mIncludeDescription,
1639  pospriority, possummary, posdue, poscomplete,
1640  0, 0, mCurrentLinePos, width, height, todoList, 0,
1641  mExcludeConfidential, mExcludePrivate );
1642  }
1643  }
1644 
1645  if ( mPrintFooter ) {
1646  drawFooter( p, footerBox );
1647  }
1648  p.setFont( oldFont );
1649 }
CalPrintPluginBase::dayStart
QTime dayStart()
Definition: calprintpluginbase.cpp:246
CalPrintPluginBase::drawDays
void drawDays(QPainter &p, const QDate &start, const QDate &end, const QTime &fromTime, const QTime &toTime, const QRect &box, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate)
Draw the (filofax) table for a bunch of days, using drawDayBox.
Definition: calprintpluginbase.cpp:1387
cleanStr
static QString cleanStr(const QString &instr)
Definition: calprintdefaultplugins.cpp:53
CalPrintPluginBase::drawHeader
int drawHeader(QPainter &p, const QString &title, const QDate &month1, const QDate &month2, const QRect &box, bool expand=false, QColor backColor=QColor())
Draw the gray header bar of the printout to the QPainter.
Definition: calprintpluginbase.cpp:553
CalPrintWeek::mStartTime
QTime mStartTime
Definition: calprintdefaultplugins.h:194
CalPrintTodos::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: calprintdefaultplugins.cpp:1484
CalPrintDay::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: calprintdefaultplugins.cpp:766
CalPrintMonth::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: calprintdefaultplugins.cpp:1214
KOrg::PrintPlugin::mFromDate
QDate mFromDate
Definition: printplugin.h:172
CalPrintMonth::~CalPrintMonth
virtual ~CalPrintMonth()
Definition: calprintdefaultplugins.cpp:1210
CalPrintDay::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: calprintdefaultplugins.cpp:786
CalPrintIncidence::groupName
virtual QString groupName()
Returns KConfig group name where store settings.
Definition: calprintdefaultplugins.h:48
calprintdefaultplugins.h
CalPrintWeek::eWeekPrintType
eWeekPrintType
Definition: calprintdefaultplugins.h:189
koglobals.h
CalPrintPluginBase::orientation
QPrinter::Orientation orientation() const
Definition: calprintpluginbase.cpp:241
CalPrintMonth::mIncludeDescription
bool mIncludeDescription
Definition: calprintdefaultplugins.h:246
CalPrintIncidence::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: calprintdefaultplugins.cpp:106
CalPrintMonth::groupName
virtual QString groupName()
Returns KConfig group name where store settings.
Definition: calprintdefaultplugins.h:206
CalPrintPluginBase::padding
int padding() const
Definition: calprintpluginbase.cpp:371
CalPrintMonth::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: calprintdefaultplugins.cpp:1262
CalPrintMonth::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: calprintdefaultplugins.cpp:1219
CalPrintWeek::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: calprintdefaultplugins.cpp:1020
CalPrintDay::print
void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: calprintdefaultplugins.cpp:797
CalPrintWeek::Filofax
Definition: calprintdefaultplugins.h:190
CalPrintIncidenceConfig
Definition: calprintdefaultplugins.h:318
CalPrintIncidence::CalPrintIncidence
CalPrintIncidence()
Definition: calprintdefaultplugins.cpp:63
CalPrintTodos::CalPrintTodos
CalPrintTodos()
Definition: calprintdefaultplugins.cpp:1369
KOrg::PrintPlugin::mPrinter
QPrinter * mPrinter
The printer object.
Definition: printplugin.h:180
CalPrintDay::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: calprintdefaultplugins.cpp:686
CalPrintIncidence::printCaptionAndText
int printCaptionAndText(QPainter &p, const QRect &box, const QString &caption, const QString &text, QFont captionFont, QFont textFont)
Definition: calprintdefaultplugins.cpp:209
CalPrintPluginBase::mPrintFooter
bool mPrintFooter
Definition: calprintpluginbase.h:648
CalPrintTodos::eTodoSortField
eTodoSortField
Definition: calprintdefaultplugins.h:293
CalPrintWeek::mEndTime
QTime mEndTime
Definition: calprintdefaultplugins.h:194
QWidget
CalPrintWeek::Timetable
Definition: calprintdefaultplugins.h:191
CalPrintDay::Filofax
Definition: calprintdefaultplugins.h:135
CalPrintTodos::mIncludeDueDate
bool mIncludeDueDate
Definition: calprintdefaultplugins.h:310
CalPrintWeek::mExcludeTime
bool mExcludeTime
Definition: calprintdefaultplugins.h:198
CalPrintTodos::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: calprintdefaultplugins.cpp:1464
CalPrintTodos::TodosAll
Definition: calprintdefaultplugins.h:288
CalPrintTodos::TodoFieldPercentComplete
Definition: calprintdefaultplugins.h:298
CalPrintTodos::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: calprintdefaultplugins.cpp:1384
CalPrintTodos::eTodoPrintType
eTodoPrintType
Definition: calprintdefaultplugins.h:287
CalPrintPluginBase::categoryBgColor
QColor categoryBgColor(const Incidence::Ptr &incidence)
Helper functions to hide the KOrg::CoreHelper.
Definition: calprintpluginbase.cpp:267
CalPrintTodos::mIncludeDescription
bool mIncludeDescription
Definition: calprintdefaultplugins.h:308
CalPrintDay::groupName
virtual QString groupName()
Returns KConfig group name where store settings.
Definition: calprintdefaultplugins.h:103
CalPrintDay::mDayPrintType
enum CalPrintDay::eDayPrintType mDayPrintType
CalPrintTodos::TodosDueRange
Definition: calprintdefaultplugins.h:290
CalPrintPluginBase::weekdayColumn
static int weekdayColumn(int weekday)
Determines the column of the given weekday ( 1=Monday, 7=Sunday ), taking the start of the week setti...
Definition: calprintpluginbase.cpp:2067
CalPrintWeek::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: calprintdefaultplugins.cpp:994
CalPrintMonth::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: calprintdefaultplugins.cpp:1292
CalPrintMonth::mIncludeTodos
bool mIncludeTodos
Definition: calprintdefaultplugins.h:244
CalPrintTodos::TodoDirectionDescending
Definition: calprintdefaultplugins.h:304
CalPrintTodos::eTodoSortDirection
eTodoSortDirection
Definition: calprintdefaultplugins.h:302
CalPrintTodos::mIncludePriority
bool mIncludePriority
Definition: calprintdefaultplugins.h:309
CalPrintTodos::mTodoSortDirection
enum CalPrintTodos::eTodoSortDirection mTodoSortDirection
CalPrintIncidence::mShowAttachments
bool mShowAttachments
Definition: calprintdefaultplugins.h:94
CalPrintPluginBase::drawSplitHeaderRight
void drawSplitHeaderRight(QPainter &p, const QDate &fd, const QDate &td, const QDate &cd, int width, int height)
Definition: calprintpluginbase.cpp:2144
CalPrintIncidence::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: calprintdefaultplugins.cpp:119
CalPrintDay::Timetable
Definition: calprintdefaultplugins.h:136
CalPrintTodoConfig
Definition: calprintdefaultplugins.h:354
CalPrintTodos::TodoFieldDueDate
Definition: calprintdefaultplugins.h:296
CalPrintWeek::CalPrintWeek
CalPrintWeek()
Definition: calprintdefaultplugins.cpp:949
CalPrintPluginBase::drawNoteLines
void drawNoteLines(QPainter &p, const QRect &box, int startY)
Draws dotted lines for notes in a box.
Definition: calprintpluginbase.cpp:2198
CalPrintMonth::mWeekNumbers
bool mWeekNumbers
Definition: calprintdefaultplugins.h:241
KOrg::PrintPlugin::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: printplugin.h:165
CalPrintPluginBase::mExcludeConfidential
bool mExcludeConfidential
Definition: calprintpluginbase.h:650
CalPrintWeekConfig
Definition: calprintdefaultplugins.h:336
CalPrintWeek::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: calprintdefaultplugins.cpp:1040
CalPrintDay::mSingleLineLimit
bool mSingleLineLimit
Definition: calprintdefaultplugins.h:141
CalPrintPluginBase::mShowNoteLines
bool mShowNoteLines
Definition: calprintpluginbase.h:649
CalPrintPluginBase::headerHeight
int headerHeight() const
Returns the height of the page header.
Definition: calprintpluginbase.cpp:315
CalPrintIncidence::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: calprintdefaultplugins.cpp:71
CalPrintMonth::mRecurWeekly
bool mRecurWeekly
Definition: calprintdefaultplugins.h:243
CalPrintDay::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: calprintdefaultplugins.cpp:681
CalPrintWeek::groupName
virtual QString groupName()
Returns KConfig group name where store settings.
Definition: calprintdefaultplugins.h:153
CalPrintTodos::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: calprintdefaultplugins.cpp:1420
CalPrintDay::mIncludeTodos
bool mIncludeTodos
Definition: calprintdefaultplugins.h:142
CalPrintDay::mExcludeTime
bool mExcludeTime
Definition: calprintdefaultplugins.h:144
CalPrintIncidence::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: calprintdefaultplugins.cpp:76
CalPrintTodos::~CalPrintTodos
virtual ~CalPrintTodos()
Definition: calprintdefaultplugins.cpp:1375
CalPrintPluginBase::drawBox
static void drawBox(QPainter &p, int linewidth, const QRect &rect)
Draw a box with given width at the given coordinates.
Definition: calprintpluginbase.cpp:391
CalPrintMonth::print
void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: calprintdefaultplugins.cpp:1316
CalPrintWeek::print
void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: calprintdefaultplugins.cpp:1081
CalPrintWeek::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: calprintdefaultplugins.cpp:962
CalPrintTodos::groupName
virtual QString groupName()
Returns KConfig group name where store settings.
Definition: calprintdefaultplugins.h:255
CalPrintIncidence::print
void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: calprintdefaultplugins.cpp:231
CalPrintDay::mEndTime
QTime mEndTime
Definition: calprintdefaultplugins.h:139
CalPrintTodos::TodoFieldSummary
Definition: calprintdefaultplugins.h:294
CalPrintPluginBase::drawTimeTable
void drawTimeTable(QPainter &p, const QDate &fromDate, const QDate &toDate, bool expandable, const QTime &fromTime, const QTime &toTime, const QRect &box, bool includeDescription, bool excludeTime, bool excludeConfidential, bool excludePrivate)
Draw the timetable view of the given time range from fromDate to toDate.
Definition: calprintpluginbase.cpp:1428
CalPrintPluginBase::mExcludePrivate
bool mExcludePrivate
Definition: calprintpluginbase.h:651
CalPrintIncidence::~CalPrintIncidence
virtual ~CalPrintIncidence()
Definition: calprintdefaultplugins.cpp:67
CalPrintPluginBase::drawBoxWithCaption
int drawBoxWithCaption(QPainter &p, const QRect &box, const QString &caption, const QString &contents, bool sameLine, bool expand, const QFont &captionFont, const QFont &textFont, bool richContents=false)
Draw a component box with a heading (printed in bold).
Definition: calprintpluginbase.cpp:470
CalPrintDay::CalPrintDay
CalPrintDay()
Definition: calprintdefaultplugins.cpp:673
CalPrintIncidence::mShowOptions
bool mShowOptions
Definition: calprintdefaultplugins.h:91
CalPrintTodos::TodoDirectionAscending
Definition: calprintdefaultplugins.h:303
CalPrintDay::SingleTimetable
Definition: calprintdefaultplugins.h:137
CalPrintPluginBase
Base class for KOrganizer printing classes.
Definition: calprintpluginbase.h:64
KOGlobals::self
static KOGlobals * self()
Definition: koglobals.cpp:43
CalPrintMonth::mRecurDaily
bool mRecurDaily
Definition: calprintdefaultplugins.h:242
CalPrintWeek::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: calprintdefaultplugins.cpp:1070
CalPrintPluginBase::drawMonthTable
void drawMonthTable(QPainter &p, const QDate &qd, const QTime &fromTime, const QTime &toTime, bool weeknumbers, bool recurDaily, bool recurWeekly, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate, const QRect &box)
Draw the month table of the month containing the date qd.
Definition: calprintpluginbase.cpp:1738
CalPrintTodos::mTodoPrintType
enum CalPrintTodos::eTodoPrintType mTodoPrintType
KOGlobals::workDays
QList< QDate > workDays(const QDate &start, const QDate &end) const
Returns a list containing work days between start and .
Definition: koglobals.cpp:96
KOrg::PrintPlugin::mToDate
QDate mToDate
Definition: printplugin.h:173
CalPrintMonth::CalPrintMonth
CalPrintMonth()
Definition: calprintdefaultplugins.cpp:1206
CalPrintDay::eDayPrintType
eDayPrintType
Definition: calprintdefaultplugins.h:134
CalPrintPluginBase::calendarSystem
const KCalendarSystem * calendarSystem() const
Definition: calprintpluginbase.cpp:305
CalPrintTodos::TodoFieldStartDate
Definition: calprintdefaultplugins.h:295
CalPrintTodos::print
void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: calprintdefaultplugins.cpp:1502
CalPrintIncidence::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: calprintdefaultplugins.cpp:91
CalPrintPluginBase::mUseColors
bool mUseColors
Definition: calprintpluginbase.h:647
CalPrintIncidence::mShowNoteLines
bool mShowNoteLines
Definition: calprintdefaultplugins.h:95
CalPrintDay::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: calprintdefaultplugins.cpp:745
CalPrintTodos::TodoDirectionUnset
Definition: calprintdefaultplugins.h:305
CalPrintMonth::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: calprintdefaultplugins.cpp:1241
CalPrintTodos::mConnectSubTodos
bool mConnectSubTodos
Definition: calprintdefaultplugins.h:312
CalPrintDayConfig
Definition: calprintdefaultplugins.h:327
CalPrintDay::~CalPrintDay
virtual ~CalPrintDay()
Definition: calprintdefaultplugins.cpp:677
CalPrintWeek::mSingleLineLimit
bool mSingleLineLimit
Definition: calprintdefaultplugins.h:195
CalPrintPluginBase::drawTodo
void drawTodo(int &count, const KCalCore::Todo::Ptr &todo, QPainter &p, KCalCore::TodoSortField sortField, KCalCore::SortDirection sortDir, bool connectSubTodos, bool strikeoutCompleted, bool desc, int posPriority, int posSummary, int posDueDt, int posPercentComplete, int level, int x, int &y, int width, int pageHeight, const KCalCore::Todo::List &todoList, TodoParentStart *r, bool excludeConfidential, bool excludePrivate)
Draws single to-do and its (intented) sub-to-dos, optionally connects them by a tree-like line...
Definition: calprintpluginbase.cpp:1865
BOX_BORDER_WIDTH
#define BOX_BORDER_WIDTH
Definition: calprintpluginbase.h:55
CalPrintPluginBase::drawFooter
int drawFooter(QPainter &p, const QRect &box)
Draw a page footer containing the printing date and possibly other things, like a page number...
Definition: calprintpluginbase.cpp:628
CalPrintPluginBase::footerHeight
int footerHeight() const
Returns the height of the page footer.
Definition: calprintpluginbase.cpp:341
CalPrintWeek::defaultOrientation
virtual QPrinter::Orientation defaultOrientation()
Returns the default orientation for the eWeekPrintType.
Definition: calprintdefaultplugins.cpp:1059
CalPrintTodos::mPageTitle
QString mPageTitle
Definition: calprintdefaultplugins.h:285
KOrg::PrintPlugin::mConfig
KConfig * mConfig
Definition: printplugin.h:183
CalPrintPluginBase::printEventString
void printEventString(QPainter &p, const QRect &box, const QString &str, int flags=-1)
Print the given string (event summary) in the given rectangle.
Definition: calprintpluginbase.cpp:415
TIMELINE_WIDTH
#define TIMELINE_WIDTH
Definition: calprintpluginbase.h:58
CalPrintWeek::~CalPrintWeek
virtual ~CalPrintWeek()
Definition: calprintdefaultplugins.cpp:953
CalPrintPluginBase::drawWeek
void drawWeek(QPainter &p, const QDate &qd, const QTime &fromTime, const QTime &toTime, const QRect &box, bool singleLineLimit, bool showNoteLines, bool includeDescription, bool excludeConfidential, bool excludePrivate)
Draw the week (filofax) table of the week containing the date qd.
Definition: calprintpluginbase.cpp:1348
CalPrintPluginBase::drawAgendaDayBox
void drawAgendaDayBox(QPainter &p, const KCalCore::Event::List &eventList, const QDate &qd, bool expandable, const QTime &fromTime, const QTime &toTime, const QRect &box, bool includeDescription, bool excludeTime, bool mExcludeConfidential, bool mExcludePrivate, const QList< QDate > &workDays)
Draw the agenda box for the day print style (the box showing all events of that day).
Definition: calprintpluginbase.cpp:858
CalPrintDay::mIncludeDescription
bool mIncludeDescription
Definition: calprintdefaultplugins.h:140
CalPrintTodos::TodosUnfinished
Definition: calprintdefaultplugins.h:289
CalPrintWeek::SplitWeek
Definition: calprintdefaultplugins.h:192
CalPrintPluginBase::drawTimeLine
void drawTimeLine(QPainter &p, const QTime &fromTime, const QTime &toTime, const QRect &box)
Draw a (vertical) time scale from time fromTime to toTime inside the given area of the painter...
Definition: calprintpluginbase.cpp:726
CalPrintTodos::TodoFieldUnset
Definition: calprintdefaultplugins.h:299
CalPrintMonth::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: calprintdefaultplugins.cpp:1277
CalPrintWeek::mIncludeTodos
bool mIncludeTodos
Definition: calprintdefaultplugins.h:196
CalPrintDay::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: calprintdefaultplugins.cpp:718
KOrg::PrintPlugin::mConfigWidget
QPointer< QWidget > mConfigWidget
Definition: printplugin.h:176
CalPrintTodos::mTodoSortField
enum CalPrintTodos::eTodoSortField mTodoSortField
CalPrintIncidence::mShowSubitemsNotes
bool mShowSubitemsNotes
Definition: calprintdefaultplugins.h:92
KOrg::PrintPlugin::mCalendar
Akonadi::ETMCalendar::Ptr mCalendar
Definition: printplugin.h:181
CalPrintPluginBase::drawVerticalBox
void drawVerticalBox(QPainter &p, int linewidth, const QRect &box, const QString &str, int flags=-1)
Draw an event box with vertical text.
Definition: calprintpluginbase.cpp:454
CalPrintTodos::mIncludePercentComplete
bool mIncludePercentComplete
Definition: calprintdefaultplugins.h:311
CalPrintTodos::mStrikeOutCompleted
bool mStrikeOutCompleted
Definition: calprintdefaultplugins.h:313
CalPrintWeek::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: calprintdefaultplugins.cpp:957
CalPrintDay::mIncludeAllEvents
bool mIncludeAllEvents
Definition: calprintdefaultplugins.h:143
CalPrintTodos::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: calprintdefaultplugins.cpp:1379
CalPrintIncidence::mShowAttendees
bool mShowAttendees
Definition: calprintdefaultplugins.h:93
CalPrintMonthConfig
Definition: calprintdefaultplugins.h:345
CalPrintMonth::mSingleLineLimit
bool mSingleLineLimit
Definition: calprintdefaultplugins.h:245
CalPrintDay::mStartTime
QTime mStartTime
Definition: calprintdefaultplugins.h:139
CalPrintTodos::TodoFieldPriority
Definition: calprintdefaultplugins.h:297
CalPrintWeek::mWeekPrintType
enum CalPrintWeek::eWeekPrintType mWeekPrintType
KOrg::PrintPlugin::mSelectedIncidences
KCalCore::Incidence::List mSelectedIncidences
Definition: printplugin.h:182
CalPrintWeek::mIncludeDescription
bool mIncludeDescription
Definition: calprintdefaultplugins.h:197
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:56:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

korganizer

Skip menu "korganizer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal