Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 27ba9e0..f6f62a4 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -160,130 +160,128 @@ void DateNavigatorContainer::setCalendar( Calendar *cal ) | |||
160 | void DateNavigatorContainer::checkUpdateDayMatrixDates() | 160 | void 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 | } else { | 208 | } |
209 | if ( mNavigatorView->fontChanged() ) { | 209 | |
210 | fontchange = true; | ||
211 | fo = KOPrefs::instance()->mDateNavigatorFont; | ||
212 | mNavigatorView->changeFont( fo ); | ||
213 | mNavigatorView->unsetFontChanged(); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | mLastDisplayedDN = horizontalCount*verticalCount-1; | 210 | mLastDisplayedDN = horizontalCount*verticalCount-1; |
218 | while ( count > ( mExtraViews.count() + 1 ) ) { | 211 | while ( count > ( mExtraViews.count() + 1 ) ) { |
219 | KDateNavigator *n = new KDateNavigator( this ); | 212 | KDateNavigator *n = new KDateNavigator( this ); |
220 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 213 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
221 | mExtraViews.append( n ); | 214 | mExtraViews.append( n ); |
222 | n->setCalendar( mCalendar ); | 215 | n->setCalendar( mCalendar ); |
223 | connectNavigatorView( n ); | 216 | connectNavigatorView( n ); |
224 | // n->show(); | 217 | // n->show(); |
225 | } | 218 | } |
226 | 219 | ||
227 | |||
228 | setBaseDates(); | 220 | setBaseDates(); |
229 | if ( fontchange ) { | ||
230 | //mNavigatorView->changeFont( fo ); | ||
231 | uint i; | ||
232 | for( i = 0; i < mExtraViews.count(); ++i ) { | ||
233 | KDateNavigator *view = mExtraViews.at( i ); | ||
234 | view->changeFont( fo ); | ||
235 | } | ||
236 | } | ||
237 | mHorizontalCount = horizontalCount; | 221 | mHorizontalCount = horizontalCount; |
238 | mVerticalCount = verticalCount; | 222 | mVerticalCount = verticalCount; |
239 | 223 | ||
240 | } | 224 | } |
241 | 225 | if ( !fontchange ) { | |
226 | if ( mNavigatorView->fontChanged() ) { | ||
227 | fontchange = true; | ||
228 | fo = KOPrefs::instance()->mDateNavigatorFont; | ||
229 | mNavigatorView->changeFont( fo ); | ||
230 | mNavigatorView->unsetFontChanged(); | ||
231 | } | ||
232 | } | ||
233 | if ( fontchange ) { | ||
234 | uint i; | ||
235 | for( i = 0; i < mLastDisplayedDN; ++i ) { | ||
236 | KDateNavigator *view = mExtraViews.at( i ); | ||
237 | view->changeFont( fo ); | ||
238 | } | ||
239 | } | ||
242 | int theight = height() / mVerticalCount; | 240 | int theight = height() / mVerticalCount; |
243 | int twidth = width() / mHorizontalCount; | 241 | int twidth = width() / mHorizontalCount; |
244 | 242 | ||
245 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 243 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
246 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); | 244 | if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); |
247 | else bar->showButtons( true, true ); | 245 | else bar->showButtons( true, true ); |
248 | 246 | ||
249 | mNavigatorView->setGeometry(0, | 247 | mNavigatorView->setGeometry(0, |
250 | 0, twidth, theight ); | 248 | 0, twidth, theight ); |
251 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { | 249 | for( uint i = 0; i < mLastDisplayedDN; ++i ) { |
252 | int x = ( i + 1 ) % mHorizontalCount; | 250 | int x = ( i + 1 ) % mHorizontalCount; |
253 | int y = ( i + 1 ) / mHorizontalCount; | 251 | int y = ( i + 1 ) / mHorizontalCount; |
254 | 252 | ||
255 | KDateNavigator *view = mExtraViews.at( i ); | 253 | KDateNavigator *view = mExtraViews.at( i ); |
256 | bar = view->navigatorBar(); | 254 | bar = view->navigatorBar(); |
257 | if ( y > 0 ) bar->showButtons( false, false ); | 255 | if ( y > 0 ) bar->showButtons( false, false ); |
258 | else { | 256 | else { |
259 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); | 257 | if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); |
260 | else bar->showButtons( false, false ); | 258 | else bar->showButtons( false, false ); |
261 | } | 259 | } |
262 | view->setGeometry( x * twidth, | 260 | view->setGeometry( x * twidth, |
263 | y * theight, twidth, theight ); | 261 | y * theight, twidth, theight ); |
264 | } | 262 | } |
265 | int iii = 0; | 263 | int iii = 0; |
266 | int ccc = mHorizontalCount * mVerticalCount; | 264 | int ccc = mHorizontalCount * mVerticalCount; |
267 | mNavigatorView->show(); | 265 | mNavigatorView->show(); |
268 | while ( iii < ( mExtraViews.count() ) ) { | 266 | while ( iii < ( mExtraViews.count() ) ) { |
269 | if ( iii < ccc-1 ) | 267 | if ( iii < ccc-1 ) |
270 | mExtraViews.at( iii )->show(); | 268 | mExtraViews.at( iii )->show(); |
271 | else | 269 | else |
272 | mExtraViews.at( iii )->hide(); | 270 | mExtraViews.at( iii )->hide(); |
273 | ++iii; | 271 | ++iii; |
274 | } | 272 | } |
275 | } | 273 | } |
276 | 274 | ||
277 | QDate last = lastAvailableDate(); | 275 | QDate last = lastAvailableDate(); |
278 | QDate first = firstAvailableDate(); | 276 | QDate first = firstAvailableDate(); |
279 | 277 | ||
280 | QDate selFirst = mFirstSelectedDate; | 278 | QDate selFirst = mFirstSelectedDate; |
281 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 279 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
282 | if ( selFirst >= first && selLast <= last ) { | 280 | if ( selFirst >= first && selLast <= last ) { |
283 | updateDayMatrixDates(); | 281 | updateDayMatrixDates(); |
284 | } | 282 | } |
285 | else { | 283 | else { |
286 | updateDayMatrixDates(); | 284 | updateDayMatrixDates(); |
287 | emit monthSelected( mFirstSelectedDate.month() ); | 285 | emit monthSelected( mFirstSelectedDate.month() ); |
288 | } | 286 | } |
289 | } | 287 | } |