author | zautrix <zautrix> | 2005-03-23 00:25:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-23 00:25:21 (UTC) |
commit | f9ea17deecf671a897ff594a8050e6f4728698b6 (patch) (side-by-side diff) | |
tree | 11dc1facc1140f5a58351418d98ca135f9683d12 /korganizer | |
parent | aa6d19015bc91ae3af021d766d37a473e125278f (diff) | |
download | kdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.zip kdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.tar.gz kdepimpi-f9ea17deecf671a897ff594a8050e6f4728698b6.tar.bz2 |
lf
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 224 |
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 @@ -138,9 +138,121 @@ void DateNavigatorContainer::setCalendar( Calendar *cal ) n->setCalendar( cal ); } } void DateNavigatorContainer::checkUpdateDayMatrixDates() -{ +{ + qDebug("wid %d hei %d ", width(), height()); + mUpdateTimer->stop(); + //return; + if ( width() < 3 || height() < 3 ) + return; + static int lastWid = 0; + static int lastHei = 0; + if ( lastWid == width() && height() == lastHei ) { + qDebug("no layout computing needed. "); + } else { + lastWid = width(); + lastHei = height(); + + QSize minSize = mNavigatorView->yourSizeHint(); + + int verticalCount = size().height() / minSize.height(); + int horizontalCount = size().width() / minSize.width(); + //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); + //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); + bool fontchange = false; + if ( horizontalCount == 1) + horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); + QFont fo; + if ( horizontalCount != mHorizontalCount || + verticalCount != mVerticalCount ) { + uint count = horizontalCount * verticalCount; + if ( count == 0 ) { + bool ok; + fo = mNavigatorView->yourFontHint( size() , &ok ); + //mNavigatorView->resize( size() ); + //if ( ! ok ) + // return; + int butt = 2; + horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); + if ( horizontalCount <= 1 ) + minSize = mNavigatorView->sizeHintTwoButtons( 4 ); + else + minSize = mNavigatorView->sizeHintTwoButtons(); + verticalCount = size().height() / minSize.height(); + horizontalCount = size().width() / minSize.width(); + if ( horizontalCount == 0 ) + horizontalCount = 1; + if ( verticalCount == 0 ) + verticalCount = 1; + fontchange = true; + count = horizontalCount * verticalCount; + } else { + if ( mNavigatorView->fontChanged() ) { + fontchange = true; + fo = KOPrefs::instance()->mDateNavigatorFont; + mNavigatorView->changeFont( fo ); + mNavigatorView->unsetFontChanged(); + } + } + + mLastDisplayedDN = horizontalCount*verticalCount-1; + while ( count > ( mExtraViews.count() + 1 ) ) { + KDateNavigator *n = new KDateNavigator( this ); + n->setMonthSignalOffset ( mExtraViews.count()+1 ); + mExtraViews.append( n ); + n->setCalendar( mCalendar ); + connectNavigatorView( n ); + n->show(); + } + int iii = 0; + while ( iii < ( mExtraViews.count() ) ) { + if ( iii < count-1 ) + mExtraViews.at( iii )->show(); + else + mExtraViews.at( iii )->hide(); + ++iii; + } + + setBaseDates(); + if ( fontchange ) { + //mNavigatorView->changeFont( fo ); + uint i; + for( i = 0; i < mExtraViews.count(); ++i ) { + KDateNavigator *view = mExtraViews.at( i ); + view->changeFont( fo ); + } + } + mHorizontalCount = horizontalCount; + mVerticalCount = verticalCount; + + } + + int theight = height() / mVerticalCount; + int twidth = width() / mHorizontalCount; + + NavigatorBar *bar = mNavigatorView->navigatorBar(); + if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); + else bar->showButtons( true, true ); + + mNavigatorView->setGeometry(0, + 0, twidth, theight ); + for( uint i = 0; i < mLastDisplayedDN; ++i ) { + int x = ( i + 1 ) % mHorizontalCount; + int y = ( i + 1 ) / mHorizontalCount; + + KDateNavigator *view = mExtraViews.at( i ); + bar = view->navigatorBar(); + if ( y > 0 ) bar->showButtons( false, false ); + else { + if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); + else bar->showButtons( false, false ); + } + view->setGeometry( x * twidth, + y * theight, twidth, theight ); + } + } + QDate last = lastAvailableDate(); QDate first = firstAvailableDate(); QDate selFirst = mFirstSelectedDate; @@ -154,9 +266,8 @@ void DateNavigatorContainer::checkUpdateDayMatrixDates() } } void DateNavigatorContainer::updateDayMatrixDates() { - mUpdateTimer->stop(); QDate fDate = mFirstSelectedDate; QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); mNavigatorView->dayMatrix()->repaint( false ); @@ -268,116 +379,13 @@ void DateNavigatorContainer::setBaseDates() } void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) { -#if 0 - kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; - kdDebug(5850) << " CURRENT SIZE: " << size() << endl; - kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; - kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; - kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; -#endif - //QSize minSize = mNavigatorView->sizeHintTwoButtons(); - QSize minSize = mNavigatorView->yourSizeHint(); - -// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; - - int verticalCount = size().height() / minSize.height(); - int horizontalCount = size().width() / minSize.width(); - //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); - //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); - bool fontchange = false; - if ( horizontalCount == 1) - horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); - QFont fo; - if ( horizontalCount != mHorizontalCount || - verticalCount != mVerticalCount ) { - uint count = horizontalCount * verticalCount; - if ( count == 0 ) { - bool ok; - fo = mNavigatorView->yourFontHint( size() , &ok ); - //mNavigatorView->resize( size() ); - //if ( ! ok ) - // return; - int butt = 2; - horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); - if ( horizontalCount <= 1 ) - minSize = mNavigatorView->sizeHintTwoButtons( 4 ); - else - minSize = mNavigatorView->sizeHintTwoButtons(); - verticalCount = size().height() / minSize.height(); - horizontalCount = size().width() / minSize.width(); - if ( horizontalCount == 0 ) - horizontalCount = 1; - if ( verticalCount == 0 ) - verticalCount = 1; - fontchange = true; - count = horizontalCount * verticalCount; - } else { - if ( mNavigatorView->fontChanged() ) { - fontchange = true; - fo = KOPrefs::instance()->mDateNavigatorFont; - mNavigatorView->changeFont( fo ); - mNavigatorView->unsetFontChanged(); - } - } - mLastDisplayedDN = horizontalCount*verticalCount-1; - while ( count > ( mExtraViews.count() + 1 ) ) { - KDateNavigator *n = new KDateNavigator( this ); - n->setMonthSignalOffset ( mExtraViews.count()+1 ); - mExtraViews.append( n ); - n->setCalendar( mCalendar ); - connectNavigatorView( n ); - n->show(); - } - int iii = 0; - while ( iii < ( mExtraViews.count() ) ) { - if ( iii < count-1 ) - mExtraViews.at( iii )->show(); - else - mExtraViews.at( iii )->hide(); - ++iii; - } - - setBaseDates(); - if ( fontchange ) { - //mNavigatorView->changeFont( fo ); - uint i; - for( i = 0; i < mExtraViews.count(); ++i ) { - KDateNavigator *view = mExtraViews.at( i ); - view->changeFont( fo ); - } - } - mHorizontalCount = horizontalCount; - mVerticalCount = verticalCount; - - } - //qDebug("COUNT %d ", mExtraViews.count()); - int height = size().height() / verticalCount; - int width = size().width() / horizontalCount; - - NavigatorBar *bar = mNavigatorView->navigatorBar(); - if ( horizontalCount > 1 ) bar->showButtons( true, false ); - else bar->showButtons( true, true ); - mNavigatorView->setGeometry(0, - 0, width, height ); - for( uint i = 0; i < mLastDisplayedDN; ++i ) { - int x = ( i + 1 ) % horizontalCount; - int y = ( i + 1 ) / horizontalCount; - - KDateNavigator *view = mExtraViews.at( i ); - bar = view->navigatorBar(); - if ( y > 0 ) bar->showButtons( false, false ); - else { - if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); - else bar->showButtons( false, false ); - } - view->setGeometry( x * width, - y * height, width, height ); - } - mUpdateTimer->start( 250 ); + //qDebug("COUNT %d ", mExtraViews.count()); + + mUpdateTimer->start( 250 ); //updateDayMatrixDates(); } QSize DateNavigatorContainer::minimumSizeHint() const |