summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Unidiff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp71
1 files changed, 57 insertions, 14 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 18756f0..bb27bce 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -48,2 +48,4 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mDisplayedEndDate = QDate::currentDate();
50 mLastDisplayedDN = 0;
49} 51}
@@ -82,4 +84,4 @@ void DateNavigatorContainer::setCalendar( Calendar *cal )
82 mNavigatorView->setCalendar( cal ); 84 mNavigatorView->setCalendar( cal );
83 KDateNavigator *n; 85 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
84 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 86 KDateNavigator *n = mExtraViews.at( i );
85 n->setCalendar( cal ); 87 n->setCalendar( cal );
@@ -91,4 +93,4 @@ void DateNavigatorContainer::updateDayMatrix()
91 mNavigatorView->updateDayMatrix(); 93 mNavigatorView->updateDayMatrix();
92 KDateNavigator *n; 94 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
93 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 95 KDateNavigator *n = mExtraViews.at( i );
94 n->updateDayMatrix(); 96 n->updateDayMatrix();
@@ -112,4 +114,4 @@ void DateNavigatorContainer::updateView()
112 mNavigatorView->updateView(); 114 mNavigatorView->updateView();
113 KDateNavigator *n; 115 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
114 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 116 KDateNavigator *n = mExtraViews.at( i );
115 n->updateView(); 117 n->updateView();
@@ -121,4 +123,4 @@ void DateNavigatorContainer::updateConfig()
121 mNavigatorView->updateConfig(); 123 mNavigatorView->updateConfig();
122 KDateNavigator *n; 124 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
123 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 125 KDateNavigator *n = mExtraViews.at( i );
124 n->updateConfig(); 126 n->updateConfig();
@@ -129,5 +131,41 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
129{ 131{
132 if ( !mLastDisplayedDN ) {
133 mNavigatorView->selectDates( dateList );
134 return;
135 }
136 QDate fDate = dateList.first();
137 QDate lDate = dateList.last();
138 if ( mLastDisplayedDN <= 2 ) {
139 mNavigatorView->selectDates( dateList );
140 KDateNavigator *view = mExtraViews.at( 0 );
141 QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 );
142 view->setBaseDate( bDate, false );
143 view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
144 if ( mLastDisplayedDN == 2 ) {
145 view = mExtraViews.at( 1 );
146 bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 );
147 view->setBaseDate( bDate, false );
148 view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
149 }
150 return;
151 }
152 KDateNavigator *view = mExtraViews.at( 0 );
153 QDate date = view->baseDate();
154
155 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
156 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
157 if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
158 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
159 mNavigatorView->dayMatrix()->repaint( false );
160 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
161 KDateNavigator *n = mExtraViews.at( i );
162 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
163 n->dayMatrix()->repaint( false );
164 }
165 }
166 return;
167 }
130 mNavigatorView->selectDates( dateList ); 168 mNavigatorView->selectDates( dateList );
131 setBaseDates(); 169 setBaseDates();
132 if ( mExtraViews.count() ) { 170 if ( mLastDisplayedDN ) {
133 KDateNavigator *view = mExtraViews.at( 0 ); 171 KDateNavigator *view = mExtraViews.at( 0 );
@@ -135,3 +173,3 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
135 view->dayMatrix()->repaint( false ); 173 view->dayMatrix()->repaint( false );
136 if ( mExtraViews.count() > 1 ) { 174 if ( mLastDisplayedDN > 1 ) {
137 KDateNavigator *view = mExtraViews.at( 1 ); 175 KDateNavigator *view = mExtraViews.at( 1 );
@@ -150,5 +188,5 @@ void DateNavigatorContainer::setBaseDates()
150 QDate baseDate = dateList.first(); 188 QDate baseDate = dateList.first();
151 KDateNavigator *n;
152 bool doRepaint = false; // skip first repaint 189 bool doRepaint = false; // skip first repaint
153 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 190 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
191 KDateNavigator *n = mExtraViews.at( i );
154 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 192 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
@@ -213,2 +251,4 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
213 251
252 mLastDisplayedDN = horizontalCount*verticalCount-1;
253 bool setBaseD = false;
214 while ( count > ( mExtraViews.count() + 1 ) ) { 254 while ( count > ( mExtraViews.count() + 1 ) ) {
@@ -218,3 +258,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
218 n->setCalendar( mCalendar ); 258 n->setCalendar( mCalendar );
219 setBaseDates(); 259 setBaseD = true;
220 connectNavigatorView( n ); 260 connectNavigatorView( n );
@@ -230,2 +270,4 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
230 } 270 }
271 if ( setBaseD )
272 setBaseDates();
231 if ( fontchange ) { 273 if ( fontchange ) {
@@ -240,2 +282,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
240 mVerticalCount = verticalCount; 282 mVerticalCount = verticalCount;
283
241 } 284 }
@@ -251,3 +294,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
251 0, width, height ); 294 0, width, height );
252 for( uint i = 0; i < mExtraViews.count(); ++i ) { 295 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
253 int x = ( i + 1 ) % horizontalCount; 296 int x = ( i + 1 ) % horizontalCount;