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

List:       kde-commits
Subject:    kdepim/kresources/kolab/kcal
From:       David Faure <faure () kde ! org>
Date:       2004-10-11 14:10:50
Message-ID: 20041011141050.B649C16BFB () office ! kde ! org
[Download RAW message or body]

CVS commit by faure: 

Implemented "yearly weekday" recurrence, which I just added to the kolab XML spec.


  M +24 -3     incidence.cpp   1.7


--- kdepim/kresources/kolab/kcal/incidence.cpp  #1.6:1.7
@@ -507,8 +507,8 @@ void Incidence::setRecurrence( KCal::Rec
     QPtrList<int> months = recur->yearNums();
     if ( !months.isEmpty() )
-      mRecurrence.month = s_monthName[ *months.first() ];
+      mRecurrence.month = s_monthName[ *months.first() ]; // #### Kolab XML limitation
     break;
   }
-  case KCal::Recurrence::rYearlyDay: // YearlyDay (day N of the year)
+  case KCal::Recurrence::rYearlyDay: // YearlyDay (day N of the year). Not supported by Outlook
     mRecurrence.cycle = "yearly";
     mRecurrence.type = "yearday";
@@ -516,5 +516,20 @@ void Incidence::setRecurrence( KCal::Rec
     break;
   case KCal::Recurrence::rYearlyPos: // (weekday X of week N of month Y)
-    // ##### Not in Kolab XML
+    mRecurrence.cycle = "yearly";
+    mRecurrence.type = "weekday";
+    QPtrList<int> months = recur->yearNums();
+    if ( !months.isEmpty() )
+      mRecurrence.month = s_monthName[ *months.first() ]; // #### Kolab XML limitation
+    const QPtrList<KCal::Recurrence::rMonthPos> &monthPositions = recur->yearMonthPositions();
+    if ( !monthPositions.isEmpty() ) {
+      KCal::Recurrence::rMonthPos monthPos = *monthPositions.getFirst();
+      QBitArray arr = monthPos.rDays;
+      for ( uint idx = 0 ; idx < 7 ; ++idx )
+        if ( arr.testBit( idx ) )
+          mRecurrence.days.append( s_weekDayName[idx] );
+      mRecurrence.dayNumber = QString::number( monthPos.rPos );
+    mRecurrence.dayNumber = QString::number( *recur->yearNums().getFirst() );
+      // Not handled: monthPos.negative (nth days before end of month)
+    }
     break;
   }
@@ -701,4 +716,10 @@ void Incidence::saveTo( KCal::Incidence*
         recur->setYearly( KCal::Recurrence::rYearlyDay, mRecurrence.interval, -1 );
         recur->addYearlyNum( mRecurrence.dayNumber.toInt() );
+      } else if ( mRecurrence.type == "weekday" ) {
+        recur->setYearly( KCal::Recurrence::rYearlyPos, mRecurrence.interval, -1 );
+        for ( int i = 0; i < 12; ++i )
+          if ( s_monthName[ i ] == mRecurrence.month )
+            recur->addYearlyNum( i );
+        recur->addMonthlyPos( mRecurrence.dayNumber.toInt(), daysListToBitArray( mRecurrence.days ) );
       } else kdWarning() << "Unhandled yearly recurrence type " << mRecurrence.type << endl;
     } else kdWarning() << "Unhandled recurrence cycle " << mRecurrence.cycle << endl;


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

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