author | zautrix <zautrix> | 2005-03-30 13:46:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-30 13:46:29 (UTC) |
commit | 8c160d7aeeab1d22382ced11440712f6541a6db7 (patch) (unidiff) | |
tree | 83fd0df6d30db6bbb05d82dc400d6f51823f5b3a | |
parent | 056f171723a9301aea5a65340dffeda34e078abf (diff) | |
download | kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.zip kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.gz kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.bz2 |
fixes
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 36 |
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 | |||
@@ -119,165 +119,175 @@ void DateNavigatorContainer::slotMonthSelected( int month ) | |||
119 | } | 119 | } |
120 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) | 120 | void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) |
121 | { | 121 | { |
122 | //qDebug("slotMonthSelected %d ", month); | 122 | //qDebug("slotMonthSelected %d ", month); |
123 | QDate baseDate = mNavigatorView->baseDate(); | 123 | QDate baseDate = mNavigatorView->baseDate(); |
124 | if ( baseDate.month() == month ) | 124 | if ( baseDate.month() == month ) |
125 | return; | 125 | return; |
126 | //qDebug("month %d %d ",baseDate.month(),month); | 126 | //qDebug("month %d %d ",baseDate.month(),month); |
127 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); | 127 | QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); |
128 | date = date.addDays( -(baseDate.month()-month ) *30 ); | 128 | date = date.addDays( -(baseDate.month()-month ) *30 ); |
129 | QDate newBase = QDate ( date.year(), date.month() ,1 ); | 129 | QDate newBase = QDate ( date.year(), date.month() ,1 ); |
130 | 130 | ||
131 | //qDebug("NEW BASE %s", newBase.toString().latin1()); | 131 | //qDebug("NEW BASE %s", newBase.toString().latin1()); |
132 | mNavigatorView->setBaseDate( newBase ); | 132 | mNavigatorView->setBaseDate( newBase ); |
133 | QDate last = lastAvailableDate(); | 133 | QDate last = lastAvailableDate(); |
134 | QDate first = firstAvailableDate(); | 134 | QDate first = firstAvailableDate(); |
135 | 135 | ||
136 | QDate selFirst = mFirstSelectedDate; | 136 | QDate selFirst = mFirstSelectedDate; |
137 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 137 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
138 | if ( selFirst >= first && selLast <= last ) { | 138 | if ( selFirst >= first && selLast <= last ) { |
139 | setBaseDates(); | 139 | setBaseDates(); |
140 | if ( forceEmit ) | 140 | if ( forceEmit ) |
141 | updateDayMatrixDates(); | 141 | updateDayMatrixDates(); |
142 | } | 142 | } |
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 | } |
151 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 151 | void 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 | } |
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 | } | 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 | } |
260 | view->setGeometry( x * twidth, | 270 | view->setGeometry( x * twidth, |
261 | y * theight, twidth, theight ); | 271 | y * theight, twidth, theight ); |
262 | } | 272 | } |
263 | int iii = 0; | 273 | int iii = 0; |
264 | int ccc = mHorizontalCount * mVerticalCount; | 274 | int ccc = mHorizontalCount * mVerticalCount; |
265 | mNavigatorView->show(); | 275 | mNavigatorView->show(); |
266 | while ( iii < ( mExtraViews.count() ) ) { | 276 | while ( iii < ( mExtraViews.count() ) ) { |
267 | if ( iii < ccc-1 ) | 277 | if ( iii < ccc-1 ) |
268 | mExtraViews.at( iii )->show(); | 278 | mExtraViews.at( iii )->show(); |
269 | else | 279 | else |
270 | mExtraViews.at( iii )->hide(); | 280 | mExtraViews.at( iii )->hide(); |
271 | ++iii; | 281 | ++iii; |
272 | } | 282 | } |
273 | } | 283 | } |
274 | 284 | ||
275 | QDate last = lastAvailableDate(); | 285 | QDate last = lastAvailableDate(); |
276 | QDate first = firstAvailableDate(); | 286 | QDate first = firstAvailableDate(); |
277 | 287 | ||
278 | QDate selFirst = mFirstSelectedDate; | 288 | QDate selFirst = mFirstSelectedDate; |
279 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); | 289 | QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); |
280 | if ( selFirst >= first && selLast <= last ) { | 290 | if ( selFirst >= first && selLast <= last ) { |
281 | updateDayMatrixDates(); | 291 | updateDayMatrixDates(); |
282 | } | 292 | } |
283 | else { | 293 | else { |