25 #ifndef KORG_NOPRINTER
27 #include "journalprint.h"
29 #include "calprintpluginbase.h"
30 #include <libkcal/journal.h>
32 #include <libtdepim/kdateedit.h>
33 #include <tdeconfig.h>
36 #include <tqbuttongroup.h>
38 #include "calprintjournalconfig_base.h"
41 class JournalPrintFactory :
public KOrg::PrintPluginFactory {
46 K_EXPORT_COMPONENT_FACTORY( libkorg_journalprint, JournalPrintFactory )
53 TQWidget *CalPrintJournal::createConfigWidget( TQWidget *w )
55 return new CalPrintJournalConfig_Base( w );
58 void CalPrintJournal::readSettingsWidget()
60 CalPrintJournalConfig_Base *cfg =
61 dynamic_cast<CalPrintJournalConfig_Base*
>( mConfigWidget );
63 mFromDate = cfg->mFromDate->date();
64 mToDate = cfg->mToDate->date();
65 mUseDateRange = (cfg->mDateRangeGroup->selectedId() == 1);
69 void CalPrintJournal::setSettingsWidget()
71 CalPrintJournalConfig_Base *cfg =
72 dynamic_cast<CalPrintJournalConfig_Base*
>( mConfigWidget );
74 cfg->mFromDate->setDate( mFromDate );
75 cfg->mToDate->setDate( mToDate );
77 cfg->mDateRangeGroup->setButton( (mUseDateRange)?1:0 );
81 void CalPrintJournal::loadConfig()
84 mUseDateRange = mConfig->readBoolEntry(
"JournalsInRange",
false );
89 void CalPrintJournal::saveConfig()
91 kdDebug(5850) <<
"CalPrintJournal::saveConfig()" << endl;
95 mConfig->writeEntry(
"JournalsInRange", mUseDateRange );
99 void CalPrintJournal::setDateRange(
const TQDate& from,
const TQDate& to )
102 CalPrintJournalConfig_Base *cfg =
103 dynamic_cast<CalPrintJournalConfig_Base*
>( mConfigWidget );
105 cfg->mFromDate->setDate( from );
106 cfg->mToDate->setDate( to );
110 void CalPrintJournal::print( TQPainter &p,
int width,
int height )
113 Journal::List journals( mCalendar->journals() );
114 if ( mUseDateRange ) {
115 Journal::List allJournals = journals;
117 Journal::List::Iterator it = allJournals.begin();
118 for ( ; it != allJournals.end(); ++it ) {
119 TQDate dt = (*it)->dtStart().date();
120 if ( mFromDate <= dt && dt <= mToDate ) {
121 journals.append( *it );
126 TQRect headerBox( 0, 0, width, headerHeight() );
127 TQRect footerBox( 0, height - footerHeight(), width, footerHeight() );
128 height -= footerHeight();
130 drawHeader( p, i18n(
"Journal entries"), TQDate(), TQDate(), headerBox );
131 y = headerHeight() + 15;
133 Journal::List::Iterator it = journals.begin();
134 for ( ; it != journals.end(); ++it ) {
135 drawJournal( *it, p, x, y, width, height );
138 drawFooter( p, footerBox );
Base class for KOrganizer printing classes.
virtual void setDateRange(const TQDate &from, const TQDate &to)
Set date range which should be printed.