summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-23 00:25:21 (UTC)
committer zautrix <zautrix>2005-03-23 00:25:21 (UTC)
commitf9ea17deecf671a897ff594a8050e6f4728698b6 (patch) (unidiff)
tree11dc1facc1140f5a58351418d98ca135f9683d12
parentaa6d19015bc91ae3af021d766d37a473e125278f (diff)
downloadkdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.zip
kdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.tar.gz
kdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.tar.bz2
lf
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp224
1 files changed, 116 insertions, 108 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index ba97fa6..548c364 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -110,81 +110,192 @@ void DateNavigatorContainer::slotMonthSelected( int month )
110 } 110 }
111 } 111 }
112 return; 112 return;
113 } 113 }
114#endif 114#endif
115 //qDebug("NEW BASE %s", newBase.toString().latin1()); 115 //qDebug("NEW BASE %s", newBase.toString().latin1());
116 mNavigatorView->setBaseDate( newBase ); 116 mNavigatorView->setBaseDate( newBase );
117 QDate last = lastAvailableDate(); 117 QDate last = lastAvailableDate();
118 QDate first = firstAvailableDate(); 118 QDate first = firstAvailableDate();
119 119
120 QDate selFirst = mFirstSelectedDate; 120 QDate selFirst = mFirstSelectedDate;
121 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 121 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
122 if ( selFirst >= first && selLast <= last ) { 122 if ( selFirst >= first && selLast <= last ) {
123 setBaseDates(); 123 setBaseDates();
124 updateDayMatrixDates(); 124 updateDayMatrixDates();
125 } 125 }
126 else { 126 else {
127 setBaseDates(); 127 setBaseDates();
128 updateDayMatrixDates(); 128 updateDayMatrixDates();
129 emit monthSelected( month ); 129 emit monthSelected( month );
130 } 130 }
131} 131}
132void DateNavigatorContainer::setCalendar( Calendar *cal ) 132void DateNavigatorContainer::setCalendar( Calendar *cal )
133{ 133{
134 mCalendar = cal; 134 mCalendar = cal;
135 mNavigatorView->setCalendar( cal ); 135 mNavigatorView->setCalendar( cal );
136 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 136 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
137 KDateNavigator *n = mExtraViews.at( i ); 137 KDateNavigator *n = mExtraViews.at( i );
138 n->setCalendar( cal ); 138 n->setCalendar( cal );
139 } 139 }
140} 140}
141void DateNavigatorContainer::checkUpdateDayMatrixDates() 141void DateNavigatorContainer::checkUpdateDayMatrixDates()
142{ 142{
143 qDebug("wid %d hei %d ", width(), height());
144 mUpdateTimer->stop();
145 //return;
146 if ( width() < 3 || height() < 3 )
147 return;
148 static int lastWid = 0;
149 static int lastHei = 0;
150 if ( lastWid == width() && height() == lastHei ) {
151 qDebug("no layout computing needed. ");
152 } else {
153 lastWid = width();
154 lastHei = height();
155
156 QSize minSize = mNavigatorView->yourSizeHint();
157
158 int verticalCount = size().height() / minSize.height();
159 int horizontalCount = size().width() / minSize.width();
160 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
161 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
162 bool fontchange = false;
163 if ( horizontalCount == 1)
164 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
165 QFont fo;
166 if ( horizontalCount != mHorizontalCount ||
167 verticalCount != mVerticalCount ) {
168 uint count = horizontalCount * verticalCount;
169 if ( count == 0 ) {
170 bool ok;
171 fo = mNavigatorView->yourFontHint( size() , &ok );
172 //mNavigatorView->resize( size() );
173 //if ( ! ok )
174 // return;
175 int butt = 2;
176 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
177 if ( horizontalCount <= 1 )
178 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
179 else
180 minSize = mNavigatorView->sizeHintTwoButtons();
181 verticalCount = size().height() / minSize.height();
182 horizontalCount = size().width() / minSize.width();
183 if ( horizontalCount == 0 )
184 horizontalCount = 1;
185 if ( verticalCount == 0 )
186 verticalCount = 1;
187 fontchange = true;
188 count = horizontalCount * verticalCount;
189 } else {
190 if ( mNavigatorView->fontChanged() ) {
191 fontchange = true;
192 fo = KOPrefs::instance()->mDateNavigatorFont;
193 mNavigatorView->changeFont( fo );
194 mNavigatorView->unsetFontChanged();
195 }
196 }
197
198 mLastDisplayedDN = horizontalCount*verticalCount-1;
199 while ( count > ( mExtraViews.count() + 1 ) ) {
200 KDateNavigator *n = new KDateNavigator( this );
201 n->setMonthSignalOffset ( mExtraViews.count()+1 );
202 mExtraViews.append( n );
203 n->setCalendar( mCalendar );
204 connectNavigatorView( n );
205 n->show();
206 }
207 int iii = 0;
208 while ( iii < ( mExtraViews.count() ) ) {
209 if ( iii < count-1 )
210 mExtraViews.at( iii )->show();
211 else
212 mExtraViews.at( iii )->hide();
213 ++iii;
214 }
215
216 setBaseDates();
217 if ( fontchange ) {
218 //mNavigatorView->changeFont( fo );
219 uint i;
220 for( i = 0; i < mExtraViews.count(); ++i ) {
221 KDateNavigator *view = mExtraViews.at( i );
222 view->changeFont( fo );
223 }
224 }
225 mHorizontalCount = horizontalCount;
226 mVerticalCount = verticalCount;
227
228 }
229
230 int theight = height() / mVerticalCount;
231 int twidth = width() / mHorizontalCount;
232
233 NavigatorBar *bar = mNavigatorView->navigatorBar();
234 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
235 else bar->showButtons( true, true );
236
237 mNavigatorView->setGeometry(0,
238 0, twidth, theight );
239 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
240 int x = ( i + 1 ) % mHorizontalCount;
241 int y = ( i + 1 ) / mHorizontalCount;
242
243 KDateNavigator *view = mExtraViews.at( i );
244 bar = view->navigatorBar();
245 if ( y > 0 ) bar->showButtons( false, false );
246 else {
247 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
248 else bar->showButtons( false, false );
249 }
250 view->setGeometry( x * twidth,
251 y * theight, twidth, theight );
252 }
253 }
254
143 QDate last = lastAvailableDate(); 255 QDate last = lastAvailableDate();
144 QDate first = firstAvailableDate(); 256 QDate first = firstAvailableDate();
145 257
146 QDate selFirst = mFirstSelectedDate; 258 QDate selFirst = mFirstSelectedDate;
147 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 259 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
148 if ( selFirst >= first && selLast <= last ) { 260 if ( selFirst >= first && selLast <= last ) {
149 updateDayMatrixDates(); 261 updateDayMatrixDates();
150 } 262 }
151 else { 263 else {
152 updateDayMatrixDates(); 264 updateDayMatrixDates();
153 emit monthSelected( mFirstSelectedDate.month() ); 265 emit monthSelected( mFirstSelectedDate.month() );
154 } 266 }
155} 267}
156void DateNavigatorContainer::updateDayMatrixDates() 268void DateNavigatorContainer::updateDayMatrixDates()
157{ 269{
158 mUpdateTimer->stop();
159 QDate fDate = mFirstSelectedDate; 270 QDate fDate = mFirstSelectedDate;
160 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 271 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
161 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 272 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
162 mNavigatorView->dayMatrix()->repaint( false ); 273 mNavigatorView->dayMatrix()->repaint( false );
163 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 274 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
164 KDateNavigator *n = mExtraViews.at( i ); 275 KDateNavigator *n = mExtraViews.at( i );
165 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 276 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
166 n->dayMatrix()->repaint( false ); 277 n->dayMatrix()->repaint( false );
167 } 278 }
168 } 279 }
169} 280}
170 281
171void DateNavigatorContainer::updateDayMatrix() 282void DateNavigatorContainer::updateDayMatrix()
172{ 283{
173 mNavigatorView->updateDayMatrix(); 284 mNavigatorView->updateDayMatrix();
174 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 285 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
175 KDateNavigator *n = mExtraViews.at( i ); 286 KDateNavigator *n = mExtraViews.at( i );
176 n->updateDayMatrix(); 287 n->updateDayMatrix();
177 } 288 }
178} 289}
179 290
180void DateNavigatorContainer::updateToday() 291void DateNavigatorContainer::updateToday()
181{ 292{
182 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 293 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
183#if 0 294#if 0
184 mNavigatorView->updateToday(); 295 mNavigatorView->updateToday();
185 KDateNavigator *n; 296 KDateNavigator *n;
186 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 297 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
187 n->updateToday(); 298 n->updateToday();
188 } 299 }
189#endif 300#endif
190} 301}
@@ -240,152 +351,49 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
240 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 351 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
241 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { 352 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
242 updateDayMatrixDates(); 353 updateDayMatrixDates();
243 return; 354 return;
244 } 355 }
245 mNavigatorView->selectDates( dateList ); 356 mNavigatorView->selectDates( dateList );
246 setBaseDates(); 357 setBaseDates();
247 if ( mLastDisplayedDN ) { 358 if ( mLastDisplayedDN ) {
248 KDateNavigator *view = mExtraViews.at( 0 ); 359 KDateNavigator *view = mExtraViews.at( 0 );
249 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 360 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
250 view->dayMatrix()->repaint( false ); 361 view->dayMatrix()->repaint( false );
251 if ( mLastDisplayedDN > 1 ) { 362 if ( mLastDisplayedDN > 1 ) {
252 KDateNavigator *view = mExtraViews.at( 1 ); 363 KDateNavigator *view = mExtraViews.at( 1 );
253 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 364 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
254 view->dayMatrix()->repaint( false ); 365 view->dayMatrix()->repaint( false );
255 } 366 }
256 } 367 }
257} 368}
258 369
259void DateNavigatorContainer::setBaseDates() 370void DateNavigatorContainer::setBaseDates()
260{ 371{
261 QDate baseDate = mNavigatorView->baseDate(); 372 QDate baseDate = mNavigatorView->baseDate();
262 bool doRepaint = true; 373 bool doRepaint = true;
263 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 374 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
264 KDateNavigator *n = mExtraViews.at( i ); 375 KDateNavigator *n = mExtraViews.at( i );
265 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 376 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
266 n->setBaseDate( baseDate, doRepaint ); 377 n->setBaseDate( baseDate, doRepaint );
267 } 378 }
268} 379}
269 380
270void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 381void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
271{ 382{
272#if 0
273 kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
274 kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
275 kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
276 kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
277 kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
278#endif
279 //QSize minSize = mNavigatorView->sizeHintTwoButtons();
280 QSize minSize = mNavigatorView->yourSizeHint();
281
282// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
283
284 int verticalCount = size().height() / minSize.height();
285 int horizontalCount = size().width() / minSize.width();
286 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
287 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
288 bool fontchange = false;
289 if ( horizontalCount == 1)
290 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
291 QFont fo;
292 if ( horizontalCount != mHorizontalCount ||
293 verticalCount != mVerticalCount ) {
294 uint count = horizontalCount * verticalCount;
295 if ( count == 0 ) {
296 bool ok;
297 fo = mNavigatorView->yourFontHint( size() , &ok );
298 //mNavigatorView->resize( size() );
299 //if ( ! ok )
300 // return;
301 int butt = 2;
302 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
303 if ( horizontalCount <= 1 )
304 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
305 else
306 minSize = mNavigatorView->sizeHintTwoButtons();
307 verticalCount = size().height() / minSize.height();
308 horizontalCount = size().width() / minSize.width();
309 if ( horizontalCount == 0 )
310 horizontalCount = 1;
311 if ( verticalCount == 0 )
312 verticalCount = 1;
313 fontchange = true;
314 count = horizontalCount * verticalCount;
315 } else {
316 if ( mNavigatorView->fontChanged() ) {
317 fontchange = true;
318 fo = KOPrefs::instance()->mDateNavigatorFont;
319 mNavigatorView->changeFont( fo );
320 mNavigatorView->unsetFontChanged();
321 }
322 }
323 383
324 mLastDisplayedDN = horizontalCount*verticalCount-1;
325 while ( count > ( mExtraViews.count() + 1 ) ) {
326 KDateNavigator *n = new KDateNavigator( this );
327 n->setMonthSignalOffset ( mExtraViews.count()+1 );
328 mExtraViews.append( n );
329 n->setCalendar( mCalendar );
330 connectNavigatorView( n );
331 n->show();
332 }
333 int iii = 0;
334 while ( iii < ( mExtraViews.count() ) ) {
335 if ( iii < count-1 )
336 mExtraViews.at( iii )->show();
337 else
338 mExtraViews.at( iii )->hide();
339 ++iii;
340 }
341
342 setBaseDates();
343 if ( fontchange ) {
344 //mNavigatorView->changeFont( fo );
345 uint i;
346 for( i = 0; i < mExtraViews.count(); ++i ) {
347 KDateNavigator *view = mExtraViews.at( i );
348 view->changeFont( fo );
349 }
350 }
351 mHorizontalCount = horizontalCount;
352 mVerticalCount = verticalCount;
353
354 }
355 //qDebug("COUNT %d ", mExtraViews.count());
356 int height = size().height() / verticalCount;
357 int width = size().width() / horizontalCount;
358
359 NavigatorBar *bar = mNavigatorView->navigatorBar();
360 if ( horizontalCount > 1 ) bar->showButtons( true, false );
361 else bar->showButtons( true, true );
362 384
363 mNavigatorView->setGeometry(0, 385 //qDebug("COUNT %d ", mExtraViews.count());
364 0, width, height ); 386
365 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 387 mUpdateTimer->start( 250 );
366 int x = ( i + 1 ) % horizontalCount;
367 int y = ( i + 1 ) / horizontalCount;
368
369 KDateNavigator *view = mExtraViews.at( i );
370 bar = view->navigatorBar();
371 if ( y > 0 ) bar->showButtons( false, false );
372 else {
373 if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
374 else bar->showButtons( false, false );
375 }
376 view->setGeometry( x * width,
377 y * height, width, height );
378 }
379 mUpdateTimer->start( 250 );
380 //updateDayMatrixDates(); 388 //updateDayMatrixDates();
381} 389}
382 390
383QSize DateNavigatorContainer::minimumSizeHint() const 391QSize DateNavigatorContainer::minimumSizeHint() const
384{ 392{
385 return mNavigatorView->minimumSizeHint(); 393 return mNavigatorView->minimumSizeHint();
386} 394}
387 395
388QSize DateNavigatorContainer::sizeHint() const 396QSize DateNavigatorContainer::sizeHint() const
389{ 397{
390 return mNavigatorView->yourSizeHint(); 398 return mNavigatorView->yourSizeHint();
391} 399}