[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise4/kdepim/korganizer
From:       Allen Winter <winter () kde ! org>
Date:       2010-01-06 1:33:09
Message-ID: 1262741589.540132.15989.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1070563 by winterz:

Merged revisions 1070557 via svnmerge from 
https://svn.kde.org/home/kde/branches/kdepim/enterprise/kdepim

........
  r1070557 | winterz | 2010-01-05 20:10:55 -0500 (Tue, 05 Jan 2010) | 5 lines
  
  put a footer on each printout containing the "printed <datetime"> timestamp.
  kolab/issue4004
  
  MERGE: e4,4.5
........


 M  +7 -1      plugins/printing/journal/journalprint.cpp  
 M  +6 -1      plugins/printing/year/yearprint.cpp  
 M  +44 -5     printing/calprintdefaultplugins.cpp  
 M  +29 -1     printing/calprintpluginbase.cpp  
 M  +21 -0     printing/calprintpluginbase.h  


--- branches/kdepim/enterprise4/kdepim/korganizer/plugins/printing/journal/journalprint.cpp \
#1070562:1070563 @@ -129,13 +129,19 @@
     }
   }
 
-  drawHeader( p, i18n("Journal entries"), QDate(), QDate(), QRect( 0, 0, width, \
headerHeight() ) ); +  QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
+  drawHeader( p, i18n("Journal entries"), QDate(), QDate(), headerBox );
   y = headerHeight() + 15;
 
   Journal::List::Iterator it = journals.begin();
   for ( ; it != journals.end(); ++it ) {
     drawJournal( *it, p, x, y, width, height );
   }
+
+  drawFooter( p, footerBox );
 }
 
 #endif
--- branches/kdepim/enterprise4/kdepim/korganizer/plugins/printing/year/yearprint.cpp \
#1070562:1070563 @@ -138,13 +138,16 @@
 
 void CalPrintYear::print( QPainter &p, int width, int height )
 {
-  QRect headerBox( 0, 0, width, headerHeight() );
   const KCalendarSystem *calsys = calendarSystem();
   KLocale *locale = KGlobal::locale();
   if ( !calsys || !locale ) {
     return;
   }
 
+  QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
   QDate start;
   calsys->setYMD( start, mYear, 1, 1 );
 
@@ -199,6 +202,8 @@
 
       temp = calsys->addMonths( temp, 1 );
     }
+
+    drawFooter( p, footerBox );
     start = calsys->addMonths( start, monthsPerPage );
   }
 }
--- branches/kdepim/enterprise4/kdepim/korganizer/printing/calprintdefaultplugins.cpp \
#1070562:1070563 @@ -557,8 +557,12 @@
     locationBox.setBottom( locationBottom );
 
     // Now start constructing the boxes from the bottom:
-    QRect categoriesBox( locationBox );
-    categoriesBox.setBottom( box.bottom() );
+    QRect footerBox( locationBox );
+    footerBox.setBottom( box.bottom() );
+    footerBox.setTop( footerBox.bottom() - lineHeight - 2*padding() );
+
+    QRect categoriesBox( footerBox );
+    categoriesBox.setBottom( footerBox.top() );
     categoriesBox.setTop( categoriesBox.bottom() - lineHeight - 2 * padding() );
 
     QRect attendeesBox( box.left(), categoriesBox.top() - padding() - box.height() / \
9, @@ -676,6 +680,8 @@
     drawBoxWithCaption( p, categoriesBox, i18n( "Categories: " ),
            (*it)->categories().join( i18nc( "Spacer for the joined list of \
categories", ", " ) ),  /*sameLine=*/true, /*expand=*/false, captionFont, textFont );
+
+    drawFooter( p, footerBox );
   }
   p.setFont( oldFont );
 }
@@ -778,6 +784,11 @@
   QDate curDay( mFromDate );
 
   KDateTime::Spec timeSpec = KSystemTimeZones::local();
+
+  QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
   do {
     QTime curStartTime( mStartTime );
     QTime curEndTime( mEndTime );
@@ -790,7 +801,6 @@
     }
 
     KLocale *local = KGlobal::locale();
