korganizer

listprint.cpp

00001 /*
00002     This file is part of KOrganizer.
00003 
00004     Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program 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
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020     As a special exception, permission is given to link this program
00021     with any edition of Qt, and distribute the resulting executable,
00022     without including the source code for Qt in the source distribution.
00023 */
00024 
00025 #ifndef KORG_NOPRINTER
00026 
00027 #include "listprint.h"
00028 
00029 #include "calprintpluginbase.h"
00030 #include "calprinthelper.h"
00031 #include <libkcal/event.h>
00032 #include <libkcal/todo.h>
00033 #include <libkcal/calendar.h>
00034 #include <libkdepim/kdateedit.h>
00035 #include <kconfig.h> 
00036 #include <kdebug.h>
00037 
00038 #include <qbuttongroup.h>
00039 
00040 #include "calprintlistconfig_base.h"
00041 
00042 
00043 class ListPrintFactory : public KOrg::PrintPluginFactory {
00044   public:
00045     KOrg::PrintPlugin *create() { return new CalPrintList; }
00046 };
00047 
00048 K_EXPORT_COMPONENT_FACTORY( libkorg_listprint, ListPrintFactory )
00049 
00050 
00051 
00052 /**************************************************************
00053  *           Print Day
00054  **************************************************************/
00055 
00056 QWidget *CalPrintList::createConfigWidget( QWidget *w )
00057 {
00058   return new CalPrintListConfig_Base( w );
00059 }
00060 
00061 void CalPrintList::readSettingsWidget()
00062 {
00063   CalPrintListConfig_Base *cfg =
00064       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00065   if ( cfg ) {
00066     mFromDate = cfg->mFromDate->date();
00067     mToDate = cfg->mToDate->date();
00068     mUseDateRange = (cfg->mDateRangeGroup->selectedId() == 1);
00069   }
00070 }
00071 
00072 void CalPrintList::setSettingsWidget()
00073 {
00074   CalPrintListConfig_Base *cfg =
00075       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00076   if ( cfg ) {
00077     cfg->mFromDate->setDate( mFromDate );
00078     cfg->mToDate->setDate( mToDate );
00079     
00080     cfg->mDateRangeGroup->setButton( (mUseDateRange)?1:0 );
00081   }
00082 }
00083 
00084 void CalPrintList::loadConfig()
00085 {
00086   if ( mConfig ) {
00087     mUseDateRange = mConfig->readBoolEntry( "ListsInRange", false );
00088   }
00089   setSettingsWidget();
00090 }
00091 
00092 void CalPrintList::saveConfig()
00093 {
00094   kdDebug(5850) << "CalPrintList::saveConfig()" << endl;
00095 
00096   readSettingsWidget();
00097   if ( mConfig ) {
00098     mConfig->writeEntry( "ListsInRange", mUseDateRange );
00099   }
00100 }
00101 
00102 void CalPrintList::setDateRange( const QDate& from, const QDate& to )
00103 {
00104   CalPrintPluginBase::setDateRange( from, to );
00105   CalPrintListConfig_Base *cfg =
00106       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00107   if ( cfg ) {
00108     cfg->mFromDate->setDate( from );
00109     cfg->mToDate->setDate( to );
00110   }
00111 }
00112 
00113 void CalPrintList::print( QPainter &p, int width, int height )
00114 {
00115 }
00116 
00117 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys