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