00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef KORG_NOPRINTER
00028
00029 #include <qpainter.h>
00030 #include <qdatetimeedit.h>
00031 #include <qdatetime.h>
00032 #include <qcheckbox.h>
00033 #include <qlineedit.h>
00034 #include <qbuttongroup.h>
00035
00036 #include <kglobal.h>
00037 #include <klocale.h>
00038 #include <kdebug.h>
00039 #include <kprinter.h>
00040 #include <kconfig.h>
00041 #include <kcalendarsystem.h>
00042
00043 #include <libkcal/todo.h>
00044 #include <libkcal/calendar.h>
00045
00046 #include <libkdepim/kdateedit.h>
00047
00048 #include "calprinthelper.h"
00049 #include "calprintpluginbase.h"
00050 #include "calprintdefaultplugins.h"
00051
00052 #include "calprintdayconfig_base.h"
00053 #include "calprintweekconfig_base.h"
00054 #include "calprintmonthconfig_base.h"
00055 #include "calprinttodoconfig_base.h"
00056
00057
00058
00059
00060
00061
00062 CalPrintDay::CalPrintDay() : CalPrintPluginBase()
00063 {
00064 }
00065
00066 CalPrintDay::~CalPrintDay()
00067 {
00068 }
00069
00070 QWidget *CalPrintDay::createConfigWidget( QWidget *w )
00071 {
00072 return new CalPrintDayConfig_Base( w );
00073 }
00074
00075 void CalPrintDay::readSettingsWidget()
00076 {
00077 CalPrintDayConfig_Base *cfg =
00078 dynamic_cast<CalPrintDayConfig_Base*>( mConfigWidget );
00079 if ( cfg ) {
00080 mFromDate = cfg->mFromDate->date();
00081 mToDate = cfg->mToDate->date();
00082
00083 mStartTime = cfg->mFromTime->time();
00084 mEndTime = cfg->mToTime->time();
00085 mIncludeAllEvents = cfg->mIncludeAllEvents->isChecked();
00086
00087 mIncludeTodos = cfg->mIncludeTodos->isChecked();
00088 mUseColors = cfg->mColors->isChecked();
00089 }
00090 }
00091
00092 void CalPrintDay::setSettingsWidget()
00093 {
00094 CalPrintDayConfig_Base *cfg =
00095 dynamic_cast<CalPrintDayConfig_Base*>( mConfigWidget );
00096 if ( cfg ) {
00097 cfg->mFromDate->setDate( mFromDate );
00098 cfg->mToDate->setDate( mToDate );
00099
00100 cfg->mFromTime->setTime( mStartTime );
00101 cfg->mToTime->setTime( mEndTime );
00102 cfg->mIncludeAllEvents->setChecked( mIncludeAllEvents );
00103
00104 cfg->mIncludeTodos->setChecked( mIncludeTodos );
00105 cfg->mColors->setChecked( mUseColors );
00106 }
00107 }
00108
00109 void CalPrintDay::loadConfig()
00110 {
00111 if ( mConfig ) {
00112 QDate dt;
00113 QTime tm1( mCoreHelper->dayStart() );
00114 QDateTime startTm( dt, tm1 );
00115 QDateTime endTm( dt, tm1.addSecs( 12 * 60 * 60 ) );
00116 mStartTime = mConfig->readDateTimeEntry( "Start time", &startTm ).time();
00117 mEndTime = mConfig->readDateTimeEntry( "End time", &endTm ).time();
00118 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
00119 mIncludeAllEvents = mConfig->readBoolEntry( "Include all events", false );
00120 }
00121 setSettingsWidget();
00122 }
00123
00124 void CalPrintDay::saveConfig()
00125 {
00126 kdDebug(5850) << "CalPrintDay::saveConfig()" << endl;
00127
00128 readSettingsWidget();
00129 if ( mConfig ) {
00130 mConfig->writeEntry( "Start time", QDateTime( QDate(), mStartTime ) );
00131 mConfig->writeEntry( "End time", QDateTime( QDate(), mEndTime ) );
00132 mConfig->writeEntry( "Include todos", mIncludeTodos );
00133 mConfig->writeEntry( "Include all events", mIncludeAllEvents );
00134 }
00135 }
00136
00137 void CalPrintDay::setDateRange( const QDate& from, const QDate& to )
00138 {
00139 CalPrintPluginBase::setDateRange( from, to );
00140 CalPrintDayConfig_Base *cfg =
00141 dynamic_cast<CalPrintDayConfig_Base*>( mConfigWidget );
00142 if ( cfg ) {
00143 cfg->mFromDate->setDate( from );
00144 cfg->mToDate->setDate( to );
00145 }
00146 }
00147
00148 void CalPrintDay::print( QPainter &p, int width, int height )
00149 {
00150 QDate curDay( mFromDate );
00151
00152 do {
00153 int x = 0;
00154 int y = 0;
00155 int currHeight=( height - y ) / 20;
00156 QTime curStartTime( mStartTime );
00157 QTime curEndTime( mEndTime );
00158 if ( curStartTime.secsTo( curEndTime ) <= 3600 ) {
00159 if ( curStartTime.hour() == 0 ) {
00160 curStartTime = QTime( 0, 0, 0 );
00161 curEndTime = curStartTime.addSecs( 3600 );
00162 } else if ( curEndTime.hour() == 23 ) {
00163 curEndTime=QTime( 23, 59, 59 );
00164 if ( curStartTime > QTime( 23, 0, 0 ) ) {
00165 curStartTime = QTime( 23, 0, 0 );
00166 }
00167 } else {
00168 curStartTime = curStartTime.addSecs( -1200 );
00169 }
00170 curEndTime = curEndTime.addSecs( 1200 );
00171 }
00172
00173 KLocale *local = KGlobal::locale();
00174 mHelper->drawHeader( p, local->formatDate( curDay, false ),
00175 curDay, QDate(), 0, 0, width, mHelper->mHeaderHeight );
00176
00177 y += mHelper->mHeaderHeight + 5;
00178 x = 80;
00179 Event::List eventList = mCalendar->events( curDay,
00180 EventSortStartDate,
00181 SortDirectionAscending );
00182
00183 p.setFont( QFont( "helvetica", 12 ) );
00184 mHelper->drawAllDayBox( p, eventList, curDay, true, x, y, width - x, currHeight );
00185 y += currHeight;
00186 mHelper->drawAgendaDayBox( p, eventList, curDay, mIncludeAllEvents,
00187 curStartTime, curEndTime, x, y, width - x, height - y );
00188 mHelper->drawTimeLine( p, curStartTime, curEndTime, 0, y, x - 5, height - y );
00189 curDay = curDay.addDays( 1 );
00190 if ( curDay <= mToDate ) mPrinter->newPage();
00191 } while ( curDay <= mToDate );
00192 }
00193
00194
00195
00196
00197
00198
00199
00200 CalPrintWeek::CalPrintWeek() : CalPrintPluginBase()
00201 {
00202 }
00203
00204 CalPrintWeek::~CalPrintWeek()
00205 {
00206 }
00207
00208 QWidget *CalPrintWeek::createConfigWidget( QWidget *w )
00209 {
00210 return new CalPrintWeekConfig_Base( w );
00211 }
00212
00213 void CalPrintWeek::readSettingsWidget()
00214 {
00215 CalPrintWeekConfig_Base *cfg =
00216 dynamic_cast<CalPrintWeekConfig_Base*>( mConfigWidget );
00217 if ( cfg ) {
00218 mFromDate = cfg->mFromDate->date();
00219 mToDate = cfg->mToDate->date();
00220
00221 mWeekPrintType = (eWeekPrintType)( cfg->mPrintType->id(
00222 cfg->mPrintType->selected() ) );
00223
00224 mStartTime = cfg->mFromTime->time();
00225 mEndTime = cfg->mToTime->time();
00226
00227 mIncludeTodos = cfg->mIncludeTodos->isChecked();
00228 mUseColors = cfg->mColors->isChecked();
00229 }
00230 }
00231
00232 void CalPrintWeek::setSettingsWidget()
00233 {
00234 CalPrintWeekConfig_Base *cfg =
00235 dynamic_cast<CalPrintWeekConfig_Base*>( mConfigWidget );
00236 if ( cfg ) {
00237 cfg->mFromDate->setDate( mFromDate );
00238 cfg->mToDate->setDate( mToDate );
00239
00240 cfg->mPrintType->setButton( mWeekPrintType );
00241
00242 cfg->mFromTime->setTime( mStartTime );
00243 cfg->mToTime->setTime( mEndTime );
00244
00245 cfg->mIncludeTodos->setChecked( mIncludeTodos );
00246 cfg->mColors->setChecked( mUseColors );
00247 }
00248 }
00249
00250 void CalPrintWeek::loadConfig()
00251 {
00252 if ( mConfig ) {
00253 QDate dt;
00254 QTime tm1( mCoreHelper->dayStart() );
00255 QDateTime startTm( dt, tm1 );
00256 QDateTime endTm( dt, tm1.addSecs( 43200 ) );
00257 mStartTime = mConfig->readDateTimeEntry( "Start time", &startTm ).time();
00258 mEndTime = mConfig->readDateTimeEntry( "End time", &endTm ).time();
00259 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
00260 mWeekPrintType =(eWeekPrintType)( mConfig->readNumEntry( "Print type", (int)Filofax ) );
00261 }
00262 setSettingsWidget();
00263 }
00264
00265 void CalPrintWeek::saveConfig()
00266 {
00267 readSettingsWidget();
00268 if ( mConfig ) {
00269 mConfig->writeEntry( "Start time", QDateTime( QDate(), mStartTime ) );
00270 mConfig->writeEntry( "End time", QDateTime( QDate(), mEndTime ) );
00271 mConfig->writeEntry( "Include todos", mIncludeTodos );
00272 mConfig->writeEntry( "Print type", int( mWeekPrintType ) );
00273 }
00274 }
00275
00276 KPrinter::Orientation CalPrintWeek::orientation()
00277 {
00278 if ( mWeekPrintType == Filofax ) return KPrinter::Portrait;
00279 else if ( mWeekPrintType == SplitWeek ) return KPrinter::Portrait;
00280 else return KPrinter::Landscape;
00281 }
00282
00283 void CalPrintWeek::setDateRange( const QDate &from, const QDate &to )
00284 {
00285 CalPrintPluginBase::setDateRange( from, to );
00286 CalPrintWeekConfig_Base *cfg =
00287 dynamic_cast<CalPrintWeekConfig_Base*>( mConfigWidget );
00288 if ( cfg ) {
00289 cfg->mFromDate->setDate( from );
00290 cfg->mToDate->setDate( to );
00291 }
00292 }
00293
00294 void CalPrintWeek::print( QPainter &p, int width, int height )
00295 {
00296 QDate curWeek, fromWeek, toWeek;
00297
00298
00299 int weekdayCol = mHelper->weekdayColumn( mFromDate.dayOfWeek() );
00300 fromWeek = mFromDate.addDays( -weekdayCol );
00301 weekdayCol = mHelper->weekdayColumn( mFromDate.dayOfWeek() );
00302 toWeek = mToDate.addDays( 6 - weekdayCol );
00303
00304 curWeek = fromWeek.addDays( 6 );
00305 KLocale *local = KGlobal::locale();
00306
00307 switch ( mWeekPrintType ) {
00308 case Filofax:
00309 do {
00310 QString line1( local->formatDate( curWeek.addDays( -6 ) ) );
00311 QString line2( local->formatDate( curWeek ) );
00312 mHelper->drawHeader( p, line1 + "\n" + line2, curWeek.addDays( -6 ), QDate(),
00313 0, 0, width, mHelper->mHeaderHeight );
00314 int top = mHelper->mHeaderHeight + 10;
00315 mHelper->drawWeek( p, curWeek, 0, top, width, height - top );
00316 curWeek = curWeek.addDays( 7 );
00317 if ( curWeek <= toWeek )
00318 mPrinter->newPage();
00319 } while ( curWeek <= toWeek );
00320 break;
00321
00322 case Timetable:
00323 default:
00324 do {
00325 QString line1( local->formatDate( curWeek.addDays( -6 ) ) );
00326 QString line2( local->formatDate( curWeek ) );
00327 int hh = int(mHelper->mHeaderHeight * 2./3.);
00328 mHelper->drawHeader( p, i18n("date from - to", "%1 - %2\nWeek %3")
00329 .arg( line1 )
00330 .arg( line2 )
00331 .arg( curWeek.weekNumber() ),
00332 curWeek, QDate(), 0, 0, width, hh );
00333 mHelper->drawTimeTable( p, fromWeek, curWeek,
00334 mStartTime, mEndTime, 0, hh + 5,
00335 width, height - hh - 5 );
00336 fromWeek = fromWeek.addDays( 7 );
00337 curWeek = fromWeek.addDays( 6 );
00338 if ( curWeek <= toWeek )
00339 mPrinter->newPage();
00340 } while ( curWeek <= toWeek );
00341 break;
00342
00343 case SplitWeek:
00344 do {
00345 QString line1( local->formatDate( curWeek.addDays( -6 ) ) );
00346 QString line2( local->formatDate( curWeek ) );
00347 QDate endLeft( fromWeek.addDays( 3 ) );
00348 int hh = mHelper->mHeaderHeight;
00349
00350 mHelper->drawTimeTable( p, fromWeek, endLeft,
00351 mStartTime, mEndTime, 0, hh + 5,
00352 width, height - hh - 5 );
00353 mPrinter->newPage();
00354 mHelper->drawSplitHeaderRight( p, fromWeek, curWeek, QDate(), width, hh );
00355 mHelper->drawTimeTable( p, endLeft.addDays( 1 ), curWeek,
00356 mStartTime, mEndTime, 0, hh + 5,
00357 int( ( width - 50 ) * 3. / 4. + 50 ), height - hh - 5 );
00358
00359 fromWeek = fromWeek.addDays( 7 );
00360 curWeek = fromWeek.addDays( 6 );
00361 if ( curWeek <= toWeek )
00362 mPrinter->newPage();
00363 } while ( curWeek <= toWeek );
00364 break;
00365 }
00366 }
00367
00368
00369
00370
00371
00372
00373
00374
00375 CalPrintMonth::CalPrintMonth() : CalPrintPluginBase()
00376 {
00377 }
00378
00379 CalPrintMonth::~CalPrintMonth()
00380 {
00381 }
00382
00383 QWidget *CalPrintMonth::createConfigWidget( QWidget *w )
00384 {
00385 return new CalPrintMonthConfig_Base( w );
00386 }
00387
00388 void CalPrintMonth::readSettingsWidget()
00389 {
00390 CalPrintMonthConfig_Base *cfg =
00391 dynamic_cast<CalPrintMonthConfig_Base *>( mConfigWidget );
00392 if ( cfg ) {
00393 mFromDate = cfg->mFromDate->date();
00394 mToDate = cfg->mToDate->date();
00395
00396 mWeekNumbers = cfg->mWeekNumbers->isChecked();
00397 mRecurDaily = cfg->mRecurDaily->isChecked();
00398 mRecurWeekly = cfg->mRecurWeekly->isChecked();
00399 mIncludeTodos = cfg->mIncludeTodos->isChecked();
00400
00401 }
00402 }
00403
00404 void CalPrintMonth::setSettingsWidget()
00405 {
00406 CalPrintMonthConfig_Base *cfg =
00407 dynamic_cast<CalPrintMonthConfig_Base *>( mConfigWidget );
00408 if ( cfg ) {
00409 cfg->mFromDate->setDate( mFromDate );
00410 cfg->mToDate->setDate( mToDate );
00411
00412 cfg->mWeekNumbers->setChecked( mWeekNumbers );
00413 cfg->mRecurDaily->setChecked( mRecurDaily );
00414 cfg->mRecurWeekly->setChecked( mRecurWeekly );
00415 cfg->mIncludeTodos->setChecked( mIncludeTodos );
00416
00417 }
00418 }
00419
00420 void CalPrintMonth::loadConfig()
00421 {
00422 if ( mConfig ) {
00423 mWeekNumbers = mConfig->readBoolEntry( "Print week numbers", true );
00424 mRecurDaily = mConfig->readBoolEntry( "Print daily incidences", true );
00425 mRecurWeekly = mConfig->readBoolEntry( "Print weekly incidences", true );
00426 mIncludeTodos = mConfig->readBoolEntry( "Include todos", false );
00427 }
00428 setSettingsWidget();
00429 }
00430
00431 void CalPrintMonth::saveConfig()
00432 {
00433 readSettingsWidget();
00434 if ( mConfig ) {
00435 mConfig->writeEntry( "Print week numbers", mWeekNumbers );
00436 mConfig->writeEntry( "Print daily incidences", mRecurDaily );
00437 mConfig->writeEntry( "Print weekly incidences", mRecurWeekly );
00438 mConfig->writeEntry( "Include todos", mIncludeTodos );
00439 }
00440 }
00441
00442 void CalPrintMonth::setDateRange( const QDate &from, const QDate &to )
00443 {
00444 CalPrintPluginBase::setDateRange( from, to );
00445 CalPrintMonthConfig_Base *cfg =
00446 dynamic_cast<CalPrintMonthConfig_Base *>( mConfigWidget );
00447 if ( cfg ) {
00448 cfg->mFromDate->setDate( from );
00449 cfg->mToDate->setDate( to );
00450 }
00451 }
00452
00453 void CalPrintMonth::print( QPainter &p, int width, int height )
00454 {
00455 QDate curMonth, fromMonth, toMonth;
00456
00457 fromMonth = mFromDate.addDays( -( mFromDate.day() - 1 ) );
00458 toMonth = mToDate.addDays( mToDate.daysInMonth() - mToDate.day() );
00459
00460 curMonth = fromMonth;
00461 const KCalendarSystem *calSys = mHelper->calendarSystem();
00462 do {
00463 QString title( i18n("monthname year", "%1 %2") );
00464 title = title.arg( calSys->monthName( curMonth ) )
00465 .arg( curMonth.year() );
00466 QDate tmp( fromMonth );
00467 int weekdayCol = mHelper->weekdayColumn( tmp.dayOfWeek() );
00468 tmp = tmp.addDays( -weekdayCol );
00469
00470 mHelper->drawHeader( p, title,
00471 curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
00472 0, 0, width, mHelper->mHeaderHeight );
00473 mHelper->drawMonth( p, curMonth, mWeekNumbers, mRecurDaily, mRecurWeekly, 0, mHelper->mHeaderHeight + 5,
00474 width, height - mHelper->mHeaderHeight - 5 );
00475 curMonth = curMonth.addDays( curMonth.daysInMonth() );
00476 if ( curMonth <= toMonth ) mPrinter->newPage();
00477 } while ( curMonth <= toMonth );
00478
00479 }
00480
00481
00482
00483
00484
00485
00486
00487
00488 CalPrintTodos::CalPrintTodos() : CalPrintPluginBase()
00489 {
00490 }
00491
00492 CalPrintTodos::~CalPrintTodos()
00493 {
00494 }
00495
00496 QWidget *CalPrintTodos::createConfigWidget( QWidget *w )
00497 {
00498 return new CalPrintTodoConfig_Base( w );
00499 }
00500
00501 void CalPrintTodos::readSettingsWidget()
00502 {
00503 CalPrintTodoConfig_Base *cfg =
00504 dynamic_cast<CalPrintTodoConfig_Base *>( mConfigWidget );
00505 if ( cfg ) {
00506 mPageTitle = cfg->mTitle->text();
00507
00508 mTodoPrintType = (eTodoPrintType)( cfg->mPrintType->id(
00509 cfg->mPrintType->selected() ) );
00510
00511 mFromDate = cfg->mFromDate->date();
00512 mToDate = cfg->mToDate->date();
00513
00514 mIncludeDescription = cfg->mDescription->isChecked();
00515 mIncludePriority = cfg->mPriority->isChecked();
00516 mIncludeDueDate = cfg->mDueDate->isChecked();
00517 mIncludePercentComplete = cfg->mPercentComplete->isChecked();
00518 mConnectSubTodos = cfg->mConnectSubTodos->isChecked();
00519 mStrikeOutCompleted = cfg->mStrikeOutCompleted->isChecked();
00520
00521 mTodoSortField = (eTodoSortField)cfg->mSortField->currentItem();
00522 mTodoSortDirection = (eTodoSortDirection)cfg->mSortDirection->currentItem();
00523 }
00524 }
00525
00526 void CalPrintTodos::setSettingsWidget()
00527 {
00528 CalPrintTodoConfig_Base *cfg =
00529 dynamic_cast<CalPrintTodoConfig_Base *>( mConfigWidget );
00530 if ( cfg ) {
00531 cfg->mTitle->setText( mPageTitle );
00532
00533 cfg->mPrintType->setButton( mTodoPrintType );
00534
00535 cfg->mFromDate->setDate( mFromDate );
00536 cfg->mToDate->setDate( mToDate );
00537
00538 cfg->mDescription->setChecked( mIncludeDescription );
00539 cfg->mPriority->setChecked( mIncludePriority );
00540 cfg->mDueDate->setChecked( mIncludeDueDate );
00541 cfg->mPercentComplete->setChecked( mIncludePercentComplete );
00542 cfg->mConnectSubTodos->setChecked( mConnectSubTodos );
00543 cfg->mStrikeOutCompleted->setChecked( mStrikeOutCompleted );
00544
00545 cfg->mSortField->insertItem( i18n("Summary") );
00546 cfg->mSortField->insertItem( i18n("Start Date") );
00547 cfg->mSortField->insertItem( i18n("Due Date") );
00548 cfg->mSortField->insertItem( i18n("Priority") );
00549 cfg->mSortField->insertItem( i18n("Percent Complete") );
00550 cfg->mSortField->setCurrentItem( mTodoSortField );
00551
00552 cfg->mSortDirection->insertItem( i18n( "Ascending" ) );
00553 cfg->mSortDirection->insertItem( i18n( "Descending" ) );
00554 cfg->mSortDirection->setCurrentItem( mTodoSortDirection );
00555 }
00556 }
00557
00558 void CalPrintTodos::loadConfig()
00559 {
00560 if ( mConfig ) {
00561 mPageTitle = mConfig->readEntry( "Page title", i18n("To-do list") );
00562 mTodoPrintType = (eTodoPrintType)mConfig->readNumEntry( "Print type", (int)TodosAll );
00563 mIncludeDescription = mConfig->readBoolEntry( "Include description", true );
00564 mIncludePriority = mConfig->readBoolEntry( "Include priority", true );
00565 mIncludeDueDate = mConfig->readBoolEntry( "Include due date", true );
00566 mIncludePercentComplete = mConfig->readBoolEntry( "Include percentage completed", true );
00567 mConnectSubTodos = mConfig->readBoolEntry( "Connect subtodos", true );
00568 mStrikeOutCompleted = mConfig->readBoolEntry( "Strike out completed summaries", true );
00569 mTodoSortField = (eTodoSortField)mConfig->readNumEntry( "Sort field", (int)TodoFieldSummary );
00570 mTodoSortDirection = (eTodoSortDirection)mConfig->readNumEntry( "Sort direction", (int)TodoDirectionAscending );
00571 }
00572 setSettingsWidget();
00573 }
00574
00575 void CalPrintTodos::saveConfig()
00576 {
00577 readSettingsWidget();
00578 if ( mConfig ) {
00579 mConfig->writeEntry( "Page title", mPageTitle );
00580 mConfig->writeEntry( "Print type", int( mTodoPrintType ) );
00581 mConfig->writeEntry( "Include description", mIncludeDescription );
00582 mConfig->writeEntry( "Include priority", mIncludePriority );
00583 mConfig->writeEntry( "Include due date", mIncludeDueDate );
00584 mConfig->writeEntry( "Include percentage completed", mIncludePercentComplete );
00585 mConfig->writeEntry( "Connect subtodos", mConnectSubTodos );
00586 mConfig->writeEntry( "Strike out completed summaries", mStrikeOutCompleted );
00587 mConfig->writeEntry( "Sort field", mTodoSortField );
00588 mConfig->writeEntry( "Sort direction", mTodoSortDirection );
00589 }
00590 }
00591
00592 void CalPrintTodos::print( QPainter &p, int width, int height )
00593 {
00594 int pospriority = 10;
00595 int possummary = 60;
00596 int posdue = width - 65;
00597 int poscomplete = posdue - 70;
00598 int lineSpacing = 15;
00599 int fontHeight = 10;
00600
00601
00602 mHelper->drawHeader( p, mPageTitle, mFromDate, QDate(),
00603 0, 0, width, mHelper->mHeaderHeight );
00604
00605
00606 int mCurrentLinePos = mHelper->mHeaderHeight + 5;
00607 QString outStr;
00608 QFont oldFont( p.font() );
00609
00610 p.setFont( QFont( "helvetica", 10, QFont::Bold ) );
00611 lineSpacing = p.fontMetrics().lineSpacing();
00612 mCurrentLinePos += lineSpacing;
00613 if ( mIncludePriority ) {
00614 outStr += i18n( "Priority" );
00615 p.drawText( pospriority, mCurrentLinePos - 2, outStr );
00616 } else {
00617 possummary = 10;
00618 pospriority = -1;
00619 }
00620
00621 outStr.truncate( 0 );
00622 outStr += i18n( "Summary" );
00623 p.drawText( possummary, mCurrentLinePos - 2, outStr );
00624
00625 if ( mIncludePercentComplete ) {
00626 if ( !mIncludeDueDate )
00627 poscomplete = posdue;
00628 outStr.truncate( 0 );
00629 outStr += i18n( "Complete" );
00630 p.drawText( poscomplete, mCurrentLinePos - 2, outStr );
00631 } else {
00632 poscomplete = -1;
00633 }
00634
00635 if ( mIncludeDueDate ) {
00636 outStr.truncate( 0 );
00637 outStr += i18n( "Due" );
00638 p.drawText( posdue, mCurrentLinePos - 2, outStr );
00639 } else {
00640 posdue = -1;
00641 }
00642
00643 p.setFont( QFont( "helvetica", 10 ) );
00644 fontHeight = p.fontMetrics().height();
00645
00646 Todo::List todoList;
00647 Todo::List tempList;
00648 Todo::List::ConstIterator it;
00649
00650
00651 TodoSortField sortField;
00652 switch( mTodoSortField ) {
00653 case TodoFieldSummary:
00654 sortField = TodoSortSummary; break;
00655 case TodoFieldStartDate:
00656 sortField = TodoSortStartDate; break;
00657 case TodoFieldDueDate:
00658 sortField = TodoSortDueDate; break;
00659 case TodoFieldPriority:
00660 sortField = TodoSortPriority; break;
00661 case TodoFieldPercentComplete:
00662 sortField = TodoSortPercentComplete; break;
00663 }
00664
00665 SortDirection sortDirection;
00666 switch( mTodoSortDirection ) {
00667 case TodoDirectionAscending:
00668 sortDirection = SortDirectionAscending; break;
00669 case TodoDirectionDescending:
00670 sortDirection = SortDirectionDescending; break;
00671 }
00672
00673
00674
00675 todoList = mCalendar->todos( TodoSortSummary, sortDirection );
00676 switch( mTodoPrintType ) {
00677 case TodosAll:
00678 break;
00679 case TodosUnfinished:
00680 for( it = todoList.begin(); it!= todoList.end(); ++it ) {
00681 if ( !(*it)->isCompleted() )
00682 tempList.append( *it );
00683 }
00684 todoList = tempList;
00685 break;
00686 case TodosDueRange:
00687 for( it = todoList.begin(); it!= todoList.end(); ++it ) {
00688 if ( (*it)->hasDueDate() ) {
00689 if ( (*it)->dtDue().date() >= mFromDate &&
00690 (*it)->dtDue().date() <= mToDate )
00691 tempList.append( *it );
00692 } else {
00693 tempList.append( *it );
00694 }
00695 }
00696 todoList = tempList;
00697 break;
00698 }
00699
00700
00701 int count = 0;
00702 for ( it=todoList.begin(); it!=todoList.end(); ++it ) {
00703 Todo *currEvent = *it;
00704
00705
00706 if ( !currEvent->relatedTo() ) {
00707 count++;
00708 mHelper->drawTodo( count, currEvent, p,
00709 sortField, sortDirection,
00710 mConnectSubTodos,
00711 mStrikeOutCompleted, mIncludeDescription,
00712 pospriority, possummary, posdue, poscomplete,
00713 0, 0, mCurrentLinePos, width, height, todoList );
00714 }
00715 }
00716 p.setFont( oldFont );
00717 }
00718
00719
00720 #endif