korganizer

calprintpluginbase.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 1998 Preston Brown <pbrown@kde.org>
00005     Copyright (c) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
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   // the painter initially begins at 72 dpi per the Qt docs.
00078   // we want half-inch margins.
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
KDE Home | KDE Accessibility Home | Description of Access Keys