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

PIMPrint Library

  • sources
  • kde-4.14
  • kdepim
  • pimprint
  • calendar
calprintbase.h
Go to the documentation of this file.
1 /*
2  This file is part of the PimPrint library.
3 
4  Copyright (C) 2012 Allen Winter <winter@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 //
23 // arguments:
24 // <D> printer() (mPrinter)
25 // <D> style
26 // <D> calendar
27 // <D> calendarsystem
28 // <D> headertext
29 // <D> flagsList
30 //
31 // properties:
32 // <D>useColor()
33 // <D>useLandscape()
34 // <D>pageWidth()
35 // <D>pageHeight()
36 // <D>headerHeight()
37 // <D>subheaderHeight()
38 // <D>footerHeight()
39 // TODO: headerBackgroundColor?
40 // <D> margins()
41 // <D> padding()
42 // <D> timeLineWidth() (TIMELINE_WIDTH)
43 // <D> boxBorderWidth() (BOX_BORDER_WIDTH)
44 // <D> itemBoxBorderWidth() (EVENT_BORDER_WIDTH)
45 //
46 #ifndef PIMPRINT_CALPRINTBASE_H
47 #define PIMPRINT_CALPRINTBASE_H
48 
49 #include "pimprint_calendar_export.h"
50 #include "cellitem.h"
51 
52 #include <KCalCore/Calendar>
53 #include <KCalCore/Event>
54 #include <KCalCore/Incidence>
55 
56 #include <QPainter>
57 #include <QPrinter>
58 
59 class KCalendarSystem;
60 
61 namespace PimPrint
62 {
63 
64 namespace Calendar
65 {
66 
67 class PIMPRINT_CALENDAR_EXPORT CalPrintBase : public QObject
68 {
69  Q_OBJECT
70  Q_ENUMS(Style)
71  Q_FLAGS(InfoOptions)
72  Q_FLAGS(TypeOptions)
73  Q_FLAGS(RangeOptions)
74  Q_FLAGS(ExtraOptions)
75 
76  Q_PROPERTY(bool useColor
77  READ useColor WRITE setUseColor)
78 
79  Q_PROPERTY(bool useLandscape
80  READ useLandscape WRITE setUseLandscape)
81 
82  Q_PROPERTY(int pageWidth
83  READ pageWidth WRITE setPageWidth)
84 
85  Q_PROPERTY(int pageHeight
86  READ pageHeight WRITE setPageHeight)
87 
88  Q_PROPERTY(int headerHeight
89  READ headerHeight WRITE setHeaderHeight)
90 
91  Q_PROPERTY(int subheaderHeight
92  READ subHeaderHeight WRITE setSubHeaderHeight)
93 
94  Q_PROPERTY(int footerHeight
95  READ footerHeight WRITE setFooterHeight)
96 
97  Q_PROPERTY(int padding
98  READ padding WRITE setPadding)
99 
100  Q_PROPERTY(int margins READ margins)
101 
102  Q_PROPERTY(int boxBorderWidth READ boxBorderWidth)
103 
104  Q_PROPERTY(int itemBoxBorderWidth READ itemBoxBorderWidth)
105 
106  Q_PROPERTY(int timeLineWidth READ timeLineWidth)
107 
108 public:
112  explicit CalPrintBase(QPrinter *printer);
113 
117  ~CalPrintBase();
118 
119  virtual void print(QPainter &p) = 0;
120 
121  enum Style {
122  None, //< No print type is set
123  Incidence, //< Generalized for Events, To-dos and Journals
124  DayFiloFax, //<
125  DayTimeTable, //<
126  DaySingleTimeTable, //<
127  WeekFiloFax, //<
128  WeekTimeTable, //<
129  WeekSplitWeek, //<
130  MonthClassic, //<
131  TodoList, //<
132  Journal, //< (how is this different from Incidence for Journals?)
133  Year //<
134  };
135 
141  void setUseColor(const bool useColor);
142 
147  bool useColor() const;
148 
154  void setUseLandscape(const bool landscape);
155 
160  bool useLandscape() const;
161 
167  void setPageHeight(const int height) const;
168 
173  int pageHeight() const;
174 
180  void setPageWidth(const int width) const;
181 
186  int pageWidth() const;
187 
193  void setHeaderHeight(const int height);
194 
201  int headerHeight() const;
202 
208  void setSubHeaderHeight(const int height);
209 
216  int subHeaderHeight() const;
217 
223  void setFooterHeight(const int height);
224 
231  int footerHeight() const;
232 
237  void setPadding(const int padding);
238 
245  int padding() const;
246 
252  int margins() const;
253 
258  int boxBorderWidth() const;
259 
264  int itemBoxBorderWidth() const;
265 
270  int timeLineWidth() const;
271 
272  enum InfoOption {
273  InfoAll = 0x00000001,
274  InfoDescription = 0x00000002,
275  InfoLocation = 0x00000004,
276  InfoAttendees = 0x00000008,
277  InfoCategories = 0x00000010,
278  InfoPriority = 0x00000020,
279  InfoDueDate = 0x00000040, // for to-dos only
280  InfoPercentDone = 0x00000080, // for to-dos only
281  InfoTimeRange = 0x00000100
282  };
283  Q_DECLARE_FLAGS(InfoOptions, InfoOption)
284 
285  enum TypeOption {
286  TypeAll = 0x00000001,
287  TypeEvent = 0x00000002,
288  TypeTodo = 0x00000004,
289  TypeJournal = 0x00000008,
290  TypeConfidential = 0x00000010,
291  TypePrivate = 0x00000020
292  };
293  Q_DECLARE_FLAGS(TypeOptions, TypeOption)
294 
295  enum RangeOption {
296  RangeTimeExpand = 0x00000001,
297  RangeRecurAny = 0x00000002,
298  RangeRecurDaily = 0x00000004,
299  RangeRecurWeekly = 0x00000008
300  };
301  Q_DECLARE_FLAGS(RangeOptions, RangeOption)
302 
303  enum ExtraOption {
304  ExtraSingleLine = 0x00000001,
305  ExtraNoteLines = 0x00000002,
306  ExtraWeekNumbers = 0x00000004,
307  ExtraStrikeDoneTodos = 0x00000008, // for to-dos only, strikeout completed to-dos
308  ExtraConnectSubTodos = 0x00000010, // for to-dos only, connect sub-to-dos with lines
309  ExtraFooter = 0x00000020
310  };
311  Q_DECLARE_FLAGS(ExtraOptions, ExtraOption)
312 
313 
318  void setThePrinter(QPrinter *printer);
319 
324  QPrinter *thePrinter() const;
325 
331  void setPrintCalendar(const KCalCore::Calendar::Ptr &calendar);
332 
337  KCalCore::Calendar::Ptr printCalendar() const;
338 
344  void setCalendarSystem(KCalendarSystem *calSystem);
345 
350  KCalendarSystem *calendarSystem() const;
351 
357  void setPrintStyle(const Style style);
358 
363  Style printStyle() const;
364 
370  void setInfoOptions(InfoOptions flags);
371 
376  InfoOptions infoOptions() const;
377 
383  void setTypeOptions(TypeOptions flags);
384 
389  TypeOptions typeOptions() const;
390 
396  void setRangeOptions(RangeOptions flags);
397 
402  RangeOptions rangeOptions() const;
403 
409  void setExtraOptions(ExtraOptions flags);
410 
415  ExtraOptions extraOptions() const;
416 
417 protected:
443  int drawHeader(QPainter &p,
444  const QRect &box,
445  const QString &title,
446  const QDate &leftMonth = QDate(),
447  const QDate &rightMonth = QDate(),
448  const bool expand = false,
449  const QColor &backColor = QColor()) const;
457  void drawSubHeader(QPainter &p, const QRect &box, const QString &str) const;
458 
467  int drawFooter(QPainter &p, const QRect &box) const;
468 
476  //TODO: make box second arg
477  void drawBox(QPainter &p, const int linewidth, const QRect &box) const;
478 
487  //TODO: make box second arg
488  void drawShadedBox(QPainter &p, const int linewidth,
489  const QBrush &brush, const QRect &box) const;
490 
500  //TODO: make box second arg
501  void drawVerticalBox(QPainter &p,
502  const int linewidth,
503  const QRect &box,
504  const QString &str,
505  int flags = -1) const;
506 
518  //TODO: make box the second arg
519  void drawItemBox(QPainter &p,
520  int linewidth,
521  const QRect &box,
522  const KCalCore::Incidence::Ptr &incidence,
523  const QString &str,
524  int flags = -1) const;
525 
534  void drawItemString(QPainter &p, const QRect &box,
535  const QString &str, int flags = -1) const;
536 
550  void drawDayBox(QPainter &p,
551  const QRect &box,
552  const QDate &date,
553  const QTime &startTime, const QTime &endTime,
554  bool fullDate = false) const;
555 
576  void drawAgendaDayBox(QPainter &p,
577  const QRect &box,
578  const QDate &date,
579  const KCalCore::Event::List &eventList,
580  const QTime &startTime,
581  const QTime &endTime,
582  const QList<QDate> &workDays) const;
583 
584  //TODO: make QPainter the first arg
585  void drawAgendaItem(PrintCellItem *item, QPainter &p,
586  const KDateTime &startPrintDate,
587  const KDateTime &endPrintDate,
588  float minlen, const QRect &box) const;
589 
601  //TODO: make box the second arg
602  void drawTimeLine(QPainter &p,
603  const QTime &startTime,
604  const QTime &endTime,
605  const QRect &box) const;
606 
625  void drawTimeTable(QPainter &p, const QRect &box,
626  const QDate &startDate, const QDate &endDate,
627  const QTime &startTime, const QTime &endTime,
628  bool expandAll = false) const;
629 
641  void drawDaysOfWeek(QPainter &p, const QRect &box,
642  const QDate &fromDate, const QDate &toDate) const;
643 
649  int weekdayColumn(int weekday) const;
650 
658  QString cleanString(const QString &str) const;
659 
667  QString toPlainText(const QString &htmlText) const;
668 
669 private:
670  //TODO: move to dpointer
674  void init(QPrinter *printer) const;
675 
679  void finish() const;
680 
689  void drawSmallMonth(QPainter &p, const QDate &date, const QRect &box) const;
690 
698  void drawNoteLines(QPainter &p, const QRect &box, const int startY) const;
699 
700  void drawDayIncidence(QPainter &p, const QRect &dayBox, const QString &time,
701  const QString &summary, const QString &description,
702  int &textY, bool richDescription) const;
703 
704  QColor categoryColor(const QStringList &categories) const;
705 
706  QColor categoryBgColor(const KCalCore::Incidence::Ptr &incidence) const;
707 
711  void setColorsByIncidenceCategory(QPainter &p,
712  const KCalCore::Incidence::Ptr &incidence) const;
713 
714  QString holidayString(const QDate &date) const;
715 
716  KCalCore::Event::Ptr holidayEvent(const QDate &date) const;
717 
721  QColor getTextColor(const QColor &c) const;
722 
731  void drawDaysOfWeekBox(QPainter &p, const QRect &box, const QDate &date) const;
732 
753  int drawAllDayBox(QPainter &p, const QRect &box,
754  const QDate &date,
755  const KCalCore::Event::List &eventList,
756  bool expandAll = false) const;
757 
758 private:
759  Q_DISABLE_COPY(CalPrintBase)
760  //@cond PRIVATE
761  class Private;
762  Private *const d;
763  //@endcond
764 };
765 
766 Q_DECLARE_OPERATORS_FOR_FLAGS(CalPrintBase::InfoOptions)
767 Q_DECLARE_OPERATORS_FOR_FLAGS(CalPrintBase::TypeOptions)
768 Q_DECLARE_OPERATORS_FOR_FLAGS(CalPrintBase::RangeOptions)
769 Q_DECLARE_OPERATORS_FOR_FLAGS(CalPrintBase::ExtraOptions)
770 
771 }
772 
773 }
774 
775 #if 0
776 public:
777 enum DisplayFlags {
778  Text = 0x0001,
779  TimeBoxes = 0x0002
780 };
781 
782 public:
783 Actually do the printing.
784 
785  @param p QPainter the print result is painted to
786  @param width Width of printable area
787  @param height Height of printable area
788  * /
789  virtual void print(QPainter &p, int width, int height) = 0;
793 virtual void doPrint(QPrinter *printer);
794 
795 public:
796 bool printFooter() const;
797 void setPrintFooter(bool printFooter);
798 
800 QTime dayStart();
801 
802 int margin() const;
803 void setMargin(const int margin);
804 
805 /*****************************************************************
806  ** PRINTING HELPER FUNCTIONS **
807  *****************************************************************/
808 
809 public:
810 
832 int drawBoxWithCaption(QPainter &p, const QRect &box, const QString &caption,
833  const QString &contents, bool sameLine, bool expand,
834  const QFont &captionFont, const QFont &textFont,
835  bool richContents = false);
836 };
837 
838 }
839 
840 }
841 #endif //if 0
842 
843 #endif
PimPrint::Calendar::CalPrintBase::DayFiloFax
Definition: calprintbase.h:124
cellitem.h
QPrinter
PimPrint::Calendar::CalPrintBase::DayTimeTable
Definition: calprintbase.h:125
pimprint_calendar_export.h
PimPrint::Calendar::CalPrintBase::TodoList
Definition: calprintbase.h:131
QFont
QBrush
PimPrint::Calendar::CalPrintBase::WeekSplitWeek
Definition: calprintbase.h:129
QTime
PimPrint::Calendar::CalPrintBase::MonthClassic
Definition: calprintbase.h:130
PimPrint::Calendar::CalPrintBase::InfoOption
InfoOption
Definition: calprintbase.h:272
QRect
QObject
PimPrint::Calendar::PrintCellItem
Definition: cellitem.h:88
PimPrint::Calendar::CalPrintBase::None
Definition: calprintbase.h:122
QPainter
PimPrint::Calendar::CalPrintBase
Definition: calprintbase.h:67
QDate
PIMPRINT_CALENDAR_EXPORT
#define PIMPRINT_CALENDAR_EXPORT
Definition: pimprint_calendar_export.h:35
QString
QList
QColor
QStringList
PimPrint::Calendar::CalPrintBase::ExtraOption
ExtraOption
Definition: calprintbase.h:303
PimPrint::Calendar::CalPrintBase::RangeOption
RangeOption
Definition: calprintbase.h:295
to
Definition: calprinttodos.h:28
PimPrint::Calendar::CalPrintBase::WeekTimeTable
Definition: calprintbase.h:128
PimPrint::Calendar::CalPrintBase::WeekFiloFax
Definition: calprintbase.h:127
PimPrint::Calendar::CalPrintBase::Style
Style
Definition: calprintbase.h:121
PimPrint::Calendar::CalPrintBase::Journal
Definition: calprintbase.h:132
PimPrint::Calendar::CalPrintBase::TypeOption
TypeOption
Definition: calprintbase.h:285
PimPrint::Calendar::CalPrintBase::DaySingleTimeTable
Definition: calprintbase.h:126
PimPrint::Calendar::CalPrintBase::Incidence
Definition: calprintbase.h:123
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

PIMPrint Library

Skip menu "PIMPrint Library"
  • Main Page
  • Namespace List
  • 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
  • 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