printplugin.h
1/*
2 This file is part of KOrganizer.
3
4 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
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 GNU
14 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
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef PRINTPLUGINBASE_H
22#define PRINTPLUGINBASE_H
23
24#ifndef KORG_NOPRINTER
25
26#include <tqdatetime.h>
27#include <kprinter.h>
28#include <calendar/plugin.h>
29#include <libkcal/incidence.h>
30
31namespace KCal {
32class Calendar;
33}
34
35namespace KOrg {
36class CoreHelper;
37
42{
43 public:
44 enum PrintType { Incidence = 100, Day=200, Week=300, Month=400, Todolist=1000, Journallist=2000 };
45};
46
51class PrintPlugin : public KOrg::Plugin
52{
53 public:
54 PrintPlugin() : KOrg::Plugin(), mConfigWidget(0), mCoreHelper(0), mPrinter(0),
55 mCalendar(0), mConfig(0) {}
56 virtual ~PrintPlugin() {}
57
58 typedef TQPtrList<PrintPlugin> List;
59 static int interfaceVersion() { return 2; }
60 static TQString serviceType() { return "KOrganizer/PrintPlugin"; }
61
62 virtual void setKOrgCoreHelper( KOrg::CoreHelper*helper ) { mCoreHelper = helper; }
63 virtual void setConfig( TDEConfig *cfg ) { mConfig = cfg; }
64 virtual void setCalendar( KCal::Calendar *cal ) { mCalendar = cal; }
65 virtual void setSelectedIncidences( KCal::Incidence::List inc ) { mSelectedIncidences = inc; }
66 virtual KCal::Incidence::List selectedIncidences() const { return mSelectedIncidences; }
67
68
72 virtual TQString description() = 0;
76 virtual TQString info() = 0;
77
86 virtual int sortID() { return -1; }
87
91 virtual bool enabled() { return false; }
92
93 TQWidget *configWidget( TQWidget *w )
94 {
95 if ( !mConfigWidget ) {
96 mConfigWidget = createConfigWidget( w );
98 }
99 return mConfigWidget;
100 }
101 /* Create the config widget. setSettingsWidget will be automatically
102 called on it */
103 virtual TQWidget *createConfigWidget( TQWidget * ) = 0;
104
108 virtual void doPrint( KPrinter *printer ) = 0;
109
116 virtual KPrinter::Orientation defaultOrientation() { return KPrinter::Portrait; }
117
121 virtual void doLoadConfig() {};
125 virtual void doSaveConfig() {};
126
127
128 public:
132 virtual void readSettingsWidget() {}
136 virtual void setSettingsWidget() {}
137
141 virtual void setDateRange( const TQDate &from, const TQDate &to )
142 {
143 mFromDate = from;
144 mToDate = to;
145 }
146
147 protected:
148 TQDate mFromDate;
149 TQDate mToDate;
150
151 protected:
152 TQWidget *mConfigWidget;
153 KOrg::CoreHelper *mCoreHelper;
156 KPrinter *mPrinter;
157 KCal::Calendar *mCalendar;
158 KCal::Incidence::List mSelectedIncidences;
159 TDEConfig *mConfig;
160};
161
162class PrintPluginFactory : public PluginFactory
163{
164 public:
165 virtual PrintPlugin *create() = 0;
166};
167
168}
169
170#endif
171
172#endif
Base class of KOrganizer printer class.
Definition: printplugin.h:42
Base class for KOrganizer printing classes.
Definition: printplugin.h:52
virtual void doPrint(KPrinter *printer)=0
Actually do the printing.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
Definition: printplugin.h:136
virtual void setDateRange(const TQDate &from, const TQDate &to)
Set date range which should be printed.
Definition: printplugin.h:141
virtual TQString description()=0
Returns short description of print format.
virtual KPrinter::Orientation defaultOrientation()
Orientation of printout.
Definition: printplugin.h:116
virtual bool enabled()
Returns true if the plugin should be enabled; false otherwise.
Definition: printplugin.h:91
virtual void doLoadConfig()
Load complete config.
Definition: printplugin.h:121
virtual TQString info()=0
Returns long description of print format.
virtual void doSaveConfig()
Save complete config.
Definition: printplugin.h:125
virtual int sortID()
Returns the sort ID of the plugin.
Definition: printplugin.h:86
KPrinter * mPrinter
The printer object.
Definition: printplugin.h:156
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.
Definition: printplugin.h:132