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

calendarsupport

  • sources
  • kde-4.14
  • kdepim
  • calendarsupport
  • printing
calprintpluginbase.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
3  Copyright (C) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
4  Copyright (C) 2008 Ron Goodheart <rong.dev@gmail.com>
5  Copyright (c) 2012-2013 Allen Winter <winter@kde.org>
6 
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
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License along
18  with this program; if not, write to the Free Software Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of Qt, and distribute the resulting executable,
23  without including the source code for Qt in the source distribution.
24 */
25 #ifndef CALENDARSUPPORT_PRINTING_CALPRINTPLUGINBASE_H
26 #define CALENDARSUPPORT_PRINTING_CALPRINTPLUGINBASE_H
27 
28 #include "calendarsupport_export.h"
29 #include "printplugin.h"
30 
31 #include <Akonadi/Calendar/ETMCalendar>
32 #include <KCalendarSystem>
33 
34 #include <KCalCore/Event>
35 #include <KCalCore/Journal>
36 #include <KCalCore/Todo>
37 #include <KDateTime>
38 
39 #include <QPainter>
40 
41 class PrintCellItem;
42 class QWidget;
43 
44 #define PORTRAIT_HEADER_HEIGHT 72 // header height, for portrait orientation
45 #define LANDSCAPE_HEADER_HEIGHT 54 // header height, for landscape orientation
46 #define SUBHEADER_HEIGHT 20 // subheader height, for all orientations
47 #define PORTRAIT_FOOTER_HEIGHT 16 // footer height, for portrait orientation
48 #define LANDSCAPE_FOOTER_HEIGHT 14 // footer height, for landscape orientation
49 #define MARGIN_SIZE 36 // margins, for all orientations
50 #define PADDING_SIZE 7 // padding between the various top-level boxes
51 #define BOX_BORDER_WIDTH 2 // width of the border of all top-level boxes
52 #define EVENT_BORDER_WIDTH 0 // with of the border of all incidence boxes
53 
54 #define TIMELINE_WIDTH 50 // width of timeline (day and timetable)
55 
56 namespace CalendarSupport {
57 
62 class CALENDARSUPPORT_EXPORT CalPrintPluginBase : public PrintPlugin
63 {
64  public:
65  enum DisplayFlags {
66  Text=0x0001,
67  TimeBoxes=0x0002
68  };
69 
70  public:
74  CalPrintPluginBase();
75  virtual ~CalPrintPluginBase();
76 
80  virtual QWidget *createConfigWidget( QWidget * );
81 
89  virtual void print( QPainter &p, int width, int height ) = 0;
93  virtual void doPrint( QPrinter *printer );
94 
98  virtual void loadConfig() = 0;
102  virtual void saveConfig() = 0;
103 
107  void doLoadConfig();
111  void doSaveConfig();
112 
114  public:
115  bool useColors() const;
116  void setUseColors( bool useColors );
117 
118  bool printFooter() const;
119  void setPrintFooter( bool printFooter );
120 
126  static int weekdayColumn( int weekday );
127 
128  QPrinter::Orientation orientation() const;
129 
135  int headerHeight() const;
136  void setHeaderHeight( const int height );
137 
138  int subHeaderHeight() const;
139  void setSubHeaderHeight( const int height );
145  int footerHeight() const;
146  void setFooterHeight( const int height );
147 
148  int margin() const;
149  void setMargin( const int margin );
150 
151  int padding() const;
152  void setPadding( const int margin );
153 
154  int borderWidth() const;
155  void setBorderWidth( const int border );
156 
157  const KCalendarSystem *calendarSystem();
158  void setCalendarSystem( const KCalendarSystem *calsys );
159 
160  /*****************************************************************
161  ** PRINTING HELPER FUNCTIONS **
162  *****************************************************************/
163  public:
170  static void drawBox( QPainter &p, int linewidth, const QRect &rect );
178  static void drawShadedBox( QPainter &p, int linewidth, const QBrush &brush, const QRect &rect );
179 
187  void printEventString( QPainter &p, const QRect &box, const QString &str, int flags = -1 );
198  void showEventBox( QPainter &p, int linewidth, const QRect &box,
199  const KCalCore::Incidence::Ptr &incidence, const QString &str, int flags = -1 );
200 
207  void drawSubHeaderBox( QPainter &p, const QString &str, const QRect &box );
208 
217  void drawVerticalBox( QPainter &p, int linewidth, const QRect &box, const QString &str,
218  int flags=-1 );
219 
241  int drawBoxWithCaption( QPainter &p, const QRect &box, const QString &caption,
242  const QString &contents, bool sameLine, bool expand,
243  const QFont &captionFont, const QFont &textFont,
244  bool richContents = false );
245 
274  int drawHeader( QPainter &p, const QString &title,
275  const QDate &month1, const QDate &month2,
276  const QRect &box, bool expand = false,
277  QColor backColor = QColor() );
278 
286  int drawFooter( QPainter &p, const QRect &box );
287 
295  void drawSmallMonth( QPainter &p, const QDate &qd, const QRect &box );
296 
306  void drawDaysOfWeek( QPainter &p,
307  const QDate &fromDate, const QDate &toDate,
308  const QRect &box );
316  void drawDaysOfWeekBox( QPainter &p, const QDate &qd, const QRect &box );
317 
328  void drawTimeLine( QPainter &p,
329  const QTime &fromTime, const QTime &toTime,
330  const QRect &box );
331 
352  int drawAllDayBox( QPainter &p, const KCalCore::Event::List &eventList,
353  const QDate &qd, bool expandable,
354  const QRect &box,
355  bool excludeConfidential, bool excludePrivate );
382  void drawAgendaDayBox( QPainter &p, const KCalCore::Event::List &eventList,
383  const QDate &qd, bool expandable,
384  const QTime &fromTime, const QTime &toTime,
385  const QRect &box,
386  bool includeDescription, bool excludeTime,
387  bool excludeConfidential, bool excludePrivate,
388  const QList<QDate> &workDays );
389 
390  void drawAgendaItem( PrintCellItem *item, QPainter &p,
391  const KDateTime &startPrintDate,
392  const KDateTime &endPrintDate,
393  float minlen, const QRect &box,
394  bool includeDescription, bool excludeTime );
395 
415  void drawDayBox( QPainter &p, const QDate &qd,
416  const QTime &fromTime, const QTime &toTime,
417  const QRect &box,
418  bool fullDate = false, bool printRecurDaily = true,
419  bool printRecurWeekly = true,
420  bool singleLineLimit = true,
421  bool showNoteLines = false,
422  bool includeDescription = false,
423  bool excludeDescription = true,
424  bool excludePrivate = true );
441  void drawWeek( QPainter &p, const QDate &qd,
442  const QTime &fromTime, const QTime &toTime,
443  const QRect &box, bool singleLineLimit,
444  bool showNoteLines, bool includeDescription,
445  bool excludeConfidential, bool excludePrivate );
460  void drawDays( QPainter &p, const QDate &start, const QDate &end,
461  const QTime &fromTime, const QTime &toTime,
462  const QRect &box, bool singleLineLimit, bool showNoteLines,
463  bool includeDescription, bool excludeConfidential,
464  bool excludePrivate );
485  void drawTimeTable( QPainter &p, const QDate &fromDate, const QDate &toDate,
486  bool expandable, const QTime &fromTime, const QTime &toTime,
487  const QRect &box, bool includeDescription,
488  bool excludeTime, bool excludeConfidential,
489  bool excludePrivate );
490 
511  void drawMonthTable( QPainter &p, const QDate &qd,
512  const QTime &fromTime, const QTime &toTime,
513  bool weeknumbers,
514  bool recurDaily, bool recurWeekly, bool singleLineLimit,
515  bool showNoteLines, bool includeDescription,
516  bool excludeConfidential, bool excludePrivate,
517  const QRect &box );
535  void drawMonth( QPainter &p, const QDate &dt, const QRect &box,
536  int maxdays = -1, int subDailyFlags = TimeBoxes,
537  int holidaysFlags = Text,
538  bool excludeConfidential = false, bool excludePrivate = false );
539 
543  class TodoParentStart;
544 
581  void drawTodo( int &count, const KCalCore::Todo::Ptr &todo, QPainter &p,
582  KCalCore::TodoSortField sortField,
583  KCalCore::SortDirection sortDir,
584  bool connectSubTodos, bool strikeoutCompleted, bool desc,
585  int posPriority, int posSummary, int posDueDt,
586  int posPercentComplete, int level, int x, int &y,
587  int width, int pageHeight,
588  const KCalCore::Todo::List &todoList, TodoParentStart *r,
589  bool excludeConfidential, bool excludePrivate );
590 
601  void drawJournal( const KCalCore::Journal::Ptr &journal, QPainter &p, int x, int &y,
602  int width, int pageHeight );
612  void drawTextLines( QPainter &p, const QString &entry,
613  int x, int &y, int width, int pageHeight,
614  bool richTextEntry );
615 
616  void drawSplitHeaderRight( QPainter &p, const QDate &fd, const QDate &td,
617  const QDate &cd, int width, int height );
618 
625  void drawNoteLines( QPainter &p, const QRect &box, int startY );
626 
627  protected:
628  QTime dayStart() const;
629  QColor categoryBgColor( const KCalCore::Incidence::Ptr &incidence ) const;
630 
631  void drawIncidence( QPainter &p, const QRect &dayBox, const QString &time,
632  const QString &summary, const QString &description,
633  int &textY, bool singleLineLimit,
634  bool includeDescription, bool richDescription );
635  QString toPlainText( const QString &htmlText );
636  void drawTodoLines( QPainter &p, const QString &entry,
637  int x, int &y, int width, int pageHeight,
638  bool richTextEntry, QList<TodoParentStart *> &startPoints,
639  bool connectSubTodos );
640 
641  protected:
642  bool mUseColors;
643  bool mPrintFooter;
644  bool mShowNoteLines;
645  int mHeaderHeight;
646  int mSubHeaderHeight;
647  int mFooterHeight;
648  int mMargin;
649  int mPadding;
650  int mBorder;
651  const KCalendarSystem *mCalSys;
652 
653  private:
654  QColor categoryColor( const QStringList &categories ) const;
655 
659  void setColorsByIncidenceCategory( QPainter &p,
660  const KCalCore::Incidence::Ptr &incidence ) const;
661 
662 
663  QString holidayString( const QDate &date ) const;
664 
665  KCalCore::Event::Ptr holidayEvent( const QDate &date ) const;
666 
670  QColor getTextColor( const QColor &c ) const;
671 };
672 
673 }
674 
675 #endif
QWidget
QPrinter
CalendarSupport::CalPrintPluginBase::mHeaderHeight
int mHeaderHeight
Definition: calprintpluginbase.h:645
printplugin.h
QFont
CalendarSupport::CalPrintPluginBase::mFooterHeight
int mFooterHeight
Definition: calprintpluginbase.h:647
QBrush
CalendarSupport::CalPrintPluginBase::mUseColors
bool mUseColors
Definition: calprintpluginbase.h:642
QTime
CalendarSupport::incidence
CALENDARSUPPORT_EXPORT KCalCore::Incidence::Ptr incidence(const Akonadi::Item &item)
returns the incidence from an akonadi item, or a null pointer if the item has no such payload ...
Definition: utils.cpp:78
calendarsupport_export.h
CalendarSupport::todo
CALENDARSUPPORT_EXPORT KCalCore::Todo::Ptr todo(const Akonadi::Item &item)
returns the todo from an akonadi item, or a null pointer if the item has no such payload ...
Definition: utils.cpp:124
CalendarSupport::CalPrintPluginBase::mCalSys
const KCalendarSystem * mCalSys
Definition: calprintpluginbase.h:651
QRect
CalendarSupport::CalPrintPluginBase::DisplayFlags
DisplayFlags
Definition: calprintpluginbase.h:65
QPainter
QDate
CalendarSupport::CalPrintPluginBase::mPadding
int mPadding
Definition: calprintpluginbase.h:649
QString
CalendarSupport::categories
CALENDARSUPPORT_EXPORT QStringList categories(const KCalCore::Incidence::List &incidences)
Definition: utils.cpp:752
QList
QColor
QStringList
CalendarSupport::CalPrintPluginBase
Base class for Calendar printing classes.
Definition: calprintpluginbase.h:62
CalendarSupport::PrintPlugin
Base class for Calendar printing classes.
Definition: printplugin.h:56
CalendarSupport::CalPrintPluginBase::mMargin
int mMargin
Definition: calprintpluginbase.h:648
CalendarSupport::CalPrintPluginBase::mPrintFooter
bool mPrintFooter
Definition: calprintpluginbase.h:643
CalendarSupport::CalPrintPluginBase::mBorder
int mBorder
Definition: calprintpluginbase.h:650
CalendarSupport::workDays
CALENDARSUPPORT_EXPORT QList< QDate > workDays(const QDate &start, const QDate &end)
Returns a list containing work days between start and .
Definition: utils.cpp:642
CALENDARSUPPORT_EXPORT
#define CALENDARSUPPORT_EXPORT
Definition: calendarsupport_export.h:36
CalendarSupport::journal
CALENDARSUPPORT_EXPORT KCalCore::Journal::Ptr journal(const Akonadi::Item &item)
returns the journal from an akonadi item, or a null pointer if the item has no such payload ...
Definition: utils.cpp:137
CalendarSupport::CalPrintPluginBase::mShowNoteLines
bool mShowNoteLines
Definition: calprintpluginbase.h:644
CalendarSupport::CalPrintPluginBase::mSubHeaderHeight
int mSubHeaderHeight
Definition: calprintpluginbase.h:646
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:31:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

calendarsupport

Skip menu "calendarsupport"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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
  • pimprint

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