• 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
journalprint.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 
18  As a special exception, permission is given to link this program
19  with any edition of Qt, and distribute the resulting executable,
20  without including the source code for Qt in the source distribution.
21 */
22 
23 #include "journalprint.h"
24 #include "utils.h"
25 
26 using namespace CalendarSupport;
27 
28 /**************************************************************
29  * Print Journal
30  **************************************************************/
31 
32 QWidget *CalPrintJournal::createConfigWidget( QWidget *w )
33 {
34  return new CalPrintJournalConfig( w );
35 }
36 
37 void CalPrintJournal::readSettingsWidget()
38 {
39  CalPrintJournalConfig *cfg =
40  dynamic_cast<CalPrintJournalConfig*>( ( QWidget* )mConfigWidget );
41  if ( cfg ) {
42  mFromDate = cfg->mFromDate->date();
43  mToDate = cfg->mToDate->date();
44  mUseDateRange = cfg->mRangeJournals->isChecked();
45  }
46 }
47 
48 void CalPrintJournal::setSettingsWidget()
49 {
50  CalPrintJournalConfig *cfg =
51  dynamic_cast<CalPrintJournalConfig*>( ( QWidget* )mConfigWidget );
52  if ( cfg ) {
53  cfg->mFromDate->setDate( mFromDate );
54  cfg->mToDate->setDate( mToDate );
55 
56  if ( mUseDateRange ) {
57  cfg->mRangeJournals->setChecked( true );
58  cfg->mFromDateLabel->setEnabled( true );
59  cfg->mFromDate->setEnabled( true );
60  cfg->mToDateLabel->setEnabled( true );
61  cfg->mToDate->setEnabled( true );
62  } else {
63  cfg->mAllJournals->setChecked( true );
64  cfg->mFromDateLabel->setEnabled( false );
65  cfg->mFromDate->setEnabled( false );
66  cfg->mToDateLabel->setEnabled( false );
67  cfg->mToDate->setEnabled( false );
68  }
69  }
70 }
71 
72 void CalPrintJournal::loadConfig()
73 {
74  if ( mConfig ) {
75  KConfigGroup config( mConfig, "Journalprint" );
76  mUseDateRange = config.readEntry( "JournalsInRange", false );
77  }
78  setSettingsWidget();
79 }
80 
81 void CalPrintJournal::saveConfig()
82 {
83  kDebug();
84 
85  readSettingsWidget();
86  if ( mConfig ) {
87  KConfigGroup config( mConfig, "Journalprint" );
88  config.writeEntry( "JournalsInRange", mUseDateRange );
89  }
90 }
91 
92 void CalPrintJournal::setDateRange( const QDate &from, const QDate &to )
93 {
94  CalPrintPluginBase::setDateRange( from, to );
95  CalPrintJournalConfig *cfg =
96  dynamic_cast<CalPrintJournalConfig*>( ( QWidget* )mConfigWidget );
97  if ( cfg ) {
98  cfg->mFromDate->setDate( from );
99  cfg->mToDate->setDate( to );
100  }
101 }
102 
103 void CalPrintJournal::print( QPainter &p, int width, int height )
104 {
105  int x=0, y=0;
106  KCalCore::Journal::List journals( mCalendar->journals() );
107  if ( mUseDateRange ) {
108  KCalCore::Journal::List allJournals = journals;
109  journals.clear();
110  foreach( const KCalCore::Journal::Ptr &j, allJournals ) {
111  const QDate dt = j->dtStart().date();
112  if ( mFromDate <= dt && dt <= mToDate ) {
113  journals.append( j );
114  }
115  }
116  }
117 
118  QRect headerBox( 0, 0, width, headerHeight() );
119  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
120  height -= footerHeight();
121 
122  drawHeader( p, i18n( "Journal entries" ), QDate(), QDate(), headerBox );
123  y = headerHeight() + 15;
124 
125  foreach( const KCalCore::Journal::Ptr &j, journals ) {
126  drawJournal( j, p, x, y, width, height );
127  }
128 
129  drawFooter( p, footerBox );
130 }
QWidget
CalendarSupport::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:640
CalendarSupport::CalPrintJournalConfig
Definition: journalprint.h:57
CalendarSupport::PrintPlugin::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: printplugin.h:153
CalendarSupport::CalPrintPluginBase::headerHeight
int headerHeight() const
Returns the height of the page header.
Definition: calprintpluginbase.cpp:327
CalendarSupport::PrintPlugin::mFromDate
QDate mFromDate
Definition: printplugin.h:160
utils.h
QRect
QWidget::setEnabled
void setEnabled(bool)
QPainter
CalendarSupport::CalPrintJournal::mUseDateRange
bool mUseDateRange
Definition: journalprint.h:54
CalendarSupport::CalPrintJournal::print
virtual void print(QPainter &p, int width, int height)
Actually do the printing.
Definition: journalprint.cpp:103
CalendarSupport::PrintPlugin::mCalendar
Akonadi::ETMCalendar::Ptr mCalendar
Definition: printplugin.h:168
QDate
CalendarSupport::CalPrintJournal::saveConfig
virtual void saveConfig()
Write print format configuration to config file.
Definition: journalprint.cpp:81
CalendarSupport::CalPrintJournal::setSettingsWidget
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: journalprint.cpp:48
CalendarSupport::CalPrintJournal::loadConfig
virtual void loadConfig()
Load print format configuration from config file.
Definition: journalprint.cpp:72
CalendarSupport::PrintPlugin::mConfigWidget
QPointer< QWidget > mConfigWidget
Definition: printplugin.h:164
CalendarSupport::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:565
CalendarSupport::CalPrintJournal::readSettingsWidget
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: journalprint.cpp:37
CalendarSupport::PrintPlugin::mToDate
QDate mToDate
Definition: printplugin.h:161
CalendarSupport::CalPrintJournal::setDateRange
virtual void setDateRange(const QDate &from, const QDate &to)
Set date range which should be printed.
Definition: journalprint.cpp:92
CalendarSupport::CalPrintPluginBase::footerHeight
int footerHeight() const
Returns the height of the page footer.
Definition: calprintpluginbase.cpp:353
CalendarSupport::PrintPlugin::mConfig
KConfig * mConfig
Definition: printplugin.h:170
CalendarSupport::CalPrintPluginBase::drawJournal
void drawJournal(const KCalCore::Journal::Ptr &journal, QPainter &p, int x, int &y, int width, int pageHeight)
Draws single journal item.
Definition: calprintpluginbase.cpp:2119
CalendarSupport::CalPrintJournal::createConfigWidget
virtual QWidget * createConfigWidget(QWidget *)
Returns widget for configuring the print format.
Definition: journalprint.cpp:32
journalprint.h
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