korganizer
printplugin.h
00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 #ifndef PRINTPLUGINBASE_H 00022 #define PRINTPLUGINBASE_H 00023 00024 #ifndef KORG_NOPRINTER 00025 00026 #include <qdatetime.h> 00027 #include <kprinter.h> 00028 #include <calendar/plugin.h> 00029 00030 namespace KCal { 00031 class Calendar; 00032 } 00033 class CalPrintHelper; 00034 00035 namespace KOrg { 00036 00037 class CoreHelper; 00038 00043 class PrintPlugin : public KOrg::Plugin 00044 { 00045 public: 00046 PrintPlugin() : KOrg::Plugin(), mCoreHelper(0), mPrinter(0), 00047 mCalendar(0), mConfig(0), mHelper(0) {} 00048 virtual ~PrintPlugin() {} 00049 00050 typedef QPtrList<PrintPlugin> List; 00051 static int interfaceVersion() { return 2; } 00052 static QString serviceType() { return "KOrganizer/PrintPlugin"; } 00053 00054 virtual void setCalPrintHelper( CalPrintHelper *helper ) { mHelper = helper; } 00055 virtual void setKOrgCoreHelper( KOrg::CoreHelper*helper ) { mCoreHelper = helper; } 00056 virtual void setConfig( KConfig *cfg ) { mConfig = cfg; } 00057 virtual void setCalendar( KCal::Calendar *cal ) { mCalendar = cal; } 00058 virtual void setPrinter( KPrinter *pr ) { mPrinter = pr; } 00059 00063 virtual QString description() = 0; 00067 virtual QString info() = 0; 00068 00069 QWidget *configWidget( QWidget *w ) 00070 { 00071 mConfigWidget = createConfigWidget( w ); 00072 setSettingsWidget(); 00073 return mConfigWidget; 00074 } 00075 /* Create the config widget. setSettingsWidget will be automatically 00076 called on it */ 00077 virtual QWidget *createConfigWidget( QWidget * ) = 0; 00078 00082 virtual void doPrint() = 0; 00083 00090 virtual KPrinter::Orientation orientation() { return KPrinter::Portrait; } 00091 00095 virtual void doLoadConfig() {}; 00099 virtual void doSaveConfig() {}; 00100 00101 00102 public: 00106 virtual void readSettingsWidget() {} 00110 virtual void setSettingsWidget() {} 00111 00115 virtual void setDateRange( const QDate &from, const QDate &to ) 00116 { 00117 mFromDate = from; 00118 mToDate = to; 00119 } 00120 00121 protected: 00122 QDate mFromDate; 00123 QDate mToDate; 00124 00125 protected: 00126 QWidget *mConfigWidget; 00127 KOrg::CoreHelper *mCoreHelper; 00128 KPrinter *mPrinter; 00129 KCal::Calendar *mCalendar; 00130 KConfig *mConfig; 00131 CalPrintHelper *mHelper; 00132 }; 00133 00134 00135 class PrintPluginFactory : public PluginFactory 00136 { 00137 public: 00138 virtual PrintPlugin *create() = 0; 00139 }; 00140 00141 } 00142 00143 #endif 00144 00145 #endif