summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Unidiff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index f9c8b73..ea510f1 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -39,25 +39,24 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
39 const char *name ) 39 const char *name )
40 : QWidget( parent, name ), mCalendar( 0 ), 40 : QWidget( parent, name ), mCalendar( 0 ),
41 mHorizontalCount( 1 ), mVerticalCount( 1 ) 41 mHorizontalCount( 1 ), mVerticalCount( 1 )
42{ 42{
43 mResizeEnabled = false; 43 mResizeEnabled = false;
44 mExtraViews.setAutoDelete( true ); 44 mExtraViews.setAutoDelete( true );
45 45
46 mNavigatorView = new KDateNavigator( this, name ); 46 mNavigatorView = new KDateNavigator( this, name );
47 mNavigatorView->hide(); 47 mNavigatorView->hide();
48 connectNavigatorView( mNavigatorView ); 48 connectNavigatorView( mNavigatorView );
49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 49 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
50 mLastDisplayedDN = 0; 50 mLastDisplayedDN = 0;
51 mUpdateTimer;
52 mUpdateTimer = new QTimer( this ); 51 mUpdateTimer = new QTimer( this );
53 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); 52 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
54 mFirstSelectedDate = QDate::currentDate(); 53 mFirstSelectedDate = QDate::currentDate();
55 mSelectedDateCount = 1; 54 mSelectedDateCount = 1;
56} 55}
57 56
58DateNavigatorContainer::~DateNavigatorContainer() 57DateNavigatorContainer::~DateNavigatorContainer()
59{ 58{
60} 59}
61 60
62void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) 61void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
63{ 62{
@@ -142,25 +141,25 @@ void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
142 else { 141 else {
143 setBaseDates(); 142 setBaseDates();
144 if ( forceEmit ) 143 if ( forceEmit )
145 updateDayMatrixDates(); 144 updateDayMatrixDates();
146 if ( forceEmit ) 145 if ( forceEmit )
147 emit monthSelected( month ); 146 emit monthSelected( month );
148 } 147 }
149} 148}
150void DateNavigatorContainer::setCalendar( Calendar *cal ) 149void DateNavigatorContainer::setCalendar( Calendar *cal )
151{ 150{
152 mCalendar = cal; 151 mCalendar = cal;
153 mNavigatorView->setCalendar( cal ); 152 mNavigatorView->setCalendar( cal );
154 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 153 for( int i = 0; i < mLastDisplayedDN; ++i ) {
155 KDateNavigator *n = mExtraViews.at( i ); 154 KDateNavigator *n = mExtraViews.at( i );
156 n->setCalendar( cal ); 155 n->setCalendar( cal );
157 } 156 }
158} 157}
159void DateNavigatorContainer::checkUpdateDayMatrixDates() 158void DateNavigatorContainer::checkUpdateDayMatrixDates()
160{ 159{
161 //qDebug("KODNC: wid %d hei %d ", width(), height()); 160 //qDebug("KODNC: wid %d hei %d ", width(), height());
162 mUpdateTimer->stop(); 161 mUpdateTimer->stop();
163 //return; 162 //return;
164 if ( width() < 3 || height() < 3 ) 163 if ( width() < 3 || height() < 3 )
165 return; 164 return;
166 static int lastWid = 0; 165 static int lastWid = 0;
@@ -181,25 +180,24 @@ void DateNavigatorContainer::checkUpdateDayMatrixDates()
181 if ( horizontalCount == 1) 180 if ( horizontalCount == 1)
182 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 181 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
183 QFont fo; 182 QFont fo;
184 if ( horizontalCount != mHorizontalCount || 183 if ( horizontalCount != mHorizontalCount ||
185 verticalCount != mVerticalCount ) { 184 verticalCount != mVerticalCount ) {
186 uint count = horizontalCount * verticalCount; 185 uint count = horizontalCount * verticalCount;
187 if ( count == 0 ) { 186 if ( count == 0 ) {
188 bool ok; 187 bool ok;
189 fo = mNavigatorView->yourFontHint( size() , &ok ); 188 fo = mNavigatorView->yourFontHint( size() , &ok );
190 //mNavigatorView->resize( size() ); 189 //mNavigatorView->resize( size() );
191 //if ( ! ok ) 190 //if ( ! ok )
192 // return; 191 // return;
193 int butt = 2;
194 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 192 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
195 if ( horizontalCount <= 1 ) 193 if ( horizontalCount <= 1 )
196 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 194 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
197 else 195 else
198 minSize = mNavigatorView->sizeHintTwoButtons(); 196 minSize = mNavigatorView->sizeHintTwoButtons();
199 verticalCount = size().height() / minSize.height(); 197 verticalCount = size().height() / minSize.height();
200 horizontalCount = size().width() / minSize.width(); 198 horizontalCount = size().width() / minSize.width();
201 if ( horizontalCount == 0 ) 199 if ( horizontalCount == 0 )
202 horizontalCount = 1; 200 horizontalCount = 1;
203 if ( verticalCount == 0 ) 201 if ( verticalCount == 0 )
204 verticalCount = 1; 202 verticalCount = 1;
205 fontchange = true; 203 fontchange = true;
@@ -246,40 +244,40 @@ void DateNavigatorContainer::checkUpdateDayMatrixDates()
246 view->changeFont( fo ); 244 view->changeFont( fo );
247 } 245 }
248 } 246 }
249 int theight = height() / mVerticalCount; 247 int theight = height() / mVerticalCount;
250 int twidth = width() / mHorizontalCount; 248 int twidth = width() / mHorizontalCount;
251 249
252 NavigatorBar *bar = mNavigatorView->navigatorBar(); 250 NavigatorBar *bar = mNavigatorView->navigatorBar();
253 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 251 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
254 else bar->showButtons( true, true ); 252 else bar->showButtons( true, true );
255 253
256 mNavigatorView->setGeometry(0, 254 mNavigatorView->setGeometry(0,
257 0, twidth, theight ); 255 0, twidth, theight );
258 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 256 for( int i = 0; i < mLastDisplayedDN; ++i ) {
259 int x = ( i + 1 ) % mHorizontalCount; 257 int x = ( i + 1 ) % mHorizontalCount;
260 int y = ( i + 1 ) / mHorizontalCount; 258 int y = ( i + 1 ) / mHorizontalCount;
261 259
262 KDateNavigator *view = mExtraViews.at( i ); 260 KDateNavigator *view = mExtraViews.at( i );
263 bar = view->navigatorBar(); 261 bar = view->navigatorBar();
264 if ( y > 0 ) bar->showButtons( false, false ); 262 if ( y > 0 ) bar->showButtons( false, false );
265 else { 263 else {
266 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 264 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
267 else bar->showButtons( false, false ); 265 else bar->showButtons( false, false );
268 } 266 }
269 view->setGeometry( x * twidth, 267 view->setGeometry( x * twidth,
270 y * theight, twidth, theight ); 268 y * theight, twidth, theight );
271 } 269 }
272 int iii = 0; 270 uint iii = 0;
273 int ccc = mHorizontalCount * mVerticalCount; 271 uint ccc = mHorizontalCount * mVerticalCount;
274 mNavigatorView->show(); 272 mNavigatorView->show();
275 while ( iii < ( mExtraViews.count() ) ) { 273 while ( iii < ( mExtraViews.count() ) ) {
276 if ( iii < ccc-1 ) 274 if ( iii < ccc-1 )
277 mExtraViews.at( iii )->show(); 275 mExtraViews.at( iii )->show();
278 else 276 else
279 mExtraViews.at( iii )->hide(); 277 mExtraViews.at( iii )->hide();
280 ++iii; 278 ++iii;
281 } 279 }
282 } 280 }
283 281
284 QDate last = lastAvailableDate(); 282 QDate last = lastAvailableDate();
285 QDate first = firstAvailableDate(); 283 QDate first = firstAvailableDate();
@@ -291,66 +289,66 @@ void DateNavigatorContainer::checkUpdateDayMatrixDates()
291 } 289 }
292 else { 290 else {
293 updateDayMatrixDates(); 291 updateDayMatrixDates();
294 emit monthSelected( mFirstSelectedDate.month() ); 292 emit monthSelected( mFirstSelectedDate.month() );
295 } 293 }
296} 294}
297void DateNavigatorContainer::updateDayMatrixDates() 295void DateNavigatorContainer::updateDayMatrixDates()
298{ 296{
299 QDate fDate = mFirstSelectedDate; 297 QDate fDate = mFirstSelectedDate;
300 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 298 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
301 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 299 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
302 mNavigatorView->dayMatrix()->repaint( false ); 300 mNavigatorView->dayMatrix()->repaint( false );
303 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 301 for( int i = 0; i < mLastDisplayedDN; ++i ) {
304 KDateNavigator *n = mExtraViews.at( i ); 302 KDateNavigator *n = mExtraViews.at( i );
305 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 303 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
306 n->dayMatrix()->repaint( false ); 304 n->dayMatrix()->repaint( false );
307 } 305 }
308 } 306 }
309} 307}
310 308
311void DateNavigatorContainer::updateDayMatrix() 309void DateNavigatorContainer::updateDayMatrix()
312{ 310{
313 mNavigatorView->updateDayMatrix(); 311 mNavigatorView->updateDayMatrix();
314 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 312 for( int i = 0; i < mLastDisplayedDN; ++i ) {
315 KDateNavigator *n = mExtraViews.at( i ); 313 KDateNavigator *n = mExtraViews.at( i );
316 n->updateDayMatrix(); 314 n->updateDayMatrix();
317 } 315 }
318} 316}
319 317
320void DateNavigatorContainer::updateToday() 318void DateNavigatorContainer::updateToday()
321{ 319{
322 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 320 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
323#if 0 321#if 0
324 mNavigatorView->updateToday(); 322 mNavigatorView->updateToday();
325 KDateNavigator *n; 323 KDateNavigator *n;
326 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 324 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
327 n->updateToday(); 325 n->updateToday();
328 } 326 }
329#endif 327#endif
330} 328}
331 329
332void DateNavigatorContainer::updateView() 330void DateNavigatorContainer::updateView()
333{ 331{
334 mNavigatorView->updateView(); 332 mNavigatorView->updateView();
335 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 333 for( int i = 0; i < mLastDisplayedDN; ++i ) {
336 KDateNavigator *n = mExtraViews.at( i ); 334 KDateNavigator *n = mExtraViews.at( i );
337 n->updateView(); 335 n->updateView();
338 } 336 }
339} 337}
340 338
341void DateNavigatorContainer::updateConfig() 339void DateNavigatorContainer::updateConfig()
342{ 340{
343 mNavigatorView->updateConfig(); 341 mNavigatorView->updateConfig();
344 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 342 for( int i = 0; i < mLastDisplayedDN; ++i ) {
345 KDateNavigator *n = mExtraViews.at( i ); 343 KDateNavigator *n = mExtraViews.at( i );
346 n->updateConfig(); 344 n->updateConfig();
347 } 345 }
348} 346}
349QDate DateNavigatorContainer::lastAvailableDate() const 347QDate DateNavigatorContainer::lastAvailableDate() const
350{ 348{
351 QDate date = mNavigatorView->baseDate(); 349 QDate date = mNavigatorView->baseDate();
352 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() ); 350 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
353 int iii = mLastDisplayedDN; 351 int iii = mLastDisplayedDN;
354 if ( mLastDisplayedDN ) 352 if ( mLastDisplayedDN )
355 last = last.addDays( 1); 353 last = last.addDays( 1);
356 while ( iii ) { 354 while ( iii ) {
@@ -391,37 +389,37 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
391 if ( mLastDisplayedDN > 1 ) { 389 if ( mLastDisplayedDN > 1 ) {
392 KDateNavigator *view = mExtraViews.at( 1 ); 390 KDateNavigator *view = mExtraViews.at( 1 );
393 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 391 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
394 view->dayMatrix()->repaint( false ); 392 view->dayMatrix()->repaint( false );
395 } 393 }
396 } 394 }
397} 395}
398 396
399void DateNavigatorContainer::setBaseDates() 397void DateNavigatorContainer::setBaseDates()
400{ 398{
401 QDate baseDate = mNavigatorView->baseDate(); 399 QDate baseDate = mNavigatorView->baseDate();
402 bool doRepaint = true; 400 bool doRepaint = true;
403 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 401 for( int i = 0; i < mLastDisplayedDN; ++i ) {
404 KDateNavigator *n = mExtraViews.at( i ); 402 KDateNavigator *n = mExtraViews.at( i );
405 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 403 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
406 n->setBaseDate( baseDate, doRepaint ); 404 n->setBaseDate( baseDate, doRepaint );
407 } 405 }
408} 406}
409void DateNavigatorContainer::setResizeEnabled() 407void DateNavigatorContainer::setResizeEnabled()
410{ 408{
411 mResizeEnabled = true; 409 mResizeEnabled = true;
412 //qDebug("DateNavigatorContainer::setResizeEnabled "); 410 //qDebug("DateNavigatorContainer::setResizeEnabled ");
413 checkUpdateDayMatrixDates(); 411 checkUpdateDayMatrixDates();
414} 412}
415void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) 413void DateNavigatorContainer::resizeEvent( QResizeEvent * )
416{ 414{
417 415
418 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height()); 416 //qDebug("DateNavigatorContainer::resizeEvent %d %d ", width(), height());
419 //qDebug("COUNT %d ", mExtraViews.count()); 417 //qDebug("COUNT %d ", mExtraViews.count());
420 if ( ! mResizeEnabled ) { 418 if ( ! mResizeEnabled ) {
421 //qDebug("NOT ResizeEnabled"); 419 //qDebug("NOT ResizeEnabled");
422 return; 420 return;
423 } 421 }
424 else 422 else
425#ifdef DESKTOP_VERSION 423#ifdef DESKTOP_VERSION
426 mUpdateTimer->start( 100 ); 424 mUpdateTimer->start( 100 );
427#else 425#else