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

List:       kde-commits
Subject:    kdepim/korganizer
From:       Reinhold Kainhofer <reinhold () kainhofer ! com>
Date:       2003-08-01 0:18:10
[Download RAW message or body]

CVS commit by kainhofe: 

This patch adds entries to the combo box (for monthly recurrences that recur 
on the n-th weekday) to count recurrence weeks from the end of the month. 

Note that I also moved some index offsets from readEvent and writeEvent to
the RecurMonthly class (since the offset in one direction was done in
readEvent, the other direction in the RecurMonthly, this was just begging
for trouble in the future. Now all index offset handling is in
RecurMonthly).

CCMAIL: 34505-done@bugs.kde.org


  M +21 -6     koeditorrecurrence.cpp   1.47


--- kdepim/korganizer/koeditorrecurrence.cpp  #1.46:1.47
@@ -230,4 +230,10 @@ RecurMonthly::RecurMonthly( QWidget *par
   mByPosCountCombo->insertItem( i18n("4th") );
   mByPosCountCombo->insertItem( i18n("5th") );
+  mByPosCountCombo->insertItem( i18n("last") );
+  mByPosCountCombo->insertItem( i18n("2nd last") );
+  mByPosCountCombo->insertItem( i18n("3rd last") );
+  mByPosCountCombo->insertItem( i18n("4th last") );
+  mByPosCountCombo->insertItem( i18n("5th last") );
+
   buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
 
@@ -246,5 +252,5 @@ void RecurMonthly::setByDay( int day )
 {
   mByDayRadio->setChecked( true );
-  mByDayCombo->setCurrentItem( day );
+  mByDayCombo->setCurrentItem( day-1 );
 }
 
@@ -252,5 +258,9 @@ void RecurMonthly::setByPos( int count, 
 {
   mByPosRadio->setChecked( true );
-  mByPosCountCombo->setCurrentItem( count );
+  if (count>0)
+    mByPosCountCombo->setCurrentItem( count - 1 );
+  else
+    // negative weeks means counted from the end of month
+    mByPosCountCombo->setCurrentItem( -count + 4 );
   mByPosWeekdayCombo->setCurrentItem( weekday );
 }
@@ -273,5 +283,9 @@ int RecurMonthly::day()
 int RecurMonthly::count()
 {
-  return mByPosCountCombo->currentItem() + 1;
+  int pos=mByPosCountCombo->currentItem();
+  if (pos<=4) // positive  count
+    return pos+1;
+  else
+    return -pos+4;
 }
 
@@ -915,7 +929,8 @@ void KOEditorRecurrence::readEvent(Event
       rmp = r->monthPositions();
       if ( rmp.first()->negative )
-        count = 5 - rmp.first()->rPos - 1;
+        count=-rmp.first()->rPos;
       else
-        count = rmp.first()->rPos - 1;
+        // give the week as -5 to -1 and 1 to 5. the widget will do the rest
+        count = rmp.first()->rPos;
       day = 0;
       while ( !rmp.first()->rDays.testBit( day ) ) ++day;
@@ -929,5 +944,5 @@ void KOEditorRecurrence::readEvent(Event
 
       rmd = r->monthDays();
-      day = *rmd.first() - 1;
+      day = *rmd.first();
       mMonthly->setByDay( day );
 


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

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