-    QRect headerBox( 0, 0, width, headerHeight() );
 
     drawHeader( p, local->formatDate( curDay ), curDay, QDate(), headerBox );
     Event::List eventList = mCalendar->events( curDay, timeSpec,
@@ -812,6 +822,9 @@
     tlBox.setLeft( 0 );
     tlBox.setWidth( TIMELINE_WIDTH );
     drawTimeLine( p, curStartTime, curEndTime, tlBox );
+
+    drawFooter( p, footerBox );
+
     curDay = curDay.addDays( 1 );
     if ( curDay <= mToDate ) {
       mPrinter->newPage();
@@ -949,6 +962,9 @@
 
   QString line1, line2, title;
   QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
   QRect weekBox( headerBox );
   weekBox.setTop( headerBox.bottom() + padding() );
   weekBox.setBottom( height );
@@ -964,7 +980,11 @@
         title = i18nc( "date from-\nto", "%1 -\n%2", line1, line2 );
       }
       drawHeader( p, title, curWeek.addDays( -6 ), QDate(), headerBox );
+
       drawWeek( p, curWeek, weekBox );
+
+      drawFooter( p, footerBox );
+
       curWeek = curWeek.addDays( 7 );
       if ( curWeek <= toWeek ) {
         mPrinter->newPage();
@@ -984,12 +1004,18 @@
         title = i18nc( "date from -\nto (week number)", "%1 -\n%2 (Week %3)",
                        line1, line2, curWeek.weekNumber() );
       }
+        drawTimeTable( p, fromWeek, curWeek, mStartTime, mEndTime, weekBox );
 
       drawHeader( p, title, curWeek, QDate(), headerBox );
+
       QRect weekBox( headerBox );
       weekBox.setTop( headerBox.bottom() + padding() );
       weekBox.setBottom( height );
+
       drawTimeTable( p, fromWeek, curWeek, mStartTime, mEndTime, weekBox );
+
+      drawFooter( p, footerBox );
+
       fromWeek = fromWeek.addDays( 7 );
       curWeek = fromWeek.addDays( 6 );
       if ( curWeek <= toWeek ) {
@@ -1015,6 +1041,8 @@
       drawSplitHeaderRight( p, fromWeek, curWeek, QDate(), width, hh );
       drawTimeTable( p, endLeft.addDays( 1 ), curWeek, mStartTime, mEndTime, \
weekBox1 );  
+      drawFooter( p, footerBox );
+
       fromWeek = fromWeek.addDays( 7 );
       curWeek = fromWeek.addDays( 6 );
       if ( curWeek <= toWeek ) {
@@ -1136,6 +1164,9 @@
   }
 
   QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
   QRect monthBox( 0, 0, width, height );
   monthBox.setTop( headerBox.bottom() + padding() );
 
@@ -1150,6 +1181,9 @@
     drawHeader( p, title, curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
                 headerBox );
     drawMonthTable( p, curMonth, mWeekNumbers, mRecurDaily, mRecurWeekly, monthBox \
); +
+    drawFooter( p, footerBox );
+
     curMonth = curMonth.addDays( curMonth.daysInMonth() );
     if ( curMonth <= toMonth ) {
       mPrinter->newPage();
@@ -1297,9 +1331,12 @@
   int lineSpacing = 15;
   int fontHeight = 10;
 
+  QRect headerBox( 0, 0, width, headerHeight() );
+  QRect footerBox( 0, height - footerHeight(), width, footerHeight() );
+  height -= footerHeight();
+
   // Draw the First Page Header
-  drawHeader( p, mPageTitle, mFromDate, QDate(),
-                       QRect( 0, 0, width, headerHeight() ) );
+  drawHeader( p, mPageTitle, mFromDate, QDate(), headerBox );
 
   // Draw the Column Headers
   int mCurrentLinePos = headerHeight() + 5;
@@ -1424,6 +1461,8 @@
                 0, 0, mCurrentLinePos, width, height, todoList );
     }
   }
+
+  drawFooter( p, footerBox );
   p.setFont( oldFont );
 }
 
