korganizer
calprintpluginbase.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <qpainter.h>
00027 #include <qlayout.h>
00028 #include <qframe.h>
00029 #include <qlabel.h>
00030 #include <qptrlist.h>
00031 #include <qintdict.h>
00032
00033 #include <kglobal.h>
00034 #include <klocale.h>
00035 #include <kdebug.h>
00036 #include <kconfig.h>
00037 #include <kcalendarsystem.h>
00038 #include <kprinter.h>
00039
00040 #include <libkcal/todo.h>
00041 #include <libkcal/event.h>
00042 #include <libkcal/calendar.h>
00043
00044 #include "calprinthelper.h"
00045 #include "calprintpluginbase.h"
00046
00047 #ifndef KORG_NOPRINTER
00048
00049 QWidget *CalPrintPluginBase::createConfigWidget( QWidget *w )
00050 {
00051 QFrame *wdg = new QFrame( w );
00052 QVBoxLayout *layout = new QVBoxLayout( wdg );
00053
00054 QLabel *title = new QLabel( description(), wdg );
00055 QFont titleFont( title->font() );
00056 titleFont.setPointSize( 20 );
00057 titleFont.setBold( true );
00058 title->setFont( titleFont );
00059
00060 layout->addWidget( title );
00061 layout->addWidget( new QLabel( info(), wdg ) );
00062 layout->addSpacing( 20 );
00063 layout->addWidget( new QLabel( i18n("This printing style does not "
00064 "have any configuration options."),
00065 wdg ) );
00066 layout->addStretch();
00067 return wdg;
00068 }
00069
00070 void CalPrintPluginBase::doPrint()
00071 {
00072 QPainter p;
00073
00074 mPrinter->setColorMode( mUseColors?(KPrinter::Color):(KPrinter::GrayScale) );
00075
00076 p.begin(mPrinter);
00077
00078
00079 p.setViewport( mHelper->mMargin, mHelper->mMargin,
00080 p.viewport().width() - mHelper->mMargin,
00081 p.viewport().height() - mHelper->mMargin );
00082 int pageWidth = p.viewport().width();
00083 int pageHeight = p.viewport().height();
00084
00085 print(p, pageWidth, pageHeight);
00086
00087 p.end();
00088 }
00089
00090 void CalPrintPluginBase::doLoadConfig()
00091 {
00092 if ( mConfig ) {
00093 KConfigGroupSaver saver( mConfig, description() );
00094 mConfig->sync();
00095 QDateTime currDate( QDate::currentDate() );
00096 mFromDate = mConfig->readDateTimeEntry( "FromDate", &currDate ).date();
00097 mToDate = mConfig->readDateTimeEntry( "ToDate" ).date();
00098 mUseColors = mConfig->readBoolEntry( "UseColors", true );
00099 mHelper->setUseColors( mUseColors );
00100 loadConfig();
00101 } else {
00102 kdDebug(5850) << "No config available in loadConfig!!!!" << endl;
00103 }
00104 }
00105
00106 void CalPrintPluginBase::doSaveConfig()
00107 {
00108 if ( mConfig ) {
00109 KConfigGroupSaver saver( mConfig, description() );
00110 saveConfig();
00111 mConfig->writeEntry( "FromDate", QDateTime( mFromDate ) );
00112 mConfig->writeEntry( "ToDate", QDateTime( mToDate ) );
00113 mConfig->writeEntry( "UseColors", mUseColors );
00114 mConfig->sync();
00115 } else {
00116 kdDebug(5850) << "No config available in saveConfig!!!!" << endl;
00117 }
00118 }
00119
00120 #endif
|