Index: trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.cpp
===================================================================
--- trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.cpp	(revision 854669)
+++ trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.cpp	(working copy)
@@ -34,7 +34,7 @@
 #include <kcal/todo.h>
 #include <kcal/calendar.h>
 
-#include <kglobal.h>
+#include <koglobals.h>
 #include <klocale.h>
 #include <kdebug.h>
 #include <kconfig.h>
@@ -50,6 +50,7 @@
 #include <QPrinter>
 #include <QWidget>
 
+
 /**************************************************************
  *           Print Incidence
  **************************************************************/
@@ -296,13 +297,181 @@
                                      stringVis.mEndString, captionFont, textFont ), h );
     }
 
+    // Convert recurrence to a string
     if ( (*it)->recurs() ) {
-      QRect recurBox( timesBox.left() + padding(), h + padding(),
-                      timesBox.right() - padding(), lineHeight );
-      // TODO: Convert the recurrence to a string and print it out!
-      QString recurString( "TODO: Convert Repeat to String!" );
-      h = qMax( printCaptionAndText( p, recurBox, i18n( "Repeats: " ),
-                                     recurString, captionFont, textFont ), h );
+      QRect recurBox( timesBox.left()+padding(), h+padding(), timesBox.right()-padding(), lineHeight );
+      KCal::Recurrence *recurs = (*it)->recurrence();
+      // recurrence
+      QStringList dayList;
+      dayList.push_back( i18n("31st Last") );
+      dayList.push_back( i18n("30th Last") );
+      dayList.push_back( i18n("29th Last") );
+      dayList.push_back( i18n("28th Last") );
+      dayList.push_back( i18n("27th Last") );
+      dayList.push_back( i18n("26th Last") );
+      dayList.push_back( i18n("25th Last") );
+      dayList.push_back( i18n("24th Last") );
+      dayList.push_back( i18n("23rd Last") );
+      dayList.push_back( i18n("22nd Last") );
+      dayList.push_back( i18n("21st Last") );
+      dayList.push_back( i18n("20th Last") );
+      dayList.push_back( i18n("19th Last") );
+      dayList.push_back( i18n("18th Last") );
+      dayList.push_back( i18n("17th Last") );
+      dayList.push_back( i18n("16th Last") );
+      dayList.push_back( i18n("15th Last") );
+      dayList.push_back( i18n("14th Last") );
+      dayList.push_back( i18n("13th Last") );
+      dayList.push_back( i18n("12th Last") );
+      dayList.push_back( i18n("11th Last") );
+      dayList.push_back( i18n("10th Last") );
+      dayList.push_back( i18n("9th Last") );
+      dayList.push_back( i18n("8th Last") );
+      dayList.push_back( i18n("7th Last") );
+      dayList.push_back( i18n("6th Last") );
+      dayList.push_back( i18n("5th Last") );
+      dayList.push_back( i18n("4th Last") );
+      dayList.push_back( i18n("3rd Last") );
+      dayList.push_back( i18n("2nd Last") );
+      dayList.push_back( i18n("Last") ); 
+      dayList.push_back( i18n("unknown") ); //#31 - zero offset from UI, should not be referenced
+      dayList.push_back( i18n("1st") );
+      dayList.push_back( i18n("2nd") );
+      dayList.push_back( i18n("3rd") );
+      dayList.push_back( i18n("4th") );
+      dayList.push_back( i18n("5th") );      
+      QString recurString;
+      const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
+      switch(recurs->recurrenceType()) {
+        case Recurrence::rNone:
+          recurString = i18n("None");
+          break;
+        case Recurrence::rDaily:
+          recurString = i18np("Every %1 day",
+                              "Every %1 days",
+                              recurs->frequency());
+          break;
+        case Recurrence::rWeekly: 
+        {
+          QString dayNames;
+          // Respect start of week setting
+          int weekStart = KGlobal::locale()->weekStartDay();
+          bool addSpace = false;
+          for ( int i = 0; i < 7; ++i ) { 
+            if ( recurs->days().testBit( (i+weekStart+6)%7 )) {
+              if (addSpace) dayNames.append(" ");  
+              dayNames.append( calSys->weekDayName( ((i+weekStart+6)%7)+1, KCalendarSystem::ShortDayName ) );
+              addSpace=true;
+            }
+          } 
+          recurString = i18nc("Every N WEEK[S] on WEEKDAYNAMELIST"
+                              " (Every 4 weeks on Tues Wed Thu)",
+                              "Every <numid>%1</numid> %2 on %3",
+                              recurs->frequency(),
+                              i18np("week","weeks",recurs->frequency()),
+							                dayNames );
+          break;
+        }
+        case Recurrence::rMonthlyPos:
+        {
+          KCal::RecurrenceRule::WDayPos rule = recurs->monthPositions()[0];
+          recurString = i18nc("Every N MONTH[S] on the [2nd|3rd|...] WEEKDAYNAME"
+                              " (Every 2 months on the 3rd Wednesday)",
+                              "Every <numid>%1</numid> %2 on the %3 %4",
+  					            		  recurs->frequency(),
+                              i18np("month","months",recurs->frequency()),
+                              dayList[rule.pos() + 31],
+                              calSys->weekDayName(rule.day(),KCalendarSystem::LongDayName) );
+          break;
+        }
+        case Recurrence::rMonthlyDay:
+        {     
+          int days = recurs->monthDays()[0];
+          if (days < 0) {
+            recurString = i18nc("Every N MONTH[S] on the [2nd|3rd|...] day"
+                                " (Every 5 months on the 3rd day)",
+                                "Every <numid>%1<niumid> %2 on the %3 day",
+  					            		    recurs->frequency(),
+                                i18np("month","months",recurs->frequency()),
+                                dayList[days + 31] );
+          } else {
+            recurString = i18nc("Every N MONTH[S} on day N"
+                                " (Every 4 months on day 5)",
+		              					    "Every <numid>%1</numid> %2 on day <numid>%3</numid>",
+   	            						    recurs->frequency(),
+                                i18np("month","months",recurs->frequency()),
+                                recurs->monthDays()[0] );
+          }
+          break;
+        }                              
+
+        case Recurrence::rYearlyMonth:
+          recurString = i18nc("Every N YEAR[S] on day N of MONTHNAME"
+                              " (Every 2 years on day 12 of March)",
+						              	  "Every <numid>%1</numid> %2 on day <numid>%3</numid> of %4",
+  				            			  recurs->frequency(),
+                              i18np("year","years",recurs->frequency()),
+                              recurs->yearDates()[0],
+                              calSys->monthName(recurs->yearMonths()[0],1960) );
+          break;
+        case Recurrence::rYearlyPos:
+        {
+          KCal::RecurrenceRule::WDayPos rule = recurs->yearPositions()[0];
+          recurString = i18nc("Every N YEAR[S] on the [2nd|3rd|...] WEEKDAYNAME of MONTHNAME"
+                              " (Every 2 years on the 2nd Tuesday of March)",
+						              	  "Every <numid>%1</numid> %2 on the %3 %4 of %5",
+  						            	  recurs->frequency(),
+                              i18np("year","years",recurs->frequency()),
+                              dayList[rule.pos() + 31],
+                              calSys->weekDayName(rule.day(), KCalendarSystem::LongDayName),
+                              calSys->monthName(recurs->yearMonths()[0],1960) );
+          break;
+        }
+        case Recurrence::rYearlyDay:
+          recurString = i18nc("Every N YEAR[S] on day N"
+                              " (Every 2 years on day 122)",
+							                "Every <numid>%1</numid> %2 on day <numid>%3</numid>",
+  				            			  recurs->frequency(),
+                              i18np("year","years",recurs->frequency()),
+                              recurs->yearDays()[0] );
+          break;
+      }      
+      // occurrences
+      QString occurString;
+      switch (recurs->duration()) {
+        case 0: // end date set
+          occurString = i18nc("until DATE", "until %1",
+							                KGlobal::locale()->formatDate(recurs->endDate(), 
+							                KLocale::ShortDate) );
+          break;
+        case -1: // infinite
+          break;
+        default: // number of occurrences
+          occurString = i18nc("for N %OCCURENCE[S]", 
+          					          "for <numid>%1</numid> %2",
+						              	  recurs->duration(),
+						              	  i18np("occurence", "occurences", recurs->duration()) );
+          break;
+      }
+      // exception dates
+      QString exceptString;
+      if ( !recurs->exDates().isEmpty() ) {
+        exceptString = i18nc("except for listed dates", "except");
+        for ( int i = 0; i < recurs->exDates().size(); i++ ) {
+          exceptString.append(" ");
+          exceptString.append( KGlobal::locale()->formatDate(recurs->exDates()[i], 
+                               KLocale::ShortDate) );
+        }
+      }      
+      QString displayString;
+      displayString.append(recurString);
+      if (!displayString.endsWith(" "))
+        displayString.append(" ");
+      displayString.append(occurString);
+      if (!displayString.endsWith(" "))
+        displayString.append(" ");
+      displayString.append(exceptString);
+      h = QMAX( printCaptionAndText( p, recurBox, i18n("Repeats: "), displayString, captionFont, textFont ), h );
     }
 
     QRect alarmBox( timesBox.left() + padding(), h + padding(),