--- branches/kdepim/enterprise4/kdepim/korganizer/printing/calprintpluginbase.cpp \
#1070562:1070563 @@ -97,7 +97,7 @@
 
 CalPrintPluginBase::CalPrintPluginBase()
   : PrintPlugin(), mUseColors( true ),
-    mHeaderHeight(-1), mSubHeaderHeight( SUBHEADER_HEIGHT ),
+    mHeaderHeight( -1 ), mSubHeaderHeight( SUBHEADER_HEIGHT ), mFooterHeight( -1 ),
     mMargin( MARGIN_SIZE ), mPadding( PADDING_SIZE ), mCalSys( 0 )
 {
 }
@@ -314,6 +314,20 @@
   mSubHeaderHeight = height;
 }
 
+int CalPrintPluginBase::footerHeight() const
+{
+  if ( mFooterHeight >= 0 )
+    return mFooterHeight;
+  else if ( orientation() == QPrinter::Portrait )
+    return PORTRAIT_FOOTER_HEIGHT;
+  else
+    return LANDSCAPE_FOOTER_HEIGHT;
+}
+void CalPrintPluginBase::setFooterHeight( const int height )
+{
+  mFooterHeight = height;
+}
+
 int CalPrintPluginBase::margin() const
 {
   return mMargin;
@@ -537,6 +551,20 @@
   return textRect.bottom();
 }
 
+int CalPrintPluginBase::drawFooter( QPainter &p, QRect &footbox )
+{
+  // Print the timestamp
+  QFont stampFont("sans-serif", 10, QFont::Normal, true );
+  p.setFont( stampFont );
+  QDateTime now = QDateTime::currentDateTime();
+  QString str = i18nc( "printed <datetime>",
+                       "printed %1",
+                       KGlobal::locale()->formatDateTime( now ) );
+  p.drawText( footbox, Qt::AlignRight | Qt::AlignVCenter, str );
+
+  return footbox.bottom();
+}
+
 void CalPrintPluginBase::drawSmallMonth( QPainter &p, const QDate &qd, const QRect \
&box )  {
   int weekdayCol = weekdayColumn( qd.dayOfWeek() );
--- branches/kdepim/enterprise4/kdepim/korganizer/printing/calprintpluginbase.h \
#1070562:1070563 @@ -50,6 +50,8 @@
 #define PORTRAIT_HEADER_HEIGHT 72   // header height, for portrait orientation
 #define LANDSCAPE_HEADER_HEIGHT 54  // header height, for landscape orientation
 #define SUBHEADER_HEIGHT 20         // subheader height, for all orientations
+#define PORTRAIT_FOOTER_HEIGHT 16   // footer height, for portrait orientation
+#define LANDSCAPE_FOOTER_HEIGHT 14  // footer height, for landscape orientation
 #define MARGIN_SIZE 36              // margins, for all orientations
 #define PADDING_SIZE 7              // padding between the various top-level boxes
 #define BOX_BORDER_WIDTH 2          // width of the border of all top-level boxes
@@ -146,6 +148,14 @@
 
     int subHeaderHeight() const;
     void setSubHeaderHeight( const int height );
+    /** Returns the height of the page footer. If the height was explicitly
+        set using setFooterHeight, that value is returned, otherwise a
+        default value based on the printer orientation.
+        @return height of the page footer of the printout
+    */
+    int footerHeight() const;
+    void setFooterHeight( const int height );
+
     int margin() const;
     void setMargin( const int margin );
 
@@ -267,7 +277,17 @@
     int drawHeader( QPainter &p, const QString &title,
                      const QDate &month1, const QDate &month2,
                      const QRect &box, bool expand = false );
+
     /**
+      Draw a page footer containing the printing date and possibly
+      other things, like a page number.
+      @param p QPainter of the printout
+      @param box coordinates of the footer
+      @return The bottom of the printed box.
+    */
+    int drawFooter( QPainter &p, QRect &box );
+
+    /**
       Draw a small calendar with the days of a month into the given area.
       Used for example in the title bar of the sheet.
       @param p QPainter of the printout
@@ -517,6 +537,7 @@
     bool mUseColors;
     int mHeaderHeight;
     int mSubHeaderHeight;
+    int mFooterHeight;
     int mMargin;
     int mPadding;
     int mBorder;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic