27#include "journalprint.h"
29#include "calprintpluginbase.h"
30#include <libkcal/journal.h>
32#include <libtdepim/kdateedit.h>
36#include <tqbuttongroup.h>
38#include "calprintjournalconfig_base.h"
41class JournalPrintFactory :
public KOrg::PrintPluginFactory {
43 KOrg::PrintPlugin *create() {
return new CalPrintJournal; }
46K_EXPORT_COMPONENT_FACTORY( libkorg_journalprint, JournalPrintFactory )
53TQWidget *CalPrintJournal::createConfigWidget( TQWidget *w )
55 return new CalPrintJournalConfig_Base( w );
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);
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 );
84 mUseDateRange = mConfig->readBoolEntry(
"JournalsInRange",
false );
91 kdDebug(5850) <<
"CalPrintJournal::saveConfig()" << endl;
95 mConfig->writeEntry(
"JournalsInRange", mUseDateRange );
99void 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 );
110void 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 );
130 drawHeader( p, i18n(
"Journal entries"), TQDate(), TQDate(), headerBox );
133 Journal::List::Iterator it = journals.begin();
134 for ( ; it != journals.end(); ++it ) {
virtual void loadConfig()=0
Load print format configuration from config file.
int footerHeight() const
Returns the height of the page footer.
int headerHeight() const
Returns the height of the page header.
void drawJournal(Journal *journal, TQPainter &p, int x, int &y, int width, int pageHeight)
Draws single journal item.
int drawHeader(TQPainter &p, TQString title, const TQDate &month1, const TQDate &month2, const TQRect &box, bool expand=false)
Draw the gray header bar of the printout to the TQPainter.
virtual void saveConfig()=0
Write print format configuration to config file.
int drawFooter(TQPainter &p, TQRect &box)
Draw a page footer containing the printing date and possibly other things, like a page number.
virtual void setSettingsWidget()
Set configuration widget to reflect settings of current object.
virtual void setDateRange(const TQDate &from, const TQDate &to)
Set date range which should be printed.
virtual void readSettingsWidget()
Read settings from configuration widget and apply them to current object.