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 <libkcal/event.h>
00031 #include <libkcal/todo.h>
00032 #include <libkcal/calendar.h>
00033 #include <libkdepim/kdateedit.h>
00034 #include <kconfig.h> 
00035 #include <kdebug.h>
00036 
00037 #include <qbuttongroup.h>
00038 
00039 #include "calprintlistconfig_base.h"
00040 
00041 
00042 class ListPrintFactory : public KOrg::PrintPluginFactory {
00043   public:
00044     KOrg::PrintPlugin *create() { return new CalPrintList; }
00045 };
00046 
00047 K_EXPORT_COMPONENT_FACTORY( libkorg_listprint, ListPrintFactory )
00048 
00049 
00050 
00051 /**************************************************************
00052  *           Print Day
00053  **************************************************************/
00054 
00055 QWidget *CalPrintList::createConfigWidget( QWidget *w )
00056 {
00057   return new CalPrintListConfig_Base( w );
00058 }
00059 
00060 void CalPrintList::readSettingsWidget()
00061 {
00062   CalPrintListConfig_Base *cfg =
00063       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00064   if ( cfg ) {
00065     mFromDate = cfg->mFromDate->date();
00066     mToDate = cfg->mToDate->date();
00067     mUseDateRange = (cfg->mDateRangeGroup->selectedId() == 1);
00068   }
00069 }
00070 
00071 void CalPrintList::setSettingsWidget()
00072 {
00073   CalPrintListConfig_Base *cfg =
00074       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00075   if ( cfg ) {
00076     cfg->mFromDate->setDate( mFromDate );
00077     cfg->mToDate->setDate( mToDate );
00078     
00079     cfg->mDateRangeGroup->setButton( (mUseDateRange)?1:0 );
00080   }
00081 }
00082 
00083 void CalPrintList::loadConfig()
00084 {
00085   if ( mConfig ) {
00086     mUseDateRange = mConfig->readBoolEntry( "ListsInRange", false );
00087   }
00088   setSettingsWidget();
00089 }
00090 
00091 void CalPrintList::saveConfig()
00092 {
00093   kdDebug(5850) << "CalPrintList::saveConfig()" << endl;
00094 
00095   readSettingsWidget();
00096   if ( mConfig ) {
00097     mConfig->writeEntry( "ListsInRange", mUseDateRange );
00098   }
00099 }
00100 
00101 void CalPrintList::setDateRange( const QDate& from, const QDate& to )
00102 {
00103   CalPrintPluginBase::setDateRange( from, to );
00104   CalPrintListConfig_Base *cfg =
00105       dynamic_cast<CalPrintListConfig_Base*>( mConfigWidget );
00106   if ( cfg ) {
00107     cfg->mFromDate->setDate( from );
00108     cfg->mToDate->setDate( to );
00109   }
00110 }
00111 
00112 void CalPrintList::print( QPainter &p, int width, int height )
00113 {
00114 }
00115 
00116 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys