listprint.cpp
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
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 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 TQt, and distribute the resulting executable,
22  without including the source code for TQt in the source distribution.
23 */
24 
25 #ifndef KORG_NOPRINTER
26 
27 #include "listprint.h"
28 
29 #include "calprintpluginbase.h"
30 #include <libkcal/event.h>
31 #include <libkcal/todo.h>
32 #include <libkcal/calendar.h>
33 #include <libtdepim/kdateedit.h>
34 #include <tdeconfig.h>
35 #include <kdebug.h>
36 
37 #include <tqbuttongroup.h>
38 
39 #include "calprintlistconfig_base.h"
40 
41 
42 class ListPrintFactory : public KOrg::PrintPluginFactory {
43  public:
44  KOrg::PrintPlugin *create() { return new CalPrintList; }
45 };
46 
47 K_EXPORT_COMPONENT_FACTORY( libkorg_listprint, ListPrintFactory )
48 
49 
50 
51 /**************************************************************
52  * Print Day
53  **************************************************************/
54 
55 TQWidget *CalPrintList::createConfigWidget( TQWidget *w )
56 {
57  return new CalPrintListConfig_Base( w );
58 }
59 
60 void CalPrintList::readSettingsWidget()
61 {
62  CalPrintListConfig_Base *cfg =
63  dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
64  if ( cfg ) {
65  mFromDate = cfg->mFromDate->date();
66  mToDate = cfg->mToDate->date();
67  mUseDateRange = (cfg->mDateRangeGroup->selectedId() == 1);
68  }
69 }
70 
71 void CalPrintList::setSettingsWidget()
72 {
73  CalPrintListConfig_Base *cfg =
74  dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
75  if ( cfg ) {
76  cfg->mFromDate->setDate( mFromDate );
77  cfg->mToDate->setDate( mToDate );
78 
79  cfg->mDateRangeGroup->setButton( (mUseDateRange)?1:0 );
80  }
81 }
82 
83 void CalPrintList::loadConfig()
84 {
85  if ( mConfig ) {
86  mUseDateRange = mConfig->readBoolEntry( "ListsInRange", false );
87  }
88  setSettingsWidget();
89 }
90 
91 void CalPrintList::saveConfig()
92 {
93  kdDebug(5850) << "CalPrintList::saveConfig()" << endl;
94 
95  readSettingsWidget();
96  if ( mConfig ) {
97  mConfig->writeEntry( "ListsInRange", mUseDateRange );
98  }
99 }
100 
101 void CalPrintList::setDateRange( const TQDate& from, const TQDate& to )
102 {
104  CalPrintListConfig_Base *cfg =
105  dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
106  if ( cfg ) {
107  cfg->mFromDate->setDate( from );
108  cfg->mToDate->setDate( to );
109  }
110 }
111 
112 void CalPrintList::print( TQPainter &p, int width, int height )
113 {
114 }
115 
116 #endif
Base class for KOrganizer printing classes.
Definition: printplugin.h:52
virtual void setDateRange(const TQDate &from, const TQDate &to)
Set date range which should be printed.
Definition: printplugin.h:141