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 #include <libkcal/incidence.h>
00030 
00031 namespace KCal {
00032 class Calendar;
00033 }
00034 
00035 namespace KOrg {
00036 class CoreHelper;
00037 
00041 class CalPrinterBase
00042 {
00043   public:
00044     enum PrintType { Incidence = 100, Day=200, Week=300, Month=400, Todolist=1000, Journallist=2000 };
00045 };
00046 
00051 class PrintPlugin : public KOrg::Plugin
00052 {
00053   public:
00054     PrintPlugin() : KOrg::Plugin(), mConfigWidget(0), mCoreHelper(0), mPrinter(0),
00055          mCalendar(0), mConfig(0) {}
00056     virtual ~PrintPlugin() {}
00057 
00058     typedef QPtrList<PrintPlugin> List;
00059     static int interfaceVersion() { return 2; }
00060     static QString serviceType() { return "KOrganizer/PrintPlugin"; }
00061 
00062     virtual void setKOrgCoreHelper( KOrg::CoreHelper*helper ) { mCoreHelper = helper; }
00063     virtual void setConfig( KConfig *cfg ) { mConfig = cfg; }
00064     virtual void setCalendar( KCal::Calendar *cal ) { mCalendar = cal; }
00065     virtual void setSelectedIncidences( KCal::Incidence::List inc ) { mSelectedIncidences = inc; }
00066     virtual KCal::Incidence::List selectedIncidences() const { return mSelectedIncidences; }
00067 
00068 
00072     virtual QString description() = 0;
00076     virtual QString info() = 0;
00077 
00086     virtual int sortID() { return -1; }
00087 
00091     virtual bool enabled() { return false; }
00092 
00093     QWidget *configWidget( QWidget *w )
00094     {
00095       if ( !mConfigWidget ) {
00096         mConfigWidget = createConfigWidget( w );
00097         setSettingsWidget();
00098       }
00099       return mConfigWidget;
00100     }
00101     /* Create the config widget. setSettingsWidget will be automatically
00102        called on it */
00103     virtual QWidget *createConfigWidget( QWidget * ) = 0;
00104 
00108     virtual void doPrint( KPrinter *printer ) = 0;
00109 
00116     virtual KPrinter::Orientation defaultOrientation() { return KPrinter::Portrait; }
00117 
00121     virtual void doLoadConfig() {};
00125     virtual void doSaveConfig() {};
00126 
00127 
00128   public:
00132     virtual void readSettingsWidget() {}
00136     virtual void setSettingsWidget() {}
00137 
00141     virtual void setDateRange( const QDate &from, const QDate &to )
00142     {
00143       mFromDate = from;
00144       mToDate = to;
00145     }
00146 
00147   protected:
00148     QDate mFromDate;
00149     QDate mToDate;
00150 
00151   protected:
00152     QWidget *mConfigWidget;
00153     KOrg::CoreHelper *mCoreHelper;
00156     KPrinter *mPrinter;
00157     KCal::Calendar *mCalendar;
00158     KCal::Incidence::List mSelectedIncidences;
00159     KConfig *mConfig;
00160 };
00161 
00162 class PrintPluginFactory : public PluginFactory
00163 {
00164   public:
00165     virtual PrintPlugin *create() = 0;
00166 };
00167 
00168 }
00169 
00170 #endif
00171 
00172 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys