korganizer

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