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

List:       kde-commits
Subject:    KDE/kdepim/korganizer
From:       Thomas McGuire <mcguire () kde ! org>
Date:       2008-10-05 15:21:01
Message-ID: 1223220061.719485.10193.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 868143 by tmcguire:

When the next month button is clicked in the navigator, always switch
the navigator to the next month, even when the days of the next month
are still displayed after the current month.

BUG: 122333


 M  +43 -9     datenavigatorcontainer.cpp  
 M  +5 -0      datenavigatorcontainer.h  
 M  +30 -0     kdatenavigator.cpp  
 M  +3 -0      kdatenavigator.h  


--- trunk/KDE/kdepim/korganizer/datenavigatorcontainer.cpp #868142:868143
@@ -39,7 +39,8 @@
 
 DateNavigatorContainer::DateNavigatorContainer( QWidget *parent )
   : QFrame( parent ), mCalendar( 0 ),
-    mHorizontalCount( 1 ), mVerticalCount( 1 )
+    mHorizontalCount( 1 ), mVerticalCount( 1 ),
+    mIgnoreNavigatorUpdates( false )
 {
   mNavigatorView = new KDateNavigator( this );
   mNavigatorView->setWhatsThis(
@@ -75,8 +76,8 @@
   connect( v, SIGNAL(goPrevious()), SIGNAL(goPrevious()) );
   connect( v, SIGNAL(goNext()), SIGNAL(goNext()) );
 
-  connect( v, SIGNAL(goNextMonth()), SIGNAL(goNextMonth()) );
-  connect( v, SIGNAL(goPrevMonth()), SIGNAL(goPrevMonth()) );
+  connect( v, SIGNAL(goNextMonth()), SLOT(selectNextMonth()) );
+  connect( v, SIGNAL(goPrevMonth()), SLOT(selectPreviousMonth()) );
   connect( v, SIGNAL(goNextYear()), SIGNAL(goNextYear()) );
   connect( v, SIGNAL(goPrevYear()), SIGNAL(goPrevYear()) );
   connect( v, SIGNAL(goMonth(int)), SIGNAL(goMonth(int)) );
@@ -137,6 +138,34 @@
   }
 }
 
+void DateNavigatorContainer::selectNextMonth()
+{
+  mNavigatorView->selectNextMonth();
+  foreach ( KDateNavigator *n, mExtraViews ) {
+    if ( n ) {
+      n->selectNextMonth();
+    }
+  }
+
+  mIgnoreNavigatorUpdates = true;
+  emit goNextMonth();
+  mIgnoreNavigatorUpdates = false;
+}
+
+void DateNavigatorContainer::selectPreviousMonth()
+{
+  mNavigatorView->selectPreviousMonth();
+  foreach ( KDateNavigator *n, mExtraViews ) {
+    if ( n ) {
+      n->selectPreviousMonth();
+    }
+  }
+
+  mIgnoreNavigatorUpdates = true;
+  emit goPrevMonth();
+  mIgnoreNavigatorUpdates = false;
+}
+
 void DateNavigatorContainer::selectDates( const DateList &dateList )
 {
   if ( !dateList.isEmpty() ) {
@@ -159,10 +188,12 @@
       setBaseDates( start );
     }
 
-    mNavigatorView->selectDates( dateList );
-    foreach ( KDateNavigator *n, mExtraViews ) {
-      if ( n ) {
-        n->selectDates( dateList );
+    if ( !mIgnoreNavigatorUpdates ) {
+      mNavigatorView->selectDates( dateList );
+      foreach ( KDateNavigator *n, mExtraViews ) {
+        if ( n ) {
+          n->selectDates( dateList );
+        }
       }
     }
   }
@@ -171,10 +202,13 @@
 void DateNavigatorContainer::setBaseDates( const QDate &start )
 {
   QDate baseDate = start;
-  mNavigatorView->setBaseDate( baseDate );
+  if ( !mIgnoreNavigatorUpdates )
+    mNavigatorView->setBaseDate( baseDate );
+
   foreach ( KDateNavigator *n, mExtraViews ) {
     baseDate = KOGlobals::self()->calendarSystem()->addMonths( baseDate, 1 );
-    n->setBaseDate( baseDate );
+    if ( !mIgnoreNavigatorUpdates  )
+      n->setBaseDate( baseDate );
   }
 }
 
--- trunk/KDE/kdepim/korganizer/datenavigatorcontainer.h #868142:868143
@@ -51,6 +51,8 @@
 
   public slots:
     void selectDates( const KCal::DateList & );
+    void selectNextMonth();
+    void selectPreviousMonth();
     void updateView();
     void updateConfig();
     void updateDayMatrix();
@@ -85,6 +87,7 @@
     void resizeAllContents();
 
   private:
+
     KDateNavigator *mNavigatorView;
 
     KCal::Calendar *mCalendar;
@@ -93,6 +96,8 @@
 
     int mHorizontalCount;
     int mVerticalCount;
+
+    bool mIgnoreNavigatorUpdates;
 };
 
 #endif
--- trunk/KDE/kdepim/korganizer/kdatenavigator.cpp #868142:868143
@@ -139,6 +139,7 @@
   mDayMatrix->recalculateToday();
   mDayMatrix->repaint();
 }
+
 QDate KDateNavigator::startDate() const
 {
   // Find the first day of the week of the current month.
@@ -162,6 +163,7 @@
 
   return dayone;
 }
+
 QDate KDateNavigator::endDate() const
 {
   return startDate().addDays( 6 * 7 );
@@ -246,6 +248,34 @@
   }
 }
 
+void KDateNavigator::selectMonthHelper( int monthDifference )
+{
+  QDate baseDateNextMonth = KOGlobals::self()->calendarSystem()->addMonths(
+                                            mBaseDate, monthDifference );
+
+  DateList newSelection = mSelectedDates;
+  for ( int i = 0; i < mSelectedDates.count(); i++ ) {
+    newSelection[i] = KOGlobals::self()->calendarSystem()->addMonths(
+                                      newSelection[i], monthDifference );
+  }
+
+  setBaseDate( baseDateNextMonth );
+  mSelectedDates = newSelection;
+  mDayMatrix->setSelectedDaysFrom( *( newSelection.begin() ),
+                                   *( --newSelection.end() ) );
+  updateView();
+}
+
+void KDateNavigator::selectNextMonth()
+{
+  selectMonthHelper( 1 );
+}
+
+void KDateNavigator::selectPreviousMonth()
+{
+  selectMonthHelper( -1 );
+}
+
 void KDateNavigator::selectDates( const DateList &dateList )
 {
   if ( dateList.count() > 0 ) {
--- trunk/KDE/kdepim/korganizer/kdatenavigator.h #868142:868143
@@ -74,6 +74,8 @@
 
   public slots:
     void selectDates( const KCal::DateList & );
+    void selectPreviousMonth();
+    void selectNextMonth();
     void updateView();
     void updateConfig();
     void updateDayMatrix();
@@ -106,6 +108,7 @@
     void setShowWeekNums( bool enabled );
 
   private:
+    void selectMonthHelper( int monthDifference );
     NavigatorBar *mNavigatorBar;
 
     QLabel *mHeadings[ 7 ];
[prev in list] [next in list] [prev in thread] [next in thread] 

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