[kde-doc-english] KDE

Ron Goodheart rong.dev at gmail.com
Fri Oct 10 09:11:02 CEST 2008


SVN commit 869813 by rgoodheart:

BUG: 170894
option added to stop wrapping events in days boxes
all day events now sort to the top
text is now limited to the box, doesn't spill out into margins
text margins in boxes reduced

GUI: 
option added in month print options limit each event to a single line



 M  +8 -3      kdepim/korganizer/printing/calprintdefaultplugins.cpp  
 M  +1 -0      kdepim/korganizer/printing/calprintdefaultplugins.h  
 M  +10 -0     kdepim/korganizer/printing/calprintmonthconfig_base.ui  
 M  +69 -37    kdepim/korganizer/printing/calprintpluginbase.cpp  
 M  +6 -3      kdepim/korganizer/printing/calprintpluginbase.h  
 M  +12 -0     kdepimlibs/kcal/calendar.cpp  


--- trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.cpp #869812:869813
@@ -4,7 +4,7 @@
   Copyright (c) 1998 Preston Brown <pbrown at kde.org>
   Copyright (C) 2003 Reinhold Kainhofer <reinhold at kainhofer.com>
   Copyright (c) 2003 Cornelius Schumacher <schumacher at kde.org>
-  Copyright (c) 2008 Ron Goodheart <ron.goodheart at gmail.com>
+  Copyright (c) 2008 Ron Goodheart <rong.dev at gmail.com>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -1005,6 +1005,7 @@
     mRecurDaily = cfg->mRecurDaily->isChecked();
     mRecurWeekly = cfg->mRecurWeekly->isChecked();
     mIncludeTodos = cfg->mIncludeTodos->isChecked();
+    mSingleLineLimit = cfg->mSingleLineLimit->isChecked();
 //    mUseColors = cfg->mColors->isChecked();
   }
 }
@@ -1020,6 +1021,7 @@
     cfg->mRecurDaily->setChecked( mRecurDaily );
     cfg->mRecurWeekly->setChecked( mRecurWeekly );
     cfg->mIncludeTodos->setChecked( mIncludeTodos );
+    cfg->mSingleLineLimit->setChecked( mSingleLineLimit );
 //    cfg->mColors->setChecked( mUseColors );
   }
 }
@@ -1032,6 +1034,7 @@
     mRecurDaily = grp.readEntry( "Print daily incidences", true );
     mRecurWeekly = grp.readEntry( "Print weekly incidences", true );
     mIncludeTodos = grp.readEntry( "Include todos", false );
+    mSingleLineLimit = grp.readEntry( "Single line limit", false );
   }
   setSettingsWidget();
 }
@@ -1045,6 +1048,7 @@
     grp.writeEntry( "Print daily incidences", mRecurDaily );
     grp.writeEntry( "Print weekly incidences", mRecurWeekly );
     grp.writeEntry( "Include todos", mIncludeTodos );
+    grp.writeEntry( "Single line limit", mSingleLineLimit );
   }
 }
 
@@ -1087,7 +1091,7 @@
 
   QRect headerBox( 0, 0, width, headerHeight() );
   QRect monthBox( 0, 0, width, height );
-  monthBox.setTop( headerBox.bottom() + padding() );
+  monthBox.setTop( headerBox.bottom() + padding() );  
 
   do {
     QString title( i18nc( "monthname year", "%1 <numid>%2</numid>",
@@ -1099,7 +1103,8 @@
 
     drawHeader( p, title, curMonth.addMonths( -1 ), curMonth.addMonths( 1 ),
                 headerBox );
-    drawMonthTable( p, curMonth, mWeekNumbers, mRecurDaily, mRecurWeekly, monthBox );
+    drawMonthTable( p, curMonth, mWeekNumbers, mRecurDaily, mRecurWeekly, 
+                    mSingleLineLimit, monthBox );
     curMonth = curMonth.addDays( curMonth.daysInMonth() );
     if ( curMonth <= toMonth ) {
       mPrinter->newPage();
--- trunk/KDE/kdepim/korganizer/printing/calprintdefaultplugins.h #869812:869813
@@ -212,6 +212,7 @@
     bool mRecurDaily;
     bool mRecurWeekly;
     bool mIncludeTodos;
+    bool mSingleLineLimit;
 };
 
 class CalPrintTodos : public CalPrintPluginBase
--- trunk/KDE/kdepim/korganizer/printing/calprintmonthconfig_base.ui #869812:869813
@@ -166,6 +166,16 @@
     </widget>
    </item>
    <item>
+    <widget class="QCheckBox" name="mSingleLineLimit" >
+     <property name="whatsThis" >
+      <string>Check this option to limit events to a single line.</string>
+     </property>
+     <property name="text" >
+      <string>Limit events in each day to a &amp;single line</string>
+     </property>
+    </widget>
+   </item>
+   <item>
     <spacer>
      <property name="orientation" >
       <enum>Qt::Vertical</enum>
--- trunk/KDE/kdepim/korganizer/printing/calprintpluginbase.cpp #869812:869813
@@ -3,6 +3,7 @@
 
   Copyright (c) 1998 Preston Brown <pbrown at kde.org>
   Copyright (C) 2003 Reinhold Kainhofer <reinhold at kainhofer.com>
+  Copyright (C) 2008 Ron Goodheart <rong.dev at gmail.com>
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -489,17 +490,8 @@
     smallMonthWidth = 100;
   }
 
-  int right = allbox.right();
-  if ( month1.isValid() ) {
-    right -= ( 20 + smallMonthWidth );
-  }
-  if ( month2.isValid() ) {
-    right -= ( 20 + smallMonthWidth );
-  }
   QRect box( allbox );
   QRect textRect( allbox );
-  textRect.adjust( 5, 0, 0, 0 );
-  textRect.setRight( right );
 
   QFont oldFont( p.font() );
   QFont newFont( "sans-serif", ( textRect.height() < 60 ) ? 16 : 18, QFont::Bold );
@@ -517,21 +509,45 @@
 
   drawShadedBox( p, BOX_BORDER_WIDTH, QColor( 232, 232, 232 ), box );
 
-  QRect monthbox( box.right()-10-smallMonthWidth, box.top(), smallMonthWidth, box.height() );
+#if 0
+  // current month title left justified, prev month, next month right justified
+  QRect monthbox2( box.right()-10-smallMonthWidth, box.top(), 
+                   smallMonthWidth, box.height() );
   if ( month2.isValid() ) {
-    drawSmallMonth( p, QDate( month2.year(), month2.month(), 1 ), monthbox );
-    monthbox.moveLeft( 20 + smallMonthWidth );
+    drawSmallMonth( p, QDate( month2.year(), month2.month(), 1 ), monthbox2 );
+    textRect.setRight( monthbox2.left() );
   }
+  QRect monthbox1( monthbox2.left()-10-smallMonthWidth, box.top(), 
+                   smallMonthWidth, box.height() );
   if ( month1.isValid() ) {
-    drawSmallMonth( p, QDate( month1.year(), month1.month(), 1 ), monthbox );
-    monthbox.moveLeft( 20 + smallMonthWidth );
+    drawSmallMonth( p, QDate( month1.year(), month1.month(), 1 ), monthbox1 );
+    textRect.setRight( monthbox1.left() );
   }
-
+  
   // Set the margins
   p.setFont( newFont );
+  textRect.adjust( 5, 0, 0, 0 );
   p.drawText( textRect, Qt::AlignLeft | Qt::AlignVCenter | Qt::WordBreak, title );
   p.setFont( oldFont );
+#endif
+  // prev month left, current month centered, next month right
+  QRect monthbox2( box.right()-10-smallMonthWidth, box.top(), 
+                   smallMonthWidth, box.height() );
+  if ( month2.isValid() ) {
+    drawSmallMonth( p, QDate( month2.year(), month2.month(), 1 ), monthbox2 );
+    textRect.setRight( monthbox2.left() );
+  }
+  QRect monthbox1( box.left()+10, box.top(), smallMonthWidth, box.height() );
+  if ( month1.isValid() ) {
+    drawSmallMonth( p, QDate( month1.year(), month1.month(), 1 ), monthbox1 );
+    textRect.setLeft( monthbox1.right() );
+  }
 
+  // Set the margins
+  p.setFont( newFont );
+  p.drawText( textRect, Qt::AlignCenter | Qt::AlignVCenter | Qt::WordBreak, title );
+  p.setFont( oldFont );
+
   return textRect.bottom();
 }
 
@@ -870,12 +886,13 @@
 
 void CalPrintPluginBase::drawDayBox( QPainter &p, const QDate &qd,
     const QRect &box,
-    bool fullDate, bool printRecurDaily, bool printRecurWeekly )
+    bool fullDate, bool printRecurDaily, bool printRecurWeekly,
+    bool singleLineLimit )
 {
   QString dayNumStr;
   QString ampm;
   const KLocale *local = KGlobal::locale();
-
+  
   // This has to be localized
   if ( fullDate && mCalSys ) {
     dayNumStr = i18nc( "weekday month date", "%1 %2 %3",
@@ -908,12 +925,13 @@
   Event::List eventList = mCalendar->events( qd, KPIM::KPimPrefs::timeSpec(),
                                              EventSortStartDate,
                                              SortDirectionAscending );
+
   QString text;
   p.setFont( QFont( "sans-serif", 8 ) );
 
-  int textY = mSubHeaderHeight + 3; // gives the relative y-coord of the next printed entry
+  int textY = mSubHeaderHeight + 1; // gives the relative y-coord of the next printed entry
   Event::List::ConstIterator it;
-
+  
   for ( it = eventList.begin(); it != eventList.end() && textY<box.height(); ++it ) {
     Event *currEvent = *it;
     if ( ( !printRecurDaily  && currEvent->recurrenceType() == Recurrence::rDaily ) ||
@@ -923,9 +941,9 @@
     if ( currEvent->allDay() || currEvent->isMultiDay() ) {
       text = "";
     } else {
-      text = local->formatTime( currEvent->dtStart().time() );
+      text = local->formatTime( currEvent->dtStart().time() ) + ' ';
     }
-    drawIncidence( p, box, text, currEvent->summary(), textY );
+    drawIncidence( p, box, text, currEvent->summary(), textY, singleLineLimit );
   }
 
   if ( textY < box.height() ) {
@@ -942,7 +960,8 @@
       } else {
         text = "";
       }
-      drawIncidence( p, box, text, i18n( "To-do: %1", todo->summary() ), textY );
+      drawIncidence( p, box, text, i18n( "To-do: %1", todo->summary() ), 
+                     textY, singleLineLimit );
     }
   }
 
@@ -951,27 +970,38 @@
 
 void CalPrintPluginBase::drawIncidence( QPainter &p, const QRect &dayBox,
                                         const QString &time,
-                                        const QString &summary, int &textY )
+                                        const QString &summary, int &textY,
+                                        bool singleLineLimit )
 {
   kDebug() << "summary =" << summary;
 
   int flags = Qt::AlignLeft;
   QFontMetrics fm = p.fontMetrics();
-  QRect timeBound = p.boundingRect( dayBox.x() + 5, dayBox.y() + textY,
+  QRect timeBound = p.boundingRect( dayBox.x() + 2, dayBox.y() + textY,
                                     dayBox.width() - 10, fm.lineSpacing(),
                                     flags, time );
   p.drawText( timeBound, flags, time );
 
-  int summaryWidth = time.isEmpty() ? 0 : timeBound.width() + 4;
-  QRect summaryBound = QRect( dayBox.x() + 5 + summaryWidth, dayBox.y() + textY,
-                              dayBox.width() - summaryWidth -5, dayBox.height() );
+  int summaryWidth = time.isEmpty() ? 0 : timeBound.width() + 3;
+  QRect summaryBound = QRect( dayBox.x() + 2 + summaryWidth, dayBox.y() + textY,
+                              dayBox.width() - summaryWidth - 2, 
+                              dayBox.height() - textY );
 
-  KWordWrap *ww = KWordWrap::formatText( fm, summaryBound, flags, summary );
-  ww->drawText( &p, dayBox.x() + 5 + summaryWidth, dayBox.y() + textY, flags );
-
-  textY += ww->boundingRect().height();
-
-  delete ww;
+  int lineCount = 1; 
+  if ( singleLineLimit ) {
+    p.drawText( summaryBound, flags, summary );
+  } else {
+    KWordWrap *ww = KWordWrap::formatText( fm, summaryBound, flags, summary );
+    QString wrappedString = ww->wrappedString();
+    p.drawText( summaryBound, flags, wrappedString );
+    for (int i=0; i<wrappedString.size(); ++i) {
+      if (wrappedString[i] == '\n') {
+        ++lineCount;
+      }
+    }
+    delete ww;
+  }
+  textY += ( fm.height() * lineCount );
 }
 
 void CalPrintPluginBase::drawWeek( QPainter &p, const QDate &qd, const QRect &box )
@@ -1270,7 +1300,8 @@
 
 void CalPrintPluginBase::drawMonthTable( QPainter &p, const QDate &qd,
                                          bool weeknumbers, bool recurDaily,
-                                         bool recurWeekly, const QRect &box )
+                                         bool recurWeekly, bool singleLineLimit,
+                                         const QRect &box )
 {
   int yoffset = mSubHeaderHeight;
   int xoffset = 0;
@@ -1328,8 +1359,9 @@
         darkbg = true;
       }
       QRect dayBox( coledges[col], rowedges[row],
-                    coledges[col + 1] - coledges[col], rowedges[row + 1] - rowedges[row] );
-      drawDayBox( p, monthDate, dayBox, false, recurDaily, recurWeekly );
+          coledges[col + 1] - coledges[col], rowedges[row + 1] - rowedges[row] );
+      drawDayBox( p, monthDate, dayBox, false, 
+                  recurDaily, recurWeekly, singleLineLimit );
       if ( darkbg ) {
         p.setBackground( back );
         darkbg = false;
@@ -1516,7 +1548,7 @@
     p.drawText( rect, Qt::WordBreak, outStr, &newrect );
   }
 
-  // Set the new line position
+  // Set the new line position - 1
   y = newrect.bottom() + 10; //set the line position
 
   // If the to-do has sub-to-dos, we need to call ourselves recursively
--- trunk/KDE/kdepim/korganizer/printing/calprintpluginbase.h #869812:869813
@@ -372,11 +372,13 @@
                       date string or just a short.
       @param printRecurDaily Whether daily recurring incidences should be printed.
       @param printRecurWeekly Whether weekly recurring incidences should be printed.
+      @param singleLineLimit Whether Incidence text wraps or truncates.
     */
     void drawDayBox( QPainter &p, const QDate &qd,
                      const QRect &box,
                      bool fullDate = false, bool printRecurDaily = true,
-                     bool printRecurWeekly = true );
+                     bool printRecurWeekly = true,
+                     bool singleLineLimit = true );
     /**
       Draw the week (filofax) table of the week containing the date qd. The first
       three days of the week will be shown in the first column (using drawDayBox),
@@ -421,7 +423,7 @@
       @param box coordinates of the month.
     */
     void drawMonthTable( QPainter &p, const QDate &qd, bool weeknumbers,
-                    bool recurDaily, bool recurWeekly,
+                    bool recurDaily, bool recurWeekly, bool singleLineLimit,
                     const QRect &box );
     /**
       Draw a vertical representation of the month containing the date dt. Each
@@ -511,7 +513,8 @@
 
   protected:
     void drawIncidence( QPainter &p, const QRect &dayBox, const QString &time,
-                        const QString &summary, int &textY );
+                        const QString &summary, int &textY,
+                        bool singleLineLimit = true );
 
   protected:
     bool mUseColors;
--- trunk/KDE/kdepimlibs/kcal/calendar.cpp #869812:869813
@@ -307,6 +307,10 @@
   case EventSortStartDate:
     alphaList = sortEvents( eventList, EventSortSummary, sortDirection );
     for ( eit = alphaList.begin(); eit != alphaList.end(); ++eit ) {
+      if ( (*eit)->dtStart().isDateOnly() ) {
+        tempList.append( *eit );        
+        continue;
+      }
       sortIt = eventListSorted.begin();
       if ( sortDirection == SortDirectionAscending ) {
         while ( sortIt != eventListSorted.end() &&
@@ -321,6 +325,14 @@
       }
       eventListSorted.insert( sortIt, *eit );
     }
+    if ( sortDirection == SortDirectionAscending ) {
+      // Prepend the list of Events without End DateTimes
+      tempList += eventListSorted;
+      eventListSorted = tempList;
+    } else {
+      // Append the list of Events without End DateTimes
+      eventListSorted += tempList;
+    }    
     break;
 
   case EventSortEndDate:



More information about the kde-doc-english mailing list