summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index f6f62a4..92abae6 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -143,117 +143,127 @@ void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
143 else { 143 else {
144 setBaseDates(); 144 setBaseDates();
145 if ( forceEmit ) 145 if ( forceEmit )
146 updateDayMatrixDates(); 146 updateDayMatrixDates();
147 if ( forceEmit ) 147 if ( forceEmit )
148 emit monthSelected( month ); 148 emit monthSelected( month );
149 } 149 }
150} 150}
151void DateNavigatorContainer::setCalendar( Calendar *cal ) 151void DateNavigatorContainer::setCalendar( Calendar *cal )
152{ 152{
153 mCalendar = cal; 153 mCalendar = cal;
154 mNavigatorView->setCalendar( cal ); 154 mNavigatorView->setCalendar( cal );
155 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 155 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
156 KDateNavigator *n = mExtraViews.at( i ); 156 KDateNavigator *n = mExtraViews.at( i );
157 n->setCalendar( cal ); 157 n->setCalendar( cal );
158 } 158 }
159} 159}
160void DateNavigatorContainer::checkUpdateDayMatrixDates() 160void DateNavigatorContainer::checkUpdateDayMatrixDates()
161{ 161{
162 //qDebug("KODNC: wid %d hei %d ", width(), height()); 162 //qDebug("KODNC: wid %d hei %d ", width(), height());
163 mUpdateTimer->stop(); 163 mUpdateTimer->stop();
164 //return; 164 //return;
165 if ( width() < 3 || height() < 3 ) 165 if ( width() < 3 || height() < 3 )
166 return; 166 return;
167 static int lastWid = 0; 167 static int lastWid = 0;
168 static int lastHei = 0; 168 static int lastHei = 0;
169 if ( lastWid == width() && height() == lastHei ) { 169 if ( lastWid == width() && height() == lastHei ) {
170 qDebug("KODNC: No layout computing needed. "); 170 qDebug("KODNC: No layout computing needed. ");
171 } else { 171 } else {
172 lastWid = width(); 172 lastWid = width();
173 lastHei = height(); 173 lastHei = height();
174 174
175 QSize minSize = mNavigatorView->yourSizeHint(); 175 QSize minSize = mNavigatorView->yourSizeHint();
176 176
177 int verticalCount = size().height() / minSize.height(); 177 int verticalCount = size().height() / minSize.height();
178 int horizontalCount = size().width() / minSize.width(); 178 int horizontalCount = size().width() / minSize.width();
179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
181 bool fontchange = false; 181 bool fontchange = false;
182 if ( horizontalCount == 1) 182 if ( horizontalCount == 1)
183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
184 QFont fo; 184 QFont fo;
185 if ( horizontalCount != mHorizontalCount || 185 if ( horizontalCount != mHorizontalCount ||
186 verticalCount != mVerticalCount ) { 186 verticalCount != mVerticalCount ) {
187 uint count = horizontalCount * verticalCount; 187 uint count = horizontalCount * verticalCount;
188 if ( count == 0 ) { 188 if ( count == 0 ) {
189 bool ok; 189 bool ok;
190 fo = mNavigatorView->yourFontHint( size() , &ok ); 190 fo = mNavigatorView->yourFontHint( size() , &ok );
191 //mNavigatorView->resize( size() ); 191 //mNavigatorView->resize( size() );
192 //if ( ! ok ) 192 //if ( ! ok )
193 // return; 193 // return;
194 int butt = 2; 194 int butt = 2;
195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
196 if ( horizontalCount <= 1 ) 196 if ( horizontalCount <= 1 )
197 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 197 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
198 else 198 else
199 minSize = mNavigatorView->sizeHintTwoButtons(); 199 minSize = mNavigatorView->sizeHintTwoButtons();
200 verticalCount = size().height() / minSize.height(); 200 verticalCount = size().height() / minSize.height();
201 horizontalCount = size().width() / minSize.width(); 201 horizontalCount = size().width() / minSize.width();
202 if ( horizontalCount == 0 ) 202 if ( horizontalCount == 0 )
203 horizontalCount = 1; 203 horizontalCount = 1;
204 if ( verticalCount == 0 ) 204 if ( verticalCount == 0 )
205 verticalCount = 1; 205 verticalCount = 1;
206 fontchange = true; 206 fontchange = true;
207 count = horizontalCount * verticalCount; 207 count = horizontalCount * verticalCount;
208 } 208 } else {
209 209 if ( mNavigatorView->fontChanged() ) {
210 fontchange = true;
211 fo = KOPrefs::instance()->mDateNavigatorFont;
212 mNavigatorView->changeFont( fo );
213 mNavigatorView->unsetFontChanged();
214 }
215 }
210 mLastDisplayedDN = horizontalCount*verticalCount-1; 216 mLastDisplayedDN = horizontalCount*verticalCount-1;
211 while ( count > ( mExtraViews.count() + 1 ) ) { 217 while ( count > ( mExtraViews.count() + 1 ) ) {
212 KDateNavigator *n = new KDateNavigator( this ); 218 KDateNavigator *n = new KDateNavigator( this );
213 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 219 n->setMonthSignalOffset ( mExtraViews.count()+1 );
214 mExtraViews.append( n ); 220 mExtraViews.append( n );
215 n->setCalendar( mCalendar ); 221 n->setCalendar( mCalendar );
216 connectNavigatorView( n ); 222 connectNavigatorView( n );
217 // n->show(); 223 // n->show();
218 } 224 }
219 225
220 setBaseDates(); 226 setBaseDates();
227 if ( fontchange ) {
228 //mNavigatorView->changeFont( fo );
229 uint i;
230 for( i = 0; i < mExtraViews.count(); ++i ) {
231 KDateNavigator *view = mExtraViews.at( i );
232 view->changeFont( fo );
233 }
234 }
221 mHorizontalCount = horizontalCount; 235 mHorizontalCount = horizontalCount;
222 mVerticalCount = verticalCount; 236 mVerticalCount = verticalCount;
223 237
224 } 238 }
225 if ( !fontchange ) { 239 if ( mNavigatorView->fontChanged() && ! fontchange ) {
226 if ( mNavigatorView->fontChanged() ) { 240 qDebug("KDNC: Resetting all fonts ");
227 fontchange = true; 241 fo = KOPrefs::instance()->mDateNavigatorFont;
228 fo = KOPrefs::instance()->mDateNavigatorFont; 242 mNavigatorView->changeFont( fo );
229 mNavigatorView->changeFont( fo ); 243 mNavigatorView->unsetFontChanged();
230 mNavigatorView->unsetFontChanged();
231 }
232 }
233 if ( fontchange ) {
234 uint i; 244 uint i;
235 for( i = 0; i < mLastDisplayedDN; ++i ) { 245 for( i = 0; i < mExtraViews.count(); ++i ) {
236 KDateNavigator *view = mExtraViews.at( i ); 246 KDateNavigator *view = mExtraViews.at( i );
237 view->changeFont( fo ); 247 view->changeFont( fo );
238 } 248 }
239 } 249 }
240 int theight = height() / mVerticalCount; 250 int theight = height() / mVerticalCount;
241 int twidth = width() / mHorizontalCount; 251 int twidth = width() / mHorizontalCount;
242 252
243 NavigatorBar *bar = mNavigatorView->navigatorBar(); 253 NavigatorBar *bar = mNavigatorView->navigatorBar();
244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 254 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
245 else bar->showButtons( true, true ); 255 else bar->showButtons( true, true );
246 256
247 mNavigatorView->setGeometry(0, 257 mNavigatorView->setGeometry(0,
248 0, twidth, theight ); 258 0, twidth, theight );
249 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 259 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
250 int x = ( i + 1 ) % mHorizontalCount; 260 int x = ( i + 1 ) % mHorizontalCount;
251 int y = ( i + 1 ) / mHorizontalCount; 261 int y = ( i + 1 ) / mHorizontalCount;
252 262
253 KDateNavigator *view = mExtraViews.at( i ); 263 KDateNavigator *view = mExtraViews.at( i );
254 bar = view->navigatorBar(); 264 bar = view->navigatorBar();
255 if ( y > 0 ) bar->showButtons( false, false ); 265 if ( y > 0 ) bar->showButtons( false, false );
256 else { 266 else {
257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 267 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
258 else bar->showButtons( false, false ); 268 else bar->showButtons( false, false );
259 } 269 }