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

List:       kde-commits
Subject:    KDE/kdepimlibs/kcalutils
From:       Sergio Luis Martins <iamsergio () gmail ! com>
Date:       2011-01-08 16:45:33
Message-ID: 20110108164533.4B9D9AC8B0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1212924 by smartins:

Correctly display the start date of recurring to-dos.

The to-do was always being displayed with dtstart equaling dtdue.

 M  +19 -3     incidenceformatter.cpp  
 M  +2 -1      incidenceformatter.h  


--- trunk/KDE/kdepimlibs/kcalutils/incidenceformatter.cpp #1212923:1212924
@@ -736,6 +736,7 @@
                                       const QDate &date, KDateTime::Spec spec )
 {
   if ( !todo ) {
+    kDebug() << "IncidenceFormatter::displayViewFormatTodo was called without to-do, quiting";
     return QString();
   }
 
@@ -760,13 +761,28 @@
     tmpStr += "</tr>";
   }
 
-  if ( todo->hasStartDate() && todo->dtStart().isValid() ) {
-    KDateTime startDt = todo->dtStart();
+  const bool hastStartDate = todo->hasStartDate() && todo->dtStart().isValid();
+  const bool hasDueDate = todo->hasDueDate() && todo->dtDue().isValid();
+
+  if ( hastStartDate ) {
+    KDateTime startDt = todo->dtStart( true /**first*/ );
     if ( todo->recurs() ) {
       if ( date.isValid() ) {
+        if ( hasDueDate ) {
+          // In kdepim all recuring to-dos have due date.
+          const int length = startDt.daysTo( todo->dtDue( true /**first*/ ) );
+          if ( length >= 0 ) {
+            startDt.setDate( date.addDays( -length ) );
+          } else {
+            kError() << "DTSTART is bigger than DTDUE, todo->uid() is " << todo->uid();
         startDt.setDate( date );
       }
+        } else {
+          kError() << "To-do is recurring but has no DTDUE set, todo->uid() is " << todo->uid();
+          startDt.setDate( date );
     }
+      }
+    }
     tmpStr += "<tr>";
     tmpStr += "<td><b>" +
               i18nc( "to-do start date/time", "Start:" ) +
@@ -777,7 +793,7 @@
     tmpStr += "</tr>";
   }
 
-  if ( todo->hasDueDate() && todo->dtDue().isValid() ) {
+  if ( hasDueDate ) {
     KDateTime dueDt = todo->dtDue();
     if ( todo->recurs() ) {
       if ( date.isValid() ) {
--- trunk/KDE/kdepimlibs/kcalutils/incidenceformatter.h #1212923:1212924
@@ -73,7 +73,8 @@
     @param sourceName where the incidence is from (e.g. resource name)
     @param incidence is a pointer to the Incidence to be formatted.
     @param date is the QDate for which the toolTip should be computed; used
-    mainly for recurring incidences.
+    mainly for recurring incidences. Note: For to-dos, this is the due date of
+    the occurrence, not the start date.
     @param richText if yes, the QString will be created as RichText.
     @param spec is an optional time specification which, when specified,
     will shift the Incidence times to different timezones.
[prev in list] [next in list] [prev in thread] [next in thread] 

